babylon.module.d.ts 5.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts current color in rgb space to HSV values
  466. * @returns a new color3 representing the HSV values
  467. */
  468. toHSV(): Color3;
  469. /**
  470. * Converts current color in rgb space to HSV values
  471. * @param result defines the Color3 where to store the HSV values
  472. */
  473. toHSVToRef(result: Color3): void;
  474. /**
  475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the linear space version
  477. * @returns the unmodified Color3
  478. */
  479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  480. /**
  481. * Computes a new Color3 converted from the current one to gamma space
  482. * @returns a new Color3 object
  483. */
  484. toGammaSpace(): Color3;
  485. /**
  486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  487. * @param convertedColor defines the Color3 object where to store the gamma space version
  488. * @returns the unmodified Color3
  489. */
  490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  491. private static _BlackReadOnly;
  492. /**
  493. * Convert Hue, saturation and value to a Color3 (RGB)
  494. * @param hue defines the hue
  495. * @param saturation defines the saturation
  496. * @param value defines the value
  497. * @param result defines the Color3 where to store the RGB values
  498. */
  499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  500. /**
  501. * Creates a new Color3 from the string containing valid hexadecimal values
  502. * @param hex defines a string containing valid hexadecimal values
  503. * @returns a new Color3 object
  504. */
  505. static FromHexString(hex: string): Color3;
  506. /**
  507. * Creates a new Color3 from the starting index of the given array
  508. * @param array defines the source array
  509. * @param offset defines an offset in the source array
  510. * @returns a new Color3 object
  511. */
  512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  513. /**
  514. * Creates a new Color3 from integer values (< 256)
  515. * @param r defines the red component to read from (value between 0 and 255)
  516. * @param g defines the green component to read from (value between 0 and 255)
  517. * @param b defines the blue component to read from (value between 0 and 255)
  518. * @returns a new Color3 object
  519. */
  520. static FromInts(r: number, g: number, b: number): Color3;
  521. /**
  522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  523. * @param start defines the start Color3 value
  524. * @param end defines the end Color3 value
  525. * @param amount defines the gradient value between start and end
  526. * @returns a new Color3 object
  527. */
  528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  529. /**
  530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  531. * @param left defines the start value
  532. * @param right defines the end value
  533. * @param amount defines the gradient factor
  534. * @param result defines the Color3 object where to store the result
  535. */
  536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  537. /**
  538. * Returns a Color3 value containing a red color
  539. * @returns a new Color3 object
  540. */
  541. static Red(): Color3;
  542. /**
  543. * Returns a Color3 value containing a green color
  544. * @returns a new Color3 object
  545. */
  546. static Green(): Color3;
  547. /**
  548. * Returns a Color3 value containing a blue color
  549. * @returns a new Color3 object
  550. */
  551. static Blue(): Color3;
  552. /**
  553. * Returns a Color3 value containing a black color
  554. * @returns a new Color3 object
  555. */
  556. static Black(): Color3;
  557. /**
  558. * Gets a Color3 value containing a black color that must not be updated
  559. */
  560. static readonly BlackReadOnly: DeepImmutable<Color3>;
  561. /**
  562. * Returns a Color3 value containing a white color
  563. * @returns a new Color3 object
  564. */
  565. static White(): Color3;
  566. /**
  567. * Returns a Color3 value containing a purple color
  568. * @returns a new Color3 object
  569. */
  570. static Purple(): Color3;
  571. /**
  572. * Returns a Color3 value containing a magenta color
  573. * @returns a new Color3 object
  574. */
  575. static Magenta(): Color3;
  576. /**
  577. * Returns a Color3 value containing a yellow color
  578. * @returns a new Color3 object
  579. */
  580. static Yellow(): Color3;
  581. /**
  582. * Returns a Color3 value containing a gray color
  583. * @returns a new Color3 object
  584. */
  585. static Gray(): Color3;
  586. /**
  587. * Returns a Color3 value containing a teal color
  588. * @returns a new Color3 object
  589. */
  590. static Teal(): Color3;
  591. /**
  592. * Returns a Color3 value containing a random color
  593. * @returns a new Color3 object
  594. */
  595. static Random(): Color3;
  596. }
  597. /**
  598. * Class used to hold a RBGA color
  599. */
  600. export class Color4 {
  601. /**
  602. * Defines the red component (between 0 and 1, default is 0)
  603. */
  604. r: number;
  605. /**
  606. * Defines the green component (between 0 and 1, default is 0)
  607. */
  608. g: number;
  609. /**
  610. * Defines the blue component (between 0 and 1, default is 0)
  611. */
  612. b: number;
  613. /**
  614. * Defines the alpha component (between 0 and 1, default is 1)
  615. */
  616. a: number;
  617. /**
  618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  619. * @param r defines the red component (between 0 and 1, default is 0)
  620. * @param g defines the green component (between 0 and 1, default is 0)
  621. * @param b defines the blue component (between 0 and 1, default is 0)
  622. * @param a defines the alpha component (between 0 and 1, default is 1)
  623. */
  624. constructor(
  625. /**
  626. * Defines the red component (between 0 and 1, default is 0)
  627. */
  628. r?: number,
  629. /**
  630. * Defines the green component (between 0 and 1, default is 0)
  631. */
  632. g?: number,
  633. /**
  634. * Defines the blue component (between 0 and 1, default is 0)
  635. */
  636. b?: number,
  637. /**
  638. * Defines the alpha component (between 0 and 1, default is 1)
  639. */
  640. a?: number);
  641. /**
  642. * Adds in place the given Color4 values to the current Color4 object
  643. * @param right defines the second operand
  644. * @returns the current updated Color4 object
  645. */
  646. addInPlace(right: DeepImmutable<Color4>): Color4;
  647. /**
  648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  649. * @returns the new array
  650. */
  651. asArray(): number[];
  652. /**
  653. * Stores from the starting index in the given array the Color4 successive values
  654. * @param array defines the array where to store the r,g,b components
  655. * @param index defines an optional index in the target array to define where to start storing values
  656. * @returns the current Color4 object
  657. */
  658. toArray(array: number[], index?: number): Color4;
  659. /**
  660. * Determines equality between Color4 objects
  661. * @param otherColor defines the second operand
  662. * @returns true if the rgba values are equal to the given ones
  663. */
  664. equals(otherColor: DeepImmutable<Color4>): boolean;
  665. /**
  666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  667. * @param right defines the second operand
  668. * @returns a new Color4 object
  669. */
  670. add(right: DeepImmutable<Color4>): Color4;
  671. /**
  672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  673. * @param right defines the second operand
  674. * @returns a new Color4 object
  675. */
  676. subtract(right: DeepImmutable<Color4>): Color4;
  677. /**
  678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  679. * @param right defines the second operand
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the current Color4 object
  682. */
  683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  684. /**
  685. * Creates a new Color4 with the current Color4 values multiplied by scale
  686. * @param scale defines the scaling factor to apply
  687. * @returns a new Color4 object
  688. */
  689. scale(scale: number): Color4;
  690. /**
  691. * Multiplies the current Color4 values by scale and stores the result in "result"
  692. * @param scale defines the scaling factor to apply
  693. * @param result defines the Color4 object where to store the result
  694. * @returns the current unmodified Color4
  695. */
  696. scaleToRef(scale: number, result: Color4): Color4;
  697. /**
  698. * Scale the current Color4 values by a factor and add the result to a given Color4
  699. * @param scale defines the scale factor
  700. * @param result defines the Color4 object where to store the result
  701. * @returns the unmodified current Color4
  702. */
  703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  704. /**
  705. * Clamps the rgb values by the min and max values and stores the result into "result"
  706. * @param min defines minimum clamping value (default is 0)
  707. * @param max defines maximum clamping value (default is 1)
  708. * @param result defines color to store the result into.
  709. * @returns the cuurent Color4
  710. */
  711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  712. /**
  713. * Multipy an Color4 value by another and return a new Color4 object
  714. * @param color defines the Color4 value to multiply by
  715. * @returns a new Color4 object
  716. */
  717. multiply(color: Color4): Color4;
  718. /**
  719. * Multipy a Color4 value by another and push the result in a reference value
  720. * @param color defines the Color4 value to multiply by
  721. * @param result defines the Color4 to fill the result in
  722. * @returns the result Color4
  723. */
  724. multiplyToRef(color: Color4, result: Color4): Color4;
  725. /**
  726. * Creates a string with the Color4 current values
  727. * @returns the string representation of the Color4 object
  728. */
  729. toString(): string;
  730. /**
  731. * Returns the string "Color4"
  732. * @returns "Color4"
  733. */
  734. getClassName(): string;
  735. /**
  736. * Compute the Color4 hash code
  737. * @returns an unique number that can be used to hash Color4 objects
  738. */
  739. getHashCode(): number;
  740. /**
  741. * Creates a new Color4 copied from the current one
  742. * @returns a new Color4 object
  743. */
  744. clone(): Color4;
  745. /**
  746. * Copies the given Color4 values into the current one
  747. * @param source defines the source Color4 object
  748. * @returns the current updated Color4 object
  749. */
  750. copyFrom(source: Color4): Color4;
  751. /**
  752. * Copies the given float values into the current one
  753. * @param r defines the red component to read from
  754. * @param g defines the green component to read from
  755. * @param b defines the blue component to read from
  756. * @param a defines the alpha component to read from
  757. * @returns the current updated Color4 object
  758. */
  759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  760. /**
  761. * Copies the given float values into the current one
  762. * @param r defines the red component to read from
  763. * @param g defines the green component to read from
  764. * @param b defines the blue component to read from
  765. * @param a defines the alpha component to read from
  766. * @returns the current updated Color4 object
  767. */
  768. set(r: number, g: number, b: number, a: number): Color4;
  769. /**
  770. * Compute the Color4 hexadecimal code as a string
  771. * @returns a string containing the hexadecimal representation of the Color4 object
  772. */
  773. toHexString(): string;
  774. /**
  775. * Computes a new Color4 converted from the current one to linear space
  776. * @returns a new Color4 object
  777. */
  778. toLinearSpace(): Color4;
  779. /**
  780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  781. * @param convertedColor defines the Color4 object where to store the linear space version
  782. * @returns the unmodified Color4
  783. */
  784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  785. /**
  786. * Computes a new Color4 converted from the current one to gamma space
  787. * @returns a new Color4 object
  788. */
  789. toGammaSpace(): Color4;
  790. /**
  791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  792. * @param convertedColor defines the Color4 object where to store the gamma space version
  793. * @returns the unmodified Color4
  794. */
  795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  796. /**
  797. * Creates a new Color4 from the string containing valid hexadecimal values
  798. * @param hex defines a string containing valid hexadecimal values
  799. * @returns a new Color4 object
  800. */
  801. static FromHexString(hex: string): Color4;
  802. /**
  803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  804. * @param left defines the start value
  805. * @param right defines the end value
  806. * @param amount defines the gradient factor
  807. * @returns a new Color4 object
  808. */
  809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  810. /**
  811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  812. * @param left defines the start value
  813. * @param right defines the end value
  814. * @param amount defines the gradient factor
  815. * @param result defines the Color4 object where to store data
  816. */
  817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  818. /**
  819. * Creates a new Color4 from a Color3 and an alpha value
  820. * @param color3 defines the source Color3 to read from
  821. * @param alpha defines the alpha component (1.0 by default)
  822. * @returns a new Color4 object
  823. */
  824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  825. /**
  826. * Creates a new Color4 from the starting index element of the given array
  827. * @param array defines the source array to read from
  828. * @param offset defines the offset in the source array
  829. * @returns a new Color4 object
  830. */
  831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  832. /**
  833. * Creates a new Color3 from integer values (< 256)
  834. * @param r defines the red component to read from (value between 0 and 255)
  835. * @param g defines the green component to read from (value between 0 and 255)
  836. * @param b defines the blue component to read from (value between 0 and 255)
  837. * @param a defines the alpha component to read from (value between 0 and 255)
  838. * @returns a new Color3 object
  839. */
  840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  841. /**
  842. * Check the content of a given array and convert it to an array containing RGBA data
  843. * If the original array was already containing count * 4 values then it is returned directly
  844. * @param colors defines the array to check
  845. * @param count defines the number of RGBA data to expect
  846. * @returns an array containing count * 4 values (RGBA)
  847. */
  848. static CheckColors4(colors: number[], count: number): number[];
  849. }
  850. /**
  851. * Class representing a vector containing 2 coordinates
  852. */
  853. export class Vector2 {
  854. /** defines the first coordinate */
  855. x: number;
  856. /** defines the second coordinate */
  857. y: number;
  858. /**
  859. * Creates a new Vector2 from the given x and y coordinates
  860. * @param x defines the first coordinate
  861. * @param y defines the second coordinate
  862. */
  863. constructor(
  864. /** defines the first coordinate */
  865. x?: number,
  866. /** defines the second coordinate */
  867. y?: number);
  868. /**
  869. * Gets a string with the Vector2 coordinates
  870. * @returns a string with the Vector2 coordinates
  871. */
  872. toString(): string;
  873. /**
  874. * Gets class name
  875. * @returns the string "Vector2"
  876. */
  877. getClassName(): string;
  878. /**
  879. * Gets current vector hash code
  880. * @returns the Vector2 hash code as a number
  881. */
  882. getHashCode(): number;
  883. /**
  884. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  885. * @param array defines the source array
  886. * @param index defines the offset in source array
  887. * @returns the current Vector2
  888. */
  889. toArray(array: FloatArray, index?: number): Vector2;
  890. /**
  891. * Copy the current vector to an array
  892. * @returns a new array with 2 elements: the Vector2 coordinates.
  893. */
  894. asArray(): number[];
  895. /**
  896. * Sets the Vector2 coordinates with the given Vector2 coordinates
  897. * @param source defines the source Vector2
  898. * @returns the current updated Vector2
  899. */
  900. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. copyFromFloats(x: number, y: number): Vector2;
  908. /**
  909. * Sets the Vector2 coordinates with the given floats
  910. * @param x defines the first coordinate
  911. * @param y defines the second coordinate
  912. * @returns the current updated Vector2
  913. */
  914. set(x: number, y: number): Vector2;
  915. /**
  916. * Add another vector with the current one
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  919. */
  920. add(otherVector: DeepImmutable<Vector2>): Vector2;
  921. /**
  922. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  923. * @param otherVector defines the other vector
  924. * @param result defines the target vector
  925. * @returns the unmodified current Vector2
  926. */
  927. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  928. /**
  929. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  930. * @param otherVector defines the other vector
  931. * @returns the current updated Vector2
  932. */
  933. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  934. /**
  935. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  936. * @param otherVector defines the other vector
  937. * @returns a new Vector2
  938. */
  939. addVector3(otherVector: Vector3): Vector2;
  940. /**
  941. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  942. * @param otherVector defines the other vector
  943. * @returns a new Vector2
  944. */
  945. subtract(otherVector: Vector2): Vector2;
  946. /**
  947. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  948. * @param otherVector defines the other vector
  949. * @param result defines the target vector
  950. * @returns the unmodified current Vector2
  951. */
  952. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  953. /**
  954. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @returns the current updated Vector2
  957. */
  958. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  959. /**
  960. * Multiplies in place the current Vector2 coordinates by the given ones
  961. * @param otherVector defines the other vector
  962. * @returns the current updated Vector2
  963. */
  964. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  971. /**
  972. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  980. * @param x defines the first coordinate
  981. * @param y defines the second coordinate
  982. * @returns a new Vector2
  983. */
  984. multiplyByFloats(x: number, y: number): Vector2;
  985. /**
  986. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  987. * @param otherVector defines the other vector
  988. * @returns a new Vector2
  989. */
  990. divide(otherVector: Vector2): Vector2;
  991. /**
  992. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  993. * @param otherVector defines the other vector
  994. * @param result defines the target vector
  995. * @returns the unmodified current Vector2
  996. */
  997. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  998. /**
  999. * Divides the current Vector2 coordinates by the given ones
  1000. * @param otherVector defines the other vector
  1001. * @returns the current updated Vector2
  1002. */
  1003. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1004. /**
  1005. * Gets a new Vector2 with current Vector2 negated coordinates
  1006. * @returns a new Vector2
  1007. */
  1008. negate(): Vector2;
  1009. /**
  1010. * Multiply the Vector2 coordinates by scale
  1011. * @param scale defines the scaling factor
  1012. * @returns the current updated Vector2
  1013. */
  1014. scaleInPlace(scale: number): Vector2;
  1015. /**
  1016. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1017. * @param scale defines the scaling factor
  1018. * @returns a new Vector2
  1019. */
  1020. scale(scale: number): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1030. * @param scale defines the scale factor
  1031. * @param result defines the Vector2 object where to store the result
  1032. * @returns the unmodified current Vector2
  1033. */
  1034. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1035. /**
  1036. * Gets a boolean if two vectors are equals
  1037. * @param otherVector defines the other vector
  1038. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1039. */
  1040. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1041. /**
  1042. * Gets a boolean if two vectors are equals (using an epsilon value)
  1043. * @param otherVector defines the other vector
  1044. * @param epsilon defines the minimal distance to consider equality
  1045. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1046. */
  1047. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1048. /**
  1049. * Gets a new Vector2 from current Vector2 floored values
  1050. * @returns a new Vector2
  1051. */
  1052. floor(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 from current Vector2 floored values
  1055. * @returns a new Vector2
  1056. */
  1057. fract(): Vector2;
  1058. /**
  1059. * Gets the length of the vector
  1060. * @returns the vector length (float)
  1061. */
  1062. length(): number;
  1063. /**
  1064. * Gets the vector squared length
  1065. * @returns the vector squared length (float)
  1066. */
  1067. lengthSquared(): number;
  1068. /**
  1069. * Normalize the vector
  1070. * @returns the current updated Vector2
  1071. */
  1072. normalize(): Vector2;
  1073. /**
  1074. * Gets a new Vector2 copied from the Vector2
  1075. * @returns a new Vector2
  1076. */
  1077. clone(): Vector2;
  1078. /**
  1079. * Gets a new Vector2(0, 0)
  1080. * @returns a new Vector2
  1081. */
  1082. static Zero(): Vector2;
  1083. /**
  1084. * Gets a new Vector2(1, 1)
  1085. * @returns a new Vector2
  1086. */
  1087. static One(): Vector2;
  1088. /**
  1089. * Gets a new Vector2 set from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @returns a new Vector2
  1093. */
  1094. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1095. /**
  1096. * Sets "result" from the given index element of the given array
  1097. * @param array defines the data source
  1098. * @param offset defines the offset in the data source
  1099. * @param result defines the target vector
  1100. */
  1101. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1102. /**
  1103. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1104. * @param value1 defines 1st point of control
  1105. * @param value2 defines 2nd point of control
  1106. * @param value3 defines 3rd point of control
  1107. * @param value4 defines 4th point of control
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1114. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1115. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1116. * @param value defines the value to clamp
  1117. * @param min defines the lower limit
  1118. * @param max defines the upper limit
  1119. * @returns a new Vector2
  1120. */
  1121. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1122. /**
  1123. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1124. * @param value1 defines the 1st control point
  1125. * @param tangent1 defines the outgoing tangent
  1126. * @param value2 defines the 2nd control point
  1127. * @param tangent2 defines the incoming tangent
  1128. * @param amount defines the interpolation factor
  1129. * @returns a new Vector2
  1130. */
  1131. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1132. /**
  1133. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1134. * @param start defines the start vector
  1135. * @param end defines the end vector
  1136. * @param amount defines the interpolation factor
  1137. * @returns a new Vector2
  1138. */
  1139. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1140. /**
  1141. * Gets the dot product of the vector "left" and the vector "right"
  1142. * @param left defines first vector
  1143. * @param right defines second vector
  1144. * @returns the dot product (float)
  1145. */
  1146. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1147. /**
  1148. * Returns a new Vector2 equal to the normalized given vector
  1149. * @param vector defines the vector to normalize
  1150. * @returns a new Vector2
  1151. */
  1152. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1162. * @param left defines 1st vector
  1163. * @param right defines 2nd vector
  1164. * @returns a new Vector2
  1165. */
  1166. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1167. /**
  1168. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @returns a new Vector2
  1172. */
  1173. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1174. /**
  1175. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1176. * @param vector defines the vector to transform
  1177. * @param transformation defines the matrix to apply
  1178. * @param result defines the target vector
  1179. */
  1180. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1181. /**
  1182. * Determines if a given vector is included in a triangle
  1183. * @param p defines the vector to test
  1184. * @param p0 defines 1st triangle point
  1185. * @param p1 defines 2nd triangle point
  1186. * @param p2 defines 3rd triangle point
  1187. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1188. */
  1189. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1190. /**
  1191. * Gets the distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the distance between vectors
  1195. */
  1196. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Returns the squared distance between the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns the squared distance between vectors
  1202. */
  1203. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1204. /**
  1205. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1206. * @param value1 defines first vector
  1207. * @param value2 defines second vector
  1208. * @returns a new Vector2
  1209. */
  1210. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1211. /**
  1212. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1213. * @param p defines the middle point
  1214. * @param segA defines one point of the segment
  1215. * @param segB defines the other point of the segment
  1216. * @returns the shortest distance
  1217. */
  1218. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1219. }
  1220. /**
  1221. * Classed used to store (x,y,z) vector representation
  1222. * A Vector3 is the main object used in 3D geometry
  1223. * It can represent etiher the coordinates of a point the space, either a direction
  1224. * Reminder: js uses a left handed forward facing system
  1225. */
  1226. export class Vector3 {
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x: number;
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y: number;
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z: number;
  1239. private static _UpReadOnly;
  1240. private static _ZeroReadOnly;
  1241. /**
  1242. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1243. * @param x defines the first coordinates (on X axis)
  1244. * @param y defines the second coordinates (on Y axis)
  1245. * @param z defines the third coordinates (on Z axis)
  1246. */
  1247. constructor(
  1248. /**
  1249. * Defines the first coordinates (on X axis)
  1250. */
  1251. x?: number,
  1252. /**
  1253. * Defines the second coordinates (on Y axis)
  1254. */
  1255. y?: number,
  1256. /**
  1257. * Defines the third coordinates (on Z axis)
  1258. */
  1259. z?: number);
  1260. /**
  1261. * Creates a string representation of the Vector3
  1262. * @returns a string with the Vector3 coordinates.
  1263. */
  1264. toString(): string;
  1265. /**
  1266. * Gets the class name
  1267. * @returns the string "Vector3"
  1268. */
  1269. getClassName(): string;
  1270. /**
  1271. * Creates the Vector3 hash code
  1272. * @returns a number which tends to be unique between Vector3 instances
  1273. */
  1274. getHashCode(): number;
  1275. /**
  1276. * Creates an array containing three elements : the coordinates of the Vector3
  1277. * @returns a new array of numbers
  1278. */
  1279. asArray(): number[];
  1280. /**
  1281. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1282. * @param array defines the destination array
  1283. * @param index defines the offset in the destination array
  1284. * @returns the current Vector3
  1285. */
  1286. toArray(array: FloatArray, index?: number): Vector3;
  1287. /**
  1288. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1289. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1290. */
  1291. toQuaternion(): Quaternion;
  1292. /**
  1293. * Adds the given vector to the current Vector3
  1294. * @param otherVector defines the second operand
  1295. * @returns the current updated Vector3
  1296. */
  1297. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the given coordinates to the current Vector3
  1300. * @param x defines the x coordinate of the operand
  1301. * @param y defines the y coordinate of the operand
  1302. * @param z defines the z coordinate of the operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1306. /**
  1307. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Subtract the given vector from the current Vector3
  1321. * @param otherVector defines the second operand
  1322. * @returns the current updated Vector3
  1323. */
  1324. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1325. /**
  1326. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1327. * @param otherVector defines the second operand
  1328. * @returns the resulting Vector3
  1329. */
  1330. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1331. /**
  1332. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1333. * @param otherVector defines the second operand
  1334. * @param result defines the Vector3 object where to store the result
  1335. * @returns the current Vector3
  1336. */
  1337. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1338. /**
  1339. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1340. * @param x defines the x coordinate of the operand
  1341. * @param y defines the y coordinate of the operand
  1342. * @param z defines the z coordinate of the operand
  1343. * @returns the resulting Vector3
  1344. */
  1345. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1346. /**
  1347. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1348. * @param x defines the x coordinate of the operand
  1349. * @param y defines the y coordinate of the operand
  1350. * @param z defines the z coordinate of the operand
  1351. * @param result defines the Vector3 object where to store the result
  1352. * @returns the current Vector3
  1353. */
  1354. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1355. /**
  1356. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1357. * @returns a new Vector3
  1358. */
  1359. negate(): Vector3;
  1360. /**
  1361. * Multiplies the Vector3 coordinates by the float "scale"
  1362. * @param scale defines the multiplier factor
  1363. * @returns the current updated Vector3
  1364. */
  1365. scaleInPlace(scale: number): Vector3;
  1366. /**
  1367. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1368. * @param scale defines the multiplier factor
  1369. * @returns a new Vector3
  1370. */
  1371. scale(scale: number): Vector3;
  1372. /**
  1373. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1374. * @param scale defines the multiplier factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the current Vector3
  1377. */
  1378. scaleToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1381. * @param scale defines the scale factor
  1382. * @param result defines the Vector3 object where to store the result
  1383. * @returns the unmodified current Vector3
  1384. */
  1385. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1386. /**
  1387. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1388. * @param otherVector defines the second operand
  1389. * @returns true if both vectors are equals
  1390. */
  1391. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1394. * @param otherVector defines the second operand
  1395. * @param epsilon defines the minimal distance to define values as equals
  1396. * @returns true if both vectors are distant less than epsilon
  1397. */
  1398. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1399. /**
  1400. * Returns true if the current Vector3 coordinates equals the given floats
  1401. * @param x defines the x coordinate of the operand
  1402. * @param y defines the y coordinate of the operand
  1403. * @param z defines the z coordinate of the operand
  1404. * @returns true if both vectors are equals
  1405. */
  1406. equalsToFloats(x: number, y: number, z: number): boolean;
  1407. /**
  1408. * Multiplies the current Vector3 coordinates by the given ones
  1409. * @param otherVector defines the second operand
  1410. * @returns the current updated Vector3
  1411. */
  1412. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1413. /**
  1414. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1428. * @param x defines the x coordinate of the operand
  1429. * @param y defines the y coordinate of the operand
  1430. * @param z defines the z coordinate of the operand
  1431. * @returns the new Vector3
  1432. */
  1433. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1434. /**
  1435. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1436. * @param otherVector defines the second operand
  1437. * @returns the new Vector3
  1438. */
  1439. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1442. * @param otherVector defines the second operand
  1443. * @param result defines the Vector3 object where to store the result
  1444. * @returns the current Vector3
  1445. */
  1446. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1447. /**
  1448. * Divides the current Vector3 coordinates by the given ones.
  1449. * @param otherVector defines the second operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. divideInPlace(otherVector: Vector3): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1455. * @param other defines the second operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1461. * @param other defines the second operand
  1462. * @returns the current updated Vector3
  1463. */
  1464. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1465. /**
  1466. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1467. * @param x defines the x coordinate of the operand
  1468. * @param y defines the y coordinate of the operand
  1469. * @param z defines the z coordinate of the operand
  1470. * @returns the current updated Vector3
  1471. */
  1472. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1473. /**
  1474. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1475. * @param x defines the x coordinate of the operand
  1476. * @param y defines the y coordinate of the operand
  1477. * @param z defines the z coordinate of the operand
  1478. * @returns the current updated Vector3
  1479. */
  1480. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1481. /**
  1482. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1483. * Check if is non uniform within a certain amount of decimal places to account for this
  1484. * @param epsilon the amount the values can differ
  1485. * @returns if the the vector is non uniform to a certain number of decimal places
  1486. */
  1487. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1488. /**
  1489. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1490. */
  1491. readonly isNonUniform: boolean;
  1492. /**
  1493. * Gets a new Vector3 from current Vector3 floored values
  1494. * @returns a new Vector3
  1495. */
  1496. floor(): Vector3;
  1497. /**
  1498. * Gets a new Vector3 from current Vector3 floored values
  1499. * @returns a new Vector3
  1500. */
  1501. fract(): Vector3;
  1502. /**
  1503. * Gets the length of the Vector3
  1504. * @returns the length of the Vector3
  1505. */
  1506. length(): number;
  1507. /**
  1508. * Gets the squared length of the Vector3
  1509. * @returns squared length of the Vector3
  1510. */
  1511. lengthSquared(): number;
  1512. /**
  1513. * Normalize the current Vector3.
  1514. * Please note that this is an in place operation.
  1515. * @returns the current updated Vector3
  1516. */
  1517. normalize(): Vector3;
  1518. /**
  1519. * Reorders the x y z properties of the vector in place
  1520. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1521. * @returns the current updated vector
  1522. */
  1523. reorderInPlace(order: string): this;
  1524. /**
  1525. * Rotates the vector around 0,0,0 by a quaternion
  1526. * @param quaternion the rotation quaternion
  1527. * @param result vector to store the result
  1528. * @returns the resulting vector
  1529. */
  1530. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1531. /**
  1532. * Rotates a vector around a given point
  1533. * @param quaternion the rotation quaternion
  1534. * @param point the point to rotate around
  1535. * @param result vector to store the result
  1536. * @returns the resulting vector
  1537. */
  1538. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Interface for the size containing width and height
  2363. */
  2364. export interface ISize {
  2365. /**
  2366. * Width
  2367. */
  2368. width: number;
  2369. /**
  2370. * Heighht
  2371. */
  2372. height: number;
  2373. }
  2374. /**
  2375. * Size containing widht and height
  2376. */
  2377. export class Size implements ISize {
  2378. /**
  2379. * Width
  2380. */
  2381. width: number;
  2382. /**
  2383. * Height
  2384. */
  2385. height: number;
  2386. /**
  2387. * Creates a Size object from the given width and height (floats).
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. */
  2391. constructor(width: number, height: number);
  2392. /**
  2393. * Returns a string with the Size width and height
  2394. * @returns a string with the Size width and height
  2395. */
  2396. toString(): string;
  2397. /**
  2398. * "Size"
  2399. * @returns the string "Size"
  2400. */
  2401. getClassName(): string;
  2402. /**
  2403. * Returns the Size hash code.
  2404. * @returns a hash code for a unique width and height
  2405. */
  2406. getHashCode(): number;
  2407. /**
  2408. * Updates the current size from the given one.
  2409. * @param src the given size
  2410. */
  2411. copyFrom(src: Size): void;
  2412. /**
  2413. * Updates in place the current Size from the given floats.
  2414. * @param width width of the new size
  2415. * @param height height of the new size
  2416. * @returns the updated Size.
  2417. */
  2418. copyFromFloats(width: number, height: number): Size;
  2419. /**
  2420. * Updates in place the current Size from the given floats.
  2421. * @param width width to set
  2422. * @param height height to set
  2423. * @returns the updated Size.
  2424. */
  2425. set(width: number, height: number): Size;
  2426. /**
  2427. * Multiplies the width and height by numbers
  2428. * @param w factor to multiple the width by
  2429. * @param h factor to multiple the height by
  2430. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2431. */
  2432. multiplyByFloats(w: number, h: number): Size;
  2433. /**
  2434. * Clones the size
  2435. * @returns a new Size copied from the given one.
  2436. */
  2437. clone(): Size;
  2438. /**
  2439. * True if the current Size and the given one width and height are strictly equal.
  2440. * @param other the other size to compare against
  2441. * @returns True if the current Size and the given one width and height are strictly equal.
  2442. */
  2443. equals(other: Size): boolean;
  2444. /**
  2445. * The surface of the Size : width * height (float).
  2446. */
  2447. readonly surface: number;
  2448. /**
  2449. * Create a new size of zero
  2450. * @returns a new Size set to (0.0, 0.0)
  2451. */
  2452. static Zero(): Size;
  2453. /**
  2454. * Sums the width and height of two sizes
  2455. * @param otherSize size to add to this size
  2456. * @returns a new Size set as the addition result of the current Size and the given one.
  2457. */
  2458. add(otherSize: Size): Size;
  2459. /**
  2460. * Subtracts the width and height of two
  2461. * @param otherSize size to subtract to this size
  2462. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2463. */
  2464. subtract(otherSize: Size): Size;
  2465. /**
  2466. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2467. * @param start starting size to lerp between
  2468. * @param end end size to lerp between
  2469. * @param amount amount to lerp between the start and end values
  2470. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2471. */
  2472. static Lerp(start: Size, end: Size, amount: number): Size;
  2473. }
  2474. /**
  2475. * Class used to store quaternion data
  2476. * @see https://en.wikipedia.org/wiki/Quaternion
  2477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2478. */
  2479. export class Quaternion {
  2480. /** defines the first component (0 by default) */
  2481. x: number;
  2482. /** defines the second component (0 by default) */
  2483. y: number;
  2484. /** defines the third component (0 by default) */
  2485. z: number;
  2486. /** defines the fourth component (1.0 by default) */
  2487. w: number;
  2488. /**
  2489. * Creates a new Quaternion from the given floats
  2490. * @param x defines the first component (0 by default)
  2491. * @param y defines the second component (0 by default)
  2492. * @param z defines the third component (0 by default)
  2493. * @param w defines the fourth component (1.0 by default)
  2494. */
  2495. constructor(
  2496. /** defines the first component (0 by default) */
  2497. x?: number,
  2498. /** defines the second component (0 by default) */
  2499. y?: number,
  2500. /** defines the third component (0 by default) */
  2501. z?: number,
  2502. /** defines the fourth component (1.0 by default) */
  2503. w?: number);
  2504. /**
  2505. * Gets a string representation for the current quaternion
  2506. * @returns a string with the Quaternion coordinates
  2507. */
  2508. toString(): string;
  2509. /**
  2510. * Gets the class name of the quaternion
  2511. * @returns the string "Quaternion"
  2512. */
  2513. getClassName(): string;
  2514. /**
  2515. * Gets a hash code for this quaternion
  2516. * @returns the quaternion hash code
  2517. */
  2518. getHashCode(): number;
  2519. /**
  2520. * Copy the quaternion to an array
  2521. * @returns a new array populated with 4 elements from the quaternion coordinates
  2522. */
  2523. asArray(): number[];
  2524. /**
  2525. * Check if two quaternions are equals
  2526. * @param otherQuaternion defines the second operand
  2527. * @return true if the current quaternion and the given one coordinates are strictly equals
  2528. */
  2529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2530. /**
  2531. * Clone the current quaternion
  2532. * @returns a new quaternion copied from the current one
  2533. */
  2534. clone(): Quaternion;
  2535. /**
  2536. * Copy a quaternion to the current one
  2537. * @param other defines the other quaternion
  2538. * @returns the updated current quaternion
  2539. */
  2540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Updates the current quaternion with the given float coordinates
  2543. * @param x defines the x coordinate
  2544. * @param y defines the y coordinate
  2545. * @param z defines the z coordinate
  2546. * @param w defines the w coordinate
  2547. * @returns the updated current quaternion
  2548. */
  2549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2550. /**
  2551. * Updates the current quaternion from the given float coordinates
  2552. * @param x defines the x coordinate
  2553. * @param y defines the y coordinate
  2554. * @param z defines the z coordinate
  2555. * @param w defines the w coordinate
  2556. * @returns the updated current quaternion
  2557. */
  2558. set(x: number, y: number, z: number, w: number): Quaternion;
  2559. /**
  2560. * Adds two quaternions
  2561. * @param other defines the second operand
  2562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2563. */
  2564. add(other: DeepImmutable<Quaternion>): Quaternion;
  2565. /**
  2566. * Add a quaternion to the current one
  2567. * @param other defines the quaternion to add
  2568. * @returns the current quaternion
  2569. */
  2570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2571. /**
  2572. * Subtract two quaternions
  2573. * @param other defines the second operand
  2574. * @returns a new quaternion as the subtraction result of the given one from the current one
  2575. */
  2576. subtract(other: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies the current quaternion by a scale factor
  2579. * @param value defines the scale factor
  2580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2581. */
  2582. scale(value: number): Quaternion;
  2583. /**
  2584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2585. * @param scale defines the scale factor
  2586. * @param result defines the Quaternion object where to store the result
  2587. * @returns the unmodified current quaternion
  2588. */
  2589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2590. /**
  2591. * Multiplies in place the current quaternion by a scale factor
  2592. * @param value defines the scale factor
  2593. * @returns the current modified quaternion
  2594. */
  2595. scaleInPlace(value: number): Quaternion;
  2596. /**
  2597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2598. * @param scale defines the scale factor
  2599. * @param result defines the Quaternion object where to store the result
  2600. * @returns the unmodified current quaternion
  2601. */
  2602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2603. /**
  2604. * Multiplies two quaternions
  2605. * @param q1 defines the second operand
  2606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2607. */
  2608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2609. /**
  2610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2611. * @param q1 defines the second operand
  2612. * @param result defines the target quaternion
  2613. * @returns the current quaternion
  2614. */
  2615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2616. /**
  2617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2618. * @param q1 defines the second operand
  2619. * @returns the currentupdated quaternion
  2620. */
  2621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2622. /**
  2623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2624. * @param ref defines the target quaternion
  2625. * @returns the current quaternion
  2626. */
  2627. conjugateToRef(ref: Quaternion): Quaternion;
  2628. /**
  2629. * Conjugates in place (1-q) the current quaternion
  2630. * @returns the current updated quaternion
  2631. */
  2632. conjugateInPlace(): Quaternion;
  2633. /**
  2634. * Conjugates in place (1-q) the current quaternion
  2635. * @returns a new quaternion
  2636. */
  2637. conjugate(): Quaternion;
  2638. /**
  2639. * Gets length of current quaternion
  2640. * @returns the quaternion length (float)
  2641. */
  2642. length(): number;
  2643. /**
  2644. * Normalize in place the current quaternion
  2645. * @returns the current updated quaternion
  2646. */
  2647. normalize(): Quaternion;
  2648. /**
  2649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2650. * @param order is a reserved parameter and is ignore for now
  2651. * @returns a new Vector3 containing the Euler angles
  2652. */
  2653. toEulerAngles(order?: string): Vector3;
  2654. /**
  2655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2656. * @param result defines the vector which will be filled with the Euler angles
  2657. * @param order is a reserved parameter and is ignore for now
  2658. * @returns the current unchanged quaternion
  2659. */
  2660. toEulerAnglesToRef(result: Vector3): Quaternion;
  2661. /**
  2662. * Updates the given rotation matrix with the current quaternion values
  2663. * @param result defines the target matrix
  2664. * @returns the current unchanged quaternion
  2665. */
  2666. toRotationMatrix(result: Matrix): Quaternion;
  2667. /**
  2668. * Updates the current quaternion from the given rotation matrix values
  2669. * @param matrix defines the source matrix
  2670. * @returns the current updated quaternion
  2671. */
  2672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2673. /**
  2674. * Creates a new quaternion from a rotation matrix
  2675. * @param matrix defines the source matrix
  2676. * @returns a new quaternion created from the given rotation matrix values
  2677. */
  2678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2679. /**
  2680. * Updates the given quaternion with the given rotation matrix values
  2681. * @param matrix defines the source matrix
  2682. * @param result defines the target quaternion
  2683. */
  2684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2685. /**
  2686. * Returns the dot product (float) between the quaternions "left" and "right"
  2687. * @param left defines the left operand
  2688. * @param right defines the right operand
  2689. * @returns the dot product
  2690. */
  2691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2692. /**
  2693. * Checks if the two quaternions are close to each other
  2694. * @param quat0 defines the first quaternion to check
  2695. * @param quat1 defines the second quaternion to check
  2696. * @returns true if the two quaternions are close to each other
  2697. */
  2698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2699. /**
  2700. * Creates an empty quaternion
  2701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2702. */
  2703. static Zero(): Quaternion;
  2704. /**
  2705. * Inverse a given quaternion
  2706. * @param q defines the source quaternion
  2707. * @returns a new quaternion as the inverted current quaternion
  2708. */
  2709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2710. /**
  2711. * Inverse a given quaternion
  2712. * @param q defines the source quaternion
  2713. * @param result the quaternion the result will be stored in
  2714. * @returns the result quaternion
  2715. */
  2716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates an identity quaternion
  2719. * @returns the identity quaternion
  2720. */
  2721. static Identity(): Quaternion;
  2722. /**
  2723. * Gets a boolean indicating if the given quaternion is identity
  2724. * @param quaternion defines the quaternion to check
  2725. * @returns true if the quaternion is identity
  2726. */
  2727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2728. /**
  2729. * Creates a quaternion from a rotation around an axis
  2730. * @param axis defines the axis to use
  2731. * @param angle defines the angle to use
  2732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2733. */
  2734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2735. /**
  2736. * Creates a rotation around an axis and stores it into the given quaternion
  2737. * @param axis defines the axis to use
  2738. * @param angle defines the angle to use
  2739. * @param result defines the target quaternion
  2740. * @returns the target quaternion
  2741. */
  2742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Creates a new quaternion from data stored into an array
  2745. * @param array defines the data source
  2746. * @param offset defines the offset in the source array where the data starts
  2747. * @returns a new quaternion
  2748. */
  2749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2750. /**
  2751. * Create a quaternion from Euler rotation angles
  2752. * @param x Pitch
  2753. * @param y Yaw
  2754. * @param z Roll
  2755. * @returns the new Quaternion
  2756. */
  2757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2758. /**
  2759. * Updates a quaternion from Euler rotation angles
  2760. * @param x Pitch
  2761. * @param y Yaw
  2762. * @param z Roll
  2763. * @param result the quaternion to store the result
  2764. * @returns the updated quaternion
  2765. */
  2766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2767. /**
  2768. * Create a quaternion from Euler rotation vector
  2769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2770. * @returns the new Quaternion
  2771. */
  2772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2773. /**
  2774. * Updates a quaternion from Euler rotation vector
  2775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2776. * @param result the quaternion to store the result
  2777. * @returns the updated quaternion
  2778. */
  2779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2782. * @param yaw defines the rotation around Y axis
  2783. * @param pitch defines the rotation around X axis
  2784. * @param roll defines the rotation around Z axis
  2785. * @returns the new quaternion
  2786. */
  2787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2788. /**
  2789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2790. * @param yaw defines the rotation around Y axis
  2791. * @param pitch defines the rotation around X axis
  2792. * @param roll defines the rotation around Z axis
  2793. * @param result defines the target quaternion
  2794. */
  2795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2796. /**
  2797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2798. * @param alpha defines the rotation around first axis
  2799. * @param beta defines the rotation around second axis
  2800. * @param gamma defines the rotation around third axis
  2801. * @returns the new quaternion
  2802. */
  2803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2804. /**
  2805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2806. * @param alpha defines the rotation around first axis
  2807. * @param beta defines the rotation around second axis
  2808. * @param gamma defines the rotation around third axis
  2809. * @param result defines the target quaternion
  2810. */
  2811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2812. /**
  2813. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2814. * @param axis1 defines the first axis
  2815. * @param axis2 defines the second axis
  2816. * @param axis3 defines the third axis
  2817. * @returns the new quaternion
  2818. */
  2819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2820. /**
  2821. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2822. * @param axis1 defines the first axis
  2823. * @param axis2 defines the second axis
  2824. * @param axis3 defines the third axis
  2825. * @param ref defines the target quaternion
  2826. */
  2827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2828. /**
  2829. * Interpolates between two quaternions
  2830. * @param left defines first quaternion
  2831. * @param right defines second quaternion
  2832. * @param amount defines the gradient to use
  2833. * @returns the new interpolated quaternion
  2834. */
  2835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2836. /**
  2837. * Interpolates between two quaternions and stores it into a target quaternion
  2838. * @param left defines first quaternion
  2839. * @param right defines second quaternion
  2840. * @param amount defines the gradient to use
  2841. * @param result defines the target quaternion
  2842. */
  2843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2844. /**
  2845. * Interpolate between two quaternions using Hermite interpolation
  2846. * @param value1 defines first quaternion
  2847. * @param tangent1 defines the incoming tangent
  2848. * @param value2 defines second quaternion
  2849. * @param tangent2 defines the outgoing tangent
  2850. * @param amount defines the target quaternion
  2851. * @returns the new interpolated quaternion
  2852. */
  2853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2854. }
  2855. /**
  2856. * Class used to store matrix data (4x4)
  2857. */
  2858. export class Matrix {
  2859. private static _updateFlagSeed;
  2860. private static _identityReadOnly;
  2861. private _isIdentity;
  2862. private _isIdentityDirty;
  2863. private _isIdentity3x2;
  2864. private _isIdentity3x2Dirty;
  2865. /**
  2866. * Gets the update flag of the matrix which is an unique number for the matrix.
  2867. * It will be incremented every time the matrix data change.
  2868. * You can use it to speed the comparison between two versions of the same matrix.
  2869. */
  2870. updateFlag: number;
  2871. private readonly _m;
  2872. /**
  2873. * Gets the internal data of the matrix
  2874. */
  2875. readonly m: DeepImmutable<Float32Array>;
  2876. /** @hidden */
  2877. _markAsUpdated(): void;
  2878. /** @hidden */
  2879. private _updateIdentityStatus;
  2880. /**
  2881. * Creates an empty matrix (filled with zeros)
  2882. */
  2883. constructor();
  2884. /**
  2885. * Check if the current matrix is identity
  2886. * @returns true is the matrix is the identity matrix
  2887. */
  2888. isIdentity(): boolean;
  2889. /**
  2890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2891. * @returns true is the matrix is the identity matrix
  2892. */
  2893. isIdentityAs3x2(): boolean;
  2894. /**
  2895. * Gets the determinant of the matrix
  2896. * @returns the matrix determinant
  2897. */
  2898. determinant(): number;
  2899. /**
  2900. * Returns the matrix as a Float32Array
  2901. * @returns the matrix underlying array
  2902. */
  2903. toArray(): DeepImmutable<Float32Array>;
  2904. /**
  2905. * Returns the matrix as a Float32Array
  2906. * @returns the matrix underlying array.
  2907. */
  2908. asArray(): DeepImmutable<Float32Array>;
  2909. /**
  2910. * Inverts the current matrix in place
  2911. * @returns the current inverted matrix
  2912. */
  2913. invert(): Matrix;
  2914. /**
  2915. * Sets all the matrix elements to zero
  2916. * @returns the current matrix
  2917. */
  2918. reset(): Matrix;
  2919. /**
  2920. * Adds the current matrix with a second one
  2921. * @param other defines the matrix to add
  2922. * @returns a new matrix as the addition of the current matrix and the given one
  2923. */
  2924. add(other: DeepImmutable<Matrix>): Matrix;
  2925. /**
  2926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2927. * @param other defines the matrix to add
  2928. * @param result defines the target matrix
  2929. * @returns the current matrix
  2930. */
  2931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2932. /**
  2933. * Adds in place the given matrix to the current matrix
  2934. * @param other defines the second operand
  2935. * @returns the current updated matrix
  2936. */
  2937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2938. /**
  2939. * Sets the given matrix to the current inverted Matrix
  2940. * @param other defines the target matrix
  2941. * @returns the unmodified current matrix
  2942. */
  2943. invertToRef(other: Matrix): Matrix;
  2944. /**
  2945. * add a value at the specified position in the current Matrix
  2946. * @param index the index of the value within the matrix. between 0 and 15.
  2947. * @param value the value to be added
  2948. * @returns the current updated matrix
  2949. */
  2950. addAtIndex(index: number, value: number): Matrix;
  2951. /**
  2952. * mutiply the specified position in the current Matrix by a value
  2953. * @param index the index of the value within the matrix. between 0 and 15.
  2954. * @param value the value to be added
  2955. * @returns the current updated matrix
  2956. */
  2957. multiplyAtIndex(index: number, value: number): Matrix;
  2958. /**
  2959. * Inserts the translation vector (using 3 floats) in the current matrix
  2960. * @param x defines the 1st component of the translation
  2961. * @param y defines the 2nd component of the translation
  2962. * @param z defines the 3rd component of the translation
  2963. * @returns the current updated matrix
  2964. */
  2965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2966. /**
  2967. * Adds the translation vector (using 3 floats) in the current matrix
  2968. * @param x defines the 1st component of the translation
  2969. * @param y defines the 2nd component of the translation
  2970. * @param z defines the 3rd component of the translation
  2971. * @returns the current updated matrix
  2972. */
  2973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2974. /**
  2975. * Inserts the translation vector in the current matrix
  2976. * @param vector3 defines the translation to insert
  2977. * @returns the current updated matrix
  2978. */
  2979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2980. /**
  2981. * Gets the translation value of the current matrix
  2982. * @returns a new Vector3 as the extracted translation from the matrix
  2983. */
  2984. getTranslation(): Vector3;
  2985. /**
  2986. * Fill a Vector3 with the extracted translation from the matrix
  2987. * @param result defines the Vector3 where to store the translation
  2988. * @returns the current matrix
  2989. */
  2990. getTranslationToRef(result: Vector3): Matrix;
  2991. /**
  2992. * Remove rotation and scaling part from the matrix
  2993. * @returns the updated matrix
  2994. */
  2995. removeRotationAndScaling(): Matrix;
  2996. /**
  2997. * Multiply two matrices
  2998. * @param other defines the second operand
  2999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3000. */
  3001. multiply(other: DeepImmutable<Matrix>): Matrix;
  3002. /**
  3003. * Copy the current matrix from the given one
  3004. * @param other defines the source matrix
  3005. * @returns the current updated matrix
  3006. */
  3007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3008. /**
  3009. * Populates the given array from the starting index with the current matrix values
  3010. * @param array defines the target array
  3011. * @param offset defines the offset in the target array where to start storing values
  3012. * @returns the current matrix
  3013. */
  3014. copyToArray(array: Float32Array, offset?: number): Matrix;
  3015. /**
  3016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3017. * @param other defines the second operand
  3018. * @param result defines the matrix where to store the multiplication
  3019. * @returns the current matrix
  3020. */
  3021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3022. /**
  3023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3024. * @param other defines the second operand
  3025. * @param result defines the array where to store the multiplication
  3026. * @param offset defines the offset in the target array where to start storing values
  3027. * @returns the current matrix
  3028. */
  3029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3030. /**
  3031. * Check equality between this matrix and a second one
  3032. * @param value defines the second matrix to compare
  3033. * @returns true is the current matrix and the given one values are strictly equal
  3034. */
  3035. equals(value: DeepImmutable<Matrix>): boolean;
  3036. /**
  3037. * Clone the current matrix
  3038. * @returns a new matrix from the current matrix
  3039. */
  3040. clone(): Matrix;
  3041. /**
  3042. * Returns the name of the current matrix class
  3043. * @returns the string "Matrix"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Gets the hash code of the current matrix
  3048. * @returns the hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Decomposes the current Matrix into a translation, rotation and scaling components
  3053. * @param scale defines the scale vector3 given as a reference to update
  3054. * @param rotation defines the rotation quaternion given as a reference to update
  3055. * @param translation defines the translation vector3 given as a reference to update
  3056. * @returns true if operation was successful
  3057. */
  3058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3059. /**
  3060. * Gets specific row of the matrix
  3061. * @param index defines the number of the row to get
  3062. * @returns the index-th row of the current matrix as a new Vector4
  3063. */
  3064. getRow(index: number): Nullable<Vector4>;
  3065. /**
  3066. * Sets the index-th row of the current matrix to the vector4 values
  3067. * @param index defines the number of the row to set
  3068. * @param row defines the target vector4
  3069. * @returns the updated current matrix
  3070. */
  3071. setRow(index: number, row: Vector4): Matrix;
  3072. /**
  3073. * Compute the transpose of the matrix
  3074. * @returns the new transposed matrix
  3075. */
  3076. transpose(): Matrix;
  3077. /**
  3078. * Compute the transpose of the matrix and store it in a given matrix
  3079. * @param result defines the target matrix
  3080. * @returns the current matrix
  3081. */
  3082. transposeToRef(result: Matrix): Matrix;
  3083. /**
  3084. * Sets the index-th row of the current matrix with the given 4 x float values
  3085. * @param index defines the row index
  3086. * @param x defines the x component to set
  3087. * @param y defines the y component to set
  3088. * @param z defines the z component to set
  3089. * @param w defines the w component to set
  3090. * @returns the updated current matrix
  3091. */
  3092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3093. /**
  3094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3095. * @param scale defines the scale factor
  3096. * @returns a new matrix
  3097. */
  3098. scale(scale: number): Matrix;
  3099. /**
  3100. * Scale the current matrix values by a factor to a given result matrix
  3101. * @param scale defines the scale factor
  3102. * @param result defines the matrix to store the result
  3103. * @returns the current matrix
  3104. */
  3105. scaleToRef(scale: number, result: Matrix): Matrix;
  3106. /**
  3107. * Scale the current matrix values by a factor and add the result to a given matrix
  3108. * @param scale defines the scale factor
  3109. * @param result defines the Matrix to store the result
  3110. * @returns the current matrix
  3111. */
  3112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3113. /**
  3114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3115. * @param ref matrix to store the result
  3116. */
  3117. toNormalMatrix(ref: Matrix): void;
  3118. /**
  3119. * Gets only rotation part of the current matrix
  3120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3121. */
  3122. getRotationMatrix(): Matrix;
  3123. /**
  3124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3125. * @param result defines the target matrix to store data to
  3126. * @returns the current matrix
  3127. */
  3128. getRotationMatrixToRef(result: Matrix): Matrix;
  3129. /**
  3130. * Toggles model matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleModelMatrixHandInPlace(): void;
  3133. /**
  3134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3135. */
  3136. toggleProjectionMatrixHandInPlace(): void;
  3137. /**
  3138. * Creates a matrix from an array
  3139. * @param array defines the source array
  3140. * @param offset defines an offset in the source array
  3141. * @returns a new Matrix set from the starting index of the given array
  3142. */
  3143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3144. /**
  3145. * Copy the content of an array into a given matrix
  3146. * @param array defines the source array
  3147. * @param offset defines an offset in the source array
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3151. /**
  3152. * Stores an array into a matrix after having multiplied each component by a given factor
  3153. * @param array defines the source array
  3154. * @param offset defines the offset in the source array
  3155. * @param scale defines the scaling factor
  3156. * @param result defines the target matrix
  3157. */
  3158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3159. /**
  3160. * Gets an identity matrix that must not be updated
  3161. */
  3162. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3163. /**
  3164. * Stores a list of values (16) inside a given matrix
  3165. * @param initialM11 defines 1st value of 1st row
  3166. * @param initialM12 defines 2nd value of 1st row
  3167. * @param initialM13 defines 3rd value of 1st row
  3168. * @param initialM14 defines 4th value of 1st row
  3169. * @param initialM21 defines 1st value of 2nd row
  3170. * @param initialM22 defines 2nd value of 2nd row
  3171. * @param initialM23 defines 3rd value of 2nd row
  3172. * @param initialM24 defines 4th value of 2nd row
  3173. * @param initialM31 defines 1st value of 3rd row
  3174. * @param initialM32 defines 2nd value of 3rd row
  3175. * @param initialM33 defines 3rd value of 3rd row
  3176. * @param initialM34 defines 4th value of 3rd row
  3177. * @param initialM41 defines 1st value of 4th row
  3178. * @param initialM42 defines 2nd value of 4th row
  3179. * @param initialM43 defines 3rd value of 4th row
  3180. * @param initialM44 defines 4th value of 4th row
  3181. * @param result defines the target matrix
  3182. */
  3183. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3184. /**
  3185. * Creates new matrix from a list of values (16)
  3186. * @param initialM11 defines 1st value of 1st row
  3187. * @param initialM12 defines 2nd value of 1st row
  3188. * @param initialM13 defines 3rd value of 1st row
  3189. * @param initialM14 defines 4th value of 1st row
  3190. * @param initialM21 defines 1st value of 2nd row
  3191. * @param initialM22 defines 2nd value of 2nd row
  3192. * @param initialM23 defines 3rd value of 2nd row
  3193. * @param initialM24 defines 4th value of 2nd row
  3194. * @param initialM31 defines 1st value of 3rd row
  3195. * @param initialM32 defines 2nd value of 3rd row
  3196. * @param initialM33 defines 3rd value of 3rd row
  3197. * @param initialM34 defines 4th value of 3rd row
  3198. * @param initialM41 defines 1st value of 4th row
  3199. * @param initialM42 defines 2nd value of 4th row
  3200. * @param initialM43 defines 3rd value of 4th row
  3201. * @param initialM44 defines 4th value of 4th row
  3202. * @returns the new matrix
  3203. */
  3204. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3205. /**
  3206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3207. * @param scale defines the scale vector3
  3208. * @param rotation defines the rotation quaternion
  3209. * @param translation defines the translation vector3
  3210. * @returns a new matrix
  3211. */
  3212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3213. /**
  3214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3215. * @param scale defines the scale vector3
  3216. * @param rotation defines the rotation quaternion
  3217. * @param translation defines the translation vector3
  3218. * @param result defines the target matrix
  3219. */
  3220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3221. /**
  3222. * Creates a new identity matrix
  3223. * @returns a new identity matrix
  3224. */
  3225. static Identity(): Matrix;
  3226. /**
  3227. * Creates a new identity matrix and stores the result in a given matrix
  3228. * @param result defines the target matrix
  3229. */
  3230. static IdentityToRef(result: Matrix): void;
  3231. /**
  3232. * Creates a new zero matrix
  3233. * @returns a new zero matrix
  3234. */
  3235. static Zero(): Matrix;
  3236. /**
  3237. * Creates a new rotation matrix for "angle" radians around the X axis
  3238. * @param angle defines the angle (in radians) to use
  3239. * @return the new matrix
  3240. */
  3241. static RotationX(angle: number): Matrix;
  3242. /**
  3243. * Creates a new matrix as the invert of a given matrix
  3244. * @param source defines the source matrix
  3245. * @returns the new matrix
  3246. */
  3247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3248. /**
  3249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3250. * @param angle defines the angle (in radians) to use
  3251. * @param result defines the target matrix
  3252. */
  3253. static RotationXToRef(angle: number, result: Matrix): void;
  3254. /**
  3255. * Creates a new rotation matrix for "angle" radians around the Y axis
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationY(angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3262. * @param angle defines the angle (in radians) to use
  3263. * @param result defines the target matrix
  3264. */
  3265. static RotationYToRef(angle: number, result: Matrix): void;
  3266. /**
  3267. * Creates a new rotation matrix for "angle" radians around the Z axis
  3268. * @param angle defines the angle (in radians) to use
  3269. * @return the new matrix
  3270. */
  3271. static RotationZ(angle: number): Matrix;
  3272. /**
  3273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3274. * @param angle defines the angle (in radians) to use
  3275. * @param result defines the target matrix
  3276. */
  3277. static RotationZToRef(angle: number, result: Matrix): void;
  3278. /**
  3279. * Creates a new rotation matrix for "angle" radians around the given axis
  3280. * @param axis defines the axis to use
  3281. * @param angle defines the angle (in radians) to use
  3282. * @return the new matrix
  3283. */
  3284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3285. /**
  3286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3287. * @param axis defines the axis to use
  3288. * @param angle defines the angle (in radians) to use
  3289. * @param result defines the target matrix
  3290. */
  3291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3292. /**
  3293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3295. * @param from defines the vector to align
  3296. * @param to defines the vector to align to
  3297. * @param result defines the target matrix
  3298. */
  3299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3300. /**
  3301. * Creates a rotation matrix
  3302. * @param yaw defines the yaw angle in radians (Y axis)
  3303. * @param pitch defines the pitch angle in radians (X axis)
  3304. * @param roll defines the roll angle in radians (X axis)
  3305. * @returns the new rotation matrix
  3306. */
  3307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3308. /**
  3309. * Creates a rotation matrix and stores it in a given matrix
  3310. * @param yaw defines the yaw angle in radians (Y axis)
  3311. * @param pitch defines the pitch angle in radians (X axis)
  3312. * @param roll defines the roll angle in radians (X axis)
  3313. * @param result defines the target matrix
  3314. */
  3315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3316. /**
  3317. * Creates a scaling matrix
  3318. * @param x defines the scale factor on X axis
  3319. * @param y defines the scale factor on Y axis
  3320. * @param z defines the scale factor on Z axis
  3321. * @returns the new matrix
  3322. */
  3323. static Scaling(x: number, y: number, z: number): Matrix;
  3324. /**
  3325. * Creates a scaling matrix and stores it in a given matrix
  3326. * @param x defines the scale factor on X axis
  3327. * @param y defines the scale factor on Y axis
  3328. * @param z defines the scale factor on Z axis
  3329. * @param result defines the target matrix
  3330. */
  3331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3332. /**
  3333. * Creates a translation matrix
  3334. * @param x defines the translation on X axis
  3335. * @param y defines the translation on Y axis
  3336. * @param z defines the translationon Z axis
  3337. * @returns the new matrix
  3338. */
  3339. static Translation(x: number, y: number, z: number): Matrix;
  3340. /**
  3341. * Creates a translation matrix and stores it in a given matrix
  3342. * @param x defines the translation on X axis
  3343. * @param y defines the translation on Y axis
  3344. * @param z defines the translationon Z axis
  3345. * @param result defines the target matrix
  3346. */
  3347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3348. /**
  3349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3350. * @param startValue defines the start value
  3351. * @param endValue defines the end value
  3352. * @param gradient defines the gradient factor
  3353. * @returns the new matrix
  3354. */
  3355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3356. /**
  3357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3358. * @param startValue defines the start value
  3359. * @param endValue defines the end value
  3360. * @param gradient defines the gradient factor
  3361. * @param result defines the Matrix object where to store data
  3362. */
  3363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3364. /**
  3365. * Builds a new matrix whose values are computed by:
  3366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3369. * @param startValue defines the first matrix
  3370. * @param endValue defines the second matrix
  3371. * @param gradient defines the gradient between the two matrices
  3372. * @returns the new matrix
  3373. */
  3374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3375. /**
  3376. * Update a matrix to values which are computed by:
  3377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3380. * @param startValue defines the first matrix
  3381. * @param endValue defines the second matrix
  3382. * @param gradient defines the gradient between the two matrices
  3383. * @param result defines the target matrix
  3384. */
  3385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3386. /**
  3387. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3388. * This function works in left handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @returns the new matrix
  3393. */
  3394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3395. /**
  3396. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3397. * This function works in left handed mode
  3398. * @param eye defines the final position of the entity
  3399. * @param target defines where the entity should look at
  3400. * @param up defines the up vector for the entity
  3401. * @param result defines the target matrix
  3402. */
  3403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3404. /**
  3405. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3406. * This function works in right handed mode
  3407. * @param eye defines the final position of the entity
  3408. * @param target defines where the entity should look at
  3409. * @param up defines the up vector for the entity
  3410. * @returns the new matrix
  3411. */
  3412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3413. /**
  3414. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3415. * This function works in right handed mode
  3416. * @param eye defines the final position of the entity
  3417. * @param target defines where the entity should look at
  3418. * @param up defines the up vector for the entity
  3419. * @param result defines the target matrix
  3420. */
  3421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3422. /**
  3423. * Create a left-handed orthographic projection matrix
  3424. * @param width defines the viewport width
  3425. * @param height defines the viewport height
  3426. * @param znear defines the near clip plane
  3427. * @param zfar defines the far clip plane
  3428. * @returns a new matrix as a left-handed orthographic projection matrix
  3429. */
  3430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3431. /**
  3432. * Store a left-handed orthographic projection to a given matrix
  3433. * @param width defines the viewport width
  3434. * @param height defines the viewport height
  3435. * @param znear defines the near clip plane
  3436. * @param zfar defines the far clip plane
  3437. * @param result defines the target matrix
  3438. */
  3439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3440. /**
  3441. * Create a left-handed orthographic projection matrix
  3442. * @param left defines the viewport left coordinate
  3443. * @param right defines the viewport right coordinate
  3444. * @param bottom defines the viewport bottom coordinate
  3445. * @param top defines the viewport top coordinate
  3446. * @param znear defines the near clip plane
  3447. * @param zfar defines the far clip plane
  3448. * @returns a new matrix as a left-handed orthographic projection matrix
  3449. */
  3450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3451. /**
  3452. * Stores a left-handed orthographic projection into a given matrix
  3453. * @param left defines the viewport left coordinate
  3454. * @param right defines the viewport right coordinate
  3455. * @param bottom defines the viewport bottom coordinate
  3456. * @param top defines the viewport top coordinate
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @param result defines the target matrix
  3460. */
  3461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3462. /**
  3463. * Creates a right-handed orthographic projection matrix
  3464. * @param left defines the viewport left coordinate
  3465. * @param right defines the viewport right coordinate
  3466. * @param bottom defines the viewport bottom coordinate
  3467. * @param top defines the viewport top coordinate
  3468. * @param znear defines the near clip plane
  3469. * @param zfar defines the far clip plane
  3470. * @returns a new matrix as a right-handed orthographic projection matrix
  3471. */
  3472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3473. /**
  3474. * Stores a right-handed orthographic projection into a given matrix
  3475. * @param left defines the viewport left coordinate
  3476. * @param right defines the viewport right coordinate
  3477. * @param bottom defines the viewport bottom coordinate
  3478. * @param top defines the viewport top coordinate
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. */
  3483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3484. /**
  3485. * Creates a left-handed perspective projection matrix
  3486. * @param width defines the viewport width
  3487. * @param height defines the viewport height
  3488. * @param znear defines the near clip plane
  3489. * @param zfar defines the far clip plane
  3490. * @returns a new matrix as a left-handed perspective projection matrix
  3491. */
  3492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3493. /**
  3494. * Creates a left-handed perspective projection matrix
  3495. * @param fov defines the horizontal field of view
  3496. * @param aspect defines the aspect ratio
  3497. * @param znear defines the near clip plane
  3498. * @param zfar defines the far clip plane
  3499. * @returns a new matrix as a left-handed perspective projection matrix
  3500. */
  3501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3502. /**
  3503. * Stores a left-handed perspective projection into a given matrix
  3504. * @param fov defines the horizontal field of view
  3505. * @param aspect defines the aspect ratio
  3506. * @param znear defines the near clip plane
  3507. * @param zfar defines the far clip plane
  3508. * @param result defines the target matrix
  3509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3510. */
  3511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3512. /**
  3513. * Creates a right-handed perspective projection matrix
  3514. * @param fov defines the horizontal field of view
  3515. * @param aspect defines the aspect ratio
  3516. * @param znear defines the near clip plane
  3517. * @param zfar defines the far clip plane
  3518. * @returns a new matrix as a right-handed perspective projection matrix
  3519. */
  3520. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3521. /**
  3522. * Stores a right-handed perspective projection into a given matrix
  3523. * @param fov defines the horizontal field of view
  3524. * @param aspect defines the aspect ratio
  3525. * @param znear defines the near clip plane
  3526. * @param zfar defines the far clip plane
  3527. * @param result defines the target matrix
  3528. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3529. */
  3530. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3531. /**
  3532. * Stores a perspective projection for WebVR info a given matrix
  3533. * @param fov defines the field of view
  3534. * @param znear defines the near clip plane
  3535. * @param zfar defines the far clip plane
  3536. * @param result defines the target matrix
  3537. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3538. */
  3539. static PerspectiveFovWebVRToRef(fov: {
  3540. upDegrees: number;
  3541. downDegrees: number;
  3542. leftDegrees: number;
  3543. rightDegrees: number;
  3544. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3545. /**
  3546. * Computes a complete transformation matrix
  3547. * @param viewport defines the viewport to use
  3548. * @param world defines the world matrix
  3549. * @param view defines the view matrix
  3550. * @param projection defines the projection matrix
  3551. * @param zmin defines the near clip plane
  3552. * @param zmax defines the far clip plane
  3553. * @returns the transformation matrix
  3554. */
  3555. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3556. /**
  3557. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3558. * @param matrix defines the matrix to use
  3559. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3560. */
  3561. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3562. /**
  3563. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3564. * @param matrix defines the matrix to use
  3565. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3566. */
  3567. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3568. /**
  3569. * Compute the transpose of a given matrix
  3570. * @param matrix defines the matrix to transpose
  3571. * @returns the new matrix
  3572. */
  3573. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3574. /**
  3575. * Compute the transpose of a matrix and store it in a target matrix
  3576. * @param matrix defines the matrix to transpose
  3577. * @param result defines the target matrix
  3578. */
  3579. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3580. /**
  3581. * Computes a reflection matrix from a plane
  3582. * @param plane defines the reflection plane
  3583. * @returns a new matrix
  3584. */
  3585. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3586. /**
  3587. * Computes a reflection matrix from a plane
  3588. * @param plane defines the reflection plane
  3589. * @param result defines the target matrix
  3590. */
  3591. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3592. /**
  3593. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3594. * @param xaxis defines the value of the 1st axis
  3595. * @param yaxis defines the value of the 2nd axis
  3596. * @param zaxis defines the value of the 3rd axis
  3597. * @param result defines the target matrix
  3598. */
  3599. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3600. /**
  3601. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3602. * @param quat defines the quaternion to use
  3603. * @param result defines the target matrix
  3604. */
  3605. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3606. }
  3607. /**
  3608. * Represens a plane by the equation ax + by + cz + d = 0
  3609. */
  3610. export class Plane {
  3611. /**
  3612. * Normal of the plane (a,b,c)
  3613. */
  3614. normal: Vector3;
  3615. /**
  3616. * d component of the plane
  3617. */
  3618. d: number;
  3619. /**
  3620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3621. * @param a a component of the plane
  3622. * @param b b component of the plane
  3623. * @param c c component of the plane
  3624. * @param d d component of the plane
  3625. */
  3626. constructor(a: number, b: number, c: number, d: number);
  3627. /**
  3628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3629. */
  3630. asArray(): number[];
  3631. /**
  3632. * @returns a new plane copied from the current Plane.
  3633. */
  3634. clone(): Plane;
  3635. /**
  3636. * @returns the string "Plane".
  3637. */
  3638. getClassName(): string;
  3639. /**
  3640. * @returns the Plane hash code.
  3641. */
  3642. getHashCode(): number;
  3643. /**
  3644. * Normalize the current Plane in place.
  3645. * @returns the updated Plane.
  3646. */
  3647. normalize(): Plane;
  3648. /**
  3649. * Applies a transformation the plane and returns the result
  3650. * @param transformation the transformation matrix to be applied to the plane
  3651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3652. */
  3653. transform(transformation: DeepImmutable<Matrix>): Plane;
  3654. /**
  3655. * Calcualtte the dot product between the point and the plane normal
  3656. * @param point point to calculate the dot product with
  3657. * @returns the dot product (float) of the point coordinates and the plane normal.
  3658. */
  3659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3660. /**
  3661. * Updates the current Plane from the plane defined by the three given points.
  3662. * @param point1 one of the points used to contruct the plane
  3663. * @param point2 one of the points used to contruct the plane
  3664. * @param point3 one of the points used to contruct the plane
  3665. * @returns the updated Plane.
  3666. */
  3667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Checks if the plane is facing a given direction
  3670. * @param direction the direction to check if the plane is facing
  3671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3672. * @returns True is the vector "direction" is the same side than the plane normal.
  3673. */
  3674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3675. /**
  3676. * Calculates the distance to a point
  3677. * @param point point to calculate distance to
  3678. * @returns the signed distance (float) from the given point to the Plane.
  3679. */
  3680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3681. /**
  3682. * Creates a plane from an array
  3683. * @param array the array to create a plane from
  3684. * @returns a new Plane from the given array.
  3685. */
  3686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3687. /**
  3688. * Creates a plane from three points
  3689. * @param point1 point used to create the plane
  3690. * @param point2 point used to create the plane
  3691. * @param point3 point used to create the plane
  3692. * @returns a new Plane defined by the three given points.
  3693. */
  3694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3695. /**
  3696. * Creates a plane from an origin point and a normal
  3697. * @param origin origin of the plane to be constructed
  3698. * @param normal normal of the plane to be constructed
  3699. * @returns a new Plane the normal vector to this plane at the given origin point.
  3700. * Note : the vector "normal" is updated because normalized.
  3701. */
  3702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3703. /**
  3704. * Calculates the distance from a plane and a point
  3705. * @param origin origin of the plane to be constructed
  3706. * @param normal normal of the plane to be constructed
  3707. * @param point point to calculate distance to
  3708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3709. */
  3710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3711. }
  3712. /**
  3713. * Class used to represent a viewport on screen
  3714. */
  3715. export class Viewport {
  3716. /** viewport left coordinate */
  3717. x: number;
  3718. /** viewport top coordinate */
  3719. y: number;
  3720. /**viewport width */
  3721. width: number;
  3722. /** viewport height */
  3723. height: number;
  3724. /**
  3725. * Creates a Viewport object located at (x, y) and sized (width, height)
  3726. * @param x defines viewport left coordinate
  3727. * @param y defines viewport top coordinate
  3728. * @param width defines the viewport width
  3729. * @param height defines the viewport height
  3730. */
  3731. constructor(
  3732. /** viewport left coordinate */
  3733. x: number,
  3734. /** viewport top coordinate */
  3735. y: number,
  3736. /**viewport width */
  3737. width: number,
  3738. /** viewport height */
  3739. height: number);
  3740. /**
  3741. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3742. * @param renderWidth defines the rendering width
  3743. * @param renderHeight defines the rendering height
  3744. * @returns a new Viewport
  3745. */
  3746. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3747. /**
  3748. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3749. * @param renderWidth defines the rendering width
  3750. * @param renderHeight defines the rendering height
  3751. * @param ref defines the target viewport
  3752. * @returns the current viewport
  3753. */
  3754. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3755. /**
  3756. * Returns a new Viewport copied from the current one
  3757. * @returns a new Viewport
  3758. */
  3759. clone(): Viewport;
  3760. }
  3761. /**
  3762. * Reprasents a camera frustum
  3763. */
  3764. export class Frustum {
  3765. /**
  3766. * Gets the planes representing the frustum
  3767. * @param transform matrix to be applied to the returned planes
  3768. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3769. */
  3770. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3771. /**
  3772. * Gets the near frustum plane transformed by the transform matrix
  3773. * @param transform transformation matrix to be applied to the resulting frustum plane
  3774. * @param frustumPlane the resuling frustum plane
  3775. */
  3776. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3777. /**
  3778. * Gets the far frustum plane transformed by the transform matrix
  3779. * @param transform transformation matrix to be applied to the resulting frustum plane
  3780. * @param frustumPlane the resuling frustum plane
  3781. */
  3782. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3783. /**
  3784. * Gets the left frustum plane transformed by the transform matrix
  3785. * @param transform transformation matrix to be applied to the resulting frustum plane
  3786. * @param frustumPlane the resuling frustum plane
  3787. */
  3788. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3789. /**
  3790. * Gets the right frustum plane transformed by the transform matrix
  3791. * @param transform transformation matrix to be applied to the resulting frustum plane
  3792. * @param frustumPlane the resuling frustum plane
  3793. */
  3794. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3795. /**
  3796. * Gets the top frustum plane transformed by the transform matrix
  3797. * @param transform transformation matrix to be applied to the resulting frustum plane
  3798. * @param frustumPlane the resuling frustum plane
  3799. */
  3800. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3801. /**
  3802. * Gets the bottom frustum plane transformed by the transform matrix
  3803. * @param transform transformation matrix to be applied to the resulting frustum plane
  3804. * @param frustumPlane the resuling frustum plane
  3805. */
  3806. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3807. /**
  3808. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3809. * @param transform transformation matrix to be applied to the resulting frustum planes
  3810. * @param frustumPlanes the resuling frustum planes
  3811. */
  3812. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3813. }
  3814. /** Defines supported spaces */
  3815. export enum Space {
  3816. /** Local (object) space */
  3817. LOCAL = 0,
  3818. /** World space */
  3819. WORLD = 1,
  3820. /** Bone space */
  3821. BONE = 2
  3822. }
  3823. /** Defines the 3 main axes */
  3824. export class Axis {
  3825. /** X axis */
  3826. static X: Vector3;
  3827. /** Y axis */
  3828. static Y: Vector3;
  3829. /** Z axis */
  3830. static Z: Vector3;
  3831. }
  3832. /** Class used to represent a Bezier curve */
  3833. export class BezierCurve {
  3834. /**
  3835. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3836. * @param t defines the time
  3837. * @param x1 defines the left coordinate on X axis
  3838. * @param y1 defines the left coordinate on Y axis
  3839. * @param x2 defines the right coordinate on X axis
  3840. * @param y2 defines the right coordinate on Y axis
  3841. * @returns the interpolated value
  3842. */
  3843. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3844. }
  3845. /**
  3846. * Defines potential orientation for back face culling
  3847. */
  3848. export enum Orientation {
  3849. /**
  3850. * Clockwise
  3851. */
  3852. CW = 0,
  3853. /** Counter clockwise */
  3854. CCW = 1
  3855. }
  3856. /**
  3857. * Defines angle representation
  3858. */
  3859. export class Angle {
  3860. private _radians;
  3861. /**
  3862. * Creates an Angle object of "radians" radians (float).
  3863. * @param radians the angle in radians
  3864. */
  3865. constructor(radians: number);
  3866. /**
  3867. * Get value in degrees
  3868. * @returns the Angle value in degrees (float)
  3869. */
  3870. degrees(): number;
  3871. /**
  3872. * Get value in radians
  3873. * @returns the Angle value in radians (float)
  3874. */
  3875. radians(): number;
  3876. /**
  3877. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3878. * @param a defines first vector
  3879. * @param b defines second vector
  3880. * @returns a new Angle
  3881. */
  3882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3883. /**
  3884. * Gets a new Angle object from the given float in radians
  3885. * @param radians defines the angle value in radians
  3886. * @returns a new Angle
  3887. */
  3888. static FromRadians(radians: number): Angle;
  3889. /**
  3890. * Gets a new Angle object from the given float in degrees
  3891. * @param degrees defines the angle value in degrees
  3892. * @returns a new Angle
  3893. */
  3894. static FromDegrees(degrees: number): Angle;
  3895. }
  3896. /**
  3897. * This represents an arc in a 2d space.
  3898. */
  3899. export class Arc2 {
  3900. /** Defines the start point of the arc */
  3901. startPoint: Vector2;
  3902. /** Defines the mid point of the arc */
  3903. midPoint: Vector2;
  3904. /** Defines the end point of the arc */
  3905. endPoint: Vector2;
  3906. /**
  3907. * Defines the center point of the arc.
  3908. */
  3909. centerPoint: Vector2;
  3910. /**
  3911. * Defines the radius of the arc.
  3912. */
  3913. radius: number;
  3914. /**
  3915. * Defines the angle of the arc (from mid point to end point).
  3916. */
  3917. angle: Angle;
  3918. /**
  3919. * Defines the start angle of the arc (from start point to middle point).
  3920. */
  3921. startAngle: Angle;
  3922. /**
  3923. * Defines the orientation of the arc (clock wise/counter clock wise).
  3924. */
  3925. orientation: Orientation;
  3926. /**
  3927. * Creates an Arc object from the three given points : start, middle and end.
  3928. * @param startPoint Defines the start point of the arc
  3929. * @param midPoint Defines the midlle point of the arc
  3930. * @param endPoint Defines the end point of the arc
  3931. */
  3932. constructor(
  3933. /** Defines the start point of the arc */
  3934. startPoint: Vector2,
  3935. /** Defines the mid point of the arc */
  3936. midPoint: Vector2,
  3937. /** Defines the end point of the arc */
  3938. endPoint: Vector2);
  3939. }
  3940. /**
  3941. * Represents a 2D path made up of multiple 2D points
  3942. */
  3943. export class Path2 {
  3944. private _points;
  3945. private _length;
  3946. /**
  3947. * If the path start and end point are the same
  3948. */
  3949. closed: boolean;
  3950. /**
  3951. * Creates a Path2 object from the starting 2D coordinates x and y.
  3952. * @param x the starting points x value
  3953. * @param y the starting points y value
  3954. */
  3955. constructor(x: number, y: number);
  3956. /**
  3957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3958. * @param x the added points x value
  3959. * @param y the added points y value
  3960. * @returns the updated Path2.
  3961. */
  3962. addLineTo(x: number, y: number): Path2;
  3963. /**
  3964. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3965. * @param midX middle point x value
  3966. * @param midY middle point y value
  3967. * @param endX end point x value
  3968. * @param endY end point y value
  3969. * @param numberOfSegments (default: 36)
  3970. * @returns the updated Path2.
  3971. */
  3972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3973. /**
  3974. * Closes the Path2.
  3975. * @returns the Path2.
  3976. */
  3977. close(): Path2;
  3978. /**
  3979. * Gets the sum of the distance between each sequential point in the path
  3980. * @returns the Path2 total length (float).
  3981. */
  3982. length(): number;
  3983. /**
  3984. * Gets the points which construct the path
  3985. * @returns the Path2 internal array of points.
  3986. */
  3987. getPoints(): Vector2[];
  3988. /**
  3989. * Retreives the point at the distance aways from the starting point
  3990. * @param normalizedLengthPosition the length along the path to retreive the point from
  3991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3992. */
  3993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3994. /**
  3995. * Creates a new path starting from an x and y position
  3996. * @param x starting x value
  3997. * @param y starting y value
  3998. * @returns a new Path2 starting at the coordinates (x, y).
  3999. */
  4000. static StartingAt(x: number, y: number): Path2;
  4001. }
  4002. /**
  4003. * Represents a 3D path made up of multiple 3D points
  4004. */
  4005. export class Path3D {
  4006. /**
  4007. * an array of Vector3, the curve axis of the Path3D
  4008. */
  4009. path: Vector3[];
  4010. private _curve;
  4011. private _distances;
  4012. private _tangents;
  4013. private _normals;
  4014. private _binormals;
  4015. private _raw;
  4016. /**
  4017. * new Path3D(path, normal, raw)
  4018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4020. * @param path an array of Vector3, the curve axis of the Path3D
  4021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4023. */
  4024. constructor(
  4025. /**
  4026. * an array of Vector3, the curve axis of the Path3D
  4027. */
  4028. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4029. /**
  4030. * Returns the Path3D array of successive Vector3 designing its curve.
  4031. * @returns the Path3D array of successive Vector3 designing its curve.
  4032. */
  4033. getCurve(): Vector3[];
  4034. /**
  4035. * Returns an array populated with tangent vectors on each Path3D curve point.
  4036. * @returns an array populated with tangent vectors on each Path3D curve point.
  4037. */
  4038. getTangents(): Vector3[];
  4039. /**
  4040. * Returns an array populated with normal vectors on each Path3D curve point.
  4041. * @returns an array populated with normal vectors on each Path3D curve point.
  4042. */
  4043. getNormals(): Vector3[];
  4044. /**
  4045. * Returns an array populated with binormal vectors on each Path3D curve point.
  4046. * @returns an array populated with binormal vectors on each Path3D curve point.
  4047. */
  4048. getBinormals(): Vector3[];
  4049. /**
  4050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4051. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4052. */
  4053. getDistances(): number[];
  4054. /**
  4055. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4056. * @param path path which all values are copied into the curves points
  4057. * @param firstNormal which should be projected onto the curve
  4058. * @returns the same object updated.
  4059. */
  4060. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4061. private _compute;
  4062. private _getFirstNonNullVector;
  4063. private _getLastNonNullVector;
  4064. private _normalVector;
  4065. }
  4066. /**
  4067. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4068. * A Curve3 is designed from a series of successive Vector3.
  4069. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4070. */
  4071. export class Curve3 {
  4072. private _points;
  4073. private _length;
  4074. /**
  4075. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4076. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4077. * @param v1 (Vector3) the control point
  4078. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4079. * @param nbPoints (integer) the wanted number of points in the curve
  4080. * @returns the created Curve3
  4081. */
  4082. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4083. /**
  4084. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4085. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4086. * @param v1 (Vector3) the first control point
  4087. * @param v2 (Vector3) the second control point
  4088. * @param v3 (Vector3) the end point of the Cubic Bezier
  4089. * @param nbPoints (integer) the wanted number of points in the curve
  4090. * @returns the created Curve3
  4091. */
  4092. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4093. /**
  4094. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4095. * @param p1 (Vector3) the origin point of the Hermite Spline
  4096. * @param t1 (Vector3) the tangent vector at the origin point
  4097. * @param p2 (Vector3) the end point of the Hermite Spline
  4098. * @param t2 (Vector3) the tangent vector at the end point
  4099. * @param nbPoints (integer) the wanted number of points in the curve
  4100. * @returns the created Curve3
  4101. */
  4102. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4103. /**
  4104. * Returns a Curve3 object along a CatmullRom Spline curve :
  4105. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4106. * @param nbPoints (integer) the wanted number of points between each curve control points
  4107. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4108. * @returns the created Curve3
  4109. */
  4110. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4111. /**
  4112. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4113. * A Curve3 is designed from a series of successive Vector3.
  4114. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4115. * @param points points which make up the curve
  4116. */
  4117. constructor(points: Vector3[]);
  4118. /**
  4119. * @returns the Curve3 stored array of successive Vector3
  4120. */
  4121. getPoints(): Vector3[];
  4122. /**
  4123. * @returns the computed length (float) of the curve.
  4124. */
  4125. length(): number;
  4126. /**
  4127. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4128. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4129. * curveA and curveB keep unchanged.
  4130. * @param curve the curve to continue from this curve
  4131. * @returns the newly constructed curve
  4132. */
  4133. continue(curve: DeepImmutable<Curve3>): Curve3;
  4134. private _computeLength;
  4135. }
  4136. /**
  4137. * Contains position and normal vectors for a vertex
  4138. */
  4139. export class PositionNormalVertex {
  4140. /** the position of the vertex (defaut: 0,0,0) */
  4141. position: Vector3;
  4142. /** the normal of the vertex (defaut: 0,1,0) */
  4143. normal: Vector3;
  4144. /**
  4145. * Creates a PositionNormalVertex
  4146. * @param position the position of the vertex (defaut: 0,0,0)
  4147. * @param normal the normal of the vertex (defaut: 0,1,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3);
  4154. /**
  4155. * Clones the PositionNormalVertex
  4156. * @returns the cloned PositionNormalVertex
  4157. */
  4158. clone(): PositionNormalVertex;
  4159. }
  4160. /**
  4161. * Contains position, normal and uv vectors for a vertex
  4162. */
  4163. export class PositionNormalTextureVertex {
  4164. /** the position of the vertex (defaut: 0,0,0) */
  4165. position: Vector3;
  4166. /** the normal of the vertex (defaut: 0,1,0) */
  4167. normal: Vector3;
  4168. /** the uv of the vertex (default: 0,0) */
  4169. uv: Vector2;
  4170. /**
  4171. * Creates a PositionNormalTextureVertex
  4172. * @param position the position of the vertex (defaut: 0,0,0)
  4173. * @param normal the normal of the vertex (defaut: 0,1,0)
  4174. * @param uv the uv of the vertex (default: 0,0)
  4175. */
  4176. constructor(
  4177. /** the position of the vertex (defaut: 0,0,0) */
  4178. position?: Vector3,
  4179. /** the normal of the vertex (defaut: 0,1,0) */
  4180. normal?: Vector3,
  4181. /** the uv of the vertex (default: 0,0) */
  4182. uv?: Vector2);
  4183. /**
  4184. * Clones the PositionNormalTextureVertex
  4185. * @returns the cloned PositionNormalTextureVertex
  4186. */
  4187. clone(): PositionNormalTextureVertex;
  4188. }
  4189. /**
  4190. * @hidden
  4191. */
  4192. export class Tmp {
  4193. static Color3: Color3[];
  4194. static Color4: Color4[];
  4195. static Vector2: Vector2[];
  4196. static Vector3: Vector3[];
  4197. static Vector4: Vector4[];
  4198. static Quaternion: Quaternion[];
  4199. static Matrix: Matrix[];
  4200. }
  4201. }
  4202. declare module "babylonjs/Offline/IOfflineProvider" {
  4203. /**
  4204. * Class used to enable access to offline support
  4205. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4206. */
  4207. export interface IOfflineProvider {
  4208. /**
  4209. * Gets a boolean indicating if scene must be saved in the database
  4210. */
  4211. enableSceneOffline: boolean;
  4212. /**
  4213. * Gets a boolean indicating if textures must be saved in the database
  4214. */
  4215. enableTexturesOffline: boolean;
  4216. /**
  4217. * Open the offline support and make it available
  4218. * @param successCallback defines the callback to call on success
  4219. * @param errorCallback defines the callback to call on error
  4220. */
  4221. open(successCallback: () => void, errorCallback: () => void): void;
  4222. /**
  4223. * Loads an image from the offline support
  4224. * @param url defines the url to load from
  4225. * @param image defines the target DOM image
  4226. */
  4227. loadImage(url: string, image: HTMLImageElement): void;
  4228. /**
  4229. * Loads a file from offline support
  4230. * @param url defines the URL to load from
  4231. * @param sceneLoaded defines a callback to call on success
  4232. * @param progressCallBack defines a callback to call when progress changed
  4233. * @param errorCallback defines a callback to call on error
  4234. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4235. */
  4236. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4237. }
  4238. }
  4239. declare module "babylonjs/Misc/observable" {
  4240. import { Nullable } from "babylonjs/types";
  4241. /**
  4242. * A class serves as a medium between the observable and its observers
  4243. */
  4244. export class EventState {
  4245. /**
  4246. * Create a new EventState
  4247. * @param mask defines the mask associated with this state
  4248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4249. * @param target defines the original target of the state
  4250. * @param currentTarget defines the current target of the state
  4251. */
  4252. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4253. /**
  4254. * Initialize the current event state
  4255. * @param mask defines the mask associated with this state
  4256. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4257. * @param target defines the original target of the state
  4258. * @param currentTarget defines the current target of the state
  4259. * @returns the current event state
  4260. */
  4261. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4262. /**
  4263. * An Observer can set this property to true to prevent subsequent observers of being notified
  4264. */
  4265. skipNextObservers: boolean;
  4266. /**
  4267. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4268. */
  4269. mask: number;
  4270. /**
  4271. * The object that originally notified the event
  4272. */
  4273. target?: any;
  4274. /**
  4275. * The current object in the bubbling phase
  4276. */
  4277. currentTarget?: any;
  4278. /**
  4279. * This will be populated with the return value of the last function that was executed.
  4280. * If it is the first function in the callback chain it will be the event data.
  4281. */
  4282. lastReturnValue?: any;
  4283. }
  4284. /**
  4285. * Represent an Observer registered to a given Observable object.
  4286. */
  4287. export class Observer<T> {
  4288. /**
  4289. * Defines the callback to call when the observer is notified
  4290. */
  4291. callback: (eventData: T, eventState: EventState) => void;
  4292. /**
  4293. * Defines the mask of the observer (used to filter notifications)
  4294. */
  4295. mask: number;
  4296. /**
  4297. * Defines the current scope used to restore the JS context
  4298. */
  4299. scope: any;
  4300. /** @hidden */
  4301. _willBeUnregistered: boolean;
  4302. /**
  4303. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4304. */
  4305. unregisterOnNextCall: boolean;
  4306. /**
  4307. * Creates a new observer
  4308. * @param callback defines the callback to call when the observer is notified
  4309. * @param mask defines the mask of the observer (used to filter notifications)
  4310. * @param scope defines the current scope used to restore the JS context
  4311. */
  4312. constructor(
  4313. /**
  4314. * Defines the callback to call when the observer is notified
  4315. */
  4316. callback: (eventData: T, eventState: EventState) => void,
  4317. /**
  4318. * Defines the mask of the observer (used to filter notifications)
  4319. */
  4320. mask: number,
  4321. /**
  4322. * Defines the current scope used to restore the JS context
  4323. */
  4324. scope?: any);
  4325. }
  4326. /**
  4327. * Represent a list of observers registered to multiple Observables object.
  4328. */
  4329. export class MultiObserver<T> {
  4330. private _observers;
  4331. private _observables;
  4332. /**
  4333. * Release associated resources
  4334. */
  4335. dispose(): void;
  4336. /**
  4337. * Raise a callback when one of the observable will notify
  4338. * @param observables defines a list of observables to watch
  4339. * @param callback defines the callback to call on notification
  4340. * @param mask defines the mask used to filter notifications
  4341. * @param scope defines the current scope used to restore the JS context
  4342. * @returns the new MultiObserver
  4343. */
  4344. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4345. }
  4346. /**
  4347. * The Observable class is a simple implementation of the Observable pattern.
  4348. *
  4349. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4350. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4351. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4352. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4353. */
  4354. export class Observable<T> {
  4355. private _observers;
  4356. private _eventState;
  4357. private _onObserverAdded;
  4358. /**
  4359. * Creates a new observable
  4360. * @param onObserverAdded defines a callback to call when a new observer is added
  4361. */
  4362. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4363. /**
  4364. * Create a new Observer with the specified callback
  4365. * @param callback the callback that will be executed for that Observer
  4366. * @param mask the mask used to filter observers
  4367. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4368. * @param scope optional scope for the callback to be called from
  4369. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4370. * @returns the new observer created for the callback
  4371. */
  4372. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4373. /**
  4374. * Create a new Observer with the specified callback and unregisters after the next notification
  4375. * @param callback the callback that will be executed for that Observer
  4376. * @returns the new observer created for the callback
  4377. */
  4378. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4379. /**
  4380. * Remove an Observer from the Observable object
  4381. * @param observer the instance of the Observer to remove
  4382. * @returns false if it doesn't belong to this Observable
  4383. */
  4384. remove(observer: Nullable<Observer<T>>): boolean;
  4385. /**
  4386. * Remove a callback from the Observable object
  4387. * @param callback the callback to remove
  4388. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4389. * @returns false if it doesn't belong to this Observable
  4390. */
  4391. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4392. private _deferUnregister;
  4393. private _remove;
  4394. /**
  4395. * Moves the observable to the top of the observer list making it get called first when notified
  4396. * @param observer the observer to move
  4397. */
  4398. makeObserverTopPriority(observer: Observer<T>): void;
  4399. /**
  4400. * Moves the observable to the bottom of the observer list making it get called last when notified
  4401. * @param observer the observer to move
  4402. */
  4403. makeObserverBottomPriority(observer: Observer<T>): void;
  4404. /**
  4405. * Notify all Observers by calling their respective callback with the given data
  4406. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4407. * @param eventData defines the data to send to all observers
  4408. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4409. * @param target defines the original target of the state
  4410. * @param currentTarget defines the current target of the state
  4411. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4412. */
  4413. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4414. /**
  4415. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4416. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4417. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4418. * and it is crucial that all callbacks will be executed.
  4419. * The order of the callbacks is kept, callbacks are not executed parallel.
  4420. *
  4421. * @param eventData The data to be sent to each callback
  4422. * @param mask is used to filter observers defaults to -1
  4423. * @param target defines the callback target (see EventState)
  4424. * @param currentTarget defines he current object in the bubbling phase
  4425. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4426. */
  4427. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4428. /**
  4429. * Notify a specific observer
  4430. * @param observer defines the observer to notify
  4431. * @param eventData defines the data to be sent to each callback
  4432. * @param mask is used to filter observers defaults to -1
  4433. */
  4434. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4435. /**
  4436. * Gets a boolean indicating if the observable has at least one observer
  4437. * @returns true is the Observable has at least one Observer registered
  4438. */
  4439. hasObservers(): boolean;
  4440. /**
  4441. * Clear the list of observers
  4442. */
  4443. clear(): void;
  4444. /**
  4445. * Clone the current observable
  4446. * @returns a new observable
  4447. */
  4448. clone(): Observable<T>;
  4449. /**
  4450. * Does this observable handles observer registered with a given mask
  4451. * @param mask defines the mask to be tested
  4452. * @return whether or not one observer registered with the given mask is handeled
  4453. **/
  4454. hasSpecificMask(mask?: number): boolean;
  4455. }
  4456. }
  4457. declare module "babylonjs/Misc/filesInputStore" {
  4458. /**
  4459. * Class used to help managing file picking and drag'n'drop
  4460. * File Storage
  4461. */
  4462. export class FilesInputStore {
  4463. /**
  4464. * List of files ready to be loaded
  4465. */
  4466. static FilesToLoad: {
  4467. [key: string]: File;
  4468. };
  4469. }
  4470. }
  4471. declare module "babylonjs/Engines/constants" {
  4472. /** Defines the cross module used constants to avoid circular dependncies */
  4473. export class Constants {
  4474. /** Defines that alpha blending is disabled */
  4475. static readonly ALPHA_DISABLE: number;
  4476. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4477. static readonly ALPHA_ADD: number;
  4478. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4479. static readonly ALPHA_COMBINE: number;
  4480. /** Defines that alpha blending to DEST - SRC * DEST */
  4481. static readonly ALPHA_SUBTRACT: number;
  4482. /** Defines that alpha blending to SRC * DEST */
  4483. static readonly ALPHA_MULTIPLY: number;
  4484. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4485. static readonly ALPHA_MAXIMIZED: number;
  4486. /** Defines that alpha blending to SRC + DEST */
  4487. static readonly ALPHA_ONEONE: number;
  4488. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4489. static readonly ALPHA_PREMULTIPLIED: number;
  4490. /**
  4491. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4492. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4493. */
  4494. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4495. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4496. static readonly ALPHA_INTERPOLATE: number;
  4497. /**
  4498. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4499. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4500. */
  4501. static readonly ALPHA_SCREENMODE: number;
  4502. /** Defines that the ressource is not delayed*/
  4503. static readonly DELAYLOADSTATE_NONE: number;
  4504. /** Defines that the ressource was successfully delay loaded */
  4505. static readonly DELAYLOADSTATE_LOADED: number;
  4506. /** Defines that the ressource is currently delay loading */
  4507. static readonly DELAYLOADSTATE_LOADING: number;
  4508. /** Defines that the ressource is delayed and has not started loading */
  4509. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4510. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4511. static readonly NEVER: number;
  4512. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4513. static readonly ALWAYS: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4515. static readonly LESS: number;
  4516. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4517. static readonly EQUAL: number;
  4518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4519. static readonly LEQUAL: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4521. static readonly GREATER: number;
  4522. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4523. static readonly GEQUAL: number;
  4524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4525. static readonly NOTEQUAL: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be kept */
  4527. static readonly KEEP: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4529. static readonly REPLACE: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4531. static readonly INCR: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4533. static readonly DECR: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4535. static readonly INVERT: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4537. static readonly INCR_WRAP: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4539. static readonly DECR_WRAP: number;
  4540. /** Texture is not repeating outside of 0..1 UVs */
  4541. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4542. /** Texture is repeating outside of 0..1 UVs */
  4543. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4544. /** Texture is repeating and mirrored */
  4545. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4546. /** ALPHA */
  4547. static readonly TEXTUREFORMAT_ALPHA: number;
  4548. /** LUMINANCE */
  4549. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4550. /** LUMINANCE_ALPHA */
  4551. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4552. /** RGB */
  4553. static readonly TEXTUREFORMAT_RGB: number;
  4554. /** RGBA */
  4555. static readonly TEXTUREFORMAT_RGBA: number;
  4556. /** RED */
  4557. static readonly TEXTUREFORMAT_RED: number;
  4558. /** RED (2nd reference) */
  4559. static readonly TEXTUREFORMAT_R: number;
  4560. /** RG */
  4561. static readonly TEXTUREFORMAT_RG: number;
  4562. /** RED_INTEGER */
  4563. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4564. /** RED_INTEGER (2nd reference) */
  4565. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4566. /** RG_INTEGER */
  4567. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4568. /** RGB_INTEGER */
  4569. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4570. /** RGBA_INTEGER */
  4571. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4572. /** UNSIGNED_BYTE */
  4573. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4574. /** UNSIGNED_BYTE (2nd reference) */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4576. /** FLOAT */
  4577. static readonly TEXTURETYPE_FLOAT: number;
  4578. /** HALF_FLOAT */
  4579. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4580. /** BYTE */
  4581. static readonly TEXTURETYPE_BYTE: number;
  4582. /** SHORT */
  4583. static readonly TEXTURETYPE_SHORT: number;
  4584. /** UNSIGNED_SHORT */
  4585. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4586. /** INT */
  4587. static readonly TEXTURETYPE_INT: number;
  4588. /** UNSIGNED_INT */
  4589. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4590. /** UNSIGNED_SHORT_4_4_4_4 */
  4591. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4592. /** UNSIGNED_SHORT_5_5_5_1 */
  4593. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4594. /** UNSIGNED_SHORT_5_6_5 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4596. /** UNSIGNED_INT_2_10_10_10_REV */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4598. /** UNSIGNED_INT_24_8 */
  4599. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4600. /** UNSIGNED_INT_10F_11F_11F_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4602. /** UNSIGNED_INT_5_9_9_9_REV */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4604. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4605. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4606. /** nearest is mag = nearest and min = nearest and mip = linear */
  4607. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4608. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4609. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4610. /** Trilinear is mag = linear and min = linear and mip = linear */
  4611. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4612. /** nearest is mag = nearest and min = nearest and mip = linear */
  4613. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4614. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4615. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4616. /** Trilinear is mag = linear and min = linear and mip = linear */
  4617. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4618. /** mag = nearest and min = nearest and mip = nearest */
  4619. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4620. /** mag = nearest and min = linear and mip = nearest */
  4621. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4622. /** mag = nearest and min = linear and mip = linear */
  4623. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4624. /** mag = nearest and min = linear and mip = none */
  4625. static readonly TEXTURE_NEAREST_LINEAR: number;
  4626. /** mag = nearest and min = nearest and mip = none */
  4627. static readonly TEXTURE_NEAREST_NEAREST: number;
  4628. /** mag = linear and min = nearest and mip = nearest */
  4629. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4630. /** mag = linear and min = nearest and mip = linear */
  4631. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4632. /** mag = linear and min = linear and mip = none */
  4633. static readonly TEXTURE_LINEAR_LINEAR: number;
  4634. /** mag = linear and min = nearest and mip = none */
  4635. static readonly TEXTURE_LINEAR_NEAREST: number;
  4636. /** Explicit coordinates mode */
  4637. static readonly TEXTURE_EXPLICIT_MODE: number;
  4638. /** Spherical coordinates mode */
  4639. static readonly TEXTURE_SPHERICAL_MODE: number;
  4640. /** Planar coordinates mode */
  4641. static readonly TEXTURE_PLANAR_MODE: number;
  4642. /** Cubic coordinates mode */
  4643. static readonly TEXTURE_CUBIC_MODE: number;
  4644. /** Projection coordinates mode */
  4645. static readonly TEXTURE_PROJECTION_MODE: number;
  4646. /** Skybox coordinates mode */
  4647. static readonly TEXTURE_SKYBOX_MODE: number;
  4648. /** Inverse Cubic coordinates mode */
  4649. static readonly TEXTURE_INVCUBIC_MODE: number;
  4650. /** Equirectangular coordinates mode */
  4651. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4652. /** Equirectangular Fixed coordinates mode */
  4653. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4654. /** Equirectangular Fixed Mirrored coordinates mode */
  4655. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4656. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4657. static readonly SCALEMODE_FLOOR: number;
  4658. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4659. static readonly SCALEMODE_NEAREST: number;
  4660. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4661. static readonly SCALEMODE_CEILING: number;
  4662. /**
  4663. * The dirty texture flag value
  4664. */
  4665. static readonly MATERIAL_TextureDirtyFlag: number;
  4666. /**
  4667. * The dirty light flag value
  4668. */
  4669. static readonly MATERIAL_LightDirtyFlag: number;
  4670. /**
  4671. * The dirty fresnel flag value
  4672. */
  4673. static readonly MATERIAL_FresnelDirtyFlag: number;
  4674. /**
  4675. * The dirty attribute flag value
  4676. */
  4677. static readonly MATERIAL_AttributesDirtyFlag: number;
  4678. /**
  4679. * The dirty misc flag value
  4680. */
  4681. static readonly MATERIAL_MiscDirtyFlag: number;
  4682. /**
  4683. * The all dirty flag value
  4684. */
  4685. static readonly MATERIAL_AllDirtyFlag: number;
  4686. /**
  4687. * Returns the triangle fill mode
  4688. */
  4689. static readonly MATERIAL_TriangleFillMode: number;
  4690. /**
  4691. * Returns the wireframe mode
  4692. */
  4693. static readonly MATERIAL_WireFrameFillMode: number;
  4694. /**
  4695. * Returns the point fill mode
  4696. */
  4697. static readonly MATERIAL_PointFillMode: number;
  4698. /**
  4699. * Returns the point list draw mode
  4700. */
  4701. static readonly MATERIAL_PointListDrawMode: number;
  4702. /**
  4703. * Returns the line list draw mode
  4704. */
  4705. static readonly MATERIAL_LineListDrawMode: number;
  4706. /**
  4707. * Returns the line loop draw mode
  4708. */
  4709. static readonly MATERIAL_LineLoopDrawMode: number;
  4710. /**
  4711. * Returns the line strip draw mode
  4712. */
  4713. static readonly MATERIAL_LineStripDrawMode: number;
  4714. /**
  4715. * Returns the triangle strip draw mode
  4716. */
  4717. static readonly MATERIAL_TriangleStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle fan draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleFanDrawMode: number;
  4722. /**
  4723. * Stores the clock-wise side orientation
  4724. */
  4725. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4726. /**
  4727. * Stores the counter clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4730. /**
  4731. * Nothing
  4732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4733. */
  4734. static readonly ACTION_NothingTrigger: number;
  4735. /**
  4736. * On pick
  4737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4738. */
  4739. static readonly ACTION_OnPickTrigger: number;
  4740. /**
  4741. * On left pick
  4742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4743. */
  4744. static readonly ACTION_OnLeftPickTrigger: number;
  4745. /**
  4746. * On right pick
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnRightPickTrigger: number;
  4750. /**
  4751. * On center pick
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnCenterPickTrigger: number;
  4755. /**
  4756. * On pick down
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPickDownTrigger: number;
  4760. /**
  4761. * On double pick
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnDoublePickTrigger: number;
  4765. /**
  4766. * On pick up
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnPickUpTrigger: number;
  4770. /**
  4771. * On pick out.
  4772. * This trigger will only be raised if you also declared a OnPickDown
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnPickOutTrigger: number;
  4776. /**
  4777. * On long press
  4778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4779. */
  4780. static readonly ACTION_OnLongPressTrigger: number;
  4781. /**
  4782. * On pointer over
  4783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4784. */
  4785. static readonly ACTION_OnPointerOverTrigger: number;
  4786. /**
  4787. * On pointer out
  4788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4789. */
  4790. static readonly ACTION_OnPointerOutTrigger: number;
  4791. /**
  4792. * On every frame
  4793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4794. */
  4795. static readonly ACTION_OnEveryFrameTrigger: number;
  4796. /**
  4797. * On intersection enter
  4798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4799. */
  4800. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4801. /**
  4802. * On intersection exit
  4803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4804. */
  4805. static readonly ACTION_OnIntersectionExitTrigger: number;
  4806. /**
  4807. * On key down
  4808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4809. */
  4810. static readonly ACTION_OnKeyDownTrigger: number;
  4811. /**
  4812. * On key up
  4813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4814. */
  4815. static readonly ACTION_OnKeyUpTrigger: number;
  4816. /**
  4817. * Billboard mode will only apply to Y axis
  4818. */
  4819. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4820. /**
  4821. * Billboard mode will apply to all axes
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4824. /**
  4825. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4828. /**
  4829. * Gets or sets base Assets URL
  4830. */
  4831. static PARTICLES_BaseAssetsUrl: string;
  4832. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4833. * Test order :
  4834. * Is the bounding sphere outside the frustum ?
  4835. * If not, are the bounding box vertices outside the frustum ?
  4836. * It not, then the cullable object is in the frustum.
  4837. */
  4838. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4839. /** Culling strategy : Bounding Sphere Only.
  4840. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4841. * It's also less accurate than the standard because some not visible objects can still be selected.
  4842. * Test : is the bounding sphere outside the frustum ?
  4843. * If not, then the cullable object is in the frustum.
  4844. */
  4845. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4846. /** Culling strategy : Optimistic Inclusion.
  4847. * This in an inclusion test first, then the standard exclusion test.
  4848. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4849. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4850. * Anyway, it's as accurate as the standard strategy.
  4851. * Test :
  4852. * Is the cullable object bounding sphere center in the frustum ?
  4853. * If not, apply the default culling strategy.
  4854. */
  4855. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4856. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4857. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4858. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4859. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4860. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4861. * Test :
  4862. * Is the cullable object bounding sphere center in the frustum ?
  4863. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4864. */
  4865. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4866. /**
  4867. * No logging while loading
  4868. */
  4869. static readonly SCENELOADER_NO_LOGGING: number;
  4870. /**
  4871. * Minimal logging while loading
  4872. */
  4873. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4874. /**
  4875. * Summary logging while loading
  4876. */
  4877. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4878. /**
  4879. * Detailled logging while loading
  4880. */
  4881. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4882. }
  4883. }
  4884. declare module "babylonjs/Misc/domManagement" {
  4885. /**
  4886. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4887. * Babylon.js
  4888. */
  4889. export class DomManagement {
  4890. /**
  4891. * Checks if the window object exists
  4892. * @returns true if the window object exists
  4893. */
  4894. static IsWindowObjectExist(): boolean;
  4895. /**
  4896. * Extracts text content from a DOM element hierarchy
  4897. * @param element defines the root element
  4898. * @returns a string
  4899. */
  4900. static GetDOMTextContent(element: HTMLElement): string;
  4901. }
  4902. }
  4903. declare module "babylonjs/Misc/logger" {
  4904. /**
  4905. * Logger used througouht the application to allow configuration of
  4906. * the log level required for the messages.
  4907. */
  4908. export class Logger {
  4909. /**
  4910. * No log
  4911. */
  4912. static readonly NoneLogLevel: number;
  4913. /**
  4914. * Only message logs
  4915. */
  4916. static readonly MessageLogLevel: number;
  4917. /**
  4918. * Only warning logs
  4919. */
  4920. static readonly WarningLogLevel: number;
  4921. /**
  4922. * Only error logs
  4923. */
  4924. static readonly ErrorLogLevel: number;
  4925. /**
  4926. * All logs
  4927. */
  4928. static readonly AllLogLevel: number;
  4929. private static _LogCache;
  4930. /**
  4931. * Gets a value indicating the number of loading errors
  4932. * @ignorenaming
  4933. */
  4934. static errorsCount: number;
  4935. /**
  4936. * Callback called when a new log is added
  4937. */
  4938. static OnNewCacheEntry: (entry: string) => void;
  4939. private static _AddLogEntry;
  4940. private static _FormatMessage;
  4941. private static _LogDisabled;
  4942. private static _LogEnabled;
  4943. private static _WarnDisabled;
  4944. private static _WarnEnabled;
  4945. private static _ErrorDisabled;
  4946. private static _ErrorEnabled;
  4947. /**
  4948. * Log a message to the console
  4949. */
  4950. static Log: (message: string) => void;
  4951. /**
  4952. * Write a warning message to the console
  4953. */
  4954. static Warn: (message: string) => void;
  4955. /**
  4956. * Write an error message to the console
  4957. */
  4958. static Error: (message: string) => void;
  4959. /**
  4960. * Gets current log cache (list of logs)
  4961. */
  4962. static readonly LogCache: string;
  4963. /**
  4964. * Clears the log cache
  4965. */
  4966. static ClearLogCache(): void;
  4967. /**
  4968. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4969. */
  4970. static LogLevels: number;
  4971. }
  4972. }
  4973. declare module "babylonjs/Misc/typeStore" {
  4974. /** @hidden */
  4975. export class _TypeStore {
  4976. /** @hidden */
  4977. static RegisteredTypes: {
  4978. [key: string]: Object;
  4979. };
  4980. /** @hidden */
  4981. static GetClass(fqdn: string): any;
  4982. }
  4983. }
  4984. declare module "babylonjs/Misc/deepCopier" {
  4985. /**
  4986. * Class containing a set of static utilities functions for deep copy.
  4987. */
  4988. export class DeepCopier {
  4989. /**
  4990. * Tries to copy an object by duplicating every property
  4991. * @param source defines the source object
  4992. * @param destination defines the target object
  4993. * @param doNotCopyList defines a list of properties to avoid
  4994. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4995. */
  4996. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4997. }
  4998. }
  4999. declare module "babylonjs/Misc/precisionDate" {
  5000. /**
  5001. * Class containing a set of static utilities functions for precision date
  5002. */
  5003. export class PrecisionDate {
  5004. /**
  5005. * Gets either window.performance.now() if supported or Date.now() else
  5006. */
  5007. static readonly Now: number;
  5008. }
  5009. }
  5010. declare module "babylonjs/Misc/devTools" {
  5011. /** @hidden */
  5012. export class _DevTools {
  5013. static WarnImport(name: string): string;
  5014. }
  5015. }
  5016. declare module "babylonjs/Misc/webRequest" {
  5017. /**
  5018. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5019. */
  5020. export class WebRequest {
  5021. private _xhr;
  5022. /**
  5023. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5024. * i.e. when loading files, where the server/service expects an Authorization header
  5025. */
  5026. static CustomRequestHeaders: {
  5027. [key: string]: string;
  5028. };
  5029. /**
  5030. * Add callback functions in this array to update all the requests before they get sent to the network
  5031. */
  5032. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5033. private _injectCustomRequestHeaders;
  5034. /**
  5035. * Gets or sets a function to be called when loading progress changes
  5036. */
  5037. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5038. /**
  5039. * Returns client's state
  5040. */
  5041. readonly readyState: number;
  5042. /**
  5043. * Returns client's status
  5044. */
  5045. readonly status: number;
  5046. /**
  5047. * Returns client's status as a text
  5048. */
  5049. readonly statusText: string;
  5050. /**
  5051. * Returns client's response
  5052. */
  5053. readonly response: any;
  5054. /**
  5055. * Returns client's response url
  5056. */
  5057. readonly responseURL: string;
  5058. /**
  5059. * Returns client's response as text
  5060. */
  5061. readonly responseText: string;
  5062. /**
  5063. * Gets or sets the expected response type
  5064. */
  5065. responseType: XMLHttpRequestResponseType;
  5066. /** @hidden */
  5067. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5068. /** @hidden */
  5069. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5070. /**
  5071. * Cancels any network activity
  5072. */
  5073. abort(): void;
  5074. /**
  5075. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5076. * @param body defines an optional request body
  5077. */
  5078. send(body?: Document | BodyInit | null): void;
  5079. /**
  5080. * Sets the request method, request URL
  5081. * @param method defines the method to use (GET, POST, etc..)
  5082. * @param url defines the url to connect with
  5083. */
  5084. open(method: string, url: string): void;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5088. /**
  5089. * Class used to evalaute queries containing `and` and `or` operators
  5090. */
  5091. export class AndOrNotEvaluator {
  5092. /**
  5093. * Evaluate a query
  5094. * @param query defines the query to evaluate
  5095. * @param evaluateCallback defines the callback used to filter result
  5096. * @returns true if the query matches
  5097. */
  5098. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5099. private static _HandleParenthesisContent;
  5100. private static _SimplifyNegation;
  5101. }
  5102. }
  5103. declare module "babylonjs/Misc/tags" {
  5104. /**
  5105. * Class used to store custom tags
  5106. */
  5107. export class Tags {
  5108. /**
  5109. * Adds support for tags on the given object
  5110. * @param obj defines the object to use
  5111. */
  5112. static EnableFor(obj: any): void;
  5113. /**
  5114. * Removes tags support
  5115. * @param obj defines the object to use
  5116. */
  5117. static DisableFor(obj: any): void;
  5118. /**
  5119. * Gets a boolean indicating if the given object has tags
  5120. * @param obj defines the object to use
  5121. * @returns a boolean
  5122. */
  5123. static HasTags(obj: any): boolean;
  5124. /**
  5125. * Gets the tags available on a given object
  5126. * @param obj defines the object to use
  5127. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5128. * @returns the tags
  5129. */
  5130. static GetTags(obj: any, asString?: boolean): any;
  5131. /**
  5132. * Adds tags to an object
  5133. * @param obj defines the object to use
  5134. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5135. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5136. */
  5137. static AddTagsTo(obj: any, tagsString: string): void;
  5138. /**
  5139. * @hidden
  5140. */
  5141. static _AddTagTo(obj: any, tag: string): void;
  5142. /**
  5143. * Removes specific tags from a specific object
  5144. * @param obj defines the object to use
  5145. * @param tagsString defines the tags to remove
  5146. */
  5147. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5148. /**
  5149. * @hidden
  5150. */
  5151. static _RemoveTagFrom(obj: any, tag: string): void;
  5152. /**
  5153. * Defines if tags hosted on an object match a given query
  5154. * @param obj defines the object to use
  5155. * @param tagsQuery defines the tag query
  5156. * @returns a boolean
  5157. */
  5158. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5159. }
  5160. }
  5161. declare module "babylonjs/Materials/materialDefines" {
  5162. /**
  5163. * Manages the defines for the Material
  5164. */
  5165. export class MaterialDefines {
  5166. /** @hidden */
  5167. protected _keys: string[];
  5168. private _isDirty;
  5169. /** @hidden */
  5170. _renderId: number;
  5171. /** @hidden */
  5172. _areLightsDirty: boolean;
  5173. /** @hidden */
  5174. _areAttributesDirty: boolean;
  5175. /** @hidden */
  5176. _areTexturesDirty: boolean;
  5177. /** @hidden */
  5178. _areFresnelDirty: boolean;
  5179. /** @hidden */
  5180. _areMiscDirty: boolean;
  5181. /** @hidden */
  5182. _areImageProcessingDirty: boolean;
  5183. /** @hidden */
  5184. _normals: boolean;
  5185. /** @hidden */
  5186. _uvs: boolean;
  5187. /** @hidden */
  5188. _needNormals: boolean;
  5189. /** @hidden */
  5190. _needUVs: boolean;
  5191. [id: string]: any;
  5192. /**
  5193. * Specifies if the material needs to be re-calculated
  5194. */
  5195. readonly isDirty: boolean;
  5196. /**
  5197. * Marks the material to indicate that it has been re-calculated
  5198. */
  5199. markAsProcessed(): void;
  5200. /**
  5201. * Marks the material to indicate that it needs to be re-calculated
  5202. */
  5203. markAsUnprocessed(): void;
  5204. /**
  5205. * Marks the material to indicate all of its defines need to be re-calculated
  5206. */
  5207. markAllAsDirty(): void;
  5208. /**
  5209. * Marks the material to indicate that image processing needs to be re-calculated
  5210. */
  5211. markAsImageProcessingDirty(): void;
  5212. /**
  5213. * Marks the material to indicate the lights need to be re-calculated
  5214. */
  5215. markAsLightDirty(): void;
  5216. /**
  5217. * Marks the attribute state as changed
  5218. */
  5219. markAsAttributesDirty(): void;
  5220. /**
  5221. * Marks the texture state as changed
  5222. */
  5223. markAsTexturesDirty(): void;
  5224. /**
  5225. * Marks the fresnel state as changed
  5226. */
  5227. markAsFresnelDirty(): void;
  5228. /**
  5229. * Marks the misc state as changed
  5230. */
  5231. markAsMiscDirty(): void;
  5232. /**
  5233. * Rebuilds the material defines
  5234. */
  5235. rebuild(): void;
  5236. /**
  5237. * Specifies if two material defines are equal
  5238. * @param other - A material define instance to compare to
  5239. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5240. */
  5241. isEqual(other: MaterialDefines): boolean;
  5242. /**
  5243. * Clones this instance's defines to another instance
  5244. * @param other - material defines to clone values to
  5245. */
  5246. cloneTo(other: MaterialDefines): void;
  5247. /**
  5248. * Resets the material define values
  5249. */
  5250. reset(): void;
  5251. /**
  5252. * Converts the material define values to a string
  5253. * @returns - String of material define information
  5254. */
  5255. toString(): string;
  5256. }
  5257. }
  5258. declare module "babylonjs/Engines/IPipelineContext" {
  5259. /**
  5260. * Class used to store and describe the pipeline context associated with an effect
  5261. */
  5262. export interface IPipelineContext {
  5263. /**
  5264. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5265. */
  5266. isAsync: boolean;
  5267. /**
  5268. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5269. */
  5270. isReady: boolean;
  5271. /** @hidden */
  5272. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5273. }
  5274. }
  5275. declare module "babylonjs/Meshes/dataBuffer" {
  5276. /**
  5277. * Class used to store gfx data (like WebGLBuffer)
  5278. */
  5279. export class DataBuffer {
  5280. /**
  5281. * Gets or sets the number of objects referencing this buffer
  5282. */
  5283. references: number;
  5284. /** Gets or sets the size of the underlying buffer */
  5285. capacity: number;
  5286. /**
  5287. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5288. */
  5289. is32Bits: boolean;
  5290. /**
  5291. * Gets the underlying buffer
  5292. */
  5293. readonly underlyingResource: any;
  5294. }
  5295. }
  5296. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  5297. /** @hidden */
  5298. export interface IShaderProcessor {
  5299. attributeProcessor?: (attribute: string) => string;
  5300. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5301. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5302. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5303. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5304. lineProcessor?: (line: string, isFragment: boolean) => string;
  5305. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5306. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5307. }
  5308. }
  5309. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  5310. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  5311. /** @hidden */
  5312. export interface ProcessingOptions {
  5313. defines: string[];
  5314. indexParameters: any;
  5315. isFragment: boolean;
  5316. shouldUseHighPrecisionShader: boolean;
  5317. supportsUniformBuffers: boolean;
  5318. shadersRepository: string;
  5319. includesShadersStore: {
  5320. [key: string]: string;
  5321. };
  5322. processor?: IShaderProcessor;
  5323. version: string;
  5324. platformName: string;
  5325. lookForClosingBracketForUniformBuffer?: boolean;
  5326. }
  5327. }
  5328. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5329. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5330. /** @hidden */
  5331. export class ShaderCodeNode {
  5332. line: string;
  5333. children: ShaderCodeNode[];
  5334. additionalDefineKey?: string;
  5335. additionalDefineValue?: string;
  5336. isValid(preprocessors: {
  5337. [key: string]: string;
  5338. }): boolean;
  5339. process(preprocessors: {
  5340. [key: string]: string;
  5341. }, options: ProcessingOptions): string;
  5342. }
  5343. }
  5344. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5345. /** @hidden */
  5346. export class ShaderCodeCursor {
  5347. private _lines;
  5348. lineIndex: number;
  5349. readonly currentLine: string;
  5350. readonly canRead: boolean;
  5351. lines: string[];
  5352. }
  5353. }
  5354. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5355. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5356. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5357. /** @hidden */
  5358. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5359. process(preprocessors: {
  5360. [key: string]: string;
  5361. }, options: ProcessingOptions): string;
  5362. }
  5363. }
  5364. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5365. /** @hidden */
  5366. export class ShaderDefineExpression {
  5367. isTrue(preprocessors: {
  5368. [key: string]: string;
  5369. }): boolean;
  5370. }
  5371. }
  5372. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5373. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5374. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5375. /** @hidden */
  5376. export class ShaderCodeTestNode extends ShaderCodeNode {
  5377. testExpression: ShaderDefineExpression;
  5378. isValid(preprocessors: {
  5379. [key: string]: string;
  5380. }): boolean;
  5381. }
  5382. }
  5383. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5384. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5385. /** @hidden */
  5386. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5387. define: string;
  5388. not: boolean;
  5389. constructor(define: string, not?: boolean);
  5390. isTrue(preprocessors: {
  5391. [key: string]: string;
  5392. }): boolean;
  5393. }
  5394. }
  5395. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5396. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5397. /** @hidden */
  5398. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5399. leftOperand: ShaderDefineExpression;
  5400. rightOperand: ShaderDefineExpression;
  5401. isTrue(preprocessors: {
  5402. [key: string]: string;
  5403. }): boolean;
  5404. }
  5405. }
  5406. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5407. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5408. /** @hidden */
  5409. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5410. leftOperand: ShaderDefineExpression;
  5411. rightOperand: ShaderDefineExpression;
  5412. isTrue(preprocessors: {
  5413. [key: string]: string;
  5414. }): boolean;
  5415. }
  5416. }
  5417. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5418. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5419. /** @hidden */
  5420. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5421. define: string;
  5422. operand: string;
  5423. testValue: string;
  5424. constructor(define: string, operand: string, testValue: string);
  5425. isTrue(preprocessors: {
  5426. [key: string]: string;
  5427. }): boolean;
  5428. }
  5429. }
  5430. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5431. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5432. /** @hidden */
  5433. export class ShaderProcessor {
  5434. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5435. private static _ProcessPrecision;
  5436. private static _ExtractOperation;
  5437. private static _BuildSubExpression;
  5438. private static _BuildExpression;
  5439. private static _MoveCursorWithinIf;
  5440. private static _MoveCursor;
  5441. private static _EvaluatePreProcessors;
  5442. private static _PreparePreProcessors;
  5443. private static _ProcessShaderConversion;
  5444. private static _ProcessIncludes;
  5445. }
  5446. }
  5447. declare module "babylonjs/Misc/performanceMonitor" {
  5448. /**
  5449. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5450. */
  5451. export class PerformanceMonitor {
  5452. private _enabled;
  5453. private _rollingFrameTime;
  5454. private _lastFrameTimeMs;
  5455. /**
  5456. * constructor
  5457. * @param frameSampleSize The number of samples required to saturate the sliding window
  5458. */
  5459. constructor(frameSampleSize?: number);
  5460. /**
  5461. * Samples current frame
  5462. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5463. */
  5464. sampleFrame(timeMs?: number): void;
  5465. /**
  5466. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5467. */
  5468. readonly averageFrameTime: number;
  5469. /**
  5470. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5471. */
  5472. readonly averageFrameTimeVariance: number;
  5473. /**
  5474. * Returns the frame time of the most recent frame
  5475. */
  5476. readonly instantaneousFrameTime: number;
  5477. /**
  5478. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5479. */
  5480. readonly averageFPS: number;
  5481. /**
  5482. * Returns the average framerate in frames per second using the most recent frame time
  5483. */
  5484. readonly instantaneousFPS: number;
  5485. /**
  5486. * Returns true if enough samples have been taken to completely fill the sliding window
  5487. */
  5488. readonly isSaturated: boolean;
  5489. /**
  5490. * Enables contributions to the sliding window sample set
  5491. */
  5492. enable(): void;
  5493. /**
  5494. * Disables contributions to the sliding window sample set
  5495. * Samples will not be interpolated over the disabled period
  5496. */
  5497. disable(): void;
  5498. /**
  5499. * Returns true if sampling is enabled
  5500. */
  5501. readonly isEnabled: boolean;
  5502. /**
  5503. * Resets performance monitor
  5504. */
  5505. reset(): void;
  5506. }
  5507. /**
  5508. * RollingAverage
  5509. *
  5510. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5511. */
  5512. export class RollingAverage {
  5513. /**
  5514. * Current average
  5515. */
  5516. average: number;
  5517. /**
  5518. * Current variance
  5519. */
  5520. variance: number;
  5521. protected _samples: Array<number>;
  5522. protected _sampleCount: number;
  5523. protected _pos: number;
  5524. protected _m2: number;
  5525. /**
  5526. * constructor
  5527. * @param length The number of samples required to saturate the sliding window
  5528. */
  5529. constructor(length: number);
  5530. /**
  5531. * Adds a sample to the sample set
  5532. * @param v The sample value
  5533. */
  5534. add(v: number): void;
  5535. /**
  5536. * Returns previously added values or null if outside of history or outside the sliding window domain
  5537. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5538. * @return Value previously recorded with add() or null if outside of range
  5539. */
  5540. history(i: number): number;
  5541. /**
  5542. * Returns true if enough samples have been taken to completely fill the sliding window
  5543. * @return true if sample-set saturated
  5544. */
  5545. isSaturated(): boolean;
  5546. /**
  5547. * Resets the rolling average (equivalent to 0 samples taken so far)
  5548. */
  5549. reset(): void;
  5550. /**
  5551. * Wraps a value around the sample range boundaries
  5552. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5553. * @return Wrapped position in sample range
  5554. */
  5555. protected _wrapPosition(i: number): number;
  5556. }
  5557. }
  5558. declare module "babylonjs/Misc/stringDictionary" {
  5559. import { Nullable } from "babylonjs/types";
  5560. /**
  5561. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5562. * The underlying implementation relies on an associative array to ensure the best performances.
  5563. * The value can be anything including 'null' but except 'undefined'
  5564. */
  5565. export class StringDictionary<T> {
  5566. /**
  5567. * This will clear this dictionary and copy the content from the 'source' one.
  5568. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5569. * @param source the dictionary to take the content from and copy to this dictionary
  5570. */
  5571. copyFrom(source: StringDictionary<T>): void;
  5572. /**
  5573. * Get a value based from its key
  5574. * @param key the given key to get the matching value from
  5575. * @return the value if found, otherwise undefined is returned
  5576. */
  5577. get(key: string): T | undefined;
  5578. /**
  5579. * Get a value from its key or add it if it doesn't exist.
  5580. * This method will ensure you that a given key/data will be present in the dictionary.
  5581. * @param key the given key to get the matching value from
  5582. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5583. * The factory will only be invoked if there's no data for the given key.
  5584. * @return the value corresponding to the key.
  5585. */
  5586. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5587. /**
  5588. * Get a value from its key if present in the dictionary otherwise add it
  5589. * @param key the key to get the value from
  5590. * @param val if there's no such key/value pair in the dictionary add it with this value
  5591. * @return the value corresponding to the key
  5592. */
  5593. getOrAdd(key: string, val: T): T;
  5594. /**
  5595. * Check if there's a given key in the dictionary
  5596. * @param key the key to check for
  5597. * @return true if the key is present, false otherwise
  5598. */
  5599. contains(key: string): boolean;
  5600. /**
  5601. * Add a new key and its corresponding value
  5602. * @param key the key to add
  5603. * @param value the value corresponding to the key
  5604. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5605. */
  5606. add(key: string, value: T): boolean;
  5607. /**
  5608. * Update a specific value associated to a key
  5609. * @param key defines the key to use
  5610. * @param value defines the value to store
  5611. * @returns true if the value was updated (or false if the key was not found)
  5612. */
  5613. set(key: string, value: T): boolean;
  5614. /**
  5615. * Get the element of the given key and remove it from the dictionary
  5616. * @param key defines the key to search
  5617. * @returns the value associated with the key or null if not found
  5618. */
  5619. getAndRemove(key: string): Nullable<T>;
  5620. /**
  5621. * Remove a key/value from the dictionary.
  5622. * @param key the key to remove
  5623. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5624. */
  5625. remove(key: string): boolean;
  5626. /**
  5627. * Clear the whole content of the dictionary
  5628. */
  5629. clear(): void;
  5630. /**
  5631. * Gets the current count
  5632. */
  5633. readonly count: number;
  5634. /**
  5635. * Execute a callback on each key/val of the dictionary.
  5636. * Note that you can remove any element in this dictionary in the callback implementation
  5637. * @param callback the callback to execute on a given key/value pair
  5638. */
  5639. forEach(callback: (key: string, val: T) => void): void;
  5640. /**
  5641. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5642. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5643. * Note that you can remove any element in this dictionary in the callback implementation
  5644. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5645. * @returns the first item
  5646. */
  5647. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5648. private _count;
  5649. private _data;
  5650. }
  5651. }
  5652. declare module "babylonjs/Misc/promise" {
  5653. /**
  5654. * Helper class that provides a small promise polyfill
  5655. */
  5656. export class PromisePolyfill {
  5657. /**
  5658. * Static function used to check if the polyfill is required
  5659. * If this is the case then the function will inject the polyfill to window.Promise
  5660. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5661. */
  5662. static Apply(force?: boolean): void;
  5663. }
  5664. }
  5665. declare module "babylonjs/Meshes/buffer" {
  5666. import { Nullable, DataArray } from "babylonjs/types";
  5667. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5668. /**
  5669. * Class used to store data that will be store in GPU memory
  5670. */
  5671. export class Buffer {
  5672. private _engine;
  5673. private _buffer;
  5674. /** @hidden */
  5675. _data: Nullable<DataArray>;
  5676. private _updatable;
  5677. private _instanced;
  5678. /**
  5679. * Gets the byte stride.
  5680. */
  5681. readonly byteStride: number;
  5682. /**
  5683. * Constructor
  5684. * @param engine the engine
  5685. * @param data the data to use for this buffer
  5686. * @param updatable whether the data is updatable
  5687. * @param stride the stride (optional)
  5688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5689. * @param instanced whether the buffer is instanced (optional)
  5690. * @param useBytes set to true if the stride in in bytes (optional)
  5691. */
  5692. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5693. /**
  5694. * Create a new VertexBuffer based on the current buffer
  5695. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5696. * @param offset defines offset in the buffer (0 by default)
  5697. * @param size defines the size in floats of attributes (position is 3 for instance)
  5698. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5699. * @param instanced defines if the vertex buffer contains indexed data
  5700. * @param useBytes defines if the offset and stride are in bytes
  5701. * @returns the new vertex buffer
  5702. */
  5703. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5704. /**
  5705. * Gets a boolean indicating if the Buffer is updatable?
  5706. * @returns true if the buffer is updatable
  5707. */
  5708. isUpdatable(): boolean;
  5709. /**
  5710. * Gets current buffer's data
  5711. * @returns a DataArray or null
  5712. */
  5713. getData(): Nullable<DataArray>;
  5714. /**
  5715. * Gets underlying native buffer
  5716. * @returns underlying native buffer
  5717. */
  5718. getBuffer(): Nullable<DataBuffer>;
  5719. /**
  5720. * Gets the stride in float32 units (i.e. byte stride / 4).
  5721. * May not be an integer if the byte stride is not divisible by 4.
  5722. * DEPRECATED. Use byteStride instead.
  5723. * @returns the stride in float32 units
  5724. */
  5725. getStrideSize(): number;
  5726. /**
  5727. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5728. * @param data defines the data to store
  5729. */
  5730. create(data?: Nullable<DataArray>): void;
  5731. /** @hidden */
  5732. _rebuild(): void;
  5733. /**
  5734. * Update current buffer data
  5735. * @param data defines the data to store
  5736. */
  5737. update(data: DataArray): void;
  5738. /**
  5739. * Updates the data directly.
  5740. * @param data the new data
  5741. * @param offset the new offset
  5742. * @param vertexCount the vertex count (optional)
  5743. * @param useBytes set to true if the offset is in bytes
  5744. */
  5745. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5746. /**
  5747. * Release all resources
  5748. */
  5749. dispose(): void;
  5750. }
  5751. /**
  5752. * Specialized buffer used to store vertex data
  5753. */
  5754. export class VertexBuffer {
  5755. /** @hidden */
  5756. _buffer: Buffer;
  5757. private _kind;
  5758. private _size;
  5759. private _ownsBuffer;
  5760. private _instanced;
  5761. private _instanceDivisor;
  5762. /**
  5763. * The byte type.
  5764. */
  5765. static readonly BYTE: number;
  5766. /**
  5767. * The unsigned byte type.
  5768. */
  5769. static readonly UNSIGNED_BYTE: number;
  5770. /**
  5771. * The short type.
  5772. */
  5773. static readonly SHORT: number;
  5774. /**
  5775. * The unsigned short type.
  5776. */
  5777. static readonly UNSIGNED_SHORT: number;
  5778. /**
  5779. * The integer type.
  5780. */
  5781. static readonly INT: number;
  5782. /**
  5783. * The unsigned integer type.
  5784. */
  5785. static readonly UNSIGNED_INT: number;
  5786. /**
  5787. * The float type.
  5788. */
  5789. static readonly FLOAT: number;
  5790. /**
  5791. * Gets or sets the instance divisor when in instanced mode
  5792. */
  5793. instanceDivisor: number;
  5794. /**
  5795. * Gets the byte stride.
  5796. */
  5797. readonly byteStride: number;
  5798. /**
  5799. * Gets the byte offset.
  5800. */
  5801. readonly byteOffset: number;
  5802. /**
  5803. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5804. */
  5805. readonly normalized: boolean;
  5806. /**
  5807. * Gets the data type of each component in the array.
  5808. */
  5809. readonly type: number;
  5810. /**
  5811. * Constructor
  5812. * @param engine the engine
  5813. * @param data the data to use for this vertex buffer
  5814. * @param kind the vertex buffer kind
  5815. * @param updatable whether the data is updatable
  5816. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5817. * @param stride the stride (optional)
  5818. * @param instanced whether the buffer is instanced (optional)
  5819. * @param offset the offset of the data (optional)
  5820. * @param size the number of components (optional)
  5821. * @param type the type of the component (optional)
  5822. * @param normalized whether the data contains normalized data (optional)
  5823. * @param useBytes set to true if stride and offset are in bytes (optional)
  5824. */
  5825. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5826. /** @hidden */
  5827. _rebuild(): void;
  5828. /**
  5829. * Returns the kind of the VertexBuffer (string)
  5830. * @returns a string
  5831. */
  5832. getKind(): string;
  5833. /**
  5834. * Gets a boolean indicating if the VertexBuffer is updatable?
  5835. * @returns true if the buffer is updatable
  5836. */
  5837. isUpdatable(): boolean;
  5838. /**
  5839. * Gets current buffer's data
  5840. * @returns a DataArray or null
  5841. */
  5842. getData(): Nullable<DataArray>;
  5843. /**
  5844. * Gets underlying native buffer
  5845. * @returns underlying native buffer
  5846. */
  5847. getBuffer(): Nullable<DataBuffer>;
  5848. /**
  5849. * Gets the stride in float32 units (i.e. byte stride / 4).
  5850. * May not be an integer if the byte stride is not divisible by 4.
  5851. * DEPRECATED. Use byteStride instead.
  5852. * @returns the stride in float32 units
  5853. */
  5854. getStrideSize(): number;
  5855. /**
  5856. * Returns the offset as a multiple of the type byte length.
  5857. * DEPRECATED. Use byteOffset instead.
  5858. * @returns the offset in bytes
  5859. */
  5860. getOffset(): number;
  5861. /**
  5862. * Returns the number of components per vertex attribute (integer)
  5863. * @returns the size in float
  5864. */
  5865. getSize(): number;
  5866. /**
  5867. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5868. * @returns true if this buffer is instanced
  5869. */
  5870. getIsInstanced(): boolean;
  5871. /**
  5872. * Returns the instancing divisor, zero for non-instanced (integer).
  5873. * @returns a number
  5874. */
  5875. getInstanceDivisor(): number;
  5876. /**
  5877. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5878. * @param data defines the data to store
  5879. */
  5880. create(data?: DataArray): void;
  5881. /**
  5882. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5883. * This function will create a new buffer if the current one is not updatable
  5884. * @param data defines the data to store
  5885. */
  5886. update(data: DataArray): void;
  5887. /**
  5888. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5889. * Returns the directly updated WebGLBuffer.
  5890. * @param data the new data
  5891. * @param offset the new offset
  5892. * @param useBytes set to true if the offset is in bytes
  5893. */
  5894. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5895. /**
  5896. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5897. */
  5898. dispose(): void;
  5899. /**
  5900. * Enumerates each value of this vertex buffer as numbers.
  5901. * @param count the number of values to enumerate
  5902. * @param callback the callback function called for each value
  5903. */
  5904. forEach(count: number, callback: (value: number, index: number) => void): void;
  5905. /**
  5906. * Positions
  5907. */
  5908. static readonly PositionKind: string;
  5909. /**
  5910. * Normals
  5911. */
  5912. static readonly NormalKind: string;
  5913. /**
  5914. * Tangents
  5915. */
  5916. static readonly TangentKind: string;
  5917. /**
  5918. * Texture coordinates
  5919. */
  5920. static readonly UVKind: string;
  5921. /**
  5922. * Texture coordinates 2
  5923. */
  5924. static readonly UV2Kind: string;
  5925. /**
  5926. * Texture coordinates 3
  5927. */
  5928. static readonly UV3Kind: string;
  5929. /**
  5930. * Texture coordinates 4
  5931. */
  5932. static readonly UV4Kind: string;
  5933. /**
  5934. * Texture coordinates 5
  5935. */
  5936. static readonly UV5Kind: string;
  5937. /**
  5938. * Texture coordinates 6
  5939. */
  5940. static readonly UV6Kind: string;
  5941. /**
  5942. * Colors
  5943. */
  5944. static readonly ColorKind: string;
  5945. /**
  5946. * Matrix indices (for bones)
  5947. */
  5948. static readonly MatricesIndicesKind: string;
  5949. /**
  5950. * Matrix weights (for bones)
  5951. */
  5952. static readonly MatricesWeightsKind: string;
  5953. /**
  5954. * Additional matrix indices (for bones)
  5955. */
  5956. static readonly MatricesIndicesExtraKind: string;
  5957. /**
  5958. * Additional matrix weights (for bones)
  5959. */
  5960. static readonly MatricesWeightsExtraKind: string;
  5961. /**
  5962. * Deduces the stride given a kind.
  5963. * @param kind The kind string to deduce
  5964. * @returns The deduced stride
  5965. */
  5966. static DeduceStride(kind: string): number;
  5967. /**
  5968. * Gets the byte length of the given type.
  5969. * @param type the type
  5970. * @returns the number of bytes
  5971. */
  5972. static GetTypeByteLength(type: number): number;
  5973. /**
  5974. * Enumerates each value of the given parameters as numbers.
  5975. * @param data the data to enumerate
  5976. * @param byteOffset the byte offset of the data
  5977. * @param byteStride the byte stride of the data
  5978. * @param componentCount the number of components per element
  5979. * @param componentType the type of the component
  5980. * @param count the number of values to enumerate
  5981. * @param normalized whether the data is normalized
  5982. * @param callback the callback function called for each value
  5983. */
  5984. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5985. private static _GetFloatValue;
  5986. }
  5987. }
  5988. declare module "babylonjs/Maths/sphericalPolynomial" {
  5989. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5990. /**
  5991. * Class representing spherical harmonics coefficients to the 3rd degree
  5992. */
  5993. export class SphericalHarmonics {
  5994. /**
  5995. * Defines whether or not the harmonics have been prescaled for rendering.
  5996. */
  5997. preScaled: boolean;
  5998. /**
  5999. * The l0,0 coefficients of the spherical harmonics
  6000. */
  6001. l00: Vector3;
  6002. /**
  6003. * The l1,-1 coefficients of the spherical harmonics
  6004. */
  6005. l1_1: Vector3;
  6006. /**
  6007. * The l1,0 coefficients of the spherical harmonics
  6008. */
  6009. l10: Vector3;
  6010. /**
  6011. * The l1,1 coefficients of the spherical harmonics
  6012. */
  6013. l11: Vector3;
  6014. /**
  6015. * The l2,-2 coefficients of the spherical harmonics
  6016. */
  6017. l2_2: Vector3;
  6018. /**
  6019. * The l2,-1 coefficients of the spherical harmonics
  6020. */
  6021. l2_1: Vector3;
  6022. /**
  6023. * The l2,0 coefficients of the spherical harmonics
  6024. */
  6025. l20: Vector3;
  6026. /**
  6027. * The l2,1 coefficients of the spherical harmonics
  6028. */
  6029. l21: Vector3;
  6030. /**
  6031. * The l2,2 coefficients of the spherical harmonics
  6032. */
  6033. l22: Vector3;
  6034. /**
  6035. * Adds a light to the spherical harmonics
  6036. * @param direction the direction of the light
  6037. * @param color the color of the light
  6038. * @param deltaSolidAngle the delta solid angle of the light
  6039. */
  6040. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6041. /**
  6042. * Scales the spherical harmonics by the given amount
  6043. * @param scale the amount to scale
  6044. */
  6045. scaleInPlace(scale: number): void;
  6046. /**
  6047. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6048. *
  6049. * ```
  6050. * E_lm = A_l * L_lm
  6051. * ```
  6052. *
  6053. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6054. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6055. * the scaling factors are given in equation 9.
  6056. */
  6057. convertIncidentRadianceToIrradiance(): void;
  6058. /**
  6059. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6060. *
  6061. * ```
  6062. * L = (1/pi) * E * rho
  6063. * ```
  6064. *
  6065. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6066. */
  6067. convertIrradianceToLambertianRadiance(): void;
  6068. /**
  6069. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6070. * required operations at run time.
  6071. *
  6072. * This is simply done by scaling back the SH with Ylm constants parameter.
  6073. * The trigonometric part being applied by the shader at run time.
  6074. */
  6075. preScaleForRendering(): void;
  6076. /**
  6077. * Constructs a spherical harmonics from an array.
  6078. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6079. * @returns the spherical harmonics
  6080. */
  6081. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6082. /**
  6083. * Gets the spherical harmonics from polynomial
  6084. * @param polynomial the spherical polynomial
  6085. * @returns the spherical harmonics
  6086. */
  6087. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6088. }
  6089. /**
  6090. * Class representing spherical polynomial coefficients to the 3rd degree
  6091. */
  6092. export class SphericalPolynomial {
  6093. private _harmonics;
  6094. /**
  6095. * The spherical harmonics used to create the polynomials.
  6096. */
  6097. readonly preScaledHarmonics: SphericalHarmonics;
  6098. /**
  6099. * The x coefficients of the spherical polynomial
  6100. */
  6101. x: Vector3;
  6102. /**
  6103. * The y coefficients of the spherical polynomial
  6104. */
  6105. y: Vector3;
  6106. /**
  6107. * The z coefficients of the spherical polynomial
  6108. */
  6109. z: Vector3;
  6110. /**
  6111. * The xx coefficients of the spherical polynomial
  6112. */
  6113. xx: Vector3;
  6114. /**
  6115. * The yy coefficients of the spherical polynomial
  6116. */
  6117. yy: Vector3;
  6118. /**
  6119. * The zz coefficients of the spherical polynomial
  6120. */
  6121. zz: Vector3;
  6122. /**
  6123. * The xy coefficients of the spherical polynomial
  6124. */
  6125. xy: Vector3;
  6126. /**
  6127. * The yz coefficients of the spherical polynomial
  6128. */
  6129. yz: Vector3;
  6130. /**
  6131. * The zx coefficients of the spherical polynomial
  6132. */
  6133. zx: Vector3;
  6134. /**
  6135. * Adds an ambient color to the spherical polynomial
  6136. * @param color the color to add
  6137. */
  6138. addAmbient(color: Color3): void;
  6139. /**
  6140. * Scales the spherical polynomial by the given amount
  6141. * @param scale the amount to scale
  6142. */
  6143. scaleInPlace(scale: number): void;
  6144. /**
  6145. * Gets the spherical polynomial from harmonics
  6146. * @param harmonics the spherical harmonics
  6147. * @returns the spherical polynomial
  6148. */
  6149. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6150. /**
  6151. * Constructs a spherical polynomial from an array.
  6152. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6153. * @returns the spherical polynomial
  6154. */
  6155. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6156. }
  6157. }
  6158. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6159. import { Nullable } from "babylonjs/types";
  6160. /**
  6161. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6162. */
  6163. export interface CubeMapInfo {
  6164. /**
  6165. * The pixel array for the front face.
  6166. * This is stored in format, left to right, up to down format.
  6167. */
  6168. front: Nullable<ArrayBufferView>;
  6169. /**
  6170. * The pixel array for the back face.
  6171. * This is stored in format, left to right, up to down format.
  6172. */
  6173. back: Nullable<ArrayBufferView>;
  6174. /**
  6175. * The pixel array for the left face.
  6176. * This is stored in format, left to right, up to down format.
  6177. */
  6178. left: Nullable<ArrayBufferView>;
  6179. /**
  6180. * The pixel array for the right face.
  6181. * This is stored in format, left to right, up to down format.
  6182. */
  6183. right: Nullable<ArrayBufferView>;
  6184. /**
  6185. * The pixel array for the up face.
  6186. * This is stored in format, left to right, up to down format.
  6187. */
  6188. up: Nullable<ArrayBufferView>;
  6189. /**
  6190. * The pixel array for the down face.
  6191. * This is stored in format, left to right, up to down format.
  6192. */
  6193. down: Nullable<ArrayBufferView>;
  6194. /**
  6195. * The size of the cubemap stored.
  6196. *
  6197. * Each faces will be size * size pixels.
  6198. */
  6199. size: number;
  6200. /**
  6201. * The format of the texture.
  6202. *
  6203. * RGBA, RGB.
  6204. */
  6205. format: number;
  6206. /**
  6207. * The type of the texture data.
  6208. *
  6209. * UNSIGNED_INT, FLOAT.
  6210. */
  6211. type: number;
  6212. /**
  6213. * Specifies whether the texture is in gamma space.
  6214. */
  6215. gammaSpace: boolean;
  6216. }
  6217. /**
  6218. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6219. */
  6220. export class PanoramaToCubeMapTools {
  6221. private static FACE_FRONT;
  6222. private static FACE_BACK;
  6223. private static FACE_RIGHT;
  6224. private static FACE_LEFT;
  6225. private static FACE_DOWN;
  6226. private static FACE_UP;
  6227. /**
  6228. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6229. *
  6230. * @param float32Array The source data.
  6231. * @param inputWidth The width of the input panorama.
  6232. * @param inputHeight The height of the input panorama.
  6233. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6234. * @return The cubemap data
  6235. */
  6236. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6237. private static CreateCubemapTexture;
  6238. private static CalcProjectionSpherical;
  6239. }
  6240. }
  6241. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6242. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6244. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6245. /**
  6246. * Helper class dealing with the extraction of spherical polynomial dataArray
  6247. * from a cube map.
  6248. */
  6249. export class CubeMapToSphericalPolynomialTools {
  6250. private static FileFaces;
  6251. /**
  6252. * Converts a texture to the according Spherical Polynomial data.
  6253. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6254. *
  6255. * @param texture The texture to extract the information from.
  6256. * @return The Spherical Polynomial data.
  6257. */
  6258. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6259. /**
  6260. * Converts a cubemap to the according Spherical Polynomial data.
  6261. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6262. *
  6263. * @param cubeInfo The Cube map to extract the information from.
  6264. * @return The Spherical Polynomial data.
  6265. */
  6266. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6267. }
  6268. }
  6269. declare module "babylonjs/Engines/engineStore" {
  6270. import { Nullable } from "babylonjs/types";
  6271. import { Engine } from "babylonjs/Engines/engine";
  6272. import { Scene } from "babylonjs/scene";
  6273. /**
  6274. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6275. * during the life time of the application.
  6276. */
  6277. export class EngineStore {
  6278. /** Gets the list of created engines */
  6279. static Instances: import("babylonjs/Engines/engine").Engine[];
  6280. /** @hidden */
  6281. static _LastCreatedScene: Nullable<Scene>;
  6282. /**
  6283. * Gets the latest created engine
  6284. */
  6285. static readonly LastCreatedEngine: Nullable<Engine>;
  6286. /**
  6287. * Gets the latest created scene
  6288. */
  6289. static readonly LastCreatedScene: Nullable<Scene>;
  6290. }
  6291. }
  6292. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6293. /**
  6294. * Define options used to create a render target texture
  6295. */
  6296. export class RenderTargetCreationOptions {
  6297. /**
  6298. * Specifies is mipmaps must be generated
  6299. */
  6300. generateMipMaps?: boolean;
  6301. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6302. generateDepthBuffer?: boolean;
  6303. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6304. generateStencilBuffer?: boolean;
  6305. /** Defines texture type (int by default) */
  6306. type?: number;
  6307. /** Defines sampling mode (trilinear by default) */
  6308. samplingMode?: number;
  6309. /** Defines format (RGBA by default) */
  6310. format?: number;
  6311. }
  6312. }
  6313. declare module "babylonjs/States/alphaCullingState" {
  6314. /**
  6315. * @hidden
  6316. **/
  6317. export class _AlphaState {
  6318. private _isAlphaBlendDirty;
  6319. private _isBlendFunctionParametersDirty;
  6320. private _isBlendEquationParametersDirty;
  6321. private _isBlendConstantsDirty;
  6322. private _alphaBlend;
  6323. private _blendFunctionParameters;
  6324. private _blendEquationParameters;
  6325. private _blendConstants;
  6326. /**
  6327. * Initializes the state.
  6328. */
  6329. constructor();
  6330. readonly isDirty: boolean;
  6331. alphaBlend: boolean;
  6332. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6333. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6334. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6335. reset(): void;
  6336. apply(gl: WebGLRenderingContext): void;
  6337. }
  6338. }
  6339. declare module "babylonjs/States/depthCullingState" {
  6340. import { Nullable } from "babylonjs/types";
  6341. /**
  6342. * @hidden
  6343. **/
  6344. export class _DepthCullingState {
  6345. private _isDepthTestDirty;
  6346. private _isDepthMaskDirty;
  6347. private _isDepthFuncDirty;
  6348. private _isCullFaceDirty;
  6349. private _isCullDirty;
  6350. private _isZOffsetDirty;
  6351. private _isFrontFaceDirty;
  6352. private _depthTest;
  6353. private _depthMask;
  6354. private _depthFunc;
  6355. private _cull;
  6356. private _cullFace;
  6357. private _zOffset;
  6358. private _frontFace;
  6359. /**
  6360. * Initializes the state.
  6361. */
  6362. constructor();
  6363. readonly isDirty: boolean;
  6364. zOffset: number;
  6365. cullFace: Nullable<number>;
  6366. cull: Nullable<boolean>;
  6367. depthFunc: Nullable<number>;
  6368. depthMask: boolean;
  6369. depthTest: boolean;
  6370. frontFace: Nullable<number>;
  6371. reset(): void;
  6372. apply(gl: WebGLRenderingContext): void;
  6373. }
  6374. }
  6375. declare module "babylonjs/States/stencilState" {
  6376. /**
  6377. * @hidden
  6378. **/
  6379. export class _StencilState {
  6380. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6381. static readonly ALWAYS: number;
  6382. /** Passed to stencilOperation to specify that stencil value must be kept */
  6383. static readonly KEEP: number;
  6384. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6385. static readonly REPLACE: number;
  6386. private _isStencilTestDirty;
  6387. private _isStencilMaskDirty;
  6388. private _isStencilFuncDirty;
  6389. private _isStencilOpDirty;
  6390. private _stencilTest;
  6391. private _stencilMask;
  6392. private _stencilFunc;
  6393. private _stencilFuncRef;
  6394. private _stencilFuncMask;
  6395. private _stencilOpStencilFail;
  6396. private _stencilOpDepthFail;
  6397. private _stencilOpStencilDepthPass;
  6398. readonly isDirty: boolean;
  6399. stencilFunc: number;
  6400. stencilFuncRef: number;
  6401. stencilFuncMask: number;
  6402. stencilOpStencilFail: number;
  6403. stencilOpDepthFail: number;
  6404. stencilOpStencilDepthPass: number;
  6405. stencilMask: number;
  6406. stencilTest: boolean;
  6407. constructor();
  6408. reset(): void;
  6409. apply(gl: WebGLRenderingContext): void;
  6410. }
  6411. }
  6412. declare module "babylonjs/States/index" {
  6413. export * from "babylonjs/States/alphaCullingState";
  6414. export * from "babylonjs/States/depthCullingState";
  6415. export * from "babylonjs/States/stencilState";
  6416. }
  6417. declare module "babylonjs/Instrumentation/timeToken" {
  6418. import { Nullable } from "babylonjs/types";
  6419. /**
  6420. * @hidden
  6421. **/
  6422. export class _TimeToken {
  6423. _startTimeQuery: Nullable<WebGLQuery>;
  6424. _endTimeQuery: Nullable<WebGLQuery>;
  6425. _timeElapsedQuery: Nullable<WebGLQuery>;
  6426. _timeElapsedQueryEnded: boolean;
  6427. }
  6428. }
  6429. declare module "babylonjs/Materials/Textures/internalTexture" {
  6430. import { Observable } from "babylonjs/Misc/observable";
  6431. import { Nullable, int } from "babylonjs/types";
  6432. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6433. import { Engine } from "babylonjs/Engines/engine";
  6434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6435. /**
  6436. * Class used to store data associated with WebGL texture data for the engine
  6437. * This class should not be used directly
  6438. */
  6439. export class InternalTexture {
  6440. /** @hidden */
  6441. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6442. /**
  6443. * The source of the texture data is unknown
  6444. */
  6445. static DATASOURCE_UNKNOWN: number;
  6446. /**
  6447. * Texture data comes from an URL
  6448. */
  6449. static DATASOURCE_URL: number;
  6450. /**
  6451. * Texture data is only used for temporary storage
  6452. */
  6453. static DATASOURCE_TEMP: number;
  6454. /**
  6455. * Texture data comes from raw data (ArrayBuffer)
  6456. */
  6457. static DATASOURCE_RAW: number;
  6458. /**
  6459. * Texture content is dynamic (video or dynamic texture)
  6460. */
  6461. static DATASOURCE_DYNAMIC: number;
  6462. /**
  6463. * Texture content is generated by rendering to it
  6464. */
  6465. static DATASOURCE_RENDERTARGET: number;
  6466. /**
  6467. * Texture content is part of a multi render target process
  6468. */
  6469. static DATASOURCE_MULTIRENDERTARGET: number;
  6470. /**
  6471. * Texture data comes from a cube data file
  6472. */
  6473. static DATASOURCE_CUBE: number;
  6474. /**
  6475. * Texture data comes from a raw cube data
  6476. */
  6477. static DATASOURCE_CUBERAW: number;
  6478. /**
  6479. * Texture data come from a prefiltered cube data file
  6480. */
  6481. static DATASOURCE_CUBEPREFILTERED: number;
  6482. /**
  6483. * Texture content is raw 3D data
  6484. */
  6485. static DATASOURCE_RAW3D: number;
  6486. /**
  6487. * Texture content is a depth texture
  6488. */
  6489. static DATASOURCE_DEPTHTEXTURE: number;
  6490. /**
  6491. * Texture data comes from a raw cube data encoded with RGBD
  6492. */
  6493. static DATASOURCE_CUBERAW_RGBD: number;
  6494. /**
  6495. * Defines if the texture is ready
  6496. */
  6497. isReady: boolean;
  6498. /**
  6499. * Defines if the texture is a cube texture
  6500. */
  6501. isCube: boolean;
  6502. /**
  6503. * Defines if the texture contains 3D data
  6504. */
  6505. is3D: boolean;
  6506. /**
  6507. * Defines if the texture contains multiview data
  6508. */
  6509. isMultiview: boolean;
  6510. /**
  6511. * Gets the URL used to load this texture
  6512. */
  6513. url: string;
  6514. /**
  6515. * Gets the sampling mode of the texture
  6516. */
  6517. samplingMode: number;
  6518. /**
  6519. * Gets a boolean indicating if the texture needs mipmaps generation
  6520. */
  6521. generateMipMaps: boolean;
  6522. /**
  6523. * Gets the number of samples used by the texture (WebGL2+ only)
  6524. */
  6525. samples: number;
  6526. /**
  6527. * Gets the type of the texture (int, float...)
  6528. */
  6529. type: number;
  6530. /**
  6531. * Gets the format of the texture (RGB, RGBA...)
  6532. */
  6533. format: number;
  6534. /**
  6535. * Observable called when the texture is loaded
  6536. */
  6537. onLoadedObservable: Observable<InternalTexture>;
  6538. /**
  6539. * Gets the width of the texture
  6540. */
  6541. width: number;
  6542. /**
  6543. * Gets the height of the texture
  6544. */
  6545. height: number;
  6546. /**
  6547. * Gets the depth of the texture
  6548. */
  6549. depth: number;
  6550. /**
  6551. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6552. */
  6553. baseWidth: number;
  6554. /**
  6555. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6556. */
  6557. baseHeight: number;
  6558. /**
  6559. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6560. */
  6561. baseDepth: number;
  6562. /**
  6563. * Gets a boolean indicating if the texture is inverted on Y axis
  6564. */
  6565. invertY: boolean;
  6566. /** @hidden */
  6567. _invertVScale: boolean;
  6568. /** @hidden */
  6569. _associatedChannel: number;
  6570. /** @hidden */
  6571. _dataSource: number;
  6572. /** @hidden */
  6573. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6574. /** @hidden */
  6575. _bufferView: Nullable<ArrayBufferView>;
  6576. /** @hidden */
  6577. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6578. /** @hidden */
  6579. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6580. /** @hidden */
  6581. _size: number;
  6582. /** @hidden */
  6583. _extension: string;
  6584. /** @hidden */
  6585. _files: Nullable<string[]>;
  6586. /** @hidden */
  6587. _workingCanvas: Nullable<HTMLCanvasElement>;
  6588. /** @hidden */
  6589. _workingContext: Nullable<CanvasRenderingContext2D>;
  6590. /** @hidden */
  6591. _framebuffer: Nullable<WebGLFramebuffer>;
  6592. /** @hidden */
  6593. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6594. /** @hidden */
  6595. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6596. /** @hidden */
  6597. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6598. /** @hidden */
  6599. _attachments: Nullable<number[]>;
  6600. /** @hidden */
  6601. _cachedCoordinatesMode: Nullable<number>;
  6602. /** @hidden */
  6603. _cachedWrapU: Nullable<number>;
  6604. /** @hidden */
  6605. _cachedWrapV: Nullable<number>;
  6606. /** @hidden */
  6607. _cachedWrapR: Nullable<number>;
  6608. /** @hidden */
  6609. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6610. /** @hidden */
  6611. _isDisabled: boolean;
  6612. /** @hidden */
  6613. _compression: Nullable<string>;
  6614. /** @hidden */
  6615. _generateStencilBuffer: boolean;
  6616. /** @hidden */
  6617. _generateDepthBuffer: boolean;
  6618. /** @hidden */
  6619. _comparisonFunction: number;
  6620. /** @hidden */
  6621. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6622. /** @hidden */
  6623. _lodGenerationScale: number;
  6624. /** @hidden */
  6625. _lodGenerationOffset: number;
  6626. /** @hidden */
  6627. _colorTextureArray: Nullable<WebGLTexture>;
  6628. /** @hidden */
  6629. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6630. /** @hidden */
  6631. _lodTextureHigh: Nullable<BaseTexture>;
  6632. /** @hidden */
  6633. _lodTextureMid: Nullable<BaseTexture>;
  6634. /** @hidden */
  6635. _lodTextureLow: Nullable<BaseTexture>;
  6636. /** @hidden */
  6637. _isRGBD: boolean;
  6638. /** @hidden */
  6639. _linearSpecularLOD: boolean;
  6640. /** @hidden */
  6641. _irradianceTexture: Nullable<BaseTexture>;
  6642. /** @hidden */
  6643. _webGLTexture: Nullable<WebGLTexture>;
  6644. /** @hidden */
  6645. _references: number;
  6646. private _engine;
  6647. /**
  6648. * Gets the Engine the texture belongs to.
  6649. * @returns The babylon engine
  6650. */
  6651. getEngine(): Engine;
  6652. /**
  6653. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6654. */
  6655. readonly dataSource: number;
  6656. /**
  6657. * Creates a new InternalTexture
  6658. * @param engine defines the engine to use
  6659. * @param dataSource defines the type of data that will be used
  6660. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6661. */
  6662. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6663. /**
  6664. * Increments the number of references (ie. the number of Texture that point to it)
  6665. */
  6666. incrementReferences(): void;
  6667. /**
  6668. * Change the size of the texture (not the size of the content)
  6669. * @param width defines the new width
  6670. * @param height defines the new height
  6671. * @param depth defines the new depth (1 by default)
  6672. */
  6673. updateSize(width: int, height: int, depth?: int): void;
  6674. /** @hidden */
  6675. _rebuild(): void;
  6676. /** @hidden */
  6677. _swapAndDie(target: InternalTexture): void;
  6678. /**
  6679. * Dispose the current allocated resources
  6680. */
  6681. dispose(): void;
  6682. }
  6683. }
  6684. declare module "babylonjs/Animations/easing" {
  6685. /**
  6686. * This represents the main contract an easing function should follow.
  6687. * Easing functions are used throughout the animation system.
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export interface IEasingFunction {
  6691. /**
  6692. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6693. * of the easing function.
  6694. * The link below provides some of the most common examples of easing functions.
  6695. * @see https://easings.net/
  6696. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6697. * @returns the corresponding value on the curve defined by the easing function
  6698. */
  6699. ease(gradient: number): number;
  6700. }
  6701. /**
  6702. * Base class used for every default easing function.
  6703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6704. */
  6705. export class EasingFunction implements IEasingFunction {
  6706. /**
  6707. * Interpolation follows the mathematical formula associated with the easing function.
  6708. */
  6709. static readonly EASINGMODE_EASEIN: number;
  6710. /**
  6711. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6712. */
  6713. static readonly EASINGMODE_EASEOUT: number;
  6714. /**
  6715. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6716. */
  6717. static readonly EASINGMODE_EASEINOUT: number;
  6718. private _easingMode;
  6719. /**
  6720. * Sets the easing mode of the current function.
  6721. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6722. */
  6723. setEasingMode(easingMode: number): void;
  6724. /**
  6725. * Gets the current easing mode.
  6726. * @returns the easing mode
  6727. */
  6728. getEasingMode(): number;
  6729. /**
  6730. * @hidden
  6731. */
  6732. easeInCore(gradient: number): number;
  6733. /**
  6734. * Given an input gradient between 0 and 1, this returns the corresponding value
  6735. * of the easing function.
  6736. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6737. * @returns the corresponding value on the curve defined by the easing function
  6738. */
  6739. ease(gradient: number): number;
  6740. }
  6741. /**
  6742. * Easing function with a circle shape (see link below).
  6743. * @see https://easings.net/#easeInCirc
  6744. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6745. */
  6746. export class CircleEase extends EasingFunction implements IEasingFunction {
  6747. /** @hidden */
  6748. easeInCore(gradient: number): number;
  6749. }
  6750. /**
  6751. * Easing function with a ease back shape (see link below).
  6752. * @see https://easings.net/#easeInBack
  6753. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6754. */
  6755. export class BackEase extends EasingFunction implements IEasingFunction {
  6756. /** Defines the amplitude of the function */
  6757. amplitude: number;
  6758. /**
  6759. * Instantiates a back ease easing
  6760. * @see https://easings.net/#easeInBack
  6761. * @param amplitude Defines the amplitude of the function
  6762. */
  6763. constructor(
  6764. /** Defines the amplitude of the function */
  6765. amplitude?: number);
  6766. /** @hidden */
  6767. easeInCore(gradient: number): number;
  6768. }
  6769. /**
  6770. * Easing function with a bouncing shape (see link below).
  6771. * @see https://easings.net/#easeInBounce
  6772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6773. */
  6774. export class BounceEase extends EasingFunction implements IEasingFunction {
  6775. /** Defines the number of bounces */
  6776. bounces: number;
  6777. /** Defines the amplitude of the bounce */
  6778. bounciness: number;
  6779. /**
  6780. * Instantiates a bounce easing
  6781. * @see https://easings.net/#easeInBounce
  6782. * @param bounces Defines the number of bounces
  6783. * @param bounciness Defines the amplitude of the bounce
  6784. */
  6785. constructor(
  6786. /** Defines the number of bounces */
  6787. bounces?: number,
  6788. /** Defines the amplitude of the bounce */
  6789. bounciness?: number);
  6790. /** @hidden */
  6791. easeInCore(gradient: number): number;
  6792. }
  6793. /**
  6794. * Easing function with a power of 3 shape (see link below).
  6795. * @see https://easings.net/#easeInCubic
  6796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6797. */
  6798. export class CubicEase extends EasingFunction implements IEasingFunction {
  6799. /** @hidden */
  6800. easeInCore(gradient: number): number;
  6801. }
  6802. /**
  6803. * Easing function with an elastic shape (see link below).
  6804. * @see https://easings.net/#easeInElastic
  6805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6806. */
  6807. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6808. /** Defines the number of oscillations*/
  6809. oscillations: number;
  6810. /** Defines the amplitude of the oscillations*/
  6811. springiness: number;
  6812. /**
  6813. * Instantiates an elastic easing function
  6814. * @see https://easings.net/#easeInElastic
  6815. * @param oscillations Defines the number of oscillations
  6816. * @param springiness Defines the amplitude of the oscillations
  6817. */
  6818. constructor(
  6819. /** Defines the number of oscillations*/
  6820. oscillations?: number,
  6821. /** Defines the amplitude of the oscillations*/
  6822. springiness?: number);
  6823. /** @hidden */
  6824. easeInCore(gradient: number): number;
  6825. }
  6826. /**
  6827. * Easing function with an exponential shape (see link below).
  6828. * @see https://easings.net/#easeInExpo
  6829. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6830. */
  6831. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6832. /** Defines the exponent of the function */
  6833. exponent: number;
  6834. /**
  6835. * Instantiates an exponential easing function
  6836. * @see https://easings.net/#easeInExpo
  6837. * @param exponent Defines the exponent of the function
  6838. */
  6839. constructor(
  6840. /** Defines the exponent of the function */
  6841. exponent?: number);
  6842. /** @hidden */
  6843. easeInCore(gradient: number): number;
  6844. }
  6845. /**
  6846. * Easing function with a power shape (see link below).
  6847. * @see https://easings.net/#easeInQuad
  6848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6849. */
  6850. export class PowerEase extends EasingFunction implements IEasingFunction {
  6851. /** Defines the power of the function */
  6852. power: number;
  6853. /**
  6854. * Instantiates an power base easing function
  6855. * @see https://easings.net/#easeInQuad
  6856. * @param power Defines the power of the function
  6857. */
  6858. constructor(
  6859. /** Defines the power of the function */
  6860. power?: number);
  6861. /** @hidden */
  6862. easeInCore(gradient: number): number;
  6863. }
  6864. /**
  6865. * Easing function with a power of 2 shape (see link below).
  6866. * @see https://easings.net/#easeInQuad
  6867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6868. */
  6869. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6870. /** @hidden */
  6871. easeInCore(gradient: number): number;
  6872. }
  6873. /**
  6874. * Easing function with a power of 4 shape (see link below).
  6875. * @see https://easings.net/#easeInQuart
  6876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6877. */
  6878. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6879. /** @hidden */
  6880. easeInCore(gradient: number): number;
  6881. }
  6882. /**
  6883. * Easing function with a power of 5 shape (see link below).
  6884. * @see https://easings.net/#easeInQuint
  6885. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6886. */
  6887. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6888. /** @hidden */
  6889. easeInCore(gradient: number): number;
  6890. }
  6891. /**
  6892. * Easing function with a sin shape (see link below).
  6893. * @see https://easings.net/#easeInSine
  6894. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6895. */
  6896. export class SineEase extends EasingFunction implements IEasingFunction {
  6897. /** @hidden */
  6898. easeInCore(gradient: number): number;
  6899. }
  6900. /**
  6901. * Easing function with a bezier shape (see link below).
  6902. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6903. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6904. */
  6905. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6906. /** Defines the x component of the start tangent in the bezier curve */
  6907. x1: number;
  6908. /** Defines the y component of the start tangent in the bezier curve */
  6909. y1: number;
  6910. /** Defines the x component of the end tangent in the bezier curve */
  6911. x2: number;
  6912. /** Defines the y component of the end tangent in the bezier curve */
  6913. y2: number;
  6914. /**
  6915. * Instantiates a bezier function
  6916. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6917. * @param x1 Defines the x component of the start tangent in the bezier curve
  6918. * @param y1 Defines the y component of the start tangent in the bezier curve
  6919. * @param x2 Defines the x component of the end tangent in the bezier curve
  6920. * @param y2 Defines the y component of the end tangent in the bezier curve
  6921. */
  6922. constructor(
  6923. /** Defines the x component of the start tangent in the bezier curve */
  6924. x1?: number,
  6925. /** Defines the y component of the start tangent in the bezier curve */
  6926. y1?: number,
  6927. /** Defines the x component of the end tangent in the bezier curve */
  6928. x2?: number,
  6929. /** Defines the y component of the end tangent in the bezier curve */
  6930. y2?: number);
  6931. /** @hidden */
  6932. easeInCore(gradient: number): number;
  6933. }
  6934. }
  6935. declare module "babylonjs/Animations/animationKey" {
  6936. /**
  6937. * Defines an interface which represents an animation key frame
  6938. */
  6939. export interface IAnimationKey {
  6940. /**
  6941. * Frame of the key frame
  6942. */
  6943. frame: number;
  6944. /**
  6945. * Value at the specifies key frame
  6946. */
  6947. value: any;
  6948. /**
  6949. * The input tangent for the cubic hermite spline
  6950. */
  6951. inTangent?: any;
  6952. /**
  6953. * The output tangent for the cubic hermite spline
  6954. */
  6955. outTangent?: any;
  6956. /**
  6957. * The animation interpolation type
  6958. */
  6959. interpolation?: AnimationKeyInterpolation;
  6960. }
  6961. /**
  6962. * Enum for the animation key frame interpolation type
  6963. */
  6964. export enum AnimationKeyInterpolation {
  6965. /**
  6966. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6967. */
  6968. STEP = 1
  6969. }
  6970. }
  6971. declare module "babylonjs/Animations/animationRange" {
  6972. /**
  6973. * Represents the range of an animation
  6974. */
  6975. export class AnimationRange {
  6976. /**The name of the animation range**/
  6977. name: string;
  6978. /**The starting frame of the animation */
  6979. from: number;
  6980. /**The ending frame of the animation*/
  6981. to: number;
  6982. /**
  6983. * Initializes the range of an animation
  6984. * @param name The name of the animation range
  6985. * @param from The starting frame of the animation
  6986. * @param to The ending frame of the animation
  6987. */
  6988. constructor(
  6989. /**The name of the animation range**/
  6990. name: string,
  6991. /**The starting frame of the animation */
  6992. from: number,
  6993. /**The ending frame of the animation*/
  6994. to: number);
  6995. /**
  6996. * Makes a copy of the animation range
  6997. * @returns A copy of the animation range
  6998. */
  6999. clone(): AnimationRange;
  7000. }
  7001. }
  7002. declare module "babylonjs/Animations/animationEvent" {
  7003. /**
  7004. * Composed of a frame, and an action function
  7005. */
  7006. export class AnimationEvent {
  7007. /** The frame for which the event is triggered **/
  7008. frame: number;
  7009. /** The event to perform when triggered **/
  7010. action: (currentFrame: number) => void;
  7011. /** Specifies if the event should be triggered only once**/
  7012. onlyOnce?: boolean | undefined;
  7013. /**
  7014. * Specifies if the animation event is done
  7015. */
  7016. isDone: boolean;
  7017. /**
  7018. * Initializes the animation event
  7019. * @param frame The frame for which the event is triggered
  7020. * @param action The event to perform when triggered
  7021. * @param onlyOnce Specifies if the event should be triggered only once
  7022. */
  7023. constructor(
  7024. /** The frame for which the event is triggered **/
  7025. frame: number,
  7026. /** The event to perform when triggered **/
  7027. action: (currentFrame: number) => void,
  7028. /** Specifies if the event should be triggered only once**/
  7029. onlyOnce?: boolean | undefined);
  7030. /** @hidden */
  7031. _clone(): AnimationEvent;
  7032. }
  7033. }
  7034. declare module "babylonjs/Behaviors/behavior" {
  7035. import { Nullable } from "babylonjs/types";
  7036. /**
  7037. * Interface used to define a behavior
  7038. */
  7039. export interface Behavior<T> {
  7040. /** gets or sets behavior's name */
  7041. name: string;
  7042. /**
  7043. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7044. */
  7045. init(): void;
  7046. /**
  7047. * Called when the behavior is attached to a target
  7048. * @param target defines the target where the behavior is attached to
  7049. */
  7050. attach(target: T): void;
  7051. /**
  7052. * Called when the behavior is detached from its target
  7053. */
  7054. detach(): void;
  7055. }
  7056. /**
  7057. * Interface implemented by classes supporting behaviors
  7058. */
  7059. export interface IBehaviorAware<T> {
  7060. /**
  7061. * Attach a behavior
  7062. * @param behavior defines the behavior to attach
  7063. * @returns the current host
  7064. */
  7065. addBehavior(behavior: Behavior<T>): T;
  7066. /**
  7067. * Remove a behavior from the current object
  7068. * @param behavior defines the behavior to detach
  7069. * @returns the current host
  7070. */
  7071. removeBehavior(behavior: Behavior<T>): T;
  7072. /**
  7073. * Gets a behavior using its name to search
  7074. * @param name defines the name to search
  7075. * @returns the behavior or null if not found
  7076. */
  7077. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7078. }
  7079. }
  7080. declare module "babylonjs/Collisions/intersectionInfo" {
  7081. import { Nullable } from "babylonjs/types";
  7082. /**
  7083. * @hidden
  7084. */
  7085. export class IntersectionInfo {
  7086. bu: Nullable<number>;
  7087. bv: Nullable<number>;
  7088. distance: number;
  7089. faceId: number;
  7090. subMeshId: number;
  7091. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7092. }
  7093. }
  7094. declare module "babylonjs/Culling/boundingSphere" {
  7095. import { DeepImmutable } from "babylonjs/types";
  7096. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7097. /**
  7098. * Class used to store bounding sphere information
  7099. */
  7100. export class BoundingSphere {
  7101. /**
  7102. * Gets the center of the bounding sphere in local space
  7103. */
  7104. readonly center: Vector3;
  7105. /**
  7106. * Radius of the bounding sphere in local space
  7107. */
  7108. radius: number;
  7109. /**
  7110. * Gets the center of the bounding sphere in world space
  7111. */
  7112. readonly centerWorld: Vector3;
  7113. /**
  7114. * Radius of the bounding sphere in world space
  7115. */
  7116. radiusWorld: number;
  7117. /**
  7118. * Gets the minimum vector in local space
  7119. */
  7120. readonly minimum: Vector3;
  7121. /**
  7122. * Gets the maximum vector in local space
  7123. */
  7124. readonly maximum: Vector3;
  7125. private _worldMatrix;
  7126. private static readonly TmpVector3;
  7127. /**
  7128. * Creates a new bounding sphere
  7129. * @param min defines the minimum vector (in local space)
  7130. * @param max defines the maximum vector (in local space)
  7131. * @param worldMatrix defines the new world matrix
  7132. */
  7133. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7134. /**
  7135. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7136. * @param min defines the new minimum vector (in local space)
  7137. * @param max defines the new maximum vector (in local space)
  7138. * @param worldMatrix defines the new world matrix
  7139. */
  7140. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7141. /**
  7142. * Scale the current bounding sphere by applying a scale factor
  7143. * @param factor defines the scale factor to apply
  7144. * @returns the current bounding box
  7145. */
  7146. scale(factor: number): BoundingSphere;
  7147. /**
  7148. * Gets the world matrix of the bounding box
  7149. * @returns a matrix
  7150. */
  7151. getWorldMatrix(): DeepImmutable<Matrix>;
  7152. /** @hidden */
  7153. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7154. /**
  7155. * Tests if the bounding sphere is intersecting the frustum planes
  7156. * @param frustumPlanes defines the frustum planes to test
  7157. * @returns true if there is an intersection
  7158. */
  7159. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7160. /**
  7161. * Tests if the bounding sphere center is in between the frustum planes.
  7162. * Used for optimistic fast inclusion.
  7163. * @param frustumPlanes defines the frustum planes to test
  7164. * @returns true if the sphere center is in between the frustum planes
  7165. */
  7166. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7167. /**
  7168. * Tests if a point is inside the bounding sphere
  7169. * @param point defines the point to test
  7170. * @returns true if the point is inside the bounding sphere
  7171. */
  7172. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7173. /**
  7174. * Checks if two sphere intersct
  7175. * @param sphere0 sphere 0
  7176. * @param sphere1 sphere 1
  7177. * @returns true if the speres intersect
  7178. */
  7179. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7180. }
  7181. }
  7182. declare module "babylonjs/Culling/boundingBox" {
  7183. import { DeepImmutable } from "babylonjs/types";
  7184. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7187. /**
  7188. * Class used to store bounding box information
  7189. */
  7190. export class BoundingBox implements ICullable {
  7191. /**
  7192. * Gets the 8 vectors representing the bounding box in local space
  7193. */
  7194. readonly vectors: Vector3[];
  7195. /**
  7196. * Gets the center of the bounding box in local space
  7197. */
  7198. readonly center: Vector3;
  7199. /**
  7200. * Gets the center of the bounding box in world space
  7201. */
  7202. readonly centerWorld: Vector3;
  7203. /**
  7204. * Gets the extend size in local space
  7205. */
  7206. readonly extendSize: Vector3;
  7207. /**
  7208. * Gets the extend size in world space
  7209. */
  7210. readonly extendSizeWorld: Vector3;
  7211. /**
  7212. * Gets the OBB (object bounding box) directions
  7213. */
  7214. readonly directions: Vector3[];
  7215. /**
  7216. * Gets the 8 vectors representing the bounding box in world space
  7217. */
  7218. readonly vectorsWorld: Vector3[];
  7219. /**
  7220. * Gets the minimum vector in world space
  7221. */
  7222. readonly minimumWorld: Vector3;
  7223. /**
  7224. * Gets the maximum vector in world space
  7225. */
  7226. readonly maximumWorld: Vector3;
  7227. /**
  7228. * Gets the minimum vector in local space
  7229. */
  7230. readonly minimum: Vector3;
  7231. /**
  7232. * Gets the maximum vector in local space
  7233. */
  7234. readonly maximum: Vector3;
  7235. private _worldMatrix;
  7236. private static readonly TmpVector3;
  7237. /**
  7238. * @hidden
  7239. */
  7240. _tag: number;
  7241. /**
  7242. * Creates a new bounding box
  7243. * @param min defines the minimum vector (in local space)
  7244. * @param max defines the maximum vector (in local space)
  7245. * @param worldMatrix defines the new world matrix
  7246. */
  7247. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7248. /**
  7249. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7250. * @param min defines the new minimum vector (in local space)
  7251. * @param max defines the new maximum vector (in local space)
  7252. * @param worldMatrix defines the new world matrix
  7253. */
  7254. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7255. /**
  7256. * Scale the current bounding box by applying a scale factor
  7257. * @param factor defines the scale factor to apply
  7258. * @returns the current bounding box
  7259. */
  7260. scale(factor: number): BoundingBox;
  7261. /**
  7262. * Gets the world matrix of the bounding box
  7263. * @returns a matrix
  7264. */
  7265. getWorldMatrix(): DeepImmutable<Matrix>;
  7266. /** @hidden */
  7267. _update(world: DeepImmutable<Matrix>): void;
  7268. /**
  7269. * Tests if the bounding box is intersecting the frustum planes
  7270. * @param frustumPlanes defines the frustum planes to test
  7271. * @returns true if there is an intersection
  7272. */
  7273. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /**
  7275. * Tests if the bounding box is entirely inside the frustum planes
  7276. * @param frustumPlanes defines the frustum planes to test
  7277. * @returns true if there is an inclusion
  7278. */
  7279. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7280. /**
  7281. * Tests if a point is inside the bounding box
  7282. * @param point defines the point to test
  7283. * @returns true if the point is inside the bounding box
  7284. */
  7285. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7286. /**
  7287. * Tests if the bounding box intersects with a bounding sphere
  7288. * @param sphere defines the sphere to test
  7289. * @returns true if there is an intersection
  7290. */
  7291. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7292. /**
  7293. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7294. * @param min defines the min vector to use
  7295. * @param max defines the max vector to use
  7296. * @returns true if there is an intersection
  7297. */
  7298. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7299. /**
  7300. * Tests if two bounding boxes are intersections
  7301. * @param box0 defines the first box to test
  7302. * @param box1 defines the second box to test
  7303. * @returns true if there is an intersection
  7304. */
  7305. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7306. /**
  7307. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7308. * @param minPoint defines the minimum vector of the bounding box
  7309. * @param maxPoint defines the maximum vector of the bounding box
  7310. * @param sphereCenter defines the sphere center
  7311. * @param sphereRadius defines the sphere radius
  7312. * @returns true if there is an intersection
  7313. */
  7314. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7315. /**
  7316. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7317. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7318. * @param frustumPlanes defines the frustum planes to test
  7319. * @return true if there is an inclusion
  7320. */
  7321. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7322. /**
  7323. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7324. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7325. * @param frustumPlanes defines the frustum planes to test
  7326. * @return true if there is an intersection
  7327. */
  7328. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7329. }
  7330. }
  7331. declare module "babylonjs/Collisions/collider" {
  7332. import { Nullable, IndicesArray } from "babylonjs/types";
  7333. import { Vector3, Plane } from "babylonjs/Maths/math";
  7334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7335. /** @hidden */
  7336. export class Collider {
  7337. /** Define if a collision was found */
  7338. collisionFound: boolean;
  7339. /**
  7340. * Define last intersection point in local space
  7341. */
  7342. intersectionPoint: Vector3;
  7343. /**
  7344. * Define last collided mesh
  7345. */
  7346. collidedMesh: Nullable<AbstractMesh>;
  7347. private _collisionPoint;
  7348. private _planeIntersectionPoint;
  7349. private _tempVector;
  7350. private _tempVector2;
  7351. private _tempVector3;
  7352. private _tempVector4;
  7353. private _edge;
  7354. private _baseToVertex;
  7355. private _destinationPoint;
  7356. private _slidePlaneNormal;
  7357. private _displacementVector;
  7358. /** @hidden */
  7359. _radius: Vector3;
  7360. /** @hidden */
  7361. _retry: number;
  7362. private _velocity;
  7363. private _basePoint;
  7364. private _epsilon;
  7365. /** @hidden */
  7366. _velocityWorldLength: number;
  7367. /** @hidden */
  7368. _basePointWorld: Vector3;
  7369. private _velocityWorld;
  7370. private _normalizedVelocity;
  7371. /** @hidden */
  7372. _initialVelocity: Vector3;
  7373. /** @hidden */
  7374. _initialPosition: Vector3;
  7375. private _nearestDistance;
  7376. private _collisionMask;
  7377. collisionMask: number;
  7378. /**
  7379. * Gets the plane normal used to compute the sliding response (in local space)
  7380. */
  7381. readonly slidePlaneNormal: Vector3;
  7382. /** @hidden */
  7383. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7384. /** @hidden */
  7385. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7386. /** @hidden */
  7387. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7388. /** @hidden */
  7389. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7390. /** @hidden */
  7391. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7392. /** @hidden */
  7393. _getResponse(pos: Vector3, vel: Vector3): void;
  7394. }
  7395. }
  7396. declare module "babylonjs/Culling/boundingInfo" {
  7397. import { DeepImmutable } from "babylonjs/types";
  7398. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7399. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7400. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7401. import { Collider } from "babylonjs/Collisions/collider";
  7402. /**
  7403. * Interface for cullable objects
  7404. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7405. */
  7406. export interface ICullable {
  7407. /**
  7408. * Checks if the object or part of the object is in the frustum
  7409. * @param frustumPlanes Camera near/planes
  7410. * @returns true if the object is in frustum otherwise false
  7411. */
  7412. isInFrustum(frustumPlanes: Plane[]): boolean;
  7413. /**
  7414. * Checks if a cullable object (mesh...) is in the camera frustum
  7415. * Unlike isInFrustum this cheks the full bounding box
  7416. * @param frustumPlanes Camera near/planes
  7417. * @returns true if the object is in frustum otherwise false
  7418. */
  7419. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7420. }
  7421. /**
  7422. * Info for a bounding data of a mesh
  7423. */
  7424. export class BoundingInfo implements ICullable {
  7425. /**
  7426. * Bounding box for the mesh
  7427. */
  7428. readonly boundingBox: BoundingBox;
  7429. /**
  7430. * Bounding sphere for the mesh
  7431. */
  7432. readonly boundingSphere: BoundingSphere;
  7433. private _isLocked;
  7434. private static readonly TmpVector3;
  7435. /**
  7436. * Constructs bounding info
  7437. * @param minimum min vector of the bounding box/sphere
  7438. * @param maximum max vector of the bounding box/sphere
  7439. * @param worldMatrix defines the new world matrix
  7440. */
  7441. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7442. /**
  7443. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7444. * @param min defines the new minimum vector (in local space)
  7445. * @param max defines the new maximum vector (in local space)
  7446. * @param worldMatrix defines the new world matrix
  7447. */
  7448. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7449. /**
  7450. * min vector of the bounding box/sphere
  7451. */
  7452. readonly minimum: Vector3;
  7453. /**
  7454. * max vector of the bounding box/sphere
  7455. */
  7456. readonly maximum: Vector3;
  7457. /**
  7458. * If the info is locked and won't be updated to avoid perf overhead
  7459. */
  7460. isLocked: boolean;
  7461. /**
  7462. * Updates the bounding sphere and box
  7463. * @param world world matrix to be used to update
  7464. */
  7465. update(world: DeepImmutable<Matrix>): void;
  7466. /**
  7467. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7468. * @param center New center of the bounding info
  7469. * @param extend New extend of the bounding info
  7470. * @returns the current bounding info
  7471. */
  7472. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7473. /**
  7474. * Scale the current bounding info by applying a scale factor
  7475. * @param factor defines the scale factor to apply
  7476. * @returns the current bounding info
  7477. */
  7478. scale(factor: number): BoundingInfo;
  7479. /**
  7480. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7481. * @param frustumPlanes defines the frustum to test
  7482. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7483. * @returns true if the bounding info is in the frustum planes
  7484. */
  7485. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7486. /**
  7487. * Gets the world distance between the min and max points of the bounding box
  7488. */
  7489. readonly diagonalLength: number;
  7490. /**
  7491. * Checks if a cullable object (mesh...) is in the camera frustum
  7492. * Unlike isInFrustum this cheks the full bounding box
  7493. * @param frustumPlanes Camera near/planes
  7494. * @returns true if the object is in frustum otherwise false
  7495. */
  7496. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7497. /** @hidden */
  7498. _checkCollision(collider: Collider): boolean;
  7499. /**
  7500. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7501. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7502. * @param point the point to check intersection with
  7503. * @returns if the point intersects
  7504. */
  7505. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7506. /**
  7507. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7508. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7509. * @param boundingInfo the bounding info to check intersection with
  7510. * @param precise if the intersection should be done using OBB
  7511. * @returns if the bounding info intersects
  7512. */
  7513. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7514. }
  7515. }
  7516. declare module "babylonjs/Misc/smartArray" {
  7517. /**
  7518. * Defines an array and its length.
  7519. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7520. */
  7521. export interface ISmartArrayLike<T> {
  7522. /**
  7523. * The data of the array.
  7524. */
  7525. data: Array<T>;
  7526. /**
  7527. * The active length of the array.
  7528. */
  7529. length: number;
  7530. }
  7531. /**
  7532. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7533. */
  7534. export class SmartArray<T> implements ISmartArrayLike<T> {
  7535. /**
  7536. * The full set of data from the array.
  7537. */
  7538. data: Array<T>;
  7539. /**
  7540. * The active length of the array.
  7541. */
  7542. length: number;
  7543. protected _id: number;
  7544. /**
  7545. * Instantiates a Smart Array.
  7546. * @param capacity defines the default capacity of the array.
  7547. */
  7548. constructor(capacity: number);
  7549. /**
  7550. * Pushes a value at the end of the active data.
  7551. * @param value defines the object to push in the array.
  7552. */
  7553. push(value: T): void;
  7554. /**
  7555. * Iterates over the active data and apply the lambda to them.
  7556. * @param func defines the action to apply on each value.
  7557. */
  7558. forEach(func: (content: T) => void): void;
  7559. /**
  7560. * Sorts the full sets of data.
  7561. * @param compareFn defines the comparison function to apply.
  7562. */
  7563. sort(compareFn: (a: T, b: T) => number): void;
  7564. /**
  7565. * Resets the active data to an empty array.
  7566. */
  7567. reset(): void;
  7568. /**
  7569. * Releases all the data from the array as well as the array.
  7570. */
  7571. dispose(): void;
  7572. /**
  7573. * Concats the active data with a given array.
  7574. * @param array defines the data to concatenate with.
  7575. */
  7576. concat(array: any): void;
  7577. /**
  7578. * Returns the position of a value in the active data.
  7579. * @param value defines the value to find the index for
  7580. * @returns the index if found in the active data otherwise -1
  7581. */
  7582. indexOf(value: T): number;
  7583. /**
  7584. * Returns whether an element is part of the active data.
  7585. * @param value defines the value to look for
  7586. * @returns true if found in the active data otherwise false
  7587. */
  7588. contains(value: T): boolean;
  7589. private static _GlobalId;
  7590. }
  7591. /**
  7592. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7593. * The data in this array can only be present once
  7594. */
  7595. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7596. private _duplicateId;
  7597. /**
  7598. * Pushes a value at the end of the active data.
  7599. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7600. * @param value defines the object to push in the array.
  7601. */
  7602. push(value: T): void;
  7603. /**
  7604. * Pushes a value at the end of the active data.
  7605. * If the data is already present, it won t be added again
  7606. * @param value defines the object to push in the array.
  7607. * @returns true if added false if it was already present
  7608. */
  7609. pushNoDuplicate(value: T): boolean;
  7610. /**
  7611. * Resets the active data to an empty array.
  7612. */
  7613. reset(): void;
  7614. /**
  7615. * Concats the active data with a given array.
  7616. * This ensures no dupplicate will be present in the result.
  7617. * @param array defines the data to concatenate with.
  7618. */
  7619. concatWithNoDuplicate(array: any): void;
  7620. }
  7621. }
  7622. declare module "babylonjs/Misc/iInspectable" {
  7623. /**
  7624. * Enum that determines the text-wrapping mode to use.
  7625. */
  7626. export enum InspectableType {
  7627. /**
  7628. * Checkbox for booleans
  7629. */
  7630. Checkbox = 0,
  7631. /**
  7632. * Sliders for numbers
  7633. */
  7634. Slider = 1,
  7635. /**
  7636. * Vector3
  7637. */
  7638. Vector3 = 2,
  7639. /**
  7640. * Quaternions
  7641. */
  7642. Quaternion = 3,
  7643. /**
  7644. * Color3
  7645. */
  7646. Color3 = 4
  7647. }
  7648. /**
  7649. * Interface used to define custom inspectable properties.
  7650. * This interface is used by the inspector to display custom property grids
  7651. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7652. */
  7653. export interface IInspectable {
  7654. /**
  7655. * Gets the label to display
  7656. */
  7657. label: string;
  7658. /**
  7659. * Gets the name of the property to edit
  7660. */
  7661. propertyName: string;
  7662. /**
  7663. * Gets the type of the editor to use
  7664. */
  7665. type: InspectableType;
  7666. /**
  7667. * Gets the minimum value of the property when using in "slider" mode
  7668. */
  7669. min?: number;
  7670. /**
  7671. * Gets the maximum value of the property when using in "slider" mode
  7672. */
  7673. max?: number;
  7674. /**
  7675. * Gets the setp to use when using in "slider" mode
  7676. */
  7677. step?: number;
  7678. }
  7679. }
  7680. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7681. import { Nullable } from "babylonjs/types";
  7682. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7683. /**
  7684. * This represents the required contract to create a new type of texture loader.
  7685. */
  7686. export interface IInternalTextureLoader {
  7687. /**
  7688. * Defines wether the loader supports cascade loading the different faces.
  7689. */
  7690. supportCascades: boolean;
  7691. /**
  7692. * This returns if the loader support the current file information.
  7693. * @param extension defines the file extension of the file being loaded
  7694. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7695. * @param fallback defines the fallback internal texture if any
  7696. * @param isBase64 defines whether the texture is encoded as a base64
  7697. * @param isBuffer defines whether the texture data are stored as a buffer
  7698. * @returns true if the loader can load the specified file
  7699. */
  7700. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7701. /**
  7702. * Transform the url before loading if required.
  7703. * @param rootUrl the url of the texture
  7704. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7705. * @returns the transformed texture
  7706. */
  7707. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7708. /**
  7709. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7710. * @param rootUrl the url of the texture
  7711. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7712. * @returns the fallback texture
  7713. */
  7714. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7715. /**
  7716. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7717. * @param data contains the texture data
  7718. * @param texture defines the BabylonJS internal texture
  7719. * @param createPolynomials will be true if polynomials have been requested
  7720. * @param onLoad defines the callback to trigger once the texture is ready
  7721. * @param onError defines the callback to trigger in case of error
  7722. */
  7723. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7724. /**
  7725. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7726. * @param data contains the texture data
  7727. * @param texture defines the BabylonJS internal texture
  7728. * @param callback defines the method to call once ready to upload
  7729. */
  7730. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7731. }
  7732. }
  7733. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7734. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7735. import { Nullable } from "babylonjs/types";
  7736. import { Scene } from "babylonjs/scene";
  7737. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7738. module "babylonjs/Engines/engine" {
  7739. interface Engine {
  7740. /**
  7741. * Creates a depth stencil cube texture.
  7742. * This is only available in WebGL 2.
  7743. * @param size The size of face edge in the cube texture.
  7744. * @param options The options defining the cube texture.
  7745. * @returns The cube texture
  7746. */
  7747. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7748. /**
  7749. * Creates a cube texture
  7750. * @param rootUrl defines the url where the files to load is located
  7751. * @param scene defines the current scene
  7752. * @param files defines the list of files to load (1 per face)
  7753. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7754. * @param onLoad defines an optional callback raised when the texture is loaded
  7755. * @param onError defines an optional callback raised if there is an issue to load the texture
  7756. * @param format defines the format of the data
  7757. * @param forcedExtension defines the extension to use to pick the right loader
  7758. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7759. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7760. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7761. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7762. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7763. * @returns the cube texture as an InternalTexture
  7764. */
  7765. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7766. /**
  7767. * Creates a cube texture
  7768. * @param rootUrl defines the url where the files to load is located
  7769. * @param scene defines the current scene
  7770. * @param files defines the list of files to load (1 per face)
  7771. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7772. * @param onLoad defines an optional callback raised when the texture is loaded
  7773. * @param onError defines an optional callback raised if there is an issue to load the texture
  7774. * @param format defines the format of the data
  7775. * @param forcedExtension defines the extension to use to pick the right loader
  7776. * @returns the cube texture as an InternalTexture
  7777. */
  7778. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7779. /**
  7780. * Creates a cube texture
  7781. * @param rootUrl defines the url where the files to load is located
  7782. * @param scene defines the current scene
  7783. * @param files defines the list of files to load (1 per face)
  7784. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7785. * @param onLoad defines an optional callback raised when the texture is loaded
  7786. * @param onError defines an optional callback raised if there is an issue to load the texture
  7787. * @param format defines the format of the data
  7788. * @param forcedExtension defines the extension to use to pick the right loader
  7789. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7790. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7791. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7792. * @returns the cube texture as an InternalTexture
  7793. */
  7794. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7795. /** @hidden */
  7796. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7797. /** @hidden */
  7798. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7799. /** @hidden */
  7800. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7801. /** @hidden */
  7802. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7803. }
  7804. }
  7805. }
  7806. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7807. import { Nullable } from "babylonjs/types";
  7808. import { Scene } from "babylonjs/scene";
  7809. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7811. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7812. /**
  7813. * Class for creating a cube texture
  7814. */
  7815. export class CubeTexture extends BaseTexture {
  7816. private _delayedOnLoad;
  7817. /**
  7818. * The url of the texture
  7819. */
  7820. url: string;
  7821. /**
  7822. * Gets or sets the center of the bounding box associated with the cube texture.
  7823. * It must define where the camera used to render the texture was set
  7824. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7825. */
  7826. boundingBoxPosition: Vector3;
  7827. private _boundingBoxSize;
  7828. /**
  7829. * Gets or sets the size of the bounding box associated with the cube texture
  7830. * When defined, the cubemap will switch to local mode
  7831. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7832. * @example https://www.babylonjs-playground.com/#RNASML
  7833. */
  7834. /**
  7835. * Returns the bounding box size
  7836. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7837. */
  7838. boundingBoxSize: Vector3;
  7839. protected _rotationY: number;
  7840. /**
  7841. * Sets texture matrix rotation angle around Y axis in radians.
  7842. */
  7843. /**
  7844. * Gets texture matrix rotation angle around Y axis radians.
  7845. */
  7846. rotationY: number;
  7847. /**
  7848. * Are mip maps generated for this texture or not.
  7849. */
  7850. readonly noMipmap: boolean;
  7851. private _noMipmap;
  7852. private _files;
  7853. private _extensions;
  7854. private _textureMatrix;
  7855. private _format;
  7856. private _createPolynomials;
  7857. /** @hidden */
  7858. _prefiltered: boolean;
  7859. /**
  7860. * Creates a cube texture from an array of image urls
  7861. * @param files defines an array of image urls
  7862. * @param scene defines the hosting scene
  7863. * @param noMipmap specifies if mip maps are not used
  7864. * @returns a cube texture
  7865. */
  7866. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7867. /**
  7868. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7869. * @param url defines the url of the prefiltered texture
  7870. * @param scene defines the scene the texture is attached to
  7871. * @param forcedExtension defines the extension of the file if different from the url
  7872. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7873. * @return the prefiltered texture
  7874. */
  7875. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7876. /**
  7877. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7878. * as prefiltered data.
  7879. * @param rootUrl defines the url of the texture or the root name of the six images
  7880. * @param scene defines the scene the texture is attached to
  7881. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7882. * @param noMipmap defines if mipmaps should be created or not
  7883. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7884. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7885. * @param onError defines a callback triggered in case of error during load
  7886. * @param format defines the internal format to use for the texture once loaded
  7887. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7888. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7889. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7890. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7891. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7892. * @return the cube texture
  7893. */
  7894. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7895. /**
  7896. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7897. */
  7898. readonly isPrefiltered: boolean;
  7899. /**
  7900. * Get the current class name of the texture useful for serialization or dynamic coding.
  7901. * @returns "CubeTexture"
  7902. */
  7903. getClassName(): string;
  7904. /**
  7905. * Update the url (and optional buffer) of this texture if url was null during construction.
  7906. * @param url the url of the texture
  7907. * @param forcedExtension defines the extension to use
  7908. * @param onLoad callback called when the texture is loaded (defaults to null)
  7909. */
  7910. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7911. /**
  7912. * Delays loading of the cube texture
  7913. * @param forcedExtension defines the extension to use
  7914. */
  7915. delayLoad(forcedExtension?: string): void;
  7916. /**
  7917. * Returns the reflection texture matrix
  7918. * @returns the reflection texture matrix
  7919. */
  7920. getReflectionTextureMatrix(): Matrix;
  7921. /**
  7922. * Sets the reflection texture matrix
  7923. * @param value Reflection texture matrix
  7924. */
  7925. setReflectionTextureMatrix(value: Matrix): void;
  7926. /**
  7927. * Parses text to create a cube texture
  7928. * @param parsedTexture define the serialized text to read from
  7929. * @param scene defines the hosting scene
  7930. * @param rootUrl defines the root url of the cube texture
  7931. * @returns a cube texture
  7932. */
  7933. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7934. /**
  7935. * Makes a clone, or deep copy, of the cube texture
  7936. * @returns a new cube texture
  7937. */
  7938. clone(): CubeTexture;
  7939. }
  7940. }
  7941. declare module "babylonjs/Shaders/postprocess.vertex" {
  7942. /** @hidden */
  7943. export var postprocessVertexShader: {
  7944. name: string;
  7945. shader: string;
  7946. };
  7947. }
  7948. declare module "babylonjs/Cameras/targetCamera" {
  7949. import { Nullable } from "babylonjs/types";
  7950. import { Camera } from "babylonjs/Cameras/camera";
  7951. import { Scene } from "babylonjs/scene";
  7952. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7953. /**
  7954. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7955. * This is the base of the follow, arc rotate cameras and Free camera
  7956. * @see http://doc.babylonjs.com/features/cameras
  7957. */
  7958. export class TargetCamera extends Camera {
  7959. private static _RigCamTransformMatrix;
  7960. private static _TargetTransformMatrix;
  7961. private static _TargetFocalPoint;
  7962. /**
  7963. * Define the current direction the camera is moving to
  7964. */
  7965. cameraDirection: Vector3;
  7966. /**
  7967. * Define the current rotation the camera is rotating to
  7968. */
  7969. cameraRotation: Vector2;
  7970. /**
  7971. * When set, the up vector of the camera will be updated by the rotation of the camera
  7972. */
  7973. updateUpVectorFromRotation: boolean;
  7974. private _tmpQuaternion;
  7975. /**
  7976. * Define the current rotation of the camera
  7977. */
  7978. rotation: Vector3;
  7979. /**
  7980. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7981. */
  7982. rotationQuaternion: Quaternion;
  7983. /**
  7984. * Define the current speed of the camera
  7985. */
  7986. speed: number;
  7987. /**
  7988. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7989. * around all axis.
  7990. */
  7991. noRotationConstraint: boolean;
  7992. /**
  7993. * Define the current target of the camera as an object or a position.
  7994. */
  7995. lockedTarget: any;
  7996. /** @hidden */
  7997. _currentTarget: Vector3;
  7998. /** @hidden */
  7999. _initialFocalDistance: number;
  8000. /** @hidden */
  8001. _viewMatrix: Matrix;
  8002. /** @hidden */
  8003. _camMatrix: Matrix;
  8004. /** @hidden */
  8005. _cameraTransformMatrix: Matrix;
  8006. /** @hidden */
  8007. _cameraRotationMatrix: Matrix;
  8008. /** @hidden */
  8009. _referencePoint: Vector3;
  8010. /** @hidden */
  8011. _transformedReferencePoint: Vector3;
  8012. protected _globalCurrentTarget: Vector3;
  8013. protected _globalCurrentUpVector: Vector3;
  8014. /** @hidden */
  8015. _reset: () => void;
  8016. private _defaultUp;
  8017. /**
  8018. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8019. * This is the base of the follow, arc rotate cameras and Free camera
  8020. * @see http://doc.babylonjs.com/features/cameras
  8021. * @param name Defines the name of the camera in the scene
  8022. * @param position Defines the start position of the camera in the scene
  8023. * @param scene Defines the scene the camera belongs to
  8024. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8025. */
  8026. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8027. /**
  8028. * Gets the position in front of the camera at a given distance.
  8029. * @param distance The distance from the camera we want the position to be
  8030. * @returns the position
  8031. */
  8032. getFrontPosition(distance: number): Vector3;
  8033. /** @hidden */
  8034. _getLockedTargetPosition(): Nullable<Vector3>;
  8035. private _storedPosition;
  8036. private _storedRotation;
  8037. private _storedRotationQuaternion;
  8038. /**
  8039. * Store current camera state of the camera (fov, position, rotation, etc..)
  8040. * @returns the camera
  8041. */
  8042. storeState(): Camera;
  8043. /**
  8044. * Restored camera state. You must call storeState() first
  8045. * @returns whether it was successful or not
  8046. * @hidden
  8047. */
  8048. _restoreStateValues(): boolean;
  8049. /** @hidden */
  8050. _initCache(): void;
  8051. /** @hidden */
  8052. _updateCache(ignoreParentClass?: boolean): void;
  8053. /** @hidden */
  8054. _isSynchronizedViewMatrix(): boolean;
  8055. /** @hidden */
  8056. _computeLocalCameraSpeed(): number;
  8057. /**
  8058. * Defines the target the camera should look at.
  8059. * This will automatically adapt alpha beta and radius to fit within the new target.
  8060. * @param target Defines the new target as a Vector or a mesh
  8061. */
  8062. setTarget(target: Vector3): void;
  8063. /**
  8064. * Return the current target position of the camera. This value is expressed in local space.
  8065. * @returns the target position
  8066. */
  8067. getTarget(): Vector3;
  8068. /** @hidden */
  8069. _decideIfNeedsToMove(): boolean;
  8070. /** @hidden */
  8071. _updatePosition(): void;
  8072. /** @hidden */
  8073. _checkInputs(): void;
  8074. protected _updateCameraRotationMatrix(): void;
  8075. /**
  8076. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8077. * @returns the current camera
  8078. */
  8079. private _rotateUpVectorWithCameraRotationMatrix;
  8080. private _cachedRotationZ;
  8081. private _cachedQuaternionRotationZ;
  8082. /** @hidden */
  8083. _getViewMatrix(): Matrix;
  8084. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8085. /**
  8086. * @hidden
  8087. */
  8088. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8089. /**
  8090. * @hidden
  8091. */
  8092. _updateRigCameras(): void;
  8093. private _getRigCamPositionAndTarget;
  8094. /**
  8095. * Gets the current object class name.
  8096. * @return the class name
  8097. */
  8098. getClassName(): string;
  8099. }
  8100. }
  8101. declare module "babylonjs/Cameras/cameraInputsManager" {
  8102. import { Nullable } from "babylonjs/types";
  8103. import { Camera } from "babylonjs/Cameras/camera";
  8104. /**
  8105. * @ignore
  8106. * This is a list of all the different input types that are available in the application.
  8107. * Fo instance: ArcRotateCameraGamepadInput...
  8108. */
  8109. export var CameraInputTypes: {};
  8110. /**
  8111. * This is the contract to implement in order to create a new input class.
  8112. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8113. */
  8114. export interface ICameraInput<TCamera extends Camera> {
  8115. /**
  8116. * Defines the camera the input is attached to.
  8117. */
  8118. camera: Nullable<TCamera>;
  8119. /**
  8120. * Gets the class name of the current intput.
  8121. * @returns the class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Get the friendly name associated with the input class.
  8126. * @returns the input friendly name
  8127. */
  8128. getSimpleName(): string;
  8129. /**
  8130. * Attach the input controls to a specific dom element to get the input from.
  8131. * @param element Defines the element the controls should be listened from
  8132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8133. */
  8134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8135. /**
  8136. * Detach the current controls from the specified dom element.
  8137. * @param element Defines the element to stop listening the inputs from
  8138. */
  8139. detachControl(element: Nullable<HTMLElement>): void;
  8140. /**
  8141. * Update the current camera state depending on the inputs that have been used this frame.
  8142. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8143. */
  8144. checkInputs?: () => void;
  8145. }
  8146. /**
  8147. * Represents a map of input types to input instance or input index to input instance.
  8148. */
  8149. export interface CameraInputsMap<TCamera extends Camera> {
  8150. /**
  8151. * Accessor to the input by input type.
  8152. */
  8153. [name: string]: ICameraInput<TCamera>;
  8154. /**
  8155. * Accessor to the input by input index.
  8156. */
  8157. [idx: number]: ICameraInput<TCamera>;
  8158. }
  8159. /**
  8160. * This represents the input manager used within a camera.
  8161. * It helps dealing with all the different kind of input attached to a camera.
  8162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8163. */
  8164. export class CameraInputsManager<TCamera extends Camera> {
  8165. /**
  8166. * Defines the list of inputs attahed to the camera.
  8167. */
  8168. attached: CameraInputsMap<TCamera>;
  8169. /**
  8170. * Defines the dom element the camera is collecting inputs from.
  8171. * This is null if the controls have not been attached.
  8172. */
  8173. attachedElement: Nullable<HTMLElement>;
  8174. /**
  8175. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8176. */
  8177. noPreventDefault: boolean;
  8178. /**
  8179. * Defined the camera the input manager belongs to.
  8180. */
  8181. camera: TCamera;
  8182. /**
  8183. * Update the current camera state depending on the inputs that have been used this frame.
  8184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8185. */
  8186. checkInputs: () => void;
  8187. /**
  8188. * Instantiate a new Camera Input Manager.
  8189. * @param camera Defines the camera the input manager blongs to
  8190. */
  8191. constructor(camera: TCamera);
  8192. /**
  8193. * Add an input method to a camera
  8194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8195. * @param input camera input method
  8196. */
  8197. add(input: ICameraInput<TCamera>): void;
  8198. /**
  8199. * Remove a specific input method from a camera
  8200. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8201. * @param inputToRemove camera input method
  8202. */
  8203. remove(inputToRemove: ICameraInput<TCamera>): void;
  8204. /**
  8205. * Remove a specific input type from a camera
  8206. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8207. * @param inputType the type of the input to remove
  8208. */
  8209. removeByType(inputType: string): void;
  8210. private _addCheckInputs;
  8211. /**
  8212. * Attach the input controls to the currently attached dom element to listen the events from.
  8213. * @param input Defines the input to attach
  8214. */
  8215. attachInput(input: ICameraInput<TCamera>): void;
  8216. /**
  8217. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8218. * @param element Defines the dom element to collect the events from
  8219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8220. */
  8221. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8222. /**
  8223. * Detach the current manager inputs controls from a specific dom element.
  8224. * @param element Defines the dom element to collect the events from
  8225. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8226. */
  8227. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8228. /**
  8229. * Rebuild the dynamic inputCheck function from the current list of
  8230. * defined inputs in the manager.
  8231. */
  8232. rebuildInputCheck(): void;
  8233. /**
  8234. * Remove all attached input methods from a camera
  8235. */
  8236. clear(): void;
  8237. /**
  8238. * Serialize the current input manager attached to a camera.
  8239. * This ensures than once parsed,
  8240. * the input associated to the camera will be identical to the current ones
  8241. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8242. */
  8243. serialize(serializedCamera: any): void;
  8244. /**
  8245. * Parses an input manager serialized JSON to restore the previous list of inputs
  8246. * and states associated to a camera.
  8247. * @param parsedCamera Defines the JSON to parse
  8248. */
  8249. parse(parsedCamera: any): void;
  8250. }
  8251. }
  8252. declare module "babylonjs/Events/keyboardEvents" {
  8253. /**
  8254. * Gather the list of keyboard event types as constants.
  8255. */
  8256. export class KeyboardEventTypes {
  8257. /**
  8258. * The keydown event is fired when a key becomes active (pressed).
  8259. */
  8260. static readonly KEYDOWN: number;
  8261. /**
  8262. * The keyup event is fired when a key has been released.
  8263. */
  8264. static readonly KEYUP: number;
  8265. }
  8266. /**
  8267. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8268. */
  8269. export class KeyboardInfo {
  8270. /**
  8271. * Defines the type of event (KeyboardEventTypes)
  8272. */
  8273. type: number;
  8274. /**
  8275. * Defines the related dom event
  8276. */
  8277. event: KeyboardEvent;
  8278. /**
  8279. * Instantiates a new keyboard info.
  8280. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8281. * @param type Defines the type of event (KeyboardEventTypes)
  8282. * @param event Defines the related dom event
  8283. */
  8284. constructor(
  8285. /**
  8286. * Defines the type of event (KeyboardEventTypes)
  8287. */
  8288. type: number,
  8289. /**
  8290. * Defines the related dom event
  8291. */
  8292. event: KeyboardEvent);
  8293. }
  8294. /**
  8295. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8296. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8297. */
  8298. export class KeyboardInfoPre extends KeyboardInfo {
  8299. /**
  8300. * Defines the type of event (KeyboardEventTypes)
  8301. */
  8302. type: number;
  8303. /**
  8304. * Defines the related dom event
  8305. */
  8306. event: KeyboardEvent;
  8307. /**
  8308. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8309. */
  8310. skipOnPointerObservable: boolean;
  8311. /**
  8312. * Instantiates a new keyboard pre info.
  8313. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8314. * @param type Defines the type of event (KeyboardEventTypes)
  8315. * @param event Defines the related dom event
  8316. */
  8317. constructor(
  8318. /**
  8319. * Defines the type of event (KeyboardEventTypes)
  8320. */
  8321. type: number,
  8322. /**
  8323. * Defines the related dom event
  8324. */
  8325. event: KeyboardEvent);
  8326. }
  8327. }
  8328. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8329. import { Nullable } from "babylonjs/types";
  8330. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8331. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8332. /**
  8333. * Manage the keyboard inputs to control the movement of a free camera.
  8334. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8335. */
  8336. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8337. /**
  8338. * Defines the camera the input is attached to.
  8339. */
  8340. camera: FreeCamera;
  8341. /**
  8342. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8343. */
  8344. keysUp: number[];
  8345. /**
  8346. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8347. */
  8348. keysDown: number[];
  8349. /**
  8350. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8351. */
  8352. keysLeft: number[];
  8353. /**
  8354. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8355. */
  8356. keysRight: number[];
  8357. private _keys;
  8358. private _onCanvasBlurObserver;
  8359. private _onKeyboardObserver;
  8360. private _engine;
  8361. private _scene;
  8362. /**
  8363. * Attach the input controls to a specific dom element to get the input from.
  8364. * @param element Defines the element the controls should be listened from
  8365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8366. */
  8367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8368. /**
  8369. * Detach the current controls from the specified dom element.
  8370. * @param element Defines the element to stop listening the inputs from
  8371. */
  8372. detachControl(element: Nullable<HTMLElement>): void;
  8373. /**
  8374. * Update the current camera state depending on the inputs that have been used this frame.
  8375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8376. */
  8377. checkInputs(): void;
  8378. /**
  8379. * Gets the class name of the current intput.
  8380. * @returns the class name
  8381. */
  8382. getClassName(): string;
  8383. /** @hidden */
  8384. _onLostFocus(): void;
  8385. /**
  8386. * Get the friendly name associated with the input class.
  8387. * @returns the input friendly name
  8388. */
  8389. getSimpleName(): string;
  8390. }
  8391. }
  8392. declare module "babylonjs/Materials/multiMaterial" {
  8393. import { Nullable } from "babylonjs/types";
  8394. import { Scene } from "babylonjs/scene";
  8395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8396. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  8397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8398. import { Material } from "babylonjs/Materials/material";
  8399. /**
  8400. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8401. * separate meshes. This can be use to improve performances.
  8402. * @see http://doc.babylonjs.com/how_to/multi_materials
  8403. */
  8404. export class MultiMaterial extends Material {
  8405. private _subMaterials;
  8406. /**
  8407. * Gets or Sets the list of Materials used within the multi material.
  8408. * They need to be ordered according to the submeshes order in the associated mesh
  8409. */
  8410. subMaterials: Nullable<Material>[];
  8411. /**
  8412. * Function used to align with Node.getChildren()
  8413. * @returns the list of Materials used within the multi material
  8414. */
  8415. getChildren(): Nullable<Material>[];
  8416. /**
  8417. * Instantiates a new Multi Material
  8418. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8419. * separate meshes. This can be use to improve performances.
  8420. * @see http://doc.babylonjs.com/how_to/multi_materials
  8421. * @param name Define the name in the scene
  8422. * @param scene Define the scene the material belongs to
  8423. */
  8424. constructor(name: string, scene: Scene);
  8425. private _hookArray;
  8426. /**
  8427. * Get one of the submaterial by its index in the submaterials array
  8428. * @param index The index to look the sub material at
  8429. * @returns The Material if the index has been defined
  8430. */
  8431. getSubMaterial(index: number): Nullable<Material>;
  8432. /**
  8433. * Get the list of active textures for the whole sub materials list.
  8434. * @returns All the textures that will be used during the rendering
  8435. */
  8436. getActiveTextures(): BaseTexture[];
  8437. /**
  8438. * Gets the current class name of the material e.g. "MultiMaterial"
  8439. * Mainly use in serialization.
  8440. * @returns the class name
  8441. */
  8442. getClassName(): string;
  8443. /**
  8444. * Checks if the material is ready to render the requested sub mesh
  8445. * @param mesh Define the mesh the submesh belongs to
  8446. * @param subMesh Define the sub mesh to look readyness for
  8447. * @param useInstances Define whether or not the material is used with instances
  8448. * @returns true if ready, otherwise false
  8449. */
  8450. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8451. /**
  8452. * Clones the current material and its related sub materials
  8453. * @param name Define the name of the newly cloned material
  8454. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8455. * @returns the cloned material
  8456. */
  8457. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8458. /**
  8459. * Serializes the materials into a JSON representation.
  8460. * @returns the JSON representation
  8461. */
  8462. serialize(): any;
  8463. /**
  8464. * Dispose the material and release its associated resources
  8465. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  8466. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  8467. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  8468. */
  8469. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8470. /**
  8471. * Creates a MultiMaterial from parsed MultiMaterial data.
  8472. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8473. * @param scene defines the hosting scene
  8474. * @returns a new MultiMaterial
  8475. */
  8476. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8477. }
  8478. }
  8479. declare module "babylonjs/Loading/sceneLoaderFlags" {
  8480. /**
  8481. * Class used to represent data loading progression
  8482. */
  8483. export class SceneLoaderFlags {
  8484. private static _ForceFullSceneLoadingForIncremental;
  8485. private static _ShowLoadingScreen;
  8486. private static _CleanBoneMatrixWeights;
  8487. private static _loggingLevel;
  8488. /**
  8489. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8490. */
  8491. static ForceFullSceneLoadingForIncremental: boolean;
  8492. /**
  8493. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8494. */
  8495. static ShowLoadingScreen: boolean;
  8496. /**
  8497. * Defines the current logging level (while loading the scene)
  8498. * @ignorenaming
  8499. */
  8500. static loggingLevel: number;
  8501. /**
  8502. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8503. */
  8504. static CleanBoneMatrixWeights: boolean;
  8505. }
  8506. }
  8507. declare module "babylonjs/Meshes/transformNode" {
  8508. import { DeepImmutable } from "babylonjs/types";
  8509. import { Observable } from "babylonjs/Misc/observable";
  8510. import { Nullable } from "babylonjs/types";
  8511. import { Camera } from "babylonjs/Cameras/camera";
  8512. import { Scene } from "babylonjs/scene";
  8513. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  8514. import { Node } from "babylonjs/node";
  8515. import { Bone } from "babylonjs/Bones/bone";
  8516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8517. /**
  8518. * 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.
  8519. * @see https://doc.babylonjs.com/how_to/transformnode
  8520. */
  8521. export class TransformNode extends Node {
  8522. /**
  8523. * Object will not rotate to face the camera
  8524. */
  8525. static BILLBOARDMODE_NONE: number;
  8526. /**
  8527. * Object will rotate to face the camera but only on the x axis
  8528. */
  8529. static BILLBOARDMODE_X: number;
  8530. /**
  8531. * Object will rotate to face the camera but only on the y axis
  8532. */
  8533. static BILLBOARDMODE_Y: number;
  8534. /**
  8535. * Object will rotate to face the camera but only on the z axis
  8536. */
  8537. static BILLBOARDMODE_Z: number;
  8538. /**
  8539. * Object will rotate to face the camera
  8540. */
  8541. static BILLBOARDMODE_ALL: number;
  8542. private _forward;
  8543. private _forwardInverted;
  8544. private _up;
  8545. private _right;
  8546. private _rightInverted;
  8547. private _position;
  8548. private _rotation;
  8549. private _rotationQuaternion;
  8550. protected _scaling: Vector3;
  8551. protected _isDirty: boolean;
  8552. private _transformToBoneReferal;
  8553. private _billboardMode;
  8554. /**
  8555. * Gets or sets the billboard mode. Default is 0.
  8556. *
  8557. * | Value | Type | Description |
  8558. * | --- | --- | --- |
  8559. * | 0 | BILLBOARDMODE_NONE | |
  8560. * | 1 | BILLBOARDMODE_X | |
  8561. * | 2 | BILLBOARDMODE_Y | |
  8562. * | 4 | BILLBOARDMODE_Z | |
  8563. * | 7 | BILLBOARDMODE_ALL | |
  8564. *
  8565. */
  8566. billboardMode: number;
  8567. private _preserveParentRotationForBillboard;
  8568. /**
  8569. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8570. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8571. */
  8572. preserveParentRotationForBillboard: boolean;
  8573. /**
  8574. * 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
  8575. */
  8576. scalingDeterminant: number;
  8577. private _infiniteDistance;
  8578. /**
  8579. * Gets or sets the distance of the object to max, often used by skybox
  8580. */
  8581. infiniteDistance: boolean;
  8582. /**
  8583. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8584. * By default the system will update normals to compensate
  8585. */
  8586. ignoreNonUniformScaling: boolean;
  8587. /**
  8588. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  8589. */
  8590. reIntegrateRotationIntoRotationQuaternion: boolean;
  8591. /** @hidden */
  8592. _poseMatrix: Nullable<Matrix>;
  8593. /** @hidden */
  8594. _localMatrix: Matrix;
  8595. private _usePivotMatrix;
  8596. private _absolutePosition;
  8597. private _pivotMatrix;
  8598. private _pivotMatrixInverse;
  8599. protected _postMultiplyPivotMatrix: boolean;
  8600. protected _isWorldMatrixFrozen: boolean;
  8601. /** @hidden */
  8602. _indexInSceneTransformNodesArray: number;
  8603. /**
  8604. * An event triggered after the world matrix is updated
  8605. */
  8606. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8607. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8608. /**
  8609. * Gets a string identifying the name of the class
  8610. * @returns "TransformNode" string
  8611. */
  8612. getClassName(): string;
  8613. /**
  8614. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8615. */
  8616. position: Vector3;
  8617. /**
  8618. * 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)).
  8619. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8620. */
  8621. rotation: Vector3;
  8622. /**
  8623. * 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)).
  8624. */
  8625. scaling: Vector3;
  8626. /**
  8627. * 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).
  8628. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8629. */
  8630. rotationQuaternion: Nullable<Quaternion>;
  8631. /**
  8632. * The forward direction of that transform in world space.
  8633. */
  8634. readonly forward: Vector3;
  8635. /**
  8636. * The up direction of that transform in world space.
  8637. */
  8638. readonly up: Vector3;
  8639. /**
  8640. * The right direction of that transform in world space.
  8641. */
  8642. readonly right: Vector3;
  8643. /**
  8644. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8645. * @param matrix the matrix to copy the pose from
  8646. * @returns this TransformNode.
  8647. */
  8648. updatePoseMatrix(matrix: Matrix): TransformNode;
  8649. /**
  8650. * Returns the mesh Pose matrix.
  8651. * @returns the pose matrix
  8652. */
  8653. getPoseMatrix(): Matrix;
  8654. /** @hidden */
  8655. _isSynchronized(): boolean;
  8656. /** @hidden */
  8657. _initCache(): void;
  8658. /**
  8659. * Flag the transform node as dirty (Forcing it to update everything)
  8660. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8661. * @returns this transform node
  8662. */
  8663. markAsDirty(property: string): TransformNode;
  8664. /**
  8665. * Returns the current mesh absolute position.
  8666. * Returns a Vector3.
  8667. */
  8668. readonly absolutePosition: Vector3;
  8669. /**
  8670. * Sets a new matrix to apply before all other transformation
  8671. * @param matrix defines the transform matrix
  8672. * @returns the current TransformNode
  8673. */
  8674. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8675. /**
  8676. * Sets a new pivot matrix to the current node
  8677. * @param matrix defines the new pivot matrix to use
  8678. * @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
  8679. * @returns the current TransformNode
  8680. */
  8681. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8682. /**
  8683. * Returns the mesh pivot matrix.
  8684. * Default : Identity.
  8685. * @returns the matrix
  8686. */
  8687. getPivotMatrix(): Matrix;
  8688. /**
  8689. * Prevents the World matrix to be computed any longer.
  8690. * @returns the TransformNode.
  8691. */
  8692. freezeWorldMatrix(): TransformNode;
  8693. /**
  8694. * Allows back the World matrix computation.
  8695. * @returns the TransformNode.
  8696. */
  8697. unfreezeWorldMatrix(): this;
  8698. /**
  8699. * True if the World matrix has been frozen.
  8700. */
  8701. readonly isWorldMatrixFrozen: boolean;
  8702. /**
  8703. * Retuns the mesh absolute position in the World.
  8704. * @returns a Vector3.
  8705. */
  8706. getAbsolutePosition(): Vector3;
  8707. /**
  8708. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8709. * @param absolutePosition the absolute position to set
  8710. * @returns the TransformNode.
  8711. */
  8712. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8713. /**
  8714. * Sets the mesh position in its local space.
  8715. * @param vector3 the position to set in localspace
  8716. * @returns the TransformNode.
  8717. */
  8718. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8719. /**
  8720. * Returns the mesh position in the local space from the current World matrix values.
  8721. * @returns a new Vector3.
  8722. */
  8723. getPositionExpressedInLocalSpace(): Vector3;
  8724. /**
  8725. * Translates the mesh along the passed Vector3 in its local space.
  8726. * @param vector3 the distance to translate in localspace
  8727. * @returns the TransformNode.
  8728. */
  8729. locallyTranslate(vector3: Vector3): TransformNode;
  8730. private static _lookAtVectorCache;
  8731. /**
  8732. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8733. * @param targetPoint the position (must be in same space as current mesh) to look at
  8734. * @param yawCor optional yaw (y-axis) correction in radians
  8735. * @param pitchCor optional pitch (x-axis) correction in radians
  8736. * @param rollCor optional roll (z-axis) correction in radians
  8737. * @param space the choosen space of the target
  8738. * @returns the TransformNode.
  8739. */
  8740. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8741. /**
  8742. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8743. * This Vector3 is expressed in the World space.
  8744. * @param localAxis axis to rotate
  8745. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8746. */
  8747. getDirection(localAxis: Vector3): Vector3;
  8748. /**
  8749. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8750. * localAxis is expressed in the mesh local space.
  8751. * result is computed in the Wordl space from the mesh World matrix.
  8752. * @param localAxis axis to rotate
  8753. * @param result the resulting transformnode
  8754. * @returns this TransformNode.
  8755. */
  8756. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8757. /**
  8758. * Sets this transform node rotation to the given local axis.
  8759. * @param localAxis the axis in local space
  8760. * @param yawCor optional yaw (y-axis) correction in radians
  8761. * @param pitchCor optional pitch (x-axis) correction in radians
  8762. * @param rollCor optional roll (z-axis) correction in radians
  8763. * @returns this TransformNode
  8764. */
  8765. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8766. /**
  8767. * Sets a new pivot point to the current node
  8768. * @param point defines the new pivot point to use
  8769. * @param space defines if the point is in world or local space (local by default)
  8770. * @returns the current TransformNode
  8771. */
  8772. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8773. /**
  8774. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8775. * @returns the pivot point
  8776. */
  8777. getPivotPoint(): Vector3;
  8778. /**
  8779. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8780. * @param result the vector3 to store the result
  8781. * @returns this TransformNode.
  8782. */
  8783. getPivotPointToRef(result: Vector3): TransformNode;
  8784. /**
  8785. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8786. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8787. */
  8788. getAbsolutePivotPoint(): Vector3;
  8789. /**
  8790. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8791. * @param result vector3 to store the result
  8792. * @returns this TransformNode.
  8793. */
  8794. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8795. /**
  8796. * Defines the passed node as the parent of the current node.
  8797. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8798. * @see https://doc.babylonjs.com/how_to/parenting
  8799. * @param node the node ot set as the parent
  8800. * @returns this TransformNode.
  8801. */
  8802. setParent(node: Nullable<Node>): TransformNode;
  8803. private _nonUniformScaling;
  8804. /**
  8805. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8806. */
  8807. readonly nonUniformScaling: boolean;
  8808. /** @hidden */
  8809. _updateNonUniformScalingState(value: boolean): boolean;
  8810. /**
  8811. * Attach the current TransformNode to another TransformNode associated with a bone
  8812. * @param bone Bone affecting the TransformNode
  8813. * @param affectedTransformNode TransformNode associated with the bone
  8814. * @returns this object
  8815. */
  8816. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8817. /**
  8818. * Detach the transform node if its associated with a bone
  8819. * @returns this object
  8820. */
  8821. detachFromBone(): TransformNode;
  8822. private static _rotationAxisCache;
  8823. /**
  8824. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8825. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8826. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8827. * The passed axis is also normalized.
  8828. * @param axis the axis to rotate around
  8829. * @param amount the amount to rotate in radians
  8830. * @param space Space to rotate in (Default: local)
  8831. * @returns the TransformNode.
  8832. */
  8833. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8834. /**
  8835. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8836. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8837. * The passed axis is also normalized. .
  8838. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8839. * @param point the point to rotate around
  8840. * @param axis the axis to rotate around
  8841. * @param amount the amount to rotate in radians
  8842. * @returns the TransformNode
  8843. */
  8844. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8845. /**
  8846. * Translates the mesh along the axis vector for the passed distance in the given space.
  8847. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8848. * @param axis the axis to translate in
  8849. * @param distance the distance to translate
  8850. * @param space Space to rotate in (Default: local)
  8851. * @returns the TransformNode.
  8852. */
  8853. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8854. /**
  8855. * Adds a rotation step to the mesh current rotation.
  8856. * x, y, z are Euler angles expressed in radians.
  8857. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8858. * This means this rotation is made in the mesh local space only.
  8859. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8860. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8861. * ```javascript
  8862. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8863. * ```
  8864. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8865. * 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.
  8866. * @param x Rotation to add
  8867. * @param y Rotation to add
  8868. * @param z Rotation to add
  8869. * @returns the TransformNode.
  8870. */
  8871. addRotation(x: number, y: number, z: number): TransformNode;
  8872. /**
  8873. * @hidden
  8874. */
  8875. protected _getEffectiveParent(): Nullable<Node>;
  8876. /**
  8877. * Computes the world matrix of the node
  8878. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8879. * @returns the world matrix
  8880. */
  8881. computeWorldMatrix(force?: boolean): Matrix;
  8882. protected _afterComputeWorldMatrix(): void;
  8883. /**
  8884. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8885. * @param func callback function to add
  8886. *
  8887. * @returns the TransformNode.
  8888. */
  8889. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8890. /**
  8891. * Removes a registered callback function.
  8892. * @param func callback function to remove
  8893. * @returns the TransformNode.
  8894. */
  8895. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8896. /**
  8897. * Gets the position of the current mesh in camera space
  8898. * @param camera defines the camera to use
  8899. * @returns a position
  8900. */
  8901. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8902. /**
  8903. * Returns the distance from the mesh to the active camera
  8904. * @param camera defines the camera to use
  8905. * @returns the distance
  8906. */
  8907. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8908. /**
  8909. * Clone the current transform node
  8910. * @param name Name of the new clone
  8911. * @param newParent New parent for the clone
  8912. * @param doNotCloneChildren Do not clone children hierarchy
  8913. * @returns the new transform node
  8914. */
  8915. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8916. /**
  8917. * Serializes the objects information.
  8918. * @param currentSerializationObject defines the object to serialize in
  8919. * @returns the serialized object
  8920. */
  8921. serialize(currentSerializationObject?: any): any;
  8922. /**
  8923. * Returns a new TransformNode object parsed from the source provided.
  8924. * @param parsedTransformNode is the source.
  8925. * @param scene the scne the object belongs to
  8926. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8927. * @returns a new TransformNode object parsed from the source provided.
  8928. */
  8929. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8930. /**
  8931. * Get all child-transformNodes of this node
  8932. * @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
  8933. * @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
  8934. * @returns an array of TransformNode
  8935. */
  8936. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8937. /**
  8938. * Releases resources associated with this transform node.
  8939. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8940. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8941. */
  8942. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8943. /**
  8944. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8945. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8946. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8947. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8948. * @returns the current mesh
  8949. */
  8950. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8951. }
  8952. }
  8953. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8954. /**
  8955. * Class used to override all child animations of a given target
  8956. */
  8957. export class AnimationPropertiesOverride {
  8958. /**
  8959. * Gets or sets a value indicating if animation blending must be used
  8960. */
  8961. enableBlending: boolean;
  8962. /**
  8963. * Gets or sets the blending speed to use when enableBlending is true
  8964. */
  8965. blendingSpeed: number;
  8966. /**
  8967. * Gets or sets the default loop mode to use
  8968. */
  8969. loopMode: number;
  8970. }
  8971. }
  8972. declare module "babylonjs/Bones/bone" {
  8973. import { Skeleton } from "babylonjs/Bones/skeleton";
  8974. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8975. import { Nullable } from "babylonjs/types";
  8976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8977. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8978. import { Node } from "babylonjs/node";
  8979. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8980. /**
  8981. * Class used to store bone information
  8982. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8983. */
  8984. export class Bone extends Node {
  8985. /**
  8986. * defines the bone name
  8987. */
  8988. name: string;
  8989. private static _tmpVecs;
  8990. private static _tmpQuat;
  8991. private static _tmpMats;
  8992. /**
  8993. * Gets the list of child bones
  8994. */
  8995. children: Bone[];
  8996. /** Gets the animations associated with this bone */
  8997. animations: import("babylonjs/Animations/animation").Animation[];
  8998. /**
  8999. * Gets or sets bone length
  9000. */
  9001. length: number;
  9002. /**
  9003. * @hidden Internal only
  9004. * Set this value to map this bone to a different index in the transform matrices
  9005. * Set this value to -1 to exclude the bone from the transform matrices
  9006. */
  9007. _index: Nullable<number>;
  9008. private _skeleton;
  9009. private _localMatrix;
  9010. private _restPose;
  9011. private _baseMatrix;
  9012. private _absoluteTransform;
  9013. private _invertedAbsoluteTransform;
  9014. private _parent;
  9015. private _scalingDeterminant;
  9016. private _worldTransform;
  9017. private _localScaling;
  9018. private _localRotation;
  9019. private _localPosition;
  9020. private _needToDecompose;
  9021. private _needToCompose;
  9022. /** @hidden */
  9023. _linkedTransformNode: Nullable<TransformNode>;
  9024. /** @hidden */
  9025. _waitingTransformNodeId: Nullable<string>;
  9026. /** @hidden */
  9027. /** @hidden */
  9028. _matrix: Matrix;
  9029. /**
  9030. * Create a new bone
  9031. * @param name defines the bone name
  9032. * @param skeleton defines the parent skeleton
  9033. * @param parentBone defines the parent (can be null if the bone is the root)
  9034. * @param localMatrix defines the local matrix
  9035. * @param restPose defines the rest pose matrix
  9036. * @param baseMatrix defines the base matrix
  9037. * @param index defines index of the bone in the hiearchy
  9038. */
  9039. constructor(
  9040. /**
  9041. * defines the bone name
  9042. */
  9043. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9044. /**
  9045. * Gets the current object class name.
  9046. * @return the class name
  9047. */
  9048. getClassName(): string;
  9049. /**
  9050. * Gets the parent skeleton
  9051. * @returns a skeleton
  9052. */
  9053. getSkeleton(): Skeleton;
  9054. /**
  9055. * Gets parent bone
  9056. * @returns a bone or null if the bone is the root of the bone hierarchy
  9057. */
  9058. getParent(): Nullable<Bone>;
  9059. /**
  9060. * Returns an array containing the root bones
  9061. * @returns an array containing the root bones
  9062. */
  9063. getChildren(): Array<Bone>;
  9064. /**
  9065. * Sets the parent bone
  9066. * @param parent defines the parent (can be null if the bone is the root)
  9067. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9068. */
  9069. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9070. /**
  9071. * Gets the local matrix
  9072. * @returns a matrix
  9073. */
  9074. getLocalMatrix(): Matrix;
  9075. /**
  9076. * Gets the base matrix (initial matrix which remains unchanged)
  9077. * @returns a matrix
  9078. */
  9079. getBaseMatrix(): Matrix;
  9080. /**
  9081. * Gets the rest pose matrix
  9082. * @returns a matrix
  9083. */
  9084. getRestPose(): Matrix;
  9085. /**
  9086. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9087. */
  9088. getWorldMatrix(): Matrix;
  9089. /**
  9090. * Sets the local matrix to rest pose matrix
  9091. */
  9092. returnToRest(): void;
  9093. /**
  9094. * Gets the inverse of the absolute transform matrix.
  9095. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9096. * @returns a matrix
  9097. */
  9098. getInvertedAbsoluteTransform(): Matrix;
  9099. /**
  9100. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9101. * @returns a matrix
  9102. */
  9103. getAbsoluteTransform(): Matrix;
  9104. /**
  9105. * Links with the given transform node.
  9106. * The local matrix of this bone is copied from the transform node every frame.
  9107. * @param transformNode defines the transform node to link to
  9108. */
  9109. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9110. /** Gets or sets current position (in local space) */
  9111. position: Vector3;
  9112. /** Gets or sets current rotation (in local space) */
  9113. rotation: Vector3;
  9114. /** Gets or sets current rotation quaternion (in local space) */
  9115. rotationQuaternion: Quaternion;
  9116. /** Gets or sets current scaling (in local space) */
  9117. scaling: Vector3;
  9118. /**
  9119. * Gets the animation properties override
  9120. */
  9121. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9122. private _decompose;
  9123. private _compose;
  9124. /**
  9125. * Update the base and local matrices
  9126. * @param matrix defines the new base or local matrix
  9127. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9128. * @param updateLocalMatrix defines if the local matrix should be updated
  9129. */
  9130. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9131. /** @hidden */
  9132. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9133. /**
  9134. * Flag the bone as dirty (Forcing it to update everything)
  9135. */
  9136. markAsDirty(): void;
  9137. /** @hidden */
  9138. _markAsDirtyAndCompose(): void;
  9139. private _markAsDirtyAndDecompose;
  9140. /**
  9141. * Translate the bone in local or world space
  9142. * @param vec The amount to translate the bone
  9143. * @param space The space that the translation is in
  9144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9145. */
  9146. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9147. /**
  9148. * Set the postion of the bone in local or world space
  9149. * @param position The position to set the bone
  9150. * @param space The space that the position is in
  9151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9152. */
  9153. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9154. /**
  9155. * Set the absolute position of the bone (world space)
  9156. * @param position The position to set the bone
  9157. * @param mesh The mesh that this bone is attached to
  9158. */
  9159. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9160. /**
  9161. * Scale the bone on the x, y and z axes (in local space)
  9162. * @param x The amount to scale the bone on the x axis
  9163. * @param y The amount to scale the bone on the y axis
  9164. * @param z The amount to scale the bone on the z axis
  9165. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9166. */
  9167. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9168. /**
  9169. * Set the bone scaling in local space
  9170. * @param scale defines the scaling vector
  9171. */
  9172. setScale(scale: Vector3): void;
  9173. /**
  9174. * Gets the current scaling in local space
  9175. * @returns the current scaling vector
  9176. */
  9177. getScale(): Vector3;
  9178. /**
  9179. * Gets the current scaling in local space and stores it in a target vector
  9180. * @param result defines the target vector
  9181. */
  9182. getScaleToRef(result: Vector3): void;
  9183. /**
  9184. * Set the yaw, pitch, and roll of the bone in local or world space
  9185. * @param yaw The rotation of the bone on the y axis
  9186. * @param pitch The rotation of the bone on the x axis
  9187. * @param roll The rotation of the bone on the z axis
  9188. * @param space The space that the axes of rotation are in
  9189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9190. */
  9191. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9192. /**
  9193. * Add a rotation to the bone on an axis in local or world space
  9194. * @param axis The axis to rotate the bone on
  9195. * @param amount The amount to rotate the bone
  9196. * @param space The space that the axis is in
  9197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9198. */
  9199. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9200. /**
  9201. * Set the rotation of the bone to a particular axis angle in local or world space
  9202. * @param axis The axis to rotate the bone on
  9203. * @param angle The angle that the bone should be rotated to
  9204. * @param space The space that the axis is in
  9205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9206. */
  9207. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9208. /**
  9209. * Set the euler rotation of the bone in local of world space
  9210. * @param rotation The euler rotation that the bone should be set to
  9211. * @param space The space that the rotation is in
  9212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9213. */
  9214. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9215. /**
  9216. * Set the quaternion rotation of the bone in local of world space
  9217. * @param quat The quaternion rotation that the bone should be set to
  9218. * @param space The space that the rotation is in
  9219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9220. */
  9221. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9222. /**
  9223. * Set the rotation matrix of the bone in local of world space
  9224. * @param rotMat The rotation matrix that the bone should be set to
  9225. * @param space The space that the rotation is in
  9226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9227. */
  9228. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9229. private _rotateWithMatrix;
  9230. private _getNegativeRotationToRef;
  9231. /**
  9232. * Get the position of the bone in local or world space
  9233. * @param space The space that the returned position is in
  9234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9235. * @returns The position of the bone
  9236. */
  9237. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9238. /**
  9239. * Copy the position of the bone to a vector3 in local or world space
  9240. * @param space The space that the returned position is in
  9241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9242. * @param result The vector3 to copy the position to
  9243. */
  9244. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9245. /**
  9246. * Get the absolute position of the bone (world space)
  9247. * @param mesh The mesh that this bone is attached to
  9248. * @returns The absolute position of the bone
  9249. */
  9250. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9251. /**
  9252. * Copy the absolute position of the bone (world space) to the result param
  9253. * @param mesh The mesh that this bone is attached to
  9254. * @param result The vector3 to copy the absolute position to
  9255. */
  9256. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9257. /**
  9258. * Compute the absolute transforms of this bone and its children
  9259. */
  9260. computeAbsoluteTransforms(): void;
  9261. /**
  9262. * Get the world direction from an axis that is in the local space of the bone
  9263. * @param localAxis The local direction that is used to compute the world direction
  9264. * @param mesh The mesh that this bone is attached to
  9265. * @returns The world direction
  9266. */
  9267. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9268. /**
  9269. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9270. * @param localAxis The local direction that is used to compute the world direction
  9271. * @param mesh The mesh that this bone is attached to
  9272. * @param result The vector3 that the world direction will be copied to
  9273. */
  9274. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9275. /**
  9276. * Get the euler rotation of the bone in local or world space
  9277. * @param space The space that the rotation should be in
  9278. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9279. * @returns The euler rotation
  9280. */
  9281. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9282. /**
  9283. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9284. * @param space The space that the rotation should be in
  9285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9286. * @param result The vector3 that the rotation should be copied to
  9287. */
  9288. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9289. /**
  9290. * Get the quaternion rotation of the bone in either local or world space
  9291. * @param space The space that the rotation should be in
  9292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9293. * @returns The quaternion rotation
  9294. */
  9295. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9296. /**
  9297. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9298. * @param space The space that the rotation should be in
  9299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9300. * @param result The quaternion that the rotation should be copied to
  9301. */
  9302. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9303. /**
  9304. * Get the rotation matrix of the bone in local or world space
  9305. * @param space The space that the rotation should be in
  9306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9307. * @returns The rotation matrix
  9308. */
  9309. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9310. /**
  9311. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9312. * @param space The space that the rotation should be in
  9313. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9314. * @param result The quaternion that the rotation should be copied to
  9315. */
  9316. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9317. /**
  9318. * Get the world position of a point that is in the local space of the bone
  9319. * @param position The local position
  9320. * @param mesh The mesh that this bone is attached to
  9321. * @returns The world position
  9322. */
  9323. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9324. /**
  9325. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9326. * @param position The local position
  9327. * @param mesh The mesh that this bone is attached to
  9328. * @param result The vector3 that the world position should be copied to
  9329. */
  9330. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9331. /**
  9332. * Get the local position of a point that is in world space
  9333. * @param position The world position
  9334. * @param mesh The mesh that this bone is attached to
  9335. * @returns The local position
  9336. */
  9337. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9338. /**
  9339. * Get the local position of a point that is in world space and copy it to the result param
  9340. * @param position The world position
  9341. * @param mesh The mesh that this bone is attached to
  9342. * @param result The vector3 that the local position should be copied to
  9343. */
  9344. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9345. }
  9346. }
  9347. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  9348. import { Nullable } from "babylonjs/types";
  9349. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  9350. import { Scene } from "babylonjs/scene";
  9351. module "babylonjs/Engines/engine" {
  9352. interface Engine {
  9353. /**
  9354. * Creates a raw texture
  9355. * @param data defines the data to store in the texture
  9356. * @param width defines the width of the texture
  9357. * @param height defines the height of the texture
  9358. * @param format defines the format of the data
  9359. * @param generateMipMaps defines if the engine should generate the mip levels
  9360. * @param invertY defines if data must be stored with Y axis inverted
  9361. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9362. * @param compression defines the compression used (null by default)
  9363. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9364. * @returns the raw texture inside an InternalTexture
  9365. */
  9366. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9367. /**
  9368. * Update a raw texture
  9369. * @param texture defines the texture to update
  9370. * @param data defines the data to store in the texture
  9371. * @param format defines the format of the data
  9372. * @param invertY defines if data must be stored with Y axis inverted
  9373. */
  9374. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9375. /**
  9376. * Update a raw texture
  9377. * @param texture defines the texture to update
  9378. * @param data defines the data to store in the texture
  9379. * @param format defines the format of the data
  9380. * @param invertY defines if data must be stored with Y axis inverted
  9381. * @param compression defines the compression used (null by default)
  9382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9383. */
  9384. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9385. /**
  9386. * Creates a new raw cube texture
  9387. * @param data defines the array of data to use to create each face
  9388. * @param size defines the size of the textures
  9389. * @param format defines the format of the data
  9390. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9391. * @param generateMipMaps defines if the engine should generate the mip levels
  9392. * @param invertY defines if data must be stored with Y axis inverted
  9393. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9394. * @param compression defines the compression used (null by default)
  9395. * @returns the cube texture as an InternalTexture
  9396. */
  9397. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9398. /**
  9399. * Update a raw cube texture
  9400. * @param texture defines the texture to udpdate
  9401. * @param data defines the data to store
  9402. * @param format defines the data format
  9403. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9404. * @param invertY defines if data must be stored with Y axis inverted
  9405. */
  9406. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9407. /**
  9408. * Update a raw cube texture
  9409. * @param texture defines the texture to udpdate
  9410. * @param data defines the data to store
  9411. * @param format defines the data format
  9412. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9413. * @param invertY defines if data must be stored with Y axis inverted
  9414. * @param compression defines the compression used (null by default)
  9415. */
  9416. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9417. /**
  9418. * Update a raw cube texture
  9419. * @param texture defines the texture to udpdate
  9420. * @param data defines the data to store
  9421. * @param format defines the data format
  9422. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9423. * @param invertY defines if data must be stored with Y axis inverted
  9424. * @param compression defines the compression used (null by default)
  9425. * @param level defines which level of the texture to update
  9426. */
  9427. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9428. /**
  9429. * Creates a new raw cube texture from a specified url
  9430. * @param url defines the url where the data is located
  9431. * @param scene defines the current scene
  9432. * @param size defines the size of the textures
  9433. * @param format defines the format of the data
  9434. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9435. * @param noMipmap defines if the engine should avoid generating the mip levels
  9436. * @param callback defines a callback used to extract texture data from loaded data
  9437. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9438. * @param onLoad defines a callback called when texture is loaded
  9439. * @param onError defines a callback called if there is an error
  9440. * @returns the cube texture as an InternalTexture
  9441. */
  9442. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  9443. /**
  9444. * Creates a new raw cube texture from a specified url
  9445. * @param url defines the url where the data is located
  9446. * @param scene defines the current scene
  9447. * @param size defines the size of the textures
  9448. * @param format defines the format of the data
  9449. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9450. * @param noMipmap defines if the engine should avoid generating the mip levels
  9451. * @param callback defines a callback used to extract texture data from loaded data
  9452. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9453. * @param onLoad defines a callback called when texture is loaded
  9454. * @param onError defines a callback called if there is an error
  9455. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9456. * @param invertY defines if data must be stored with Y axis inverted
  9457. * @returns the cube texture as an InternalTexture
  9458. */
  9459. 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;
  9460. /**
  9461. * Creates a new raw 3D texture
  9462. * @param data defines the data used to create the texture
  9463. * @param width defines the width of the texture
  9464. * @param height defines the height of the texture
  9465. * @param depth defines the depth of the texture
  9466. * @param format defines the format of the texture
  9467. * @param generateMipMaps defines if the engine must generate mip levels
  9468. * @param invertY defines if data must be stored with Y axis inverted
  9469. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9470. * @param compression defines the compressed used (can be null)
  9471. * @param textureType defines the compressed used (can be null)
  9472. * @returns a new raw 3D texture (stored in an InternalTexture)
  9473. */
  9474. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9475. /**
  9476. * Update a raw 3D texture
  9477. * @param texture defines the texture to update
  9478. * @param data defines the data to store
  9479. * @param format defines the data format
  9480. * @param invertY defines if data must be stored with Y axis inverted
  9481. */
  9482. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9483. /**
  9484. * Update a raw 3D texture
  9485. * @param texture defines the texture to update
  9486. * @param data defines the data to store
  9487. * @param format defines the data format
  9488. * @param invertY defines if data must be stored with Y axis inverted
  9489. * @param compression defines the used compression (can be null)
  9490. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9491. */
  9492. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9493. }
  9494. }
  9495. }
  9496. declare module "babylonjs/Materials/Textures/rawTexture" {
  9497. import { Scene } from "babylonjs/scene";
  9498. import { Texture } from "babylonjs/Materials/Textures/texture";
  9499. import "babylonjs/Engines/Extensions/engine.rawTexture";
  9500. /**
  9501. * Raw texture can help creating a texture directly from an array of data.
  9502. * This can be super useful if you either get the data from an uncompressed source or
  9503. * if you wish to create your texture pixel by pixel.
  9504. */
  9505. export class RawTexture extends Texture {
  9506. /**
  9507. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9508. */
  9509. format: number;
  9510. private _engine;
  9511. /**
  9512. * Instantiates a new RawTexture.
  9513. * Raw texture can help creating a texture directly from an array of data.
  9514. * This can be super useful if you either get the data from an uncompressed source or
  9515. * if you wish to create your texture pixel by pixel.
  9516. * @param data define the array of data to use to create the texture
  9517. * @param width define the width of the texture
  9518. * @param height define the height of the texture
  9519. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9520. * @param scene define the scene the texture belongs to
  9521. * @param generateMipMaps define whether mip maps should be generated or not
  9522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9524. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9525. */
  9526. constructor(data: ArrayBufferView, width: number, height: number,
  9527. /**
  9528. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9529. */
  9530. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9531. /**
  9532. * Updates the texture underlying data.
  9533. * @param data Define the new data of the texture
  9534. */
  9535. update(data: ArrayBufferView): void;
  9536. /**
  9537. * Creates a luminance texture from some data.
  9538. * @param data Define the texture data
  9539. * @param width Define the width of the texture
  9540. * @param height Define the height of the texture
  9541. * @param scene Define the scene the texture belongs to
  9542. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9543. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9544. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9545. * @returns the luminance texture
  9546. */
  9547. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9548. /**
  9549. * Creates a luminance alpha texture from some data.
  9550. * @param data Define the texture data
  9551. * @param width Define the width of the texture
  9552. * @param height Define the height of the texture
  9553. * @param scene Define the scene the texture belongs to
  9554. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9555. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9556. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9557. * @returns the luminance alpha texture
  9558. */
  9559. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9560. /**
  9561. * Creates an alpha texture from some data.
  9562. * @param data Define the texture data
  9563. * @param width Define the width of the texture
  9564. * @param height Define the height of the texture
  9565. * @param scene Define the scene the texture belongs to
  9566. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9567. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9568. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9569. * @returns the alpha texture
  9570. */
  9571. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9572. /**
  9573. * Creates a RGB texture from some data.
  9574. * @param data Define the texture data
  9575. * @param width Define the width of the texture
  9576. * @param height Define the height of the texture
  9577. * @param scene Define the scene the texture belongs to
  9578. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9579. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9580. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9581. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9582. * @returns the RGB alpha texture
  9583. */
  9584. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9585. /**
  9586. * Creates a RGBA texture from some data.
  9587. * @param data Define the texture data
  9588. * @param width Define the width of the texture
  9589. * @param height Define the height of the texture
  9590. * @param scene Define the scene the texture belongs to
  9591. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9592. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9593. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9594. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9595. * @returns the RGBA texture
  9596. */
  9597. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9598. /**
  9599. * Creates a R texture from some data.
  9600. * @param data Define the texture data
  9601. * @param width Define the width of the texture
  9602. * @param height Define the height of the texture
  9603. * @param scene Define the scene the texture belongs to
  9604. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9605. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9606. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9607. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9608. * @returns the R texture
  9609. */
  9610. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9611. }
  9612. }
  9613. declare module "babylonjs/Animations/runtimeAnimation" {
  9614. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  9615. import { Animatable } from "babylonjs/Animations/animatable";
  9616. import { Scene } from "babylonjs/scene";
  9617. /**
  9618. * Defines a runtime animation
  9619. */
  9620. export class RuntimeAnimation {
  9621. private _events;
  9622. /**
  9623. * The current frame of the runtime animation
  9624. */
  9625. private _currentFrame;
  9626. /**
  9627. * The animation used by the runtime animation
  9628. */
  9629. private _animation;
  9630. /**
  9631. * The target of the runtime animation
  9632. */
  9633. private _target;
  9634. /**
  9635. * The initiating animatable
  9636. */
  9637. private _host;
  9638. /**
  9639. * The original value of the runtime animation
  9640. */
  9641. private _originalValue;
  9642. /**
  9643. * The original blend value of the runtime animation
  9644. */
  9645. private _originalBlendValue;
  9646. /**
  9647. * The offsets cache of the runtime animation
  9648. */
  9649. private _offsetsCache;
  9650. /**
  9651. * The high limits cache of the runtime animation
  9652. */
  9653. private _highLimitsCache;
  9654. /**
  9655. * Specifies if the runtime animation has been stopped
  9656. */
  9657. private _stopped;
  9658. /**
  9659. * The blending factor of the runtime animation
  9660. */
  9661. private _blendingFactor;
  9662. /**
  9663. * The BabylonJS scene
  9664. */
  9665. private _scene;
  9666. /**
  9667. * The current value of the runtime animation
  9668. */
  9669. private _currentValue;
  9670. /** @hidden */
  9671. _animationState: _IAnimationState;
  9672. /**
  9673. * The active target of the runtime animation
  9674. */
  9675. private _activeTargets;
  9676. private _currentActiveTarget;
  9677. private _directTarget;
  9678. /**
  9679. * The target path of the runtime animation
  9680. */
  9681. private _targetPath;
  9682. /**
  9683. * The weight of the runtime animation
  9684. */
  9685. private _weight;
  9686. /**
  9687. * The ratio offset of the runtime animation
  9688. */
  9689. private _ratioOffset;
  9690. /**
  9691. * The previous delay of the runtime animation
  9692. */
  9693. private _previousDelay;
  9694. /**
  9695. * The previous ratio of the runtime animation
  9696. */
  9697. private _previousRatio;
  9698. private _enableBlending;
  9699. private _keys;
  9700. private _minFrame;
  9701. private _maxFrame;
  9702. private _minValue;
  9703. private _maxValue;
  9704. private _targetIsArray;
  9705. /**
  9706. * Gets the current frame of the runtime animation
  9707. */
  9708. readonly currentFrame: number;
  9709. /**
  9710. * Gets the weight of the runtime animation
  9711. */
  9712. readonly weight: number;
  9713. /**
  9714. * Gets the current value of the runtime animation
  9715. */
  9716. readonly currentValue: any;
  9717. /**
  9718. * Gets the target path of the runtime animation
  9719. */
  9720. readonly targetPath: string;
  9721. /**
  9722. * Gets the actual target of the runtime animation
  9723. */
  9724. readonly target: any;
  9725. /** @hidden */
  9726. _onLoop: () => void;
  9727. /**
  9728. * Create a new RuntimeAnimation object
  9729. * @param target defines the target of the animation
  9730. * @param animation defines the source animation object
  9731. * @param scene defines the hosting scene
  9732. * @param host defines the initiating Animatable
  9733. */
  9734. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9735. private _preparePath;
  9736. /**
  9737. * Gets the animation from the runtime animation
  9738. */
  9739. readonly animation: Animation;
  9740. /**
  9741. * Resets the runtime animation to the beginning
  9742. * @param restoreOriginal defines whether to restore the target property to the original value
  9743. */
  9744. reset(restoreOriginal?: boolean): void;
  9745. /**
  9746. * Specifies if the runtime animation is stopped
  9747. * @returns Boolean specifying if the runtime animation is stopped
  9748. */
  9749. isStopped(): boolean;
  9750. /**
  9751. * Disposes of the runtime animation
  9752. */
  9753. dispose(): void;
  9754. /**
  9755. * Apply the interpolated value to the target
  9756. * @param currentValue defines the value computed by the animation
  9757. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9758. */
  9759. setValue(currentValue: any, weight: number): void;
  9760. private _getOriginalValues;
  9761. private _setValue;
  9762. /**
  9763. * Gets the loop pmode of the runtime animation
  9764. * @returns Loop Mode
  9765. */
  9766. private _getCorrectLoopMode;
  9767. /**
  9768. * Move the current animation to a given frame
  9769. * @param frame defines the frame to move to
  9770. */
  9771. goToFrame(frame: number): void;
  9772. /**
  9773. * @hidden Internal use only
  9774. */
  9775. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9776. /**
  9777. * Execute the current animation
  9778. * @param delay defines the delay to add to the current frame
  9779. * @param from defines the lower bound of the animation range
  9780. * @param to defines the upper bound of the animation range
  9781. * @param loop defines if the current animation must loop
  9782. * @param speedRatio defines the current speed ratio
  9783. * @param weight defines the weight of the animation (default is -1 so no weight)
  9784. * @param onLoop optional callback called when animation loops
  9785. * @returns a boolean indicating if the animation is running
  9786. */
  9787. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9788. }
  9789. }
  9790. declare module "babylonjs/Animations/animatable" {
  9791. import { Animation } from "babylonjs/Animations/animation";
  9792. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  9793. import { Nullable } from "babylonjs/types";
  9794. import { Observable } from "babylonjs/Misc/observable";
  9795. import { Scene } from "babylonjs/scene";
  9796. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  9797. import { Node } from "babylonjs/node";
  9798. /**
  9799. * Class used to store an actual running animation
  9800. */
  9801. export class Animatable {
  9802. /** defines the target object */
  9803. target: any;
  9804. /** defines the starting frame number (default is 0) */
  9805. fromFrame: number;
  9806. /** defines the ending frame number (default is 100) */
  9807. toFrame: number;
  9808. /** defines if the animation must loop (default is false) */
  9809. loopAnimation: boolean;
  9810. /** defines a callback to call when animation ends if it is not looping */
  9811. onAnimationEnd?: (() => void) | null | undefined;
  9812. /** defines a callback to call when animation loops */
  9813. onAnimationLoop?: (() => void) | null | undefined;
  9814. private _localDelayOffset;
  9815. private _pausedDelay;
  9816. private _runtimeAnimations;
  9817. private _paused;
  9818. private _scene;
  9819. private _speedRatio;
  9820. private _weight;
  9821. private _syncRoot;
  9822. /**
  9823. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9824. * This will only apply for non looping animation (default is true)
  9825. */
  9826. disposeOnEnd: boolean;
  9827. /**
  9828. * Gets a boolean indicating if the animation has started
  9829. */
  9830. animationStarted: boolean;
  9831. /**
  9832. * Observer raised when the animation ends
  9833. */
  9834. onAnimationEndObservable: Observable<Animatable>;
  9835. /**
  9836. * Observer raised when the animation loops
  9837. */
  9838. onAnimationLoopObservable: Observable<Animatable>;
  9839. /**
  9840. * Gets the root Animatable used to synchronize and normalize animations
  9841. */
  9842. readonly syncRoot: Nullable<Animatable>;
  9843. /**
  9844. * Gets the current frame of the first RuntimeAnimation
  9845. * Used to synchronize Animatables
  9846. */
  9847. readonly masterFrame: number;
  9848. /**
  9849. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9850. */
  9851. weight: number;
  9852. /**
  9853. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9854. */
  9855. speedRatio: number;
  9856. /**
  9857. * Creates a new Animatable
  9858. * @param scene defines the hosting scene
  9859. * @param target defines the target object
  9860. * @param fromFrame defines the starting frame number (default is 0)
  9861. * @param toFrame defines the ending frame number (default is 100)
  9862. * @param loopAnimation defines if the animation must loop (default is false)
  9863. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9864. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9865. * @param animations defines a group of animation to add to the new Animatable
  9866. * @param onAnimationLoop defines a callback to call when animation loops
  9867. */
  9868. constructor(scene: Scene,
  9869. /** defines the target object */
  9870. target: any,
  9871. /** defines the starting frame number (default is 0) */
  9872. fromFrame?: number,
  9873. /** defines the ending frame number (default is 100) */
  9874. toFrame?: number,
  9875. /** defines if the animation must loop (default is false) */
  9876. loopAnimation?: boolean, speedRatio?: number,
  9877. /** defines a callback to call when animation ends if it is not looping */
  9878. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9879. /** defines a callback to call when animation loops */
  9880. onAnimationLoop?: (() => void) | null | undefined);
  9881. /**
  9882. * Synchronize and normalize current Animatable with a source Animatable
  9883. * This is useful when using animation weights and when animations are not of the same length
  9884. * @param root defines the root Animatable to synchronize with
  9885. * @returns the current Animatable
  9886. */
  9887. syncWith(root: Animatable): Animatable;
  9888. /**
  9889. * Gets the list of runtime animations
  9890. * @returns an array of RuntimeAnimation
  9891. */
  9892. getAnimations(): RuntimeAnimation[];
  9893. /**
  9894. * Adds more animations to the current animatable
  9895. * @param target defines the target of the animations
  9896. * @param animations defines the new animations to add
  9897. */
  9898. appendAnimations(target: any, animations: Animation[]): void;
  9899. /**
  9900. * Gets the source animation for a specific property
  9901. * @param property defines the propertyu to look for
  9902. * @returns null or the source animation for the given property
  9903. */
  9904. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9905. /**
  9906. * Gets the runtime animation for a specific property
  9907. * @param property defines the propertyu to look for
  9908. * @returns null or the runtime animation for the given property
  9909. */
  9910. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9911. /**
  9912. * Resets the animatable to its original state
  9913. */
  9914. reset(): void;
  9915. /**
  9916. * Allows the animatable to blend with current running animations
  9917. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9918. * @param blendingSpeed defines the blending speed to use
  9919. */
  9920. enableBlending(blendingSpeed: number): void;
  9921. /**
  9922. * Disable animation blending
  9923. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9924. */
  9925. disableBlending(): void;
  9926. /**
  9927. * Jump directly to a given frame
  9928. * @param frame defines the frame to jump to
  9929. */
  9930. goToFrame(frame: number): void;
  9931. /**
  9932. * Pause the animation
  9933. */
  9934. pause(): void;
  9935. /**
  9936. * Restart the animation
  9937. */
  9938. restart(): void;
  9939. private _raiseOnAnimationEnd;
  9940. /**
  9941. * Stop and delete the current animation
  9942. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9943. * @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)
  9944. */
  9945. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9946. /**
  9947. * Wait asynchronously for the animation to end
  9948. * @returns a promise which will be fullfilled when the animation ends
  9949. */
  9950. waitAsync(): Promise<Animatable>;
  9951. /** @hidden */
  9952. _animate(delay: number): boolean;
  9953. }
  9954. module "babylonjs/scene" {
  9955. interface Scene {
  9956. /** @hidden */
  9957. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9958. /** @hidden */
  9959. _processLateAnimationBindingsForMatrices(holder: {
  9960. totalWeight: number;
  9961. animations: RuntimeAnimation[];
  9962. originalValue: Matrix;
  9963. }): any;
  9964. /** @hidden */
  9965. _processLateAnimationBindingsForQuaternions(holder: {
  9966. totalWeight: number;
  9967. animations: RuntimeAnimation[];
  9968. originalValue: Quaternion;
  9969. }, refQuaternion: Quaternion): Quaternion;
  9970. /** @hidden */
  9971. _processLateAnimationBindings(): void;
  9972. /**
  9973. * Will start the animation sequence of a given target
  9974. * @param target defines the target
  9975. * @param from defines from which frame should animation start
  9976. * @param to defines until which frame should animation run.
  9977. * @param weight defines the weight to apply to the animation (1.0 by default)
  9978. * @param loop defines if the animation loops
  9979. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9980. * @param onAnimationEnd defines the function to be executed when the animation ends
  9981. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9982. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9983. * @param onAnimationLoop defines the callback to call when an animation loops
  9984. * @returns the animatable object created for this animation
  9985. */
  9986. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9987. /**
  9988. * Will start the animation sequence of a given target
  9989. * @param target defines the target
  9990. * @param from defines from which frame should animation start
  9991. * @param to defines until which frame should animation run.
  9992. * @param loop defines if the animation loops
  9993. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9994. * @param onAnimationEnd defines the function to be executed when the animation ends
  9995. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9996. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9997. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9998. * @param onAnimationLoop defines the callback to call when an animation loops
  9999. * @returns the animatable object created for this animation
  10000. */
  10001. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  10002. /**
  10003. * Will start the animation sequence of a given target and its hierarchy
  10004. * @param target defines the target
  10005. * @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.
  10006. * @param from defines from which frame should animation start
  10007. * @param to defines until which frame should animation run.
  10008. * @param loop defines if the animation loops
  10009. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  10010. * @param onAnimationEnd defines the function to be executed when the animation ends
  10011. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  10012. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10013. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  10014. * @param onAnimationLoop defines the callback to call when an animation loops
  10015. * @returns the list of created animatables
  10016. */
  10017. 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[];
  10018. /**
  10019. * Begin a new animation on a given node
  10020. * @param target defines the target where the animation will take place
  10021. * @param animations defines the list of animations to start
  10022. * @param from defines the initial value
  10023. * @param to defines the final value
  10024. * @param loop defines if you want animation to loop (off by default)
  10025. * @param speedRatio defines the speed ratio to apply to all animations
  10026. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10027. * @param onAnimationLoop defines the callback to call when an animation loops
  10028. * @returns the list of created animatables
  10029. */
  10030. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  10031. /**
  10032. * Begin a new animation on a given node and its hierarchy
  10033. * @param target defines the root node where the animation will take place
  10034. * @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.
  10035. * @param animations defines the list of animations to start
  10036. * @param from defines the initial value
  10037. * @param to defines the final value
  10038. * @param loop defines if you want animation to loop (off by default)
  10039. * @param speedRatio defines the speed ratio to apply to all animations
  10040. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10041. * @param onAnimationLoop defines the callback to call when an animation loops
  10042. * @returns the list of animatables created for all nodes
  10043. */
  10044. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  10045. /**
  10046. * Gets the animatable associated with a specific target
  10047. * @param target defines the target of the animatable
  10048. * @returns the required animatable if found
  10049. */
  10050. getAnimatableByTarget(target: any): Nullable<Animatable>;
  10051. /**
  10052. * Gets all animatables associated with a given target
  10053. * @param target defines the target to look animatables for
  10054. * @returns an array of Animatables
  10055. */
  10056. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  10057. /**
  10058. * Stops and removes all animations that have been applied to the scene
  10059. */
  10060. stopAllAnimations(): void;
  10061. }
  10062. }
  10063. module "babylonjs/Bones/bone" {
  10064. interface Bone {
  10065. /**
  10066. * Copy an animation range from another bone
  10067. * @param source defines the source bone
  10068. * @param rangeName defines the range name to copy
  10069. * @param frameOffset defines the frame offset
  10070. * @param rescaleAsRequired defines if rescaling must be applied if required
  10071. * @param skelDimensionsRatio defines the scaling ratio
  10072. * @returns true if operation was successful
  10073. */
  10074. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  10075. }
  10076. }
  10077. }
  10078. declare module "babylonjs/Bones/skeleton" {
  10079. import { Bone } from "babylonjs/Bones/bone";
  10080. import { IAnimatable } from "babylonjs/Misc/tools";
  10081. import { Observable } from "babylonjs/Misc/observable";
  10082. import { Vector3, Matrix } from "babylonjs/Maths/math";
  10083. import { Scene } from "babylonjs/scene";
  10084. import { Nullable } from "babylonjs/types";
  10085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10086. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  10087. import { Animatable } from "babylonjs/Animations/animatable";
  10088. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10089. import { Animation } from "babylonjs/Animations/animation";
  10090. import { AnimationRange } from "babylonjs/Animations/animationRange";
  10091. import { IInspectable } from "babylonjs/Misc/iInspectable";
  10092. /**
  10093. * Class used to handle skinning animations
  10094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  10095. */
  10096. export class Skeleton implements IAnimatable {
  10097. /** defines the skeleton name */
  10098. name: string;
  10099. /** defines the skeleton Id */
  10100. id: string;
  10101. /**
  10102. * Defines the list of child bones
  10103. */
  10104. bones: Bone[];
  10105. /**
  10106. * Defines an estimate of the dimension of the skeleton at rest
  10107. */
  10108. dimensionsAtRest: Vector3;
  10109. /**
  10110. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  10111. */
  10112. needInitialSkinMatrix: boolean;
  10113. /**
  10114. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  10115. */
  10116. overrideMesh: Nullable<AbstractMesh>;
  10117. /**
  10118. * Gets the list of animations attached to this skeleton
  10119. */
  10120. animations: Array<Animation>;
  10121. private _scene;
  10122. private _isDirty;
  10123. private _transformMatrices;
  10124. private _transformMatrixTexture;
  10125. private _meshesWithPoseMatrix;
  10126. private _animatables;
  10127. private _identity;
  10128. private _synchronizedWithMesh;
  10129. private _ranges;
  10130. private _lastAbsoluteTransformsUpdateId;
  10131. private _canUseTextureForBones;
  10132. private _uniqueId;
  10133. /** @hidden */
  10134. _numBonesWithLinkedTransformNode: number;
  10135. /** @hidden */
  10136. _hasWaitingData: Nullable<boolean>;
  10137. /**
  10138. * Specifies if the skeleton should be serialized
  10139. */
  10140. doNotSerialize: boolean;
  10141. private _useTextureToStoreBoneMatrices;
  10142. /**
  10143. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10144. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  10145. */
  10146. useTextureToStoreBoneMatrices: boolean;
  10147. private _animationPropertiesOverride;
  10148. /**
  10149. * Gets or sets the animation properties override
  10150. */
  10151. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10152. /**
  10153. * List of inspectable custom properties (used by the Inspector)
  10154. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10155. */
  10156. inspectableCustomProperties: IInspectable[];
  10157. /**
  10158. * An observable triggered before computing the skeleton's matrices
  10159. */
  10160. onBeforeComputeObservable: Observable<Skeleton>;
  10161. /**
  10162. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10163. */
  10164. readonly isUsingTextureForMatrices: boolean;
  10165. /**
  10166. * Gets the unique ID of this skeleton
  10167. */
  10168. readonly uniqueId: number;
  10169. /**
  10170. * Creates a new skeleton
  10171. * @param name defines the skeleton name
  10172. * @param id defines the skeleton Id
  10173. * @param scene defines the hosting scene
  10174. */
  10175. constructor(
  10176. /** defines the skeleton name */
  10177. name: string,
  10178. /** defines the skeleton Id */
  10179. id: string, scene: Scene);
  10180. /**
  10181. * Gets the current object class name.
  10182. * @return the class name
  10183. */
  10184. getClassName(): string;
  10185. /**
  10186. * Returns an array containing the root bones
  10187. * @returns an array containing the root bones
  10188. */
  10189. getChildren(): Array<Bone>;
  10190. /**
  10191. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10192. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10193. * @returns a Float32Array containing matrices data
  10194. */
  10195. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10196. /**
  10197. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10198. * @returns a raw texture containing the data
  10199. */
  10200. getTransformMatrixTexture(): Nullable<RawTexture>;
  10201. /**
  10202. * Gets the current hosting scene
  10203. * @returns a scene object
  10204. */
  10205. getScene(): Scene;
  10206. /**
  10207. * Gets a string representing the current skeleton data
  10208. * @param fullDetails defines a boolean indicating if we want a verbose version
  10209. * @returns a string representing the current skeleton data
  10210. */
  10211. toString(fullDetails?: boolean): string;
  10212. /**
  10213. * Get bone's index searching by name
  10214. * @param name defines bone's name to search for
  10215. * @return the indice of the bone. Returns -1 if not found
  10216. */
  10217. getBoneIndexByName(name: string): number;
  10218. /**
  10219. * Creater a new animation range
  10220. * @param name defines the name of the range
  10221. * @param from defines the start key
  10222. * @param to defines the end key
  10223. */
  10224. createAnimationRange(name: string, from: number, to: number): void;
  10225. /**
  10226. * Delete a specific animation range
  10227. * @param name defines the name of the range
  10228. * @param deleteFrames defines if frames must be removed as well
  10229. */
  10230. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10231. /**
  10232. * Gets a specific animation range
  10233. * @param name defines the name of the range to look for
  10234. * @returns the requested animation range or null if not found
  10235. */
  10236. getAnimationRange(name: string): Nullable<AnimationRange>;
  10237. /**
  10238. * Gets the list of all animation ranges defined on this skeleton
  10239. * @returns an array
  10240. */
  10241. getAnimationRanges(): Nullable<AnimationRange>[];
  10242. /**
  10243. * Copy animation range from a source skeleton.
  10244. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10245. * @param source defines the source skeleton
  10246. * @param name defines the name of the range to copy
  10247. * @param rescaleAsRequired defines if rescaling must be applied if required
  10248. * @returns true if operation was successful
  10249. */
  10250. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10251. /**
  10252. * Forces the skeleton to go to rest pose
  10253. */
  10254. returnToRest(): void;
  10255. private _getHighestAnimationFrame;
  10256. /**
  10257. * Begin a specific animation range
  10258. * @param name defines the name of the range to start
  10259. * @param loop defines if looping must be turned on (false by default)
  10260. * @param speedRatio defines the speed ratio to apply (1 by default)
  10261. * @param onAnimationEnd defines a callback which will be called when animation will end
  10262. * @returns a new animatable
  10263. */
  10264. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10265. /** @hidden */
  10266. _markAsDirty(): void;
  10267. /** @hidden */
  10268. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10269. /** @hidden */
  10270. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10271. private _computeTransformMatrices;
  10272. /**
  10273. * Build all resources required to render a skeleton
  10274. */
  10275. prepare(): void;
  10276. /**
  10277. * Gets the list of animatables currently running for this skeleton
  10278. * @returns an array of animatables
  10279. */
  10280. getAnimatables(): IAnimatable[];
  10281. /**
  10282. * Clone the current skeleton
  10283. * @param name defines the name of the new skeleton
  10284. * @param id defines the id of the new skeleton
  10285. * @returns the new skeleton
  10286. */
  10287. clone(name: string, id: string): Skeleton;
  10288. /**
  10289. * Enable animation blending for this skeleton
  10290. * @param blendingSpeed defines the blending speed to apply
  10291. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10292. */
  10293. enableBlending(blendingSpeed?: number): void;
  10294. /**
  10295. * Releases all resources associated with the current skeleton
  10296. */
  10297. dispose(): void;
  10298. /**
  10299. * Serialize the skeleton in a JSON object
  10300. * @returns a JSON object
  10301. */
  10302. serialize(): any;
  10303. /**
  10304. * Creates a new skeleton from serialized data
  10305. * @param parsedSkeleton defines the serialized data
  10306. * @param scene defines the hosting scene
  10307. * @returns a new skeleton
  10308. */
  10309. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10310. /**
  10311. * Compute all node absolute transforms
  10312. * @param forceUpdate defines if computation must be done even if cache is up to date
  10313. */
  10314. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10315. /**
  10316. * Gets the root pose matrix
  10317. * @returns a matrix
  10318. */
  10319. getPoseMatrix(): Nullable<Matrix>;
  10320. /**
  10321. * Sorts bones per internal index
  10322. */
  10323. sortBones(): void;
  10324. private _sortBones;
  10325. }
  10326. }
  10327. declare module "babylonjs/Morph/morphTarget" {
  10328. import { IAnimatable } from "babylonjs/Misc/tools";
  10329. import { Observable } from "babylonjs/Misc/observable";
  10330. import { Nullable, FloatArray } from "babylonjs/types";
  10331. import { Scene } from "babylonjs/scene";
  10332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10333. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10334. /**
  10335. * Defines a target to use with MorphTargetManager
  10336. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10337. */
  10338. export class MorphTarget implements IAnimatable {
  10339. /** defines the name of the target */
  10340. name: string;
  10341. /**
  10342. * Gets or sets the list of animations
  10343. */
  10344. animations: import("babylonjs/Animations/animation").Animation[];
  10345. private _scene;
  10346. private _positions;
  10347. private _normals;
  10348. private _tangents;
  10349. private _uvs;
  10350. private _influence;
  10351. /**
  10352. * Observable raised when the influence changes
  10353. */
  10354. onInfluenceChanged: Observable<boolean>;
  10355. /** @hidden */
  10356. _onDataLayoutChanged: Observable<void>;
  10357. /**
  10358. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10359. */
  10360. influence: number;
  10361. /**
  10362. * Gets or sets the id of the morph Target
  10363. */
  10364. id: string;
  10365. private _animationPropertiesOverride;
  10366. /**
  10367. * Gets or sets the animation properties override
  10368. */
  10369. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10370. /**
  10371. * Creates a new MorphTarget
  10372. * @param name defines the name of the target
  10373. * @param influence defines the influence to use
  10374. * @param scene defines the scene the morphtarget belongs to
  10375. */
  10376. constructor(
  10377. /** defines the name of the target */
  10378. name: string, influence?: number, scene?: Nullable<Scene>);
  10379. /**
  10380. * Gets a boolean defining if the target contains position data
  10381. */
  10382. readonly hasPositions: boolean;
  10383. /**
  10384. * Gets a boolean defining if the target contains normal data
  10385. */
  10386. readonly hasNormals: boolean;
  10387. /**
  10388. * Gets a boolean defining if the target contains tangent data
  10389. */
  10390. readonly hasTangents: boolean;
  10391. /**
  10392. * Gets a boolean defining if the target contains texture coordinates data
  10393. */
  10394. readonly hasUVs: boolean;
  10395. /**
  10396. * Affects position data to this target
  10397. * @param data defines the position data to use
  10398. */
  10399. setPositions(data: Nullable<FloatArray>): void;
  10400. /**
  10401. * Gets the position data stored in this target
  10402. * @returns a FloatArray containing the position data (or null if not present)
  10403. */
  10404. getPositions(): Nullable<FloatArray>;
  10405. /**
  10406. * Affects normal data to this target
  10407. * @param data defines the normal data to use
  10408. */
  10409. setNormals(data: Nullable<FloatArray>): void;
  10410. /**
  10411. * Gets the normal data stored in this target
  10412. * @returns a FloatArray containing the normal data (or null if not present)
  10413. */
  10414. getNormals(): Nullable<FloatArray>;
  10415. /**
  10416. * Affects tangent data to this target
  10417. * @param data defines the tangent data to use
  10418. */
  10419. setTangents(data: Nullable<FloatArray>): void;
  10420. /**
  10421. * Gets the tangent data stored in this target
  10422. * @returns a FloatArray containing the tangent data (or null if not present)
  10423. */
  10424. getTangents(): Nullable<FloatArray>;
  10425. /**
  10426. * Affects texture coordinates data to this target
  10427. * @param data defines the texture coordinates data to use
  10428. */
  10429. setUVs(data: Nullable<FloatArray>): void;
  10430. /**
  10431. * Gets the texture coordinates data stored in this target
  10432. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10433. */
  10434. getUVs(): Nullable<FloatArray>;
  10435. /**
  10436. * Serializes the current target into a Serialization object
  10437. * @returns the serialized object
  10438. */
  10439. serialize(): any;
  10440. /**
  10441. * Returns the string "MorphTarget"
  10442. * @returns "MorphTarget"
  10443. */
  10444. getClassName(): string;
  10445. /**
  10446. * Creates a new target from serialized data
  10447. * @param serializationObject defines the serialized data to use
  10448. * @returns a new MorphTarget
  10449. */
  10450. static Parse(serializationObject: any): MorphTarget;
  10451. /**
  10452. * Creates a MorphTarget from mesh data
  10453. * @param mesh defines the source mesh
  10454. * @param name defines the name to use for the new target
  10455. * @param influence defines the influence to attach to the target
  10456. * @returns a new MorphTarget
  10457. */
  10458. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10459. }
  10460. }
  10461. declare module "babylonjs/Morph/morphTargetManager" {
  10462. import { Nullable } from "babylonjs/types";
  10463. import { Scene } from "babylonjs/scene";
  10464. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  10465. /**
  10466. * This class is used to deform meshes using morphing between different targets
  10467. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10468. */
  10469. export class MorphTargetManager {
  10470. private _targets;
  10471. private _targetInfluenceChangedObservers;
  10472. private _targetDataLayoutChangedObservers;
  10473. private _activeTargets;
  10474. private _scene;
  10475. private _influences;
  10476. private _supportsNormals;
  10477. private _supportsTangents;
  10478. private _supportsUVs;
  10479. private _vertexCount;
  10480. private _uniqueId;
  10481. private _tempInfluences;
  10482. /**
  10483. * Creates a new MorphTargetManager
  10484. * @param scene defines the current scene
  10485. */
  10486. constructor(scene?: Nullable<Scene>);
  10487. /**
  10488. * Gets the unique ID of this manager
  10489. */
  10490. readonly uniqueId: number;
  10491. /**
  10492. * Gets the number of vertices handled by this manager
  10493. */
  10494. readonly vertexCount: number;
  10495. /**
  10496. * Gets a boolean indicating if this manager supports morphing of normals
  10497. */
  10498. readonly supportsNormals: boolean;
  10499. /**
  10500. * Gets a boolean indicating if this manager supports morphing of tangents
  10501. */
  10502. readonly supportsTangents: boolean;
  10503. /**
  10504. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10505. */
  10506. readonly supportsUVs: boolean;
  10507. /**
  10508. * Gets the number of targets stored in this manager
  10509. */
  10510. readonly numTargets: number;
  10511. /**
  10512. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10513. */
  10514. readonly numInfluencers: number;
  10515. /**
  10516. * Gets the list of influences (one per target)
  10517. */
  10518. readonly influences: Float32Array;
  10519. /**
  10520. * Gets the active target at specified index. An active target is a target with an influence > 0
  10521. * @param index defines the index to check
  10522. * @returns the requested target
  10523. */
  10524. getActiveTarget(index: number): MorphTarget;
  10525. /**
  10526. * Gets the target at specified index
  10527. * @param index defines the index to check
  10528. * @returns the requested target
  10529. */
  10530. getTarget(index: number): MorphTarget;
  10531. /**
  10532. * Add a new target to this manager
  10533. * @param target defines the target to add
  10534. */
  10535. addTarget(target: MorphTarget): void;
  10536. /**
  10537. * Removes a target from the manager
  10538. * @param target defines the target to remove
  10539. */
  10540. removeTarget(target: MorphTarget): void;
  10541. /**
  10542. * Serializes the current manager into a Serialization object
  10543. * @returns the serialized object
  10544. */
  10545. serialize(): any;
  10546. private _syncActiveTargets;
  10547. /**
  10548. * Syncrhonize the targets with all the meshes using this morph target manager
  10549. */
  10550. synchronize(): void;
  10551. /**
  10552. * Creates a new MorphTargetManager from serialized data
  10553. * @param serializationObject defines the serialized data
  10554. * @param scene defines the hosting scene
  10555. * @returns the new MorphTargetManager
  10556. */
  10557. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10558. }
  10559. }
  10560. declare module "babylonjs/sceneComponent" {
  10561. import { Scene } from "babylonjs/scene";
  10562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10563. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10564. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10565. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10566. import { Nullable } from "babylonjs/types";
  10567. import { Camera } from "babylonjs/Cameras/camera";
  10568. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10569. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10570. import { AbstractScene } from "babylonjs/abstractScene";
  10571. /**
  10572. * Groups all the scene component constants in one place to ease maintenance.
  10573. * @hidden
  10574. */
  10575. export class SceneComponentConstants {
  10576. static readonly NAME_EFFECTLAYER: string;
  10577. static readonly NAME_LAYER: string;
  10578. static readonly NAME_LENSFLARESYSTEM: string;
  10579. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10580. static readonly NAME_PARTICLESYSTEM: string;
  10581. static readonly NAME_GAMEPAD: string;
  10582. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10583. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10584. static readonly NAME_DEPTHRENDERER: string;
  10585. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10586. static readonly NAME_SPRITE: string;
  10587. static readonly NAME_OUTLINERENDERER: string;
  10588. static readonly NAME_PROCEDURALTEXTURE: string;
  10589. static readonly NAME_SHADOWGENERATOR: string;
  10590. static readonly NAME_OCTREE: string;
  10591. static readonly NAME_PHYSICSENGINE: string;
  10592. static readonly NAME_AUDIO: string;
  10593. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10594. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10595. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10596. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10597. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10598. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10599. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10600. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10601. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10602. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10603. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10604. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10605. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10606. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10607. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10608. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10609. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10610. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10611. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10612. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10613. static readonly STEP_AFTERRENDER_AUDIO: number;
  10614. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10615. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10616. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10617. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10618. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10619. static readonly STEP_POINTERMOVE_SPRITE: number;
  10620. static readonly STEP_POINTERDOWN_SPRITE: number;
  10621. static readonly STEP_POINTERUP_SPRITE: number;
  10622. }
  10623. /**
  10624. * This represents a scene component.
  10625. *
  10626. * This is used to decouple the dependency the scene is having on the different workloads like
  10627. * layers, post processes...
  10628. */
  10629. export interface ISceneComponent {
  10630. /**
  10631. * The name of the component. Each component must have a unique name.
  10632. */
  10633. name: string;
  10634. /**
  10635. * The scene the component belongs to.
  10636. */
  10637. scene: Scene;
  10638. /**
  10639. * Register the component to one instance of a scene.
  10640. */
  10641. register(): void;
  10642. /**
  10643. * Rebuilds the elements related to this component in case of
  10644. * context lost for instance.
  10645. */
  10646. rebuild(): void;
  10647. /**
  10648. * Disposes the component and the associated ressources.
  10649. */
  10650. dispose(): void;
  10651. }
  10652. /**
  10653. * This represents a SERIALIZABLE scene component.
  10654. *
  10655. * This extends Scene Component to add Serialization methods on top.
  10656. */
  10657. export interface ISceneSerializableComponent extends ISceneComponent {
  10658. /**
  10659. * Adds all the elements from the container to the scene
  10660. * @param container the container holding the elements
  10661. */
  10662. addFromContainer(container: AbstractScene): void;
  10663. /**
  10664. * Removes all the elements in the container from the scene
  10665. * @param container contains the elements to remove
  10666. * @param dispose if the removed element should be disposed (default: false)
  10667. */
  10668. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10669. /**
  10670. * Serializes the component data to the specified json object
  10671. * @param serializationObject The object to serialize to
  10672. */
  10673. serialize(serializationObject: any): void;
  10674. }
  10675. /**
  10676. * Strong typing of a Mesh related stage step action
  10677. */
  10678. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10679. /**
  10680. * Strong typing of a Evaluate Sub Mesh related stage step action
  10681. */
  10682. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10683. /**
  10684. * Strong typing of a Active Mesh related stage step action
  10685. */
  10686. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10687. /**
  10688. * Strong typing of a Camera related stage step action
  10689. */
  10690. export type CameraStageAction = (camera: Camera) => void;
  10691. /**
  10692. * Strong typing of a Camera Frame buffer related stage step action
  10693. */
  10694. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10695. /**
  10696. * Strong typing of a Render Target related stage step action
  10697. */
  10698. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10699. /**
  10700. * Strong typing of a RenderingGroup related stage step action
  10701. */
  10702. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10703. /**
  10704. * Strong typing of a Mesh Render related stage step action
  10705. */
  10706. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10707. /**
  10708. * Strong typing of a simple stage step action
  10709. */
  10710. export type SimpleStageAction = () => void;
  10711. /**
  10712. * Strong typing of a render target action.
  10713. */
  10714. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10715. /**
  10716. * Strong typing of a pointer move action.
  10717. */
  10718. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10719. /**
  10720. * Strong typing of a pointer up/down action.
  10721. */
  10722. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10723. /**
  10724. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10725. * @hidden
  10726. */
  10727. export class Stage<T extends Function> extends Array<{
  10728. index: number;
  10729. component: ISceneComponent;
  10730. action: T;
  10731. }> {
  10732. /**
  10733. * Hide ctor from the rest of the world.
  10734. * @param items The items to add.
  10735. */
  10736. private constructor();
  10737. /**
  10738. * Creates a new Stage.
  10739. * @returns A new instance of a Stage
  10740. */
  10741. static Create<T extends Function>(): Stage<T>;
  10742. /**
  10743. * Registers a step in an ordered way in the targeted stage.
  10744. * @param index Defines the position to register the step in
  10745. * @param component Defines the component attached to the step
  10746. * @param action Defines the action to launch during the step
  10747. */
  10748. registerStep(index: number, component: ISceneComponent, action: T): void;
  10749. /**
  10750. * Clears all the steps from the stage.
  10751. */
  10752. clear(): void;
  10753. }
  10754. }
  10755. declare module "babylonjs/Meshes/meshLODLevel" {
  10756. import { Mesh } from "babylonjs/Meshes/mesh";
  10757. import { Nullable } from "babylonjs/types";
  10758. /**
  10759. * Class used to represent a specific level of detail of a mesh
  10760. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10761. */
  10762. export class MeshLODLevel {
  10763. /** Defines the distance where this level should star being displayed */
  10764. distance: number;
  10765. /** Defines the mesh to use to render this level */
  10766. mesh: Nullable<Mesh>;
  10767. /**
  10768. * Creates a new LOD level
  10769. * @param distance defines the distance where this level should star being displayed
  10770. * @param mesh defines the mesh to use to render this level
  10771. */
  10772. constructor(
  10773. /** Defines the distance where this level should star being displayed */
  10774. distance: number,
  10775. /** Defines the mesh to use to render this level */
  10776. mesh: Nullable<Mesh>);
  10777. }
  10778. }
  10779. declare module "babylonjs/Lights/shadowLight" {
  10780. import { Camera } from "babylonjs/Cameras/camera";
  10781. import { Scene } from "babylonjs/scene";
  10782. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10784. import { Light } from "babylonjs/Lights/light";
  10785. /**
  10786. * Interface describing all the common properties and methods a shadow light needs to implement.
  10787. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10788. * as well as binding the different shadow properties to the effects.
  10789. */
  10790. export interface IShadowLight extends Light {
  10791. /**
  10792. * The light id in the scene (used in scene.findLighById for instance)
  10793. */
  10794. id: string;
  10795. /**
  10796. * The position the shdow will be casted from.
  10797. */
  10798. position: Vector3;
  10799. /**
  10800. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10801. */
  10802. direction: Vector3;
  10803. /**
  10804. * The transformed position. Position of the light in world space taking parenting in account.
  10805. */
  10806. transformedPosition: Vector3;
  10807. /**
  10808. * The transformed direction. Direction of the light in world space taking parenting in account.
  10809. */
  10810. transformedDirection: Vector3;
  10811. /**
  10812. * The friendly name of the light in the scene.
  10813. */
  10814. name: string;
  10815. /**
  10816. * Defines the shadow projection clipping minimum z value.
  10817. */
  10818. shadowMinZ: number;
  10819. /**
  10820. * Defines the shadow projection clipping maximum z value.
  10821. */
  10822. shadowMaxZ: number;
  10823. /**
  10824. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10825. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10826. */
  10827. computeTransformedInformation(): boolean;
  10828. /**
  10829. * Gets the scene the light belongs to.
  10830. * @returns The scene
  10831. */
  10832. getScene(): Scene;
  10833. /**
  10834. * Callback defining a custom Projection Matrix Builder.
  10835. * This can be used to override the default projection matrix computation.
  10836. */
  10837. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10838. /**
  10839. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10840. * @param matrix The materix to updated with the projection information
  10841. * @param viewMatrix The transform matrix of the light
  10842. * @param renderList The list of mesh to render in the map
  10843. * @returns The current light
  10844. */
  10845. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10846. /**
  10847. * Gets the current depth scale used in ESM.
  10848. * @returns The scale
  10849. */
  10850. getDepthScale(): number;
  10851. /**
  10852. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10853. * @returns true if a cube texture needs to be use
  10854. */
  10855. needCube(): boolean;
  10856. /**
  10857. * Detects if the projection matrix requires to be recomputed this frame.
  10858. * @returns true if it requires to be recomputed otherwise, false.
  10859. */
  10860. needProjectionMatrixCompute(): boolean;
  10861. /**
  10862. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10863. */
  10864. forceProjectionMatrixCompute(): void;
  10865. /**
  10866. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10867. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10868. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10869. */
  10870. getShadowDirection(faceIndex?: number): Vector3;
  10871. /**
  10872. * Gets the minZ used for shadow according to both the scene and the light.
  10873. * @param activeCamera The camera we are returning the min for
  10874. * @returns the depth min z
  10875. */
  10876. getDepthMinZ(activeCamera: Camera): number;
  10877. /**
  10878. * Gets the maxZ used for shadow according to both the scene and the light.
  10879. * @param activeCamera The camera we are returning the max for
  10880. * @returns the depth max z
  10881. */
  10882. getDepthMaxZ(activeCamera: Camera): number;
  10883. }
  10884. /**
  10885. * Base implementation IShadowLight
  10886. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10887. */
  10888. export abstract class ShadowLight extends Light implements IShadowLight {
  10889. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10890. protected _position: Vector3;
  10891. protected _setPosition(value: Vector3): void;
  10892. /**
  10893. * Sets the position the shadow will be casted from. Also use as the light position for both
  10894. * point and spot lights.
  10895. */
  10896. /**
  10897. * Sets the position the shadow will be casted from. Also use as the light position for both
  10898. * point and spot lights.
  10899. */
  10900. position: Vector3;
  10901. protected _direction: Vector3;
  10902. protected _setDirection(value: Vector3): void;
  10903. /**
  10904. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10905. * Also use as the light direction on spot and directional lights.
  10906. */
  10907. /**
  10908. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10909. * Also use as the light direction on spot and directional lights.
  10910. */
  10911. direction: Vector3;
  10912. private _shadowMinZ;
  10913. /**
  10914. * Gets the shadow projection clipping minimum z value.
  10915. */
  10916. /**
  10917. * Sets the shadow projection clipping minimum z value.
  10918. */
  10919. shadowMinZ: number;
  10920. private _shadowMaxZ;
  10921. /**
  10922. * Sets the shadow projection clipping maximum z value.
  10923. */
  10924. /**
  10925. * Gets the shadow projection clipping maximum z value.
  10926. */
  10927. shadowMaxZ: number;
  10928. /**
  10929. * Callback defining a custom Projection Matrix Builder.
  10930. * This can be used to override the default projection matrix computation.
  10931. */
  10932. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10933. /**
  10934. * The transformed position. Position of the light in world space taking parenting in account.
  10935. */
  10936. transformedPosition: Vector3;
  10937. /**
  10938. * The transformed direction. Direction of the light in world space taking parenting in account.
  10939. */
  10940. transformedDirection: Vector3;
  10941. private _needProjectionMatrixCompute;
  10942. /**
  10943. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10944. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10945. */
  10946. computeTransformedInformation(): boolean;
  10947. /**
  10948. * Return the depth scale used for the shadow map.
  10949. * @returns the depth scale.
  10950. */
  10951. getDepthScale(): number;
  10952. /**
  10953. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10954. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10955. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10956. */
  10957. getShadowDirection(faceIndex?: number): Vector3;
  10958. /**
  10959. * Returns the ShadowLight absolute position in the World.
  10960. * @returns the position vector in world space
  10961. */
  10962. getAbsolutePosition(): Vector3;
  10963. /**
  10964. * Sets the ShadowLight direction toward the passed target.
  10965. * @param target The point to target in local space
  10966. * @returns the updated ShadowLight direction
  10967. */
  10968. setDirectionToTarget(target: Vector3): Vector3;
  10969. /**
  10970. * Returns the light rotation in euler definition.
  10971. * @returns the x y z rotation in local space.
  10972. */
  10973. getRotation(): Vector3;
  10974. /**
  10975. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10976. * @returns true if a cube texture needs to be use
  10977. */
  10978. needCube(): boolean;
  10979. /**
  10980. * Detects if the projection matrix requires to be recomputed this frame.
  10981. * @returns true if it requires to be recomputed otherwise, false.
  10982. */
  10983. needProjectionMatrixCompute(): boolean;
  10984. /**
  10985. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10986. */
  10987. forceProjectionMatrixCompute(): void;
  10988. /** @hidden */
  10989. _initCache(): void;
  10990. /** @hidden */
  10991. _isSynchronized(): boolean;
  10992. /**
  10993. * Computes the world matrix of the node
  10994. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10995. * @returns the world matrix
  10996. */
  10997. computeWorldMatrix(force?: boolean): Matrix;
  10998. /**
  10999. * Gets the minZ used for shadow according to both the scene and the light.
  11000. * @param activeCamera The camera we are returning the min for
  11001. * @returns the depth min z
  11002. */
  11003. getDepthMinZ(activeCamera: Camera): number;
  11004. /**
  11005. * Gets the maxZ used for shadow according to both the scene and the light.
  11006. * @param activeCamera The camera we are returning the max for
  11007. * @returns the depth max z
  11008. */
  11009. getDepthMaxZ(activeCamera: Camera): number;
  11010. /**
  11011. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11012. * @param matrix The materix to updated with the projection information
  11013. * @param viewMatrix The transform matrix of the light
  11014. * @param renderList The list of mesh to render in the map
  11015. * @returns The current light
  11016. */
  11017. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11018. }
  11019. }
  11020. declare module "babylonjs/Materials/materialHelper" {
  11021. import { Nullable } from "babylonjs/types";
  11022. import { Scene } from "babylonjs/scene";
  11023. import { Engine } from "babylonjs/Engines/engine";
  11024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11025. import { Light } from "babylonjs/Lights/light";
  11026. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11027. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  11028. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11029. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11030. /**
  11031. * "Static Class" containing the most commonly used helper while dealing with material for
  11032. * rendering purpose.
  11033. *
  11034. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  11035. *
  11036. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  11037. */
  11038. export class MaterialHelper {
  11039. /**
  11040. * Bind the current view position to an effect.
  11041. * @param effect The effect to be bound
  11042. * @param scene The scene the eyes position is used from
  11043. */
  11044. static BindEyePosition(effect: Effect, scene: Scene): void;
  11045. /**
  11046. * Helps preparing the defines values about the UVs in used in the effect.
  11047. * UVs are shared as much as we can accross channels in the shaders.
  11048. * @param texture The texture we are preparing the UVs for
  11049. * @param defines The defines to update
  11050. * @param key The channel key "diffuse", "specular"... used in the shader
  11051. */
  11052. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  11053. /**
  11054. * Binds a texture matrix value to its corrsponding uniform
  11055. * @param texture The texture to bind the matrix for
  11056. * @param uniformBuffer The uniform buffer receivin the data
  11057. * @param key The channel key "diffuse", "specular"... used in the shader
  11058. */
  11059. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  11060. /**
  11061. * Gets the current status of the fog (should it be enabled?)
  11062. * @param mesh defines the mesh to evaluate for fog support
  11063. * @param scene defines the hosting scene
  11064. * @returns true if fog must be enabled
  11065. */
  11066. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  11067. /**
  11068. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  11069. * @param mesh defines the current mesh
  11070. * @param scene defines the current scene
  11071. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  11072. * @param pointsCloud defines if point cloud rendering has to be turned on
  11073. * @param fogEnabled defines if fog has to be turned on
  11074. * @param alphaTest defines if alpha testing has to be turned on
  11075. * @param defines defines the current list of defines
  11076. */
  11077. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  11078. /**
  11079. * Helper used to prepare the list of defines associated with frame values for shader compilation
  11080. * @param scene defines the current scene
  11081. * @param engine defines the current engine
  11082. * @param defines specifies the list of active defines
  11083. * @param useInstances defines if instances have to be turned on
  11084. * @param useClipPlane defines if clip plane have to be turned on
  11085. */
  11086. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  11087. /**
  11088. * Prepares the defines for bones
  11089. * @param mesh The mesh containing the geometry data we will draw
  11090. * @param defines The defines to update
  11091. */
  11092. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  11093. /**
  11094. * Prepares the defines for morph targets
  11095. * @param mesh The mesh containing the geometry data we will draw
  11096. * @param defines The defines to update
  11097. */
  11098. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  11099. /**
  11100. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  11101. * @param mesh The mesh containing the geometry data we will draw
  11102. * @param defines The defines to update
  11103. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  11104. * @param useBones Precise whether bones should be used or not (override mesh info)
  11105. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  11106. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  11107. * @returns false if defines are considered not dirty and have not been checked
  11108. */
  11109. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  11110. /**
  11111. * Prepares the defines related to multiview
  11112. * @param scene The scene we are intending to draw
  11113. * @param defines The defines to update
  11114. */
  11115. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  11116. /**
  11117. * Prepares the defines related to the light information passed in parameter
  11118. * @param scene The scene we are intending to draw
  11119. * @param mesh The mesh the effect is compiling for
  11120. * @param light The light the effect is compiling for
  11121. * @param lightIndex The index of the light
  11122. * @param defines The defines to update
  11123. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11124. * @param state Defines the current state regarding what is needed (normals, etc...)
  11125. */
  11126. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  11127. needNormals: boolean;
  11128. needRebuild: boolean;
  11129. shadowEnabled: boolean;
  11130. specularEnabled: boolean;
  11131. lightmapMode: boolean;
  11132. }): void;
  11133. /**
  11134. * Prepares the defines related to the light information passed in parameter
  11135. * @param scene The scene we are intending to draw
  11136. * @param mesh The mesh the effect is compiling for
  11137. * @param defines The defines to update
  11138. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11139. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  11140. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  11141. * @returns true if normals will be required for the rest of the effect
  11142. */
  11143. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  11144. /**
  11145. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  11146. * @param lightIndex defines the light index
  11147. * @param uniformsList The uniform list
  11148. * @param samplersList The sampler list
  11149. * @param projectedLightTexture defines if projected texture must be used
  11150. * @param uniformBuffersList defines an optional list of uniform buffers
  11151. */
  11152. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  11153. /**
  11154. * Prepares the uniforms and samplers list to be used in the effect
  11155. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  11156. * @param samplersList The sampler list
  11157. * @param defines The defines helping in the list generation
  11158. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  11159. */
  11160. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11161. /**
  11162. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11163. * @param defines The defines to update while falling back
  11164. * @param fallbacks The authorized effect fallbacks
  11165. * @param maxSimultaneousLights The maximum number of lights allowed
  11166. * @param rank the current rank of the Effect
  11167. * @returns The newly affected rank
  11168. */
  11169. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11170. private static _TmpMorphInfluencers;
  11171. /**
  11172. * Prepares the list of attributes required for morph targets according to the effect defines.
  11173. * @param attribs The current list of supported attribs
  11174. * @param mesh The mesh to prepare the morph targets attributes for
  11175. * @param influencers The number of influencers
  11176. */
  11177. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  11178. /**
  11179. * Prepares the list of attributes required for morph targets according to the effect defines.
  11180. * @param attribs The current list of supported attribs
  11181. * @param mesh The mesh to prepare the morph targets attributes for
  11182. * @param defines The current Defines of the effect
  11183. */
  11184. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11185. /**
  11186. * Prepares the list of attributes required for bones according to the effect defines.
  11187. * @param attribs The current list of supported attribs
  11188. * @param mesh The mesh to prepare the bones attributes for
  11189. * @param defines The current Defines of the effect
  11190. * @param fallbacks The current efffect fallback strategy
  11191. */
  11192. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11193. /**
  11194. * Check and prepare the list of attributes required for instances according to the effect defines.
  11195. * @param attribs The current list of supported attribs
  11196. * @param defines The current MaterialDefines of the effect
  11197. */
  11198. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11199. /**
  11200. * Add the list of attributes required for instances to the attribs array.
  11201. * @param attribs The current list of supported attribs
  11202. */
  11203. static PushAttributesForInstances(attribs: string[]): void;
  11204. /**
  11205. * Binds the light shadow information to the effect for the given mesh.
  11206. * @param light The light containing the generator
  11207. * @param scene The scene the lights belongs to
  11208. * @param mesh The mesh we are binding the information to render
  11209. * @param lightIndex The light index in the effect used to render the mesh
  11210. * @param effect The effect we are binding the data to
  11211. */
  11212. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11213. /**
  11214. * Binds the light information to the effect.
  11215. * @param light The light containing the generator
  11216. * @param effect The effect we are binding the data to
  11217. * @param lightIndex The light index in the effect used to render
  11218. */
  11219. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11220. /**
  11221. * Binds the lights information from the scene to the effect for the given mesh.
  11222. * @param light Light to bind
  11223. * @param lightIndex Light index
  11224. * @param scene The scene where the light belongs to
  11225. * @param mesh The mesh we are binding the information to render
  11226. * @param effect The effect we are binding the data to
  11227. * @param useSpecular Defines if specular is supported
  11228. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11229. */
  11230. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  11231. /**
  11232. * Binds the lights information from the scene to the effect for the given mesh.
  11233. * @param scene The scene the lights belongs to
  11234. * @param mesh The mesh we are binding the information to render
  11235. * @param effect The effect we are binding the data to
  11236. * @param defines The generated defines for the effect
  11237. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11238. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11239. */
  11240. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11241. private static _tempFogColor;
  11242. /**
  11243. * Binds the fog information from the scene to the effect for the given mesh.
  11244. * @param scene The scene the lights belongs to
  11245. * @param mesh The mesh we are binding the information to render
  11246. * @param effect The effect we are binding the data to
  11247. * @param linearSpace Defines if the fog effect is applied in linear space
  11248. */
  11249. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11250. /**
  11251. * Binds the bones information from the mesh to the effect.
  11252. * @param mesh The mesh we are binding the information to render
  11253. * @param effect The effect we are binding the data to
  11254. */
  11255. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11256. /**
  11257. * Binds the morph targets information from the mesh to the effect.
  11258. * @param abstractMesh The mesh we are binding the information to render
  11259. * @param effect The effect we are binding the data to
  11260. */
  11261. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11262. /**
  11263. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11264. * @param defines The generated defines used in the effect
  11265. * @param effect The effect we are binding the data to
  11266. * @param scene The scene we are willing to render with logarithmic scale for
  11267. */
  11268. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11269. /**
  11270. * Binds the clip plane information from the scene to the effect.
  11271. * @param scene The scene the clip plane information are extracted from
  11272. * @param effect The effect we are binding the data to
  11273. */
  11274. static BindClipPlane(effect: Effect, scene: Scene): void;
  11275. }
  11276. }
  11277. declare module "babylonjs/Shaders/shadowMap.fragment" {
  11278. /** @hidden */
  11279. export var shadowMapPixelShader: {
  11280. name: string;
  11281. shader: string;
  11282. };
  11283. }
  11284. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  11285. /** @hidden */
  11286. export var bonesDeclaration: {
  11287. name: string;
  11288. shader: string;
  11289. };
  11290. }
  11291. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  11292. /** @hidden */
  11293. export var morphTargetsVertexGlobalDeclaration: {
  11294. name: string;
  11295. shader: string;
  11296. };
  11297. }
  11298. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  11299. /** @hidden */
  11300. export var morphTargetsVertexDeclaration: {
  11301. name: string;
  11302. shader: string;
  11303. };
  11304. }
  11305. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  11306. /** @hidden */
  11307. export var instancesDeclaration: {
  11308. name: string;
  11309. shader: string;
  11310. };
  11311. }
  11312. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  11313. /** @hidden */
  11314. export var helperFunctions: {
  11315. name: string;
  11316. shader: string;
  11317. };
  11318. }
  11319. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  11320. /** @hidden */
  11321. export var morphTargetsVertex: {
  11322. name: string;
  11323. shader: string;
  11324. };
  11325. }
  11326. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  11327. /** @hidden */
  11328. export var instancesVertex: {
  11329. name: string;
  11330. shader: string;
  11331. };
  11332. }
  11333. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  11334. /** @hidden */
  11335. export var bonesVertex: {
  11336. name: string;
  11337. shader: string;
  11338. };
  11339. }
  11340. declare module "babylonjs/Shaders/shadowMap.vertex" {
  11341. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  11342. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  11343. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  11344. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  11345. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11346. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  11347. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  11348. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  11349. /** @hidden */
  11350. export var shadowMapVertexShader: {
  11351. name: string;
  11352. shader: string;
  11353. };
  11354. }
  11355. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  11356. /** @hidden */
  11357. export var depthBoxBlurPixelShader: {
  11358. name: string;
  11359. shader: string;
  11360. };
  11361. }
  11362. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  11363. import { Nullable } from "babylonjs/types";
  11364. import { Scene } from "babylonjs/scene";
  11365. import { Matrix } from "babylonjs/Maths/math";
  11366. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11368. import { Mesh } from "babylonjs/Meshes/mesh";
  11369. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  11370. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11371. import { Effect } from "babylonjs/Materials/effect";
  11372. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11373. import "babylonjs/Shaders/shadowMap.fragment";
  11374. import "babylonjs/Shaders/shadowMap.vertex";
  11375. import "babylonjs/Shaders/depthBoxBlur.fragment";
  11376. import { Observable } from "babylonjs/Misc/observable";
  11377. /**
  11378. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11379. */
  11380. export interface ICustomShaderOptions {
  11381. /**
  11382. * Gets or sets the custom shader name to use
  11383. */
  11384. shaderName: string;
  11385. /**
  11386. * The list of attribute names used in the shader
  11387. */
  11388. attributes?: string[];
  11389. /**
  11390. * The list of unifrom names used in the shader
  11391. */
  11392. uniforms?: string[];
  11393. /**
  11394. * The list of sampler names used in the shader
  11395. */
  11396. samplers?: string[];
  11397. /**
  11398. * The list of defines used in the shader
  11399. */
  11400. defines?: string[];
  11401. }
  11402. /**
  11403. * Interface to implement to create a shadow generator compatible with BJS.
  11404. */
  11405. export interface IShadowGenerator {
  11406. /**
  11407. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11408. * @returns The render target texture if present otherwise, null
  11409. */
  11410. getShadowMap(): Nullable<RenderTargetTexture>;
  11411. /**
  11412. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11413. * @returns The render target texture if the shadow map is present otherwise, null
  11414. */
  11415. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11416. /**
  11417. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11418. * @param subMesh The submesh we want to render in the shadow map
  11419. * @param useInstances Defines wether will draw in the map using instances
  11420. * @returns true if ready otherwise, false
  11421. */
  11422. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11423. /**
  11424. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11425. * @param defines Defines of the material we want to update
  11426. * @param lightIndex Index of the light in the enabled light list of the material
  11427. */
  11428. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11429. /**
  11430. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11431. * defined in the generator but impacting the effect).
  11432. * It implies the unifroms available on the materials are the standard BJS ones.
  11433. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11434. * @param effect The effect we are binfing the information for
  11435. */
  11436. bindShadowLight(lightIndex: string, effect: Effect): void;
  11437. /**
  11438. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11439. * (eq to shadow prjection matrix * light transform matrix)
  11440. * @returns The transform matrix used to create the shadow map
  11441. */
  11442. getTransformMatrix(): Matrix;
  11443. /**
  11444. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11445. * Cube and 2D textures for instance.
  11446. */
  11447. recreateShadowMap(): void;
  11448. /**
  11449. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11450. * @param onCompiled Callback triggered at the and of the effects compilation
  11451. * @param options Sets of optional options forcing the compilation with different modes
  11452. */
  11453. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11454. useInstances: boolean;
  11455. }>): void;
  11456. /**
  11457. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11458. * @param options Sets of optional options forcing the compilation with different modes
  11459. * @returns A promise that resolves when the compilation completes
  11460. */
  11461. forceCompilationAsync(options?: Partial<{
  11462. useInstances: boolean;
  11463. }>): Promise<void>;
  11464. /**
  11465. * Serializes the shadow generator setup to a json object.
  11466. * @returns The serialized JSON object
  11467. */
  11468. serialize(): any;
  11469. /**
  11470. * Disposes the Shadow map and related Textures and effects.
  11471. */
  11472. dispose(): void;
  11473. }
  11474. /**
  11475. * Default implementation IShadowGenerator.
  11476. * This is the main object responsible of generating shadows in the framework.
  11477. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11478. */
  11479. export class ShadowGenerator implements IShadowGenerator {
  11480. /**
  11481. * Shadow generator mode None: no filtering applied.
  11482. */
  11483. static readonly FILTER_NONE: number;
  11484. /**
  11485. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11486. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11487. */
  11488. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11489. /**
  11490. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11491. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11492. */
  11493. static readonly FILTER_POISSONSAMPLING: number;
  11494. /**
  11495. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11496. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11497. */
  11498. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11499. /**
  11500. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11501. * edge artifacts on steep falloff.
  11502. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11503. */
  11504. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11505. /**
  11506. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11507. * edge artifacts on steep falloff.
  11508. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11509. */
  11510. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11511. /**
  11512. * Shadow generator mode PCF: Percentage Closer Filtering
  11513. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11514. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11515. */
  11516. static readonly FILTER_PCF: number;
  11517. /**
  11518. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11519. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11520. * Contact Hardening
  11521. */
  11522. static readonly FILTER_PCSS: number;
  11523. /**
  11524. * Reserved for PCF and PCSS
  11525. * Highest Quality.
  11526. *
  11527. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11528. *
  11529. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11530. */
  11531. static readonly QUALITY_HIGH: number;
  11532. /**
  11533. * Reserved for PCF and PCSS
  11534. * Good tradeoff for quality/perf cross devices
  11535. *
  11536. * Execute PCF on a 3*3 kernel.
  11537. *
  11538. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11539. */
  11540. static readonly QUALITY_MEDIUM: number;
  11541. /**
  11542. * Reserved for PCF and PCSS
  11543. * The lowest quality but the fastest.
  11544. *
  11545. * Execute PCF on a 1*1 kernel.
  11546. *
  11547. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11548. */
  11549. static readonly QUALITY_LOW: number;
  11550. /** Gets or sets the custom shader name to use */
  11551. customShaderOptions: ICustomShaderOptions;
  11552. /**
  11553. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11554. */
  11555. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11556. /**
  11557. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11558. */
  11559. onAfterShadowMapRenderObservable: Observable<Effect>;
  11560. /**
  11561. * Observable triggered before a mesh is rendered in the shadow map.
  11562. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11563. */
  11564. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11565. /**
  11566. * Observable triggered after a mesh is rendered in the shadow map.
  11567. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11568. */
  11569. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11570. private _bias;
  11571. /**
  11572. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11573. */
  11574. /**
  11575. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11576. */
  11577. bias: number;
  11578. private _normalBias;
  11579. /**
  11580. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11581. */
  11582. /**
  11583. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11584. */
  11585. normalBias: number;
  11586. private _blurBoxOffset;
  11587. /**
  11588. * Gets the blur box offset: offset applied during the blur pass.
  11589. * Only useful if useKernelBlur = false
  11590. */
  11591. /**
  11592. * Sets the blur box offset: offset applied during the blur pass.
  11593. * Only useful if useKernelBlur = false
  11594. */
  11595. blurBoxOffset: number;
  11596. private _blurScale;
  11597. /**
  11598. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11599. * 2 means half of the size.
  11600. */
  11601. /**
  11602. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11603. * 2 means half of the size.
  11604. */
  11605. blurScale: number;
  11606. private _blurKernel;
  11607. /**
  11608. * Gets the blur kernel: kernel size of the blur pass.
  11609. * Only useful if useKernelBlur = true
  11610. */
  11611. /**
  11612. * Sets the blur kernel: kernel size of the blur pass.
  11613. * Only useful if useKernelBlur = true
  11614. */
  11615. blurKernel: number;
  11616. private _useKernelBlur;
  11617. /**
  11618. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11619. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11620. */
  11621. /**
  11622. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11623. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11624. */
  11625. useKernelBlur: boolean;
  11626. private _depthScale;
  11627. /**
  11628. * Gets the depth scale used in ESM mode.
  11629. */
  11630. /**
  11631. * Sets the depth scale used in ESM mode.
  11632. * This can override the scale stored on the light.
  11633. */
  11634. depthScale: number;
  11635. private _filter;
  11636. /**
  11637. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11638. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11639. */
  11640. /**
  11641. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11642. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11643. */
  11644. filter: number;
  11645. /**
  11646. * Gets if the current filter is set to Poisson Sampling.
  11647. */
  11648. /**
  11649. * Sets the current filter to Poisson Sampling.
  11650. */
  11651. usePoissonSampling: boolean;
  11652. /**
  11653. * Gets if the current filter is set to ESM.
  11654. */
  11655. /**
  11656. * Sets the current filter is to ESM.
  11657. */
  11658. useExponentialShadowMap: boolean;
  11659. /**
  11660. * Gets if the current filter is set to filtered ESM.
  11661. */
  11662. /**
  11663. * Gets if the current filter is set to filtered ESM.
  11664. */
  11665. useBlurExponentialShadowMap: boolean;
  11666. /**
  11667. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11668. * exponential to prevent steep falloff artifacts).
  11669. */
  11670. /**
  11671. * Sets the current filter to "close ESM" (using the inverse of the
  11672. * exponential to prevent steep falloff artifacts).
  11673. */
  11674. useCloseExponentialShadowMap: boolean;
  11675. /**
  11676. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11677. * exponential to prevent steep falloff artifacts).
  11678. */
  11679. /**
  11680. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11681. * exponential to prevent steep falloff artifacts).
  11682. */
  11683. useBlurCloseExponentialShadowMap: boolean;
  11684. /**
  11685. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11686. */
  11687. /**
  11688. * Sets the current filter to "PCF" (percentage closer filtering).
  11689. */
  11690. usePercentageCloserFiltering: boolean;
  11691. private _filteringQuality;
  11692. /**
  11693. * Gets the PCF or PCSS Quality.
  11694. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11695. */
  11696. /**
  11697. * Sets the PCF or PCSS Quality.
  11698. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11699. */
  11700. filteringQuality: number;
  11701. /**
  11702. * Gets if the current filter is set to "PCSS" (contact hardening).
  11703. */
  11704. /**
  11705. * Sets the current filter to "PCSS" (contact hardening).
  11706. */
  11707. useContactHardeningShadow: boolean;
  11708. private _contactHardeningLightSizeUVRatio;
  11709. /**
  11710. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11711. * Using a ratio helps keeping shape stability independently of the map size.
  11712. *
  11713. * It does not account for the light projection as it was having too much
  11714. * instability during the light setup or during light position changes.
  11715. *
  11716. * Only valid if useContactHardeningShadow is true.
  11717. */
  11718. /**
  11719. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11720. * Using a ratio helps keeping shape stability independently of the map size.
  11721. *
  11722. * It does not account for the light projection as it was having too much
  11723. * instability during the light setup or during light position changes.
  11724. *
  11725. * Only valid if useContactHardeningShadow is true.
  11726. */
  11727. contactHardeningLightSizeUVRatio: number;
  11728. private _darkness;
  11729. /** Gets or sets the actual darkness of a shadow */
  11730. darkness: number;
  11731. /**
  11732. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11733. * 0 means strongest and 1 would means no shadow.
  11734. * @returns the darkness.
  11735. */
  11736. getDarkness(): number;
  11737. /**
  11738. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11739. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11740. * @returns the shadow generator allowing fluent coding.
  11741. */
  11742. setDarkness(darkness: number): ShadowGenerator;
  11743. private _transparencyShadow;
  11744. /** Gets or sets the ability to have transparent shadow */
  11745. transparencyShadow: boolean;
  11746. /**
  11747. * Sets the ability to have transparent shadow (boolean).
  11748. * @param transparent True if transparent else False
  11749. * @returns the shadow generator allowing fluent coding
  11750. */
  11751. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11752. private _shadowMap;
  11753. private _shadowMap2;
  11754. /**
  11755. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11756. * @returns The render target texture if present otherwise, null
  11757. */
  11758. getShadowMap(): Nullable<RenderTargetTexture>;
  11759. /**
  11760. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11761. * @returns The render target texture if the shadow map is present otherwise, null
  11762. */
  11763. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11764. /**
  11765. * Gets the class name of that object
  11766. * @returns "ShadowGenerator"
  11767. */
  11768. getClassName(): string;
  11769. /**
  11770. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11771. * @param mesh Mesh to add
  11772. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11773. * @returns the Shadow Generator itself
  11774. */
  11775. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11776. /**
  11777. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11778. * @param mesh Mesh to remove
  11779. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11780. * @returns the Shadow Generator itself
  11781. */
  11782. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11783. /**
  11784. * Controls the extent to which the shadows fade out at the edge of the frustum
  11785. * Used only by directionals and spots
  11786. */
  11787. frustumEdgeFalloff: number;
  11788. private _light;
  11789. /**
  11790. * Returns the associated light object.
  11791. * @returns the light generating the shadow
  11792. */
  11793. getLight(): IShadowLight;
  11794. /**
  11795. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11796. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11797. * It might on the other hand introduce peter panning.
  11798. */
  11799. forceBackFacesOnly: boolean;
  11800. private _scene;
  11801. private _lightDirection;
  11802. private _effect;
  11803. private _viewMatrix;
  11804. private _projectionMatrix;
  11805. private _transformMatrix;
  11806. private _cachedPosition;
  11807. private _cachedDirection;
  11808. private _cachedDefines;
  11809. private _currentRenderID;
  11810. private _boxBlurPostprocess;
  11811. private _kernelBlurXPostprocess;
  11812. private _kernelBlurYPostprocess;
  11813. private _blurPostProcesses;
  11814. private _mapSize;
  11815. private _currentFaceIndex;
  11816. private _currentFaceIndexCache;
  11817. private _textureType;
  11818. private _defaultTextureMatrix;
  11819. /** @hidden */
  11820. static _SceneComponentInitialization: (scene: Scene) => void;
  11821. /**
  11822. * Creates a ShadowGenerator object.
  11823. * A ShadowGenerator is the required tool to use the shadows.
  11824. * Each light casting shadows needs to use its own ShadowGenerator.
  11825. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11826. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11827. * @param light The light object generating the shadows.
  11828. * @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.
  11829. */
  11830. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11831. private _initializeGenerator;
  11832. private _initializeShadowMap;
  11833. private _initializeBlurRTTAndPostProcesses;
  11834. private _renderForShadowMap;
  11835. private _renderSubMeshForShadowMap;
  11836. private _applyFilterValues;
  11837. /**
  11838. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11839. * @param onCompiled Callback triggered at the and of the effects compilation
  11840. * @param options Sets of optional options forcing the compilation with different modes
  11841. */
  11842. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11843. useInstances: boolean;
  11844. }>): void;
  11845. /**
  11846. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11847. * @param options Sets of optional options forcing the compilation with different modes
  11848. * @returns A promise that resolves when the compilation completes
  11849. */
  11850. forceCompilationAsync(options?: Partial<{
  11851. useInstances: boolean;
  11852. }>): Promise<void>;
  11853. /**
  11854. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11855. * @param subMesh The submesh we want to render in the shadow map
  11856. * @param useInstances Defines wether will draw in the map using instances
  11857. * @returns true if ready otherwise, false
  11858. */
  11859. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11860. /**
  11861. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11862. * @param defines Defines of the material we want to update
  11863. * @param lightIndex Index of the light in the enabled light list of the material
  11864. */
  11865. prepareDefines(defines: any, lightIndex: number): void;
  11866. /**
  11867. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11868. * defined in the generator but impacting the effect).
  11869. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11870. * @param effect The effect we are binfing the information for
  11871. */
  11872. bindShadowLight(lightIndex: string, effect: Effect): void;
  11873. /**
  11874. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11875. * (eq to shadow prjection matrix * light transform matrix)
  11876. * @returns The transform matrix used to create the shadow map
  11877. */
  11878. getTransformMatrix(): Matrix;
  11879. /**
  11880. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11881. * Cube and 2D textures for instance.
  11882. */
  11883. recreateShadowMap(): void;
  11884. private _disposeBlurPostProcesses;
  11885. private _disposeRTTandPostProcesses;
  11886. /**
  11887. * Disposes the ShadowGenerator.
  11888. * Returns nothing.
  11889. */
  11890. dispose(): void;
  11891. /**
  11892. * Serializes the shadow generator setup to a json object.
  11893. * @returns The serialized JSON object
  11894. */
  11895. serialize(): any;
  11896. /**
  11897. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11898. * @param parsedShadowGenerator The JSON object to parse
  11899. * @param scene The scene to create the shadow map for
  11900. * @returns The parsed shadow generator
  11901. */
  11902. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11903. }
  11904. }
  11905. declare module "babylonjs/Lights/light" {
  11906. import { Nullable } from "babylonjs/types";
  11907. import { Scene } from "babylonjs/scene";
  11908. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11909. import { Node } from "babylonjs/node";
  11910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11911. import { Effect } from "babylonjs/Materials/effect";
  11912. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11913. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11914. /**
  11915. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11916. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11917. * 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.
  11918. */
  11919. export abstract class Light extends Node {
  11920. /**
  11921. * Falloff Default: light is falling off following the material specification:
  11922. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11923. */
  11924. static readonly FALLOFF_DEFAULT: number;
  11925. /**
  11926. * Falloff Physical: light is falling off following the inverse squared distance law.
  11927. */
  11928. static readonly FALLOFF_PHYSICAL: number;
  11929. /**
  11930. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11931. * to enhance interoperability with other engines.
  11932. */
  11933. static readonly FALLOFF_GLTF: number;
  11934. /**
  11935. * Falloff Standard: light is falling off like in the standard material
  11936. * to enhance interoperability with other materials.
  11937. */
  11938. static readonly FALLOFF_STANDARD: number;
  11939. /**
  11940. * If every light affecting the material is in this lightmapMode,
  11941. * material.lightmapTexture adds or multiplies
  11942. * (depends on material.useLightmapAsShadowmap)
  11943. * after every other light calculations.
  11944. */
  11945. static readonly LIGHTMAP_DEFAULT: number;
  11946. /**
  11947. * material.lightmapTexture as only diffuse lighting from this light
  11948. * adds only specular lighting from this light
  11949. * adds dynamic shadows
  11950. */
  11951. static readonly LIGHTMAP_SPECULAR: number;
  11952. /**
  11953. * material.lightmapTexture as only lighting
  11954. * no light calculation from this light
  11955. * only adds dynamic shadows from this light
  11956. */
  11957. static readonly LIGHTMAP_SHADOWSONLY: number;
  11958. /**
  11959. * Each light type uses the default quantity according to its type:
  11960. * point/spot lights use luminous intensity
  11961. * directional lights use illuminance
  11962. */
  11963. static readonly INTENSITYMODE_AUTOMATIC: number;
  11964. /**
  11965. * lumen (lm)
  11966. */
  11967. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11968. /**
  11969. * candela (lm/sr)
  11970. */
  11971. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11972. /**
  11973. * lux (lm/m^2)
  11974. */
  11975. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11976. /**
  11977. * nit (cd/m^2)
  11978. */
  11979. static readonly INTENSITYMODE_LUMINANCE: number;
  11980. /**
  11981. * Light type const id of the point light.
  11982. */
  11983. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11984. /**
  11985. * Light type const id of the directional light.
  11986. */
  11987. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11988. /**
  11989. * Light type const id of the spot light.
  11990. */
  11991. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11992. /**
  11993. * Light type const id of the hemispheric light.
  11994. */
  11995. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11996. /**
  11997. * Diffuse gives the basic color to an object.
  11998. */
  11999. diffuse: Color3;
  12000. /**
  12001. * Specular produces a highlight color on an object.
  12002. * Note: This is note affecting PBR materials.
  12003. */
  12004. specular: Color3;
  12005. /**
  12006. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12007. * falling off base on range or angle.
  12008. * This can be set to any values in Light.FALLOFF_x.
  12009. *
  12010. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  12011. * other types of materials.
  12012. */
  12013. falloffType: number;
  12014. /**
  12015. * Strength of the light.
  12016. * Note: By default it is define in the framework own unit.
  12017. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12018. */
  12019. intensity: number;
  12020. private _range;
  12021. protected _inverseSquaredRange: number;
  12022. /**
  12023. * Defines how far from the source the light is impacting in scene units.
  12024. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12025. */
  12026. /**
  12027. * Defines how far from the source the light is impacting in scene units.
  12028. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12029. */
  12030. range: number;
  12031. /**
  12032. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12033. * of light.
  12034. */
  12035. private _photometricScale;
  12036. private _intensityMode;
  12037. /**
  12038. * Gets the photometric scale used to interpret the intensity.
  12039. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12040. */
  12041. /**
  12042. * Sets the photometric scale used to interpret the intensity.
  12043. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12044. */
  12045. intensityMode: number;
  12046. private _radius;
  12047. /**
  12048. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12049. */
  12050. /**
  12051. * sets the light radius used by PBR Materials to simulate soft area lights.
  12052. */
  12053. radius: number;
  12054. private _renderPriority;
  12055. /**
  12056. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12057. * exceeding the number allowed of the materials.
  12058. */
  12059. renderPriority: number;
  12060. private _shadowEnabled;
  12061. /**
  12062. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12063. * the current shadow generator.
  12064. */
  12065. /**
  12066. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12067. * the current shadow generator.
  12068. */
  12069. shadowEnabled: boolean;
  12070. private _includedOnlyMeshes;
  12071. /**
  12072. * Gets the only meshes impacted by this light.
  12073. */
  12074. /**
  12075. * Sets the only meshes impacted by this light.
  12076. */
  12077. includedOnlyMeshes: AbstractMesh[];
  12078. private _excludedMeshes;
  12079. /**
  12080. * Gets the meshes not impacted by this light.
  12081. */
  12082. /**
  12083. * Sets the meshes not impacted by this light.
  12084. */
  12085. excludedMeshes: AbstractMesh[];
  12086. private _excludeWithLayerMask;
  12087. /**
  12088. * Gets the layer id use to find what meshes are not impacted by the light.
  12089. * Inactive if 0
  12090. */
  12091. /**
  12092. * Sets the layer id use to find what meshes are not impacted by the light.
  12093. * Inactive if 0
  12094. */
  12095. excludeWithLayerMask: number;
  12096. private _includeOnlyWithLayerMask;
  12097. /**
  12098. * Gets the layer id use to find what meshes are impacted by the light.
  12099. * Inactive if 0
  12100. */
  12101. /**
  12102. * Sets the layer id use to find what meshes are impacted by the light.
  12103. * Inactive if 0
  12104. */
  12105. includeOnlyWithLayerMask: number;
  12106. private _lightmapMode;
  12107. /**
  12108. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12109. */
  12110. /**
  12111. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12112. */
  12113. lightmapMode: number;
  12114. /**
  12115. * Shadow generator associted to the light.
  12116. * @hidden Internal use only.
  12117. */
  12118. _shadowGenerator: Nullable<IShadowGenerator>;
  12119. /**
  12120. * @hidden Internal use only.
  12121. */
  12122. _excludedMeshesIds: string[];
  12123. /**
  12124. * @hidden Internal use only.
  12125. */
  12126. _includedOnlyMeshesIds: string[];
  12127. /**
  12128. * The current light unifom buffer.
  12129. * @hidden Internal use only.
  12130. */
  12131. _uniformBuffer: UniformBuffer;
  12132. /**
  12133. * Creates a Light object in the scene.
  12134. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12135. * @param name The firendly name of the light
  12136. * @param scene The scene the light belongs too
  12137. */
  12138. constructor(name: string, scene: Scene);
  12139. protected abstract _buildUniformLayout(): void;
  12140. /**
  12141. * Sets the passed Effect "effect" with the Light information.
  12142. * @param effect The effect to update
  12143. * @param lightIndex The index of the light in the effect to update
  12144. * @returns The light
  12145. */
  12146. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12147. /**
  12148. * Returns the string "Light".
  12149. * @returns the class name
  12150. */
  12151. getClassName(): string;
  12152. /** @hidden */
  12153. readonly _isLight: boolean;
  12154. /**
  12155. * Converts the light information to a readable string for debug purpose.
  12156. * @param fullDetails Supports for multiple levels of logging within scene loading
  12157. * @returns the human readable light info
  12158. */
  12159. toString(fullDetails?: boolean): string;
  12160. /** @hidden */
  12161. protected _syncParentEnabledState(): void;
  12162. /**
  12163. * Set the enabled state of this node.
  12164. * @param value - the new enabled state
  12165. */
  12166. setEnabled(value: boolean): void;
  12167. /**
  12168. * Returns the Light associated shadow generator if any.
  12169. * @return the associated shadow generator.
  12170. */
  12171. getShadowGenerator(): Nullable<IShadowGenerator>;
  12172. /**
  12173. * Returns a Vector3, the absolute light position in the World.
  12174. * @returns the world space position of the light
  12175. */
  12176. getAbsolutePosition(): Vector3;
  12177. /**
  12178. * Specifies if the light will affect the passed mesh.
  12179. * @param mesh The mesh to test against the light
  12180. * @return true the mesh is affected otherwise, false.
  12181. */
  12182. canAffectMesh(mesh: AbstractMesh): boolean;
  12183. /**
  12184. * Sort function to order lights for rendering.
  12185. * @param a First Light object to compare to second.
  12186. * @param b Second Light object to compare first.
  12187. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12188. */
  12189. static CompareLightsPriority(a: Light, b: Light): number;
  12190. /**
  12191. * Releases resources associated with this node.
  12192. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12193. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12194. */
  12195. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12196. /**
  12197. * Returns the light type ID (integer).
  12198. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12199. */
  12200. getTypeID(): number;
  12201. /**
  12202. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12203. * @returns the scaled intensity in intensity mode unit
  12204. */
  12205. getScaledIntensity(): number;
  12206. /**
  12207. * Returns a new Light object, named "name", from the current one.
  12208. * @param name The name of the cloned light
  12209. * @returns the new created light
  12210. */
  12211. clone(name: string): Nullable<Light>;
  12212. /**
  12213. * Serializes the current light into a Serialization object.
  12214. * @returns the serialized object.
  12215. */
  12216. serialize(): any;
  12217. /**
  12218. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12219. * This new light is named "name" and added to the passed scene.
  12220. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12221. * @param name The friendly name of the light
  12222. * @param scene The scene the new light will belong to
  12223. * @returns the constructor function
  12224. */
  12225. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12226. /**
  12227. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12228. * @param parsedLight The JSON representation of the light
  12229. * @param scene The scene to create the parsed light in
  12230. * @returns the created light after parsing
  12231. */
  12232. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12233. private _hookArrayForExcluded;
  12234. private _hookArrayForIncludedOnly;
  12235. private _resyncMeshes;
  12236. /**
  12237. * Forces the meshes to update their light related information in their rendering used effects
  12238. * @hidden Internal Use Only
  12239. */
  12240. _markMeshesAsLightDirty(): void;
  12241. /**
  12242. * Recomputes the cached photometric scale if needed.
  12243. */
  12244. private _computePhotometricScale;
  12245. /**
  12246. * Returns the Photometric Scale according to the light type and intensity mode.
  12247. */
  12248. private _getPhotometricScale;
  12249. /**
  12250. * Reorder the light in the scene according to their defined priority.
  12251. * @hidden Internal Use Only
  12252. */
  12253. _reorderLightsInScene(): void;
  12254. /**
  12255. * Prepares the list of defines specific to the light type.
  12256. * @param defines the list of defines
  12257. * @param lightIndex defines the index of the light for the effect
  12258. */
  12259. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12260. }
  12261. }
  12262. declare module "babylonjs/Meshes/instancedMesh" {
  12263. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  12264. import { Vector3, Matrix } from "babylonjs/Maths/math";
  12265. import { Camera } from "babylonjs/Cameras/camera";
  12266. import { Node } from "babylonjs/node";
  12267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12268. import { Mesh } from "babylonjs/Meshes/mesh";
  12269. import { Material } from "babylonjs/Materials/material";
  12270. import { Skeleton } from "babylonjs/Bones/skeleton";
  12271. import { Light } from "babylonjs/Lights/light";
  12272. /**
  12273. * Creates an instance based on a source mesh.
  12274. */
  12275. export class InstancedMesh extends AbstractMesh {
  12276. private _sourceMesh;
  12277. private _currentLOD;
  12278. /** @hidden */
  12279. _indexInSourceMeshInstanceArray: number;
  12280. constructor(name: string, source: Mesh);
  12281. /**
  12282. * Returns the string "InstancedMesh".
  12283. */
  12284. getClassName(): string;
  12285. /** Gets the list of lights affecting that mesh */
  12286. readonly lightSources: Light[];
  12287. _resyncLightSources(): void;
  12288. _resyncLighSource(light: Light): void;
  12289. _removeLightSource(light: Light): void;
  12290. /**
  12291. * If the source mesh receives shadows
  12292. */
  12293. readonly receiveShadows: boolean;
  12294. /**
  12295. * The material of the source mesh
  12296. */
  12297. readonly material: Nullable<Material>;
  12298. /**
  12299. * Visibility of the source mesh
  12300. */
  12301. readonly visibility: number;
  12302. /**
  12303. * Skeleton of the source mesh
  12304. */
  12305. readonly skeleton: Nullable<Skeleton>;
  12306. /**
  12307. * Rendering ground id of the source mesh
  12308. */
  12309. renderingGroupId: number;
  12310. /**
  12311. * Returns the total number of vertices (integer).
  12312. */
  12313. getTotalVertices(): number;
  12314. /**
  12315. * Returns a positive integer : the total number of indices in this mesh geometry.
  12316. * @returns the numner of indices or zero if the mesh has no geometry.
  12317. */
  12318. getTotalIndices(): number;
  12319. /**
  12320. * The source mesh of the instance
  12321. */
  12322. readonly sourceMesh: Mesh;
  12323. /**
  12324. * Is this node ready to be used/rendered
  12325. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12326. * @return {boolean} is it ready
  12327. */
  12328. isReady(completeCheck?: boolean): boolean;
  12329. /**
  12330. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12331. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12332. * @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.
  12333. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12334. */
  12335. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12336. /**
  12337. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12338. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12339. * The `data` are either a numeric array either a Float32Array.
  12340. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12341. * 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).
  12342. * Note that a new underlying VertexBuffer object is created each call.
  12343. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12344. *
  12345. * Possible `kind` values :
  12346. * - VertexBuffer.PositionKind
  12347. * - VertexBuffer.UVKind
  12348. * - VertexBuffer.UV2Kind
  12349. * - VertexBuffer.UV3Kind
  12350. * - VertexBuffer.UV4Kind
  12351. * - VertexBuffer.UV5Kind
  12352. * - VertexBuffer.UV6Kind
  12353. * - VertexBuffer.ColorKind
  12354. * - VertexBuffer.MatricesIndicesKind
  12355. * - VertexBuffer.MatricesIndicesExtraKind
  12356. * - VertexBuffer.MatricesWeightsKind
  12357. * - VertexBuffer.MatricesWeightsExtraKind
  12358. *
  12359. * Returns the Mesh.
  12360. */
  12361. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12362. /**
  12363. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12364. * If the mesh has no geometry, it is simply returned as it is.
  12365. * The `data` are either a numeric array either a Float32Array.
  12366. * No new underlying VertexBuffer object is created.
  12367. * 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.
  12368. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12369. *
  12370. * Possible `kind` values :
  12371. * - VertexBuffer.PositionKind
  12372. * - VertexBuffer.UVKind
  12373. * - VertexBuffer.UV2Kind
  12374. * - VertexBuffer.UV3Kind
  12375. * - VertexBuffer.UV4Kind
  12376. * - VertexBuffer.UV5Kind
  12377. * - VertexBuffer.UV6Kind
  12378. * - VertexBuffer.ColorKind
  12379. * - VertexBuffer.MatricesIndicesKind
  12380. * - VertexBuffer.MatricesIndicesExtraKind
  12381. * - VertexBuffer.MatricesWeightsKind
  12382. * - VertexBuffer.MatricesWeightsExtraKind
  12383. *
  12384. * Returns the Mesh.
  12385. */
  12386. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12387. /**
  12388. * Sets the mesh indices.
  12389. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12390. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12391. * This method creates a new index buffer each call.
  12392. * Returns the Mesh.
  12393. */
  12394. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12395. /**
  12396. * Boolean : True if the mesh owns the requested kind of data.
  12397. */
  12398. isVerticesDataPresent(kind: string): boolean;
  12399. /**
  12400. * Returns an array of indices (IndicesArray).
  12401. */
  12402. getIndices(): Nullable<IndicesArray>;
  12403. readonly _positions: Nullable<Vector3[]>;
  12404. /**
  12405. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12406. * This means the mesh underlying bounding box and sphere are recomputed.
  12407. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12408. * @returns the current mesh
  12409. */
  12410. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12411. /** @hidden */
  12412. _preActivate(): InstancedMesh;
  12413. /** @hidden */
  12414. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12415. /** @hidden */
  12416. _postActivate(): void;
  12417. getWorldMatrix(): Matrix;
  12418. readonly isAnInstance: boolean;
  12419. /**
  12420. * Returns the current associated LOD AbstractMesh.
  12421. */
  12422. getLOD(camera: Camera): AbstractMesh;
  12423. /** @hidden */
  12424. _syncSubMeshes(): InstancedMesh;
  12425. /** @hidden */
  12426. _generatePointsArray(): boolean;
  12427. /**
  12428. * Creates a new InstancedMesh from the current mesh.
  12429. * - name (string) : the cloned mesh name
  12430. * - newParent (optional Node) : the optional Node to parent the clone to.
  12431. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12432. *
  12433. * Returns the clone.
  12434. */
  12435. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12436. /**
  12437. * Disposes the InstancedMesh.
  12438. * Returns nothing.
  12439. */
  12440. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12441. }
  12442. }
  12443. declare module "babylonjs/Materials/shaderMaterial" {
  12444. import { Scene } from "babylonjs/scene";
  12445. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  12446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12447. import { Mesh } from "babylonjs/Meshes/mesh";
  12448. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  12449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12450. import { Texture } from "babylonjs/Materials/Textures/texture";
  12451. import { Material } from "babylonjs/Materials/material";
  12452. /**
  12453. * Defines the options associated with the creation of a shader material.
  12454. */
  12455. export interface IShaderMaterialOptions {
  12456. /**
  12457. * Does the material work in alpha blend mode
  12458. */
  12459. needAlphaBlending: boolean;
  12460. /**
  12461. * Does the material work in alpha test mode
  12462. */
  12463. needAlphaTesting: boolean;
  12464. /**
  12465. * The list of attribute names used in the shader
  12466. */
  12467. attributes: string[];
  12468. /**
  12469. * The list of unifrom names used in the shader
  12470. */
  12471. uniforms: string[];
  12472. /**
  12473. * The list of UBO names used in the shader
  12474. */
  12475. uniformBuffers: string[];
  12476. /**
  12477. * The list of sampler names used in the shader
  12478. */
  12479. samplers: string[];
  12480. /**
  12481. * The list of defines used in the shader
  12482. */
  12483. defines: string[];
  12484. }
  12485. /**
  12486. * 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.
  12487. *
  12488. * This returned material effects how the mesh will look based on the code in the shaders.
  12489. *
  12490. * @see http://doc.babylonjs.com/how_to/shader_material
  12491. */
  12492. export class ShaderMaterial extends Material {
  12493. private _shaderPath;
  12494. private _options;
  12495. private _textures;
  12496. private _textureArrays;
  12497. private _floats;
  12498. private _ints;
  12499. private _floatsArrays;
  12500. private _colors3;
  12501. private _colors3Arrays;
  12502. private _colors4;
  12503. private _colors4Arrays;
  12504. private _vectors2;
  12505. private _vectors3;
  12506. private _vectors4;
  12507. private _matrices;
  12508. private _matrices3x3;
  12509. private _matrices2x2;
  12510. private _vectors2Arrays;
  12511. private _vectors3Arrays;
  12512. private _vectors4Arrays;
  12513. private _cachedWorldViewMatrix;
  12514. private _cachedWorldViewProjectionMatrix;
  12515. private _renderId;
  12516. /**
  12517. * Instantiate a new shader material.
  12518. * 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.
  12519. * This returned material effects how the mesh will look based on the code in the shaders.
  12520. * @see http://doc.babylonjs.com/how_to/shader_material
  12521. * @param name Define the name of the material in the scene
  12522. * @param scene Define the scene the material belongs to
  12523. * @param shaderPath Defines the route to the shader code in one of three ways:
  12524. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12525. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12526. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12527. * @param options Define the options used to create the shader
  12528. */
  12529. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12530. /**
  12531. * Gets the options used to compile the shader.
  12532. * They can be modified to trigger a new compilation
  12533. */
  12534. readonly options: IShaderMaterialOptions;
  12535. /**
  12536. * Gets the current class name of the material e.g. "ShaderMaterial"
  12537. * Mainly use in serialization.
  12538. * @returns the class name
  12539. */
  12540. getClassName(): string;
  12541. /**
  12542. * Specifies if the material will require alpha blending
  12543. * @returns a boolean specifying if alpha blending is needed
  12544. */
  12545. needAlphaBlending(): boolean;
  12546. /**
  12547. * Specifies if this material should be rendered in alpha test mode
  12548. * @returns a boolean specifying if an alpha test is needed.
  12549. */
  12550. needAlphaTesting(): boolean;
  12551. private _checkUniform;
  12552. /**
  12553. * Set a texture in the shader.
  12554. * @param name Define the name of the uniform samplers as defined in the shader
  12555. * @param texture Define the texture to bind to this sampler
  12556. * @return the material itself allowing "fluent" like uniform updates
  12557. */
  12558. setTexture(name: string, texture: Texture): ShaderMaterial;
  12559. /**
  12560. * Set a texture array in the shader.
  12561. * @param name Define the name of the uniform sampler array as defined in the shader
  12562. * @param textures Define the list of textures to bind to this sampler
  12563. * @return the material itself allowing "fluent" like uniform updates
  12564. */
  12565. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12566. /**
  12567. * Set a float in the shader.
  12568. * @param name Define the name of the uniform as defined in the shader
  12569. * @param value Define the value to give to the uniform
  12570. * @return the material itself allowing "fluent" like uniform updates
  12571. */
  12572. setFloat(name: string, value: number): ShaderMaterial;
  12573. /**
  12574. * Set a int in the shader.
  12575. * @param name Define the name of the uniform as defined in the shader
  12576. * @param value Define the value to give to the uniform
  12577. * @return the material itself allowing "fluent" like uniform updates
  12578. */
  12579. setInt(name: string, value: number): ShaderMaterial;
  12580. /**
  12581. * Set an array of floats in the shader.
  12582. * @param name Define the name of the uniform as defined in the shader
  12583. * @param value Define the value to give to the uniform
  12584. * @return the material itself allowing "fluent" like uniform updates
  12585. */
  12586. setFloats(name: string, value: number[]): ShaderMaterial;
  12587. /**
  12588. * Set a vec3 in the shader from a Color3.
  12589. * @param name Define the name of the uniform as defined in the shader
  12590. * @param value Define the value to give to the uniform
  12591. * @return the material itself allowing "fluent" like uniform updates
  12592. */
  12593. setColor3(name: string, value: Color3): ShaderMaterial;
  12594. /**
  12595. * Set a vec3 array in the shader from a Color3 array.
  12596. * @param name Define the name of the uniform as defined in the shader
  12597. * @param value Define the value to give to the uniform
  12598. * @return the material itself allowing "fluent" like uniform updates
  12599. */
  12600. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12601. /**
  12602. * Set a vec4 in the shader from a Color4.
  12603. * @param name Define the name of the uniform as defined in the shader
  12604. * @param value Define the value to give to the uniform
  12605. * @return the material itself allowing "fluent" like uniform updates
  12606. */
  12607. setColor4(name: string, value: Color4): ShaderMaterial;
  12608. /**
  12609. * Set a vec4 array in the shader from a Color4 array.
  12610. * @param name Define the name of the uniform as defined in the shader
  12611. * @param value Define the value to give to the uniform
  12612. * @return the material itself allowing "fluent" like uniform updates
  12613. */
  12614. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12615. /**
  12616. * Set a vec2 in the shader from a Vector2.
  12617. * @param name Define the name of the uniform as defined in the shader
  12618. * @param value Define the value to give to the uniform
  12619. * @return the material itself allowing "fluent" like uniform updates
  12620. */
  12621. setVector2(name: string, value: Vector2): ShaderMaterial;
  12622. /**
  12623. * Set a vec3 in the shader from a Vector3.
  12624. * @param name Define the name of the uniform as defined in the shader
  12625. * @param value Define the value to give to the uniform
  12626. * @return the material itself allowing "fluent" like uniform updates
  12627. */
  12628. setVector3(name: string, value: Vector3): ShaderMaterial;
  12629. /**
  12630. * Set a vec4 in the shader from a Vector4.
  12631. * @param name Define the name of the uniform as defined in the shader
  12632. * @param value Define the value to give to the uniform
  12633. * @return the material itself allowing "fluent" like uniform updates
  12634. */
  12635. setVector4(name: string, value: Vector4): ShaderMaterial;
  12636. /**
  12637. * Set a mat4 in the shader from a Matrix.
  12638. * @param name Define the name of the uniform as defined in the shader
  12639. * @param value Define the value to give to the uniform
  12640. * @return the material itself allowing "fluent" like uniform updates
  12641. */
  12642. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12643. /**
  12644. * Set a mat3 in the shader from a Float32Array.
  12645. * @param name Define the name of the uniform as defined in the shader
  12646. * @param value Define the value to give to the uniform
  12647. * @return the material itself allowing "fluent" like uniform updates
  12648. */
  12649. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12650. /**
  12651. * Set a mat2 in the shader from a Float32Array.
  12652. * @param name Define the name of the uniform as defined in the shader
  12653. * @param value Define the value to give to the uniform
  12654. * @return the material itself allowing "fluent" like uniform updates
  12655. */
  12656. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12657. /**
  12658. * Set a vec2 array in the shader from a number array.
  12659. * @param name Define the name of the uniform as defined in the shader
  12660. * @param value Define the value to give to the uniform
  12661. * @return the material itself allowing "fluent" like uniform updates
  12662. */
  12663. setArray2(name: string, value: number[]): ShaderMaterial;
  12664. /**
  12665. * Set a vec3 array in the shader from a number array.
  12666. * @param name Define the name of the uniform as defined in the shader
  12667. * @param value Define the value to give to the uniform
  12668. * @return the material itself allowing "fluent" like uniform updates
  12669. */
  12670. setArray3(name: string, value: number[]): ShaderMaterial;
  12671. /**
  12672. * Set a vec4 array in the shader from a number array.
  12673. * @param name Define the name of the uniform as defined in the shader
  12674. * @param value Define the value to give to the uniform
  12675. * @return the material itself allowing "fluent" like uniform updates
  12676. */
  12677. setArray4(name: string, value: number[]): ShaderMaterial;
  12678. private _checkCache;
  12679. /**
  12680. * Specifies that the submesh is ready to be used
  12681. * @param mesh defines the mesh to check
  12682. * @param subMesh defines which submesh to check
  12683. * @param useInstances specifies that instances should be used
  12684. * @returns a boolean indicating that the submesh is ready or not
  12685. */
  12686. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12687. /**
  12688. * Checks if the material is ready to render the requested mesh
  12689. * @param mesh Define the mesh to render
  12690. * @param useInstances Define whether or not the material is used with instances
  12691. * @returns true if ready, otherwise false
  12692. */
  12693. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12694. /**
  12695. * Binds the world matrix to the material
  12696. * @param world defines the world transformation matrix
  12697. */
  12698. bindOnlyWorldMatrix(world: Matrix): void;
  12699. /**
  12700. * Binds the material to the mesh
  12701. * @param world defines the world transformation matrix
  12702. * @param mesh defines the mesh to bind the material to
  12703. */
  12704. bind(world: Matrix, mesh?: Mesh): void;
  12705. /**
  12706. * Gets the active textures from the material
  12707. * @returns an array of textures
  12708. */
  12709. getActiveTextures(): BaseTexture[];
  12710. /**
  12711. * Specifies if the material uses a texture
  12712. * @param texture defines the texture to check against the material
  12713. * @returns a boolean specifying if the material uses the texture
  12714. */
  12715. hasTexture(texture: BaseTexture): boolean;
  12716. /**
  12717. * Makes a duplicate of the material, and gives it a new name
  12718. * @param name defines the new name for the duplicated material
  12719. * @returns the cloned material
  12720. */
  12721. clone(name: string): ShaderMaterial;
  12722. /**
  12723. * Disposes the material
  12724. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12725. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12726. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12727. */
  12728. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12729. /**
  12730. * Serializes this material in a JSON representation
  12731. * @returns the serialized material object
  12732. */
  12733. serialize(): any;
  12734. /**
  12735. * Creates a shader material from parsed shader material data
  12736. * @param source defines the JSON represnetation of the material
  12737. * @param scene defines the hosting scene
  12738. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12739. * @returns a new material
  12740. */
  12741. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12742. }
  12743. }
  12744. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  12745. /** @hidden */
  12746. export var clipPlaneFragmentDeclaration: {
  12747. name: string;
  12748. shader: string;
  12749. };
  12750. }
  12751. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  12752. /** @hidden */
  12753. export var clipPlaneFragment: {
  12754. name: string;
  12755. shader: string;
  12756. };
  12757. }
  12758. declare module "babylonjs/Shaders/color.fragment" {
  12759. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12760. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12761. /** @hidden */
  12762. export var colorPixelShader: {
  12763. name: string;
  12764. shader: string;
  12765. };
  12766. }
  12767. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  12768. /** @hidden */
  12769. export var clipPlaneVertexDeclaration: {
  12770. name: string;
  12771. shader: string;
  12772. };
  12773. }
  12774. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  12775. /** @hidden */
  12776. export var clipPlaneVertex: {
  12777. name: string;
  12778. shader: string;
  12779. };
  12780. }
  12781. declare module "babylonjs/Shaders/color.vertex" {
  12782. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  12783. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12784. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  12785. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  12786. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  12787. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12788. /** @hidden */
  12789. export var colorVertexShader: {
  12790. name: string;
  12791. shader: string;
  12792. };
  12793. }
  12794. declare module "babylonjs/Meshes/linesMesh" {
  12795. import { Nullable } from "babylonjs/types";
  12796. import { Scene } from "babylonjs/scene";
  12797. import { Color3 } from "babylonjs/Maths/math";
  12798. import { Node } from "babylonjs/node";
  12799. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12800. import { Mesh } from "babylonjs/Meshes/mesh";
  12801. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  12802. import { Effect } from "babylonjs/Materials/effect";
  12803. import { Material } from "babylonjs/Materials/material";
  12804. import "babylonjs/Shaders/color.fragment";
  12805. import "babylonjs/Shaders/color.vertex";
  12806. /**
  12807. * Line mesh
  12808. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12809. */
  12810. export class LinesMesh extends Mesh {
  12811. /**
  12812. * If vertex color should be applied to the mesh
  12813. */
  12814. readonly useVertexColor?: boolean | undefined;
  12815. /**
  12816. * If vertex alpha should be applied to the mesh
  12817. */
  12818. readonly useVertexAlpha?: boolean | undefined;
  12819. /**
  12820. * Color of the line (Default: White)
  12821. */
  12822. color: Color3;
  12823. /**
  12824. * Alpha of the line (Default: 1)
  12825. */
  12826. alpha: number;
  12827. /**
  12828. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12829. * This margin is expressed in world space coordinates, so its value may vary.
  12830. * Default value is 0.1
  12831. */
  12832. intersectionThreshold: number;
  12833. private _colorShader;
  12834. private color4;
  12835. /**
  12836. * Creates a new LinesMesh
  12837. * @param name defines the name
  12838. * @param scene defines the hosting scene
  12839. * @param parent defines the parent mesh if any
  12840. * @param source defines the optional source LinesMesh used to clone data from
  12841. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12842. * When false, achieved by calling a clone(), also passing False.
  12843. * This will make creation of children, recursive.
  12844. * @param useVertexColor defines if this LinesMesh supports vertex color
  12845. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12846. */
  12847. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12848. /**
  12849. * If vertex color should be applied to the mesh
  12850. */
  12851. useVertexColor?: boolean | undefined,
  12852. /**
  12853. * If vertex alpha should be applied to the mesh
  12854. */
  12855. useVertexAlpha?: boolean | undefined);
  12856. private _addClipPlaneDefine;
  12857. private _removeClipPlaneDefine;
  12858. isReady(): boolean;
  12859. /**
  12860. * Returns the string "LineMesh"
  12861. */
  12862. getClassName(): string;
  12863. /**
  12864. * @hidden
  12865. */
  12866. /**
  12867. * @hidden
  12868. */
  12869. material: Material;
  12870. /**
  12871. * @hidden
  12872. */
  12873. readonly checkCollisions: boolean;
  12874. /** @hidden */
  12875. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12876. /** @hidden */
  12877. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12878. /**
  12879. * Disposes of the line mesh
  12880. * @param doNotRecurse If children should be disposed
  12881. */
  12882. dispose(doNotRecurse?: boolean): void;
  12883. /**
  12884. * Returns a new LineMesh object cloned from the current one.
  12885. */
  12886. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12887. /**
  12888. * Creates a new InstancedLinesMesh object from the mesh model.
  12889. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12890. * @param name defines the name of the new instance
  12891. * @returns a new InstancedLinesMesh
  12892. */
  12893. createInstance(name: string): InstancedLinesMesh;
  12894. }
  12895. /**
  12896. * Creates an instance based on a source LinesMesh
  12897. */
  12898. export class InstancedLinesMesh extends InstancedMesh {
  12899. /**
  12900. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12901. * This margin is expressed in world space coordinates, so its value may vary.
  12902. * Initilized with the intersectionThreshold value of the source LinesMesh
  12903. */
  12904. intersectionThreshold: number;
  12905. constructor(name: string, source: LinesMesh);
  12906. /**
  12907. * Returns the string "InstancedLinesMesh".
  12908. */
  12909. getClassName(): string;
  12910. }
  12911. }
  12912. declare module "babylonjs/Meshes/groundMesh" {
  12913. import { Scene } from "babylonjs/scene";
  12914. import { Vector3 } from "babylonjs/Maths/math";
  12915. import { Mesh } from "babylonjs/Meshes/mesh";
  12916. /**
  12917. * Mesh representing the gorund
  12918. */
  12919. export class GroundMesh extends Mesh {
  12920. /** If octree should be generated */
  12921. generateOctree: boolean;
  12922. private _heightQuads;
  12923. /** @hidden */
  12924. _subdivisionsX: number;
  12925. /** @hidden */
  12926. _subdivisionsY: number;
  12927. /** @hidden */
  12928. _width: number;
  12929. /** @hidden */
  12930. _height: number;
  12931. /** @hidden */
  12932. _minX: number;
  12933. /** @hidden */
  12934. _maxX: number;
  12935. /** @hidden */
  12936. _minZ: number;
  12937. /** @hidden */
  12938. _maxZ: number;
  12939. constructor(name: string, scene: Scene);
  12940. /**
  12941. * "GroundMesh"
  12942. * @returns "GroundMesh"
  12943. */
  12944. getClassName(): string;
  12945. /**
  12946. * The minimum of x and y subdivisions
  12947. */
  12948. readonly subdivisions: number;
  12949. /**
  12950. * X subdivisions
  12951. */
  12952. readonly subdivisionsX: number;
  12953. /**
  12954. * Y subdivisions
  12955. */
  12956. readonly subdivisionsY: number;
  12957. /**
  12958. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12959. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12960. * @param chunksCount the number of subdivisions for x and y
  12961. * @param octreeBlocksSize (Default: 32)
  12962. */
  12963. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12964. /**
  12965. * Returns a height (y) value in the Worl system :
  12966. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12967. * @param x x coordinate
  12968. * @param z z coordinate
  12969. * @returns the ground y position if (x, z) are outside the ground surface.
  12970. */
  12971. getHeightAtCoordinates(x: number, z: number): number;
  12972. /**
  12973. * Returns a normalized vector (Vector3) orthogonal to the ground
  12974. * at the ground coordinates (x, z) expressed in the World system.
  12975. * @param x x coordinate
  12976. * @param z z coordinate
  12977. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12978. */
  12979. getNormalAtCoordinates(x: number, z: number): Vector3;
  12980. /**
  12981. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12982. * at the ground coordinates (x, z) expressed in the World system.
  12983. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12984. * @param x x coordinate
  12985. * @param z z coordinate
  12986. * @param ref vector to store the result
  12987. * @returns the GroundMesh.
  12988. */
  12989. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12990. /**
  12991. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12992. * if the ground has been updated.
  12993. * This can be used in the render loop.
  12994. * @returns the GroundMesh.
  12995. */
  12996. updateCoordinateHeights(): GroundMesh;
  12997. private _getFacetAt;
  12998. private _initHeightQuads;
  12999. private _computeHeightQuads;
  13000. /**
  13001. * Serializes this ground mesh
  13002. * @param serializationObject object to write serialization to
  13003. */
  13004. serialize(serializationObject: any): void;
  13005. /**
  13006. * Parses a serialized ground mesh
  13007. * @param parsedMesh the serialized mesh
  13008. * @param scene the scene to create the ground mesh in
  13009. * @returns the created ground mesh
  13010. */
  13011. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  13012. }
  13013. }
  13014. declare module "babylonjs/Physics/physicsJoint" {
  13015. import { Vector3 } from "babylonjs/Maths/math";
  13016. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  13017. /**
  13018. * Interface for Physics-Joint data
  13019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13020. */
  13021. export interface PhysicsJointData {
  13022. /**
  13023. * The main pivot of the joint
  13024. */
  13025. mainPivot?: Vector3;
  13026. /**
  13027. * The connected pivot of the joint
  13028. */
  13029. connectedPivot?: Vector3;
  13030. /**
  13031. * The main axis of the joint
  13032. */
  13033. mainAxis?: Vector3;
  13034. /**
  13035. * The connected axis of the joint
  13036. */
  13037. connectedAxis?: Vector3;
  13038. /**
  13039. * The collision of the joint
  13040. */
  13041. collision?: boolean;
  13042. /**
  13043. * Native Oimo/Cannon/Energy data
  13044. */
  13045. nativeParams?: any;
  13046. }
  13047. /**
  13048. * This is a holder class for the physics joint created by the physics plugin
  13049. * It holds a set of functions to control the underlying joint
  13050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13051. */
  13052. export class PhysicsJoint {
  13053. /**
  13054. * The type of the physics joint
  13055. */
  13056. type: number;
  13057. /**
  13058. * The data for the physics joint
  13059. */
  13060. jointData: PhysicsJointData;
  13061. private _physicsJoint;
  13062. protected _physicsPlugin: IPhysicsEnginePlugin;
  13063. /**
  13064. * Initializes the physics joint
  13065. * @param type The type of the physics joint
  13066. * @param jointData The data for the physics joint
  13067. */
  13068. constructor(
  13069. /**
  13070. * The type of the physics joint
  13071. */
  13072. type: number,
  13073. /**
  13074. * The data for the physics joint
  13075. */
  13076. jointData: PhysicsJointData);
  13077. /**
  13078. * Gets the physics joint
  13079. */
  13080. /**
  13081. * Sets the physics joint
  13082. */
  13083. physicsJoint: any;
  13084. /**
  13085. * Sets the physics plugin
  13086. */
  13087. physicsPlugin: IPhysicsEnginePlugin;
  13088. /**
  13089. * Execute a function that is physics-plugin specific.
  13090. * @param {Function} func the function that will be executed.
  13091. * It accepts two parameters: the physics world and the physics joint
  13092. */
  13093. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  13094. /**
  13095. * Distance-Joint type
  13096. */
  13097. static DistanceJoint: number;
  13098. /**
  13099. * Hinge-Joint type
  13100. */
  13101. static HingeJoint: number;
  13102. /**
  13103. * Ball-and-Socket joint type
  13104. */
  13105. static BallAndSocketJoint: number;
  13106. /**
  13107. * Wheel-Joint type
  13108. */
  13109. static WheelJoint: number;
  13110. /**
  13111. * Slider-Joint type
  13112. */
  13113. static SliderJoint: number;
  13114. /**
  13115. * Prismatic-Joint type
  13116. */
  13117. static PrismaticJoint: number;
  13118. /**
  13119. * Universal-Joint type
  13120. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  13121. */
  13122. static UniversalJoint: number;
  13123. /**
  13124. * Hinge-Joint 2 type
  13125. */
  13126. static Hinge2Joint: number;
  13127. /**
  13128. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  13129. */
  13130. static PointToPointJoint: number;
  13131. /**
  13132. * Spring-Joint type
  13133. */
  13134. static SpringJoint: number;
  13135. /**
  13136. * Lock-Joint type
  13137. */
  13138. static LockJoint: number;
  13139. }
  13140. /**
  13141. * A class representing a physics distance joint
  13142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13143. */
  13144. export class DistanceJoint extends PhysicsJoint {
  13145. /**
  13146. *
  13147. * @param jointData The data for the Distance-Joint
  13148. */
  13149. constructor(jointData: DistanceJointData);
  13150. /**
  13151. * Update the predefined distance.
  13152. * @param maxDistance The maximum preferred distance
  13153. * @param minDistance The minimum preferred distance
  13154. */
  13155. updateDistance(maxDistance: number, minDistance?: number): void;
  13156. }
  13157. /**
  13158. * Represents a Motor-Enabled Joint
  13159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13160. */
  13161. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  13162. /**
  13163. * Initializes the Motor-Enabled Joint
  13164. * @param type The type of the joint
  13165. * @param jointData The physica joint data for the joint
  13166. */
  13167. constructor(type: number, jointData: PhysicsJointData);
  13168. /**
  13169. * Set the motor values.
  13170. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13171. * @param force the force to apply
  13172. * @param maxForce max force for this motor.
  13173. */
  13174. setMotor(force?: number, maxForce?: number): void;
  13175. /**
  13176. * Set the motor's limits.
  13177. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13178. * @param upperLimit The upper limit of the motor
  13179. * @param lowerLimit The lower limit of the motor
  13180. */
  13181. setLimit(upperLimit: number, lowerLimit?: number): void;
  13182. }
  13183. /**
  13184. * This class represents a single physics Hinge-Joint
  13185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13186. */
  13187. export class HingeJoint extends MotorEnabledJoint {
  13188. /**
  13189. * Initializes the Hinge-Joint
  13190. * @param jointData The joint data for the Hinge-Joint
  13191. */
  13192. constructor(jointData: PhysicsJointData);
  13193. /**
  13194. * Set the motor values.
  13195. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13196. * @param {number} force the force to apply
  13197. * @param {number} maxForce max force for this motor.
  13198. */
  13199. setMotor(force?: number, maxForce?: number): void;
  13200. /**
  13201. * Set the motor's limits.
  13202. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13203. * @param upperLimit The upper limit of the motor
  13204. * @param lowerLimit The lower limit of the motor
  13205. */
  13206. setLimit(upperLimit: number, lowerLimit?: number): void;
  13207. }
  13208. /**
  13209. * This class represents a dual hinge physics joint (same as wheel joint)
  13210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13211. */
  13212. export class Hinge2Joint extends MotorEnabledJoint {
  13213. /**
  13214. * Initializes the Hinge2-Joint
  13215. * @param jointData The joint data for the Hinge2-Joint
  13216. */
  13217. constructor(jointData: PhysicsJointData);
  13218. /**
  13219. * Set the motor values.
  13220. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13221. * @param {number} targetSpeed the speed the motor is to reach
  13222. * @param {number} maxForce max force for this motor.
  13223. * @param {motorIndex} the motor's index, 0 or 1.
  13224. */
  13225. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13226. /**
  13227. * Set the motor limits.
  13228. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13229. * @param {number} upperLimit the upper limit
  13230. * @param {number} lowerLimit lower limit
  13231. * @param {motorIndex} the motor's index, 0 or 1.
  13232. */
  13233. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13234. }
  13235. /**
  13236. * Interface for a motor enabled joint
  13237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13238. */
  13239. export interface IMotorEnabledJoint {
  13240. /**
  13241. * Physics joint
  13242. */
  13243. physicsJoint: any;
  13244. /**
  13245. * Sets the motor of the motor-enabled joint
  13246. * @param force The force of the motor
  13247. * @param maxForce The maximum force of the motor
  13248. * @param motorIndex The index of the motor
  13249. */
  13250. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13251. /**
  13252. * Sets the limit of the motor
  13253. * @param upperLimit The upper limit of the motor
  13254. * @param lowerLimit The lower limit of the motor
  13255. * @param motorIndex The index of the motor
  13256. */
  13257. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13258. }
  13259. /**
  13260. * Joint data for a Distance-Joint
  13261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13262. */
  13263. export interface DistanceJointData extends PhysicsJointData {
  13264. /**
  13265. * Max distance the 2 joint objects can be apart
  13266. */
  13267. maxDistance: number;
  13268. }
  13269. /**
  13270. * Joint data from a spring joint
  13271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13272. */
  13273. export interface SpringJointData extends PhysicsJointData {
  13274. /**
  13275. * Length of the spring
  13276. */
  13277. length: number;
  13278. /**
  13279. * Stiffness of the spring
  13280. */
  13281. stiffness: number;
  13282. /**
  13283. * Damping of the spring
  13284. */
  13285. damping: number;
  13286. /** this callback will be called when applying the force to the impostors. */
  13287. forceApplicationCallback: () => void;
  13288. }
  13289. }
  13290. declare module "babylonjs/Physics/physicsRaycastResult" {
  13291. import { Vector3 } from "babylonjs/Maths/math";
  13292. /**
  13293. * Holds the data for the raycast result
  13294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13295. */
  13296. export class PhysicsRaycastResult {
  13297. private _hasHit;
  13298. private _hitDistance;
  13299. private _hitNormalWorld;
  13300. private _hitPointWorld;
  13301. private _rayFromWorld;
  13302. private _rayToWorld;
  13303. /**
  13304. * Gets if there was a hit
  13305. */
  13306. readonly hasHit: boolean;
  13307. /**
  13308. * Gets the distance from the hit
  13309. */
  13310. readonly hitDistance: number;
  13311. /**
  13312. * Gets the hit normal/direction in the world
  13313. */
  13314. readonly hitNormalWorld: Vector3;
  13315. /**
  13316. * Gets the hit point in the world
  13317. */
  13318. readonly hitPointWorld: Vector3;
  13319. /**
  13320. * Gets the ray "start point" of the ray in the world
  13321. */
  13322. readonly rayFromWorld: Vector3;
  13323. /**
  13324. * Gets the ray "end point" of the ray in the world
  13325. */
  13326. readonly rayToWorld: Vector3;
  13327. /**
  13328. * Sets the hit data (normal & point in world space)
  13329. * @param hitNormalWorld defines the normal in world space
  13330. * @param hitPointWorld defines the point in world space
  13331. */
  13332. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13333. /**
  13334. * Sets the distance from the start point to the hit point
  13335. * @param distance
  13336. */
  13337. setHitDistance(distance: number): void;
  13338. /**
  13339. * Calculates the distance manually
  13340. */
  13341. calculateHitDistance(): void;
  13342. /**
  13343. * Resets all the values to default
  13344. * @param from The from point on world space
  13345. * @param to The to point on world space
  13346. */
  13347. reset(from?: Vector3, to?: Vector3): void;
  13348. }
  13349. /**
  13350. * Interface for the size containing width and height
  13351. */
  13352. interface IXYZ {
  13353. /**
  13354. * X
  13355. */
  13356. x: number;
  13357. /**
  13358. * Y
  13359. */
  13360. y: number;
  13361. /**
  13362. * Z
  13363. */
  13364. z: number;
  13365. }
  13366. }
  13367. declare module "babylonjs/Physics/IPhysicsEngine" {
  13368. import { Nullable } from "babylonjs/types";
  13369. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  13370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13371. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  13372. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  13373. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  13374. /**
  13375. * Interface used to describe a physics joint
  13376. */
  13377. export interface PhysicsImpostorJoint {
  13378. /** Defines the main impostor to which the joint is linked */
  13379. mainImpostor: PhysicsImpostor;
  13380. /** Defines the impostor that is connected to the main impostor using this joint */
  13381. connectedImpostor: PhysicsImpostor;
  13382. /** Defines the joint itself */
  13383. joint: PhysicsJoint;
  13384. }
  13385. /** @hidden */
  13386. export interface IPhysicsEnginePlugin {
  13387. world: any;
  13388. name: string;
  13389. setGravity(gravity: Vector3): void;
  13390. setTimeStep(timeStep: number): void;
  13391. getTimeStep(): number;
  13392. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13393. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13394. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13395. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13396. removePhysicsBody(impostor: PhysicsImpostor): void;
  13397. generateJoint(joint: PhysicsImpostorJoint): void;
  13398. removeJoint(joint: PhysicsImpostorJoint): void;
  13399. isSupported(): boolean;
  13400. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13401. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13402. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13403. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13404. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13405. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13406. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13407. getBodyMass(impostor: PhysicsImpostor): number;
  13408. getBodyFriction(impostor: PhysicsImpostor): number;
  13409. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13410. getBodyRestitution(impostor: PhysicsImpostor): number;
  13411. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13412. getBodyPressure?(impostor: PhysicsImpostor): number;
  13413. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13414. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13415. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13416. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13417. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13418. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13419. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13420. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13421. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13422. sleepBody(impostor: PhysicsImpostor): void;
  13423. wakeUpBody(impostor: PhysicsImpostor): void;
  13424. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13425. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13426. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13427. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13428. getRadius(impostor: PhysicsImpostor): number;
  13429. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13430. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13431. dispose(): void;
  13432. }
  13433. /**
  13434. * Interface used to define a physics engine
  13435. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13436. */
  13437. export interface IPhysicsEngine {
  13438. /**
  13439. * Gets the gravity vector used by the simulation
  13440. */
  13441. gravity: Vector3;
  13442. /**
  13443. * Sets the gravity vector used by the simulation
  13444. * @param gravity defines the gravity vector to use
  13445. */
  13446. setGravity(gravity: Vector3): void;
  13447. /**
  13448. * Set the time step of the physics engine.
  13449. * Default is 1/60.
  13450. * To slow it down, enter 1/600 for example.
  13451. * To speed it up, 1/30
  13452. * @param newTimeStep the new timestep to apply to this world.
  13453. */
  13454. setTimeStep(newTimeStep: number): void;
  13455. /**
  13456. * Get the time step of the physics engine.
  13457. * @returns the current time step
  13458. */
  13459. getTimeStep(): number;
  13460. /**
  13461. * Release all resources
  13462. */
  13463. dispose(): void;
  13464. /**
  13465. * Gets the name of the current physics plugin
  13466. * @returns the name of the plugin
  13467. */
  13468. getPhysicsPluginName(): string;
  13469. /**
  13470. * Adding a new impostor for the impostor tracking.
  13471. * This will be done by the impostor itself.
  13472. * @param impostor the impostor to add
  13473. */
  13474. addImpostor(impostor: PhysicsImpostor): void;
  13475. /**
  13476. * Remove an impostor from the engine.
  13477. * This impostor and its mesh will not longer be updated by the physics engine.
  13478. * @param impostor the impostor to remove
  13479. */
  13480. removeImpostor(impostor: PhysicsImpostor): void;
  13481. /**
  13482. * Add a joint to the physics engine
  13483. * @param mainImpostor defines the main impostor to which the joint is added.
  13484. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13485. * @param joint defines the joint that will connect both impostors.
  13486. */
  13487. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13488. /**
  13489. * Removes a joint from the simulation
  13490. * @param mainImpostor defines the impostor used with the joint
  13491. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13492. * @param joint defines the joint to remove
  13493. */
  13494. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13495. /**
  13496. * Gets the current plugin used to run the simulation
  13497. * @returns current plugin
  13498. */
  13499. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13500. /**
  13501. * Gets the list of physic impostors
  13502. * @returns an array of PhysicsImpostor
  13503. */
  13504. getImpostors(): Array<PhysicsImpostor>;
  13505. /**
  13506. * Gets the impostor for a physics enabled object
  13507. * @param object defines the object impersonated by the impostor
  13508. * @returns the PhysicsImpostor or null if not found
  13509. */
  13510. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13511. /**
  13512. * Gets the impostor for a physics body object
  13513. * @param body defines physics body used by the impostor
  13514. * @returns the PhysicsImpostor or null if not found
  13515. */
  13516. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13517. /**
  13518. * Does a raycast in the physics world
  13519. * @param from when should the ray start?
  13520. * @param to when should the ray end?
  13521. * @returns PhysicsRaycastResult
  13522. */
  13523. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13524. /**
  13525. * Called by the scene. No need to call it.
  13526. * @param delta defines the timespam between frames
  13527. */
  13528. _step(delta: number): void;
  13529. }
  13530. }
  13531. declare module "babylonjs/Physics/physicsImpostor" {
  13532. import { Nullable, IndicesArray } from "babylonjs/types";
  13533. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  13534. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13536. import { Scene } from "babylonjs/scene";
  13537. import { Bone } from "babylonjs/Bones/bone";
  13538. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  13539. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  13540. /**
  13541. * The interface for the physics imposter parameters
  13542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13543. */
  13544. export interface PhysicsImpostorParameters {
  13545. /**
  13546. * The mass of the physics imposter
  13547. */
  13548. mass: number;
  13549. /**
  13550. * The friction of the physics imposter
  13551. */
  13552. friction?: number;
  13553. /**
  13554. * The coefficient of restitution of the physics imposter
  13555. */
  13556. restitution?: number;
  13557. /**
  13558. * The native options of the physics imposter
  13559. */
  13560. nativeOptions?: any;
  13561. /**
  13562. * Specifies if the parent should be ignored
  13563. */
  13564. ignoreParent?: boolean;
  13565. /**
  13566. * Specifies if bi-directional transformations should be disabled
  13567. */
  13568. disableBidirectionalTransformation?: boolean;
  13569. /**
  13570. * The pressure inside the physics imposter, soft object only
  13571. */
  13572. pressure?: number;
  13573. /**
  13574. * The stiffness the physics imposter, soft object only
  13575. */
  13576. stiffness?: number;
  13577. /**
  13578. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13579. */
  13580. velocityIterations?: number;
  13581. /**
  13582. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13583. */
  13584. positionIterations?: number;
  13585. /**
  13586. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13587. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13588. * Add to fix multiple points
  13589. */
  13590. fixedPoints?: number;
  13591. /**
  13592. * The collision margin around a soft object
  13593. */
  13594. margin?: number;
  13595. /**
  13596. * The collision margin around a soft object
  13597. */
  13598. damping?: number;
  13599. /**
  13600. * The path for a rope based on an extrusion
  13601. */
  13602. path?: any;
  13603. /**
  13604. * The shape of an extrusion used for a rope based on an extrusion
  13605. */
  13606. shape?: any;
  13607. }
  13608. /**
  13609. * Interface for a physics-enabled object
  13610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13611. */
  13612. export interface IPhysicsEnabledObject {
  13613. /**
  13614. * The position of the physics-enabled object
  13615. */
  13616. position: Vector3;
  13617. /**
  13618. * The rotation of the physics-enabled object
  13619. */
  13620. rotationQuaternion: Nullable<Quaternion>;
  13621. /**
  13622. * The scale of the physics-enabled object
  13623. */
  13624. scaling: Vector3;
  13625. /**
  13626. * The rotation of the physics-enabled object
  13627. */
  13628. rotation?: Vector3;
  13629. /**
  13630. * The parent of the physics-enabled object
  13631. */
  13632. parent?: any;
  13633. /**
  13634. * The bounding info of the physics-enabled object
  13635. * @returns The bounding info of the physics-enabled object
  13636. */
  13637. getBoundingInfo(): BoundingInfo;
  13638. /**
  13639. * Computes the world matrix
  13640. * @param force Specifies if the world matrix should be computed by force
  13641. * @returns A world matrix
  13642. */
  13643. computeWorldMatrix(force: boolean): Matrix;
  13644. /**
  13645. * Gets the world matrix
  13646. * @returns A world matrix
  13647. */
  13648. getWorldMatrix?(): Matrix;
  13649. /**
  13650. * Gets the child meshes
  13651. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13652. * @returns An array of abstract meshes
  13653. */
  13654. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13655. /**
  13656. * Gets the vertex data
  13657. * @param kind The type of vertex data
  13658. * @returns A nullable array of numbers, or a float32 array
  13659. */
  13660. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13661. /**
  13662. * Gets the indices from the mesh
  13663. * @returns A nullable array of index arrays
  13664. */
  13665. getIndices?(): Nullable<IndicesArray>;
  13666. /**
  13667. * Gets the scene from the mesh
  13668. * @returns the indices array or null
  13669. */
  13670. getScene?(): Scene;
  13671. /**
  13672. * Gets the absolute position from the mesh
  13673. * @returns the absolute position
  13674. */
  13675. getAbsolutePosition(): Vector3;
  13676. /**
  13677. * Gets the absolute pivot point from the mesh
  13678. * @returns the absolute pivot point
  13679. */
  13680. getAbsolutePivotPoint(): Vector3;
  13681. /**
  13682. * Rotates the mesh
  13683. * @param axis The axis of rotation
  13684. * @param amount The amount of rotation
  13685. * @param space The space of the rotation
  13686. * @returns The rotation transform node
  13687. */
  13688. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13689. /**
  13690. * Translates the mesh
  13691. * @param axis The axis of translation
  13692. * @param distance The distance of translation
  13693. * @param space The space of the translation
  13694. * @returns The transform node
  13695. */
  13696. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13697. /**
  13698. * Sets the absolute position of the mesh
  13699. * @param absolutePosition The absolute position of the mesh
  13700. * @returns The transform node
  13701. */
  13702. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13703. /**
  13704. * Gets the class name of the mesh
  13705. * @returns The class name
  13706. */
  13707. getClassName(): string;
  13708. }
  13709. /**
  13710. * Represents a physics imposter
  13711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13712. */
  13713. export class PhysicsImpostor {
  13714. /**
  13715. * The physics-enabled object used as the physics imposter
  13716. */
  13717. object: IPhysicsEnabledObject;
  13718. /**
  13719. * The type of the physics imposter
  13720. */
  13721. type: number;
  13722. private _options;
  13723. private _scene?;
  13724. /**
  13725. * The default object size of the imposter
  13726. */
  13727. static DEFAULT_OBJECT_SIZE: Vector3;
  13728. /**
  13729. * The identity quaternion of the imposter
  13730. */
  13731. static IDENTITY_QUATERNION: Quaternion;
  13732. /** @hidden */
  13733. _pluginData: any;
  13734. private _physicsEngine;
  13735. private _physicsBody;
  13736. private _bodyUpdateRequired;
  13737. private _onBeforePhysicsStepCallbacks;
  13738. private _onAfterPhysicsStepCallbacks;
  13739. /** @hidden */
  13740. _onPhysicsCollideCallbacks: Array<{
  13741. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13742. otherImpostors: Array<PhysicsImpostor>;
  13743. }>;
  13744. private _deltaPosition;
  13745. private _deltaRotation;
  13746. private _deltaRotationConjugated;
  13747. /** @hidden */
  13748. _isFromLine: boolean;
  13749. private _parent;
  13750. private _isDisposed;
  13751. private static _tmpVecs;
  13752. private static _tmpQuat;
  13753. /**
  13754. * Specifies if the physics imposter is disposed
  13755. */
  13756. readonly isDisposed: boolean;
  13757. /**
  13758. * Gets the mass of the physics imposter
  13759. */
  13760. mass: number;
  13761. /**
  13762. * Gets the coefficient of friction
  13763. */
  13764. /**
  13765. * Sets the coefficient of friction
  13766. */
  13767. friction: number;
  13768. /**
  13769. * Gets the coefficient of restitution
  13770. */
  13771. /**
  13772. * Sets the coefficient of restitution
  13773. */
  13774. restitution: number;
  13775. /**
  13776. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13777. */
  13778. /**
  13779. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13780. */
  13781. pressure: number;
  13782. /**
  13783. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13784. */
  13785. /**
  13786. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13787. */
  13788. stiffness: number;
  13789. /**
  13790. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13791. */
  13792. /**
  13793. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13794. */
  13795. velocityIterations: number;
  13796. /**
  13797. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13798. */
  13799. /**
  13800. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13801. */
  13802. positionIterations: number;
  13803. /**
  13804. * The unique id of the physics imposter
  13805. * set by the physics engine when adding this impostor to the array
  13806. */
  13807. uniqueId: number;
  13808. /**
  13809. * @hidden
  13810. */
  13811. soft: boolean;
  13812. /**
  13813. * @hidden
  13814. */
  13815. segments: number;
  13816. private _joints;
  13817. /**
  13818. * Initializes the physics imposter
  13819. * @param object The physics-enabled object used as the physics imposter
  13820. * @param type The type of the physics imposter
  13821. * @param _options The options for the physics imposter
  13822. * @param _scene The Babylon scene
  13823. */
  13824. constructor(
  13825. /**
  13826. * The physics-enabled object used as the physics imposter
  13827. */
  13828. object: IPhysicsEnabledObject,
  13829. /**
  13830. * The type of the physics imposter
  13831. */
  13832. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13833. /**
  13834. * This function will completly initialize this impostor.
  13835. * It will create a new body - but only if this mesh has no parent.
  13836. * If it has, this impostor will not be used other than to define the impostor
  13837. * of the child mesh.
  13838. * @hidden
  13839. */
  13840. _init(): void;
  13841. private _getPhysicsParent;
  13842. /**
  13843. * Should a new body be generated.
  13844. * @returns boolean specifying if body initialization is required
  13845. */
  13846. isBodyInitRequired(): boolean;
  13847. /**
  13848. * Sets the updated scaling
  13849. * @param updated Specifies if the scaling is updated
  13850. */
  13851. setScalingUpdated(): void;
  13852. /**
  13853. * Force a regeneration of this or the parent's impostor's body.
  13854. * Use under cautious - This will remove all joints already implemented.
  13855. */
  13856. forceUpdate(): void;
  13857. /**
  13858. * Gets the body that holds this impostor. Either its own, or its parent.
  13859. */
  13860. /**
  13861. * Set the physics body. Used mainly by the physics engine/plugin
  13862. */
  13863. physicsBody: any;
  13864. /**
  13865. * Get the parent of the physics imposter
  13866. * @returns Physics imposter or null
  13867. */
  13868. /**
  13869. * Sets the parent of the physics imposter
  13870. */
  13871. parent: Nullable<PhysicsImpostor>;
  13872. /**
  13873. * Resets the update flags
  13874. */
  13875. resetUpdateFlags(): void;
  13876. /**
  13877. * Gets the object extend size
  13878. * @returns the object extend size
  13879. */
  13880. getObjectExtendSize(): Vector3;
  13881. /**
  13882. * Gets the object center
  13883. * @returns The object center
  13884. */
  13885. getObjectCenter(): Vector3;
  13886. /**
  13887. * Get a specific parametes from the options parameter
  13888. * @param paramName The object parameter name
  13889. * @returns The object parameter
  13890. */
  13891. getParam(paramName: string): any;
  13892. /**
  13893. * Sets a specific parameter in the options given to the physics plugin
  13894. * @param paramName The parameter name
  13895. * @param value The value of the parameter
  13896. */
  13897. setParam(paramName: string, value: number): void;
  13898. /**
  13899. * Specifically change the body's mass option. Won't recreate the physics body object
  13900. * @param mass The mass of the physics imposter
  13901. */
  13902. setMass(mass: number): void;
  13903. /**
  13904. * Gets the linear velocity
  13905. * @returns linear velocity or null
  13906. */
  13907. getLinearVelocity(): Nullable<Vector3>;
  13908. /**
  13909. * Sets the linear velocity
  13910. * @param velocity linear velocity or null
  13911. */
  13912. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13913. /**
  13914. * Gets the angular velocity
  13915. * @returns angular velocity or null
  13916. */
  13917. getAngularVelocity(): Nullable<Vector3>;
  13918. /**
  13919. * Sets the angular velocity
  13920. * @param velocity The velocity or null
  13921. */
  13922. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13923. /**
  13924. * Execute a function with the physics plugin native code
  13925. * Provide a function the will have two variables - the world object and the physics body object
  13926. * @param func The function to execute with the physics plugin native code
  13927. */
  13928. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13929. /**
  13930. * Register a function that will be executed before the physics world is stepping forward
  13931. * @param func The function to execute before the physics world is stepped forward
  13932. */
  13933. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13934. /**
  13935. * Unregister a function that will be executed before the physics world is stepping forward
  13936. * @param func The function to execute before the physics world is stepped forward
  13937. */
  13938. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13939. /**
  13940. * Register a function that will be executed after the physics step
  13941. * @param func The function to execute after physics step
  13942. */
  13943. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13944. /**
  13945. * Unregisters a function that will be executed after the physics step
  13946. * @param func The function to execute after physics step
  13947. */
  13948. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13949. /**
  13950. * register a function that will be executed when this impostor collides against a different body
  13951. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13952. * @param func Callback that is executed on collision
  13953. */
  13954. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13955. /**
  13956. * Unregisters the physics imposter on contact
  13957. * @param collideAgainst The physics object to collide against
  13958. * @param func Callback to execute on collision
  13959. */
  13960. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13961. private _tmpQuat;
  13962. private _tmpQuat2;
  13963. /**
  13964. * Get the parent rotation
  13965. * @returns The parent rotation
  13966. */
  13967. getParentsRotation(): Quaternion;
  13968. /**
  13969. * this function is executed by the physics engine.
  13970. */
  13971. beforeStep: () => void;
  13972. /**
  13973. * this function is executed by the physics engine
  13974. */
  13975. afterStep: () => void;
  13976. /**
  13977. * Legacy collision detection event support
  13978. */
  13979. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13980. /**
  13981. * event and body object due to cannon's event-based architecture.
  13982. */
  13983. onCollide: (e: {
  13984. body: any;
  13985. }) => void;
  13986. /**
  13987. * Apply a force
  13988. * @param force The force to apply
  13989. * @param contactPoint The contact point for the force
  13990. * @returns The physics imposter
  13991. */
  13992. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13993. /**
  13994. * Apply an impulse
  13995. * @param force The impulse force
  13996. * @param contactPoint The contact point for the impulse force
  13997. * @returns The physics imposter
  13998. */
  13999. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14000. /**
  14001. * A help function to create a joint
  14002. * @param otherImpostor A physics imposter used to create a joint
  14003. * @param jointType The type of joint
  14004. * @param jointData The data for the joint
  14005. * @returns The physics imposter
  14006. */
  14007. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  14008. /**
  14009. * Add a joint to this impostor with a different impostor
  14010. * @param otherImpostor A physics imposter used to add a joint
  14011. * @param joint The joint to add
  14012. * @returns The physics imposter
  14013. */
  14014. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  14015. /**
  14016. * Add an anchor to a cloth impostor
  14017. * @param otherImpostor rigid impostor to anchor to
  14018. * @param width ratio across width from 0 to 1
  14019. * @param height ratio up height from 0 to 1
  14020. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  14021. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  14022. * @returns impostor the soft imposter
  14023. */
  14024. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14025. /**
  14026. * Add a hook to a rope impostor
  14027. * @param otherImpostor rigid impostor to anchor to
  14028. * @param length ratio across rope from 0 to 1
  14029. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  14030. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  14031. * @returns impostor the rope imposter
  14032. */
  14033. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14034. /**
  14035. * Will keep this body still, in a sleep mode.
  14036. * @returns the physics imposter
  14037. */
  14038. sleep(): PhysicsImpostor;
  14039. /**
  14040. * Wake the body up.
  14041. * @returns The physics imposter
  14042. */
  14043. wakeUp(): PhysicsImpostor;
  14044. /**
  14045. * Clones the physics imposter
  14046. * @param newObject The physics imposter clones to this physics-enabled object
  14047. * @returns A nullable physics imposter
  14048. */
  14049. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  14050. /**
  14051. * Disposes the physics imposter
  14052. */
  14053. dispose(): void;
  14054. /**
  14055. * Sets the delta position
  14056. * @param position The delta position amount
  14057. */
  14058. setDeltaPosition(position: Vector3): void;
  14059. /**
  14060. * Sets the delta rotation
  14061. * @param rotation The delta rotation amount
  14062. */
  14063. setDeltaRotation(rotation: Quaternion): void;
  14064. /**
  14065. * Gets the box size of the physics imposter and stores the result in the input parameter
  14066. * @param result Stores the box size
  14067. * @returns The physics imposter
  14068. */
  14069. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  14070. /**
  14071. * Gets the radius of the physics imposter
  14072. * @returns Radius of the physics imposter
  14073. */
  14074. getRadius(): number;
  14075. /**
  14076. * Sync a bone with this impostor
  14077. * @param bone The bone to sync to the impostor.
  14078. * @param boneMesh The mesh that the bone is influencing.
  14079. * @param jointPivot The pivot of the joint / bone in local space.
  14080. * @param distToJoint Optional distance from the impostor to the joint.
  14081. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14082. */
  14083. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  14084. /**
  14085. * Sync impostor to a bone
  14086. * @param bone The bone that the impostor will be synced to.
  14087. * @param boneMesh The mesh that the bone is influencing.
  14088. * @param jointPivot The pivot of the joint / bone in local space.
  14089. * @param distToJoint Optional distance from the impostor to the joint.
  14090. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14091. * @param boneAxis Optional vector3 axis the bone is aligned with
  14092. */
  14093. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  14094. /**
  14095. * No-Imposter type
  14096. */
  14097. static NoImpostor: number;
  14098. /**
  14099. * Sphere-Imposter type
  14100. */
  14101. static SphereImpostor: number;
  14102. /**
  14103. * Box-Imposter type
  14104. */
  14105. static BoxImpostor: number;
  14106. /**
  14107. * Plane-Imposter type
  14108. */
  14109. static PlaneImpostor: number;
  14110. /**
  14111. * Mesh-imposter type
  14112. */
  14113. static MeshImpostor: number;
  14114. /**
  14115. * Capsule-Impostor type (Ammo.js plugin only)
  14116. */
  14117. static CapsuleImpostor: number;
  14118. /**
  14119. * Cylinder-Imposter type
  14120. */
  14121. static CylinderImpostor: number;
  14122. /**
  14123. * Particle-Imposter type
  14124. */
  14125. static ParticleImpostor: number;
  14126. /**
  14127. * Heightmap-Imposter type
  14128. */
  14129. static HeightmapImpostor: number;
  14130. /**
  14131. * ConvexHull-Impostor type (Ammo.js plugin only)
  14132. */
  14133. static ConvexHullImpostor: number;
  14134. /**
  14135. * Rope-Imposter type
  14136. */
  14137. static RopeImpostor: number;
  14138. /**
  14139. * Cloth-Imposter type
  14140. */
  14141. static ClothImpostor: number;
  14142. /**
  14143. * Softbody-Imposter type
  14144. */
  14145. static SoftbodyImpostor: number;
  14146. }
  14147. }
  14148. declare module "babylonjs/Meshes/mesh" {
  14149. import { Observable } from "babylonjs/Misc/observable";
  14150. import { IAnimatable } from "babylonjs/Misc/tools";
  14151. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  14152. import { Camera } from "babylonjs/Cameras/camera";
  14153. import { Scene } from "babylonjs/scene";
  14154. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  14155. import { Engine } from "babylonjs/Engines/engine";
  14156. import { Node } from "babylonjs/node";
  14157. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  14158. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  14159. import { Buffer } from "babylonjs/Meshes/buffer";
  14160. import { Geometry } from "babylonjs/Meshes/geometry";
  14161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14162. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14163. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  14164. import { Effect } from "babylonjs/Materials/effect";
  14165. import { Material } from "babylonjs/Materials/material";
  14166. import { Skeleton } from "babylonjs/Bones/skeleton";
  14167. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  14168. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  14169. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  14170. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  14171. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  14172. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  14173. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  14174. /**
  14175. * @hidden
  14176. **/
  14177. export class _CreationDataStorage {
  14178. closePath?: boolean;
  14179. closeArray?: boolean;
  14180. idx: number[];
  14181. dashSize: number;
  14182. gapSize: number;
  14183. path3D: Path3D;
  14184. pathArray: Vector3[][];
  14185. arc: number;
  14186. radius: number;
  14187. cap: number;
  14188. tessellation: number;
  14189. }
  14190. /**
  14191. * @hidden
  14192. **/
  14193. class _InstanceDataStorage {
  14194. visibleInstances: any;
  14195. batchCache: _InstancesBatch;
  14196. instancesBufferSize: number;
  14197. instancesBuffer: Nullable<Buffer>;
  14198. instancesData: Float32Array;
  14199. overridenInstanceCount: number;
  14200. isFrozen: boolean;
  14201. previousBatch: Nullable<_InstancesBatch>;
  14202. hardwareInstancedRendering: boolean;
  14203. sideOrientation: number;
  14204. }
  14205. /**
  14206. * @hidden
  14207. **/
  14208. export class _InstancesBatch {
  14209. mustReturn: boolean;
  14210. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  14211. renderSelf: boolean[];
  14212. hardwareInstancedRendering: boolean[];
  14213. }
  14214. /**
  14215. * Class used to represent renderable models
  14216. */
  14217. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  14218. /**
  14219. * Mesh side orientation : usually the external or front surface
  14220. */
  14221. static readonly FRONTSIDE: number;
  14222. /**
  14223. * Mesh side orientation : usually the internal or back surface
  14224. */
  14225. static readonly BACKSIDE: number;
  14226. /**
  14227. * Mesh side orientation : both internal and external or front and back surfaces
  14228. */
  14229. static readonly DOUBLESIDE: number;
  14230. /**
  14231. * Mesh side orientation : by default, `FRONTSIDE`
  14232. */
  14233. static readonly DEFAULTSIDE: number;
  14234. /**
  14235. * Mesh cap setting : no cap
  14236. */
  14237. static readonly NO_CAP: number;
  14238. /**
  14239. * Mesh cap setting : one cap at the beginning of the mesh
  14240. */
  14241. static readonly CAP_START: number;
  14242. /**
  14243. * Mesh cap setting : one cap at the end of the mesh
  14244. */
  14245. static readonly CAP_END: number;
  14246. /**
  14247. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  14248. */
  14249. static readonly CAP_ALL: number;
  14250. /**
  14251. * Mesh pattern setting : no flip or rotate
  14252. */
  14253. static readonly NO_FLIP: number;
  14254. /**
  14255. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  14256. */
  14257. static readonly FLIP_TILE: number;
  14258. /**
  14259. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  14260. */
  14261. static readonly ROTATE_TILE: number;
  14262. /**
  14263. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14264. */
  14265. static readonly FLIP_ROW: number;
  14266. /**
  14267. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14268. */
  14269. static readonly ROTATE_ROW: number;
  14270. /**
  14271. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14272. */
  14273. static readonly FLIP_N_ROTATE_TILE: number;
  14274. /**
  14275. * Mesh pattern setting : rotate pattern and rotate
  14276. */
  14277. static readonly FLIP_N_ROTATE_ROW: number;
  14278. /**
  14279. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14280. */
  14281. static readonly CENTER: number;
  14282. /**
  14283. * Mesh tile positioning : part tiles on left
  14284. */
  14285. static readonly LEFT: number;
  14286. /**
  14287. * Mesh tile positioning : part tiles on right
  14288. */
  14289. static readonly RIGHT: number;
  14290. /**
  14291. * Mesh tile positioning : part tiles on top
  14292. */
  14293. static readonly TOP: number;
  14294. /**
  14295. * Mesh tile positioning : part tiles on bottom
  14296. */
  14297. static readonly BOTTOM: number;
  14298. /**
  14299. * Gets the default side orientation.
  14300. * @param orientation the orientation to value to attempt to get
  14301. * @returns the default orientation
  14302. * @hidden
  14303. */
  14304. static _GetDefaultSideOrientation(orientation?: number): number;
  14305. private _internalMeshDataInfo;
  14306. /**
  14307. * An event triggered before rendering the mesh
  14308. */
  14309. readonly onBeforeRenderObservable: Observable<Mesh>;
  14310. /**
  14311. * An event triggered before binding the mesh
  14312. */
  14313. readonly onBeforeBindObservable: Observable<Mesh>;
  14314. /**
  14315. * An event triggered after rendering the mesh
  14316. */
  14317. readonly onAfterRenderObservable: Observable<Mesh>;
  14318. /**
  14319. * An event triggered before drawing the mesh
  14320. */
  14321. readonly onBeforeDrawObservable: Observable<Mesh>;
  14322. private _onBeforeDrawObserver;
  14323. /**
  14324. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14325. */
  14326. onBeforeDraw: () => void;
  14327. /**
  14328. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14329. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14330. */
  14331. delayLoadState: number;
  14332. /**
  14333. * Gets the list of instances created from this mesh
  14334. * it is not supposed to be modified manually.
  14335. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14336. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14337. */
  14338. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  14339. /**
  14340. * Gets the file containing delay loading data for this mesh
  14341. */
  14342. delayLoadingFile: string;
  14343. /** @hidden */
  14344. _binaryInfo: any;
  14345. /**
  14346. * User defined function used to change how LOD level selection is done
  14347. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14348. */
  14349. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14350. /**
  14351. * Gets or sets the morph target manager
  14352. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14353. */
  14354. morphTargetManager: Nullable<MorphTargetManager>;
  14355. /** @hidden */
  14356. _creationDataStorage: Nullable<_CreationDataStorage>;
  14357. /** @hidden */
  14358. _geometry: Nullable<Geometry>;
  14359. /** @hidden */
  14360. _delayInfo: Array<string>;
  14361. /** @hidden */
  14362. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14363. /** @hidden */
  14364. _instanceDataStorage: _InstanceDataStorage;
  14365. private _effectiveMaterial;
  14366. /** @hidden */
  14367. _shouldGenerateFlatShading: boolean;
  14368. /** @hidden */
  14369. _originalBuilderSideOrientation: number;
  14370. /**
  14371. * Use this property to change the original side orientation defined at construction time
  14372. */
  14373. overrideMaterialSideOrientation: Nullable<number>;
  14374. /**
  14375. * Gets the source mesh (the one used to clone this one from)
  14376. */
  14377. readonly source: Nullable<Mesh>;
  14378. /**
  14379. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14380. */
  14381. isUnIndexed: boolean;
  14382. /**
  14383. * @constructor
  14384. * @param name The value used by scene.getMeshByName() to do a lookup.
  14385. * @param scene The scene to add this mesh to.
  14386. * @param parent The parent of this mesh, if it has one
  14387. * @param source An optional Mesh from which geometry is shared, cloned.
  14388. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14389. * When false, achieved by calling a clone(), also passing False.
  14390. * This will make creation of children, recursive.
  14391. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14392. */
  14393. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14394. /**
  14395. * Gets the class name
  14396. * @returns the string "Mesh".
  14397. */
  14398. getClassName(): string;
  14399. /** @hidden */
  14400. readonly _isMesh: boolean;
  14401. /**
  14402. * Returns a description of this mesh
  14403. * @param fullDetails define if full details about this mesh must be used
  14404. * @returns a descriptive string representing this mesh
  14405. */
  14406. toString(fullDetails?: boolean): string;
  14407. /** @hidden */
  14408. _unBindEffect(): void;
  14409. /**
  14410. * Gets a boolean indicating if this mesh has LOD
  14411. */
  14412. readonly hasLODLevels: boolean;
  14413. /**
  14414. * Gets the list of MeshLODLevel associated with the current mesh
  14415. * @returns an array of MeshLODLevel
  14416. */
  14417. getLODLevels(): MeshLODLevel[];
  14418. private _sortLODLevels;
  14419. /**
  14420. * Add a mesh as LOD level triggered at the given distance.
  14421. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14422. * @param distance The distance from the center of the object to show this level
  14423. * @param mesh The mesh to be added as LOD level (can be null)
  14424. * @return This mesh (for chaining)
  14425. */
  14426. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14427. /**
  14428. * Returns the LOD level mesh at the passed distance or null if not found.
  14429. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14430. * @param distance The distance from the center of the object to show this level
  14431. * @returns a Mesh or `null`
  14432. */
  14433. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14434. /**
  14435. * Remove a mesh from the LOD array
  14436. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14437. * @param mesh defines the mesh to be removed
  14438. * @return This mesh (for chaining)
  14439. */
  14440. removeLODLevel(mesh: Mesh): Mesh;
  14441. /**
  14442. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14443. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14444. * @param camera defines the camera to use to compute distance
  14445. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14446. * @return This mesh (for chaining)
  14447. */
  14448. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14449. /**
  14450. * Gets the mesh internal Geometry object
  14451. */
  14452. readonly geometry: Nullable<Geometry>;
  14453. /**
  14454. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14455. * @returns the total number of vertices
  14456. */
  14457. getTotalVertices(): number;
  14458. /**
  14459. * Returns the content of an associated vertex buffer
  14460. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14461. * - VertexBuffer.PositionKind
  14462. * - VertexBuffer.UVKind
  14463. * - VertexBuffer.UV2Kind
  14464. * - VertexBuffer.UV3Kind
  14465. * - VertexBuffer.UV4Kind
  14466. * - VertexBuffer.UV5Kind
  14467. * - VertexBuffer.UV6Kind
  14468. * - VertexBuffer.ColorKind
  14469. * - VertexBuffer.MatricesIndicesKind
  14470. * - VertexBuffer.MatricesIndicesExtraKind
  14471. * - VertexBuffer.MatricesWeightsKind
  14472. * - VertexBuffer.MatricesWeightsExtraKind
  14473. * @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
  14474. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14475. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14476. */
  14477. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14478. /**
  14479. * Returns the mesh VertexBuffer object from the requested `kind`
  14480. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14481. * - VertexBuffer.PositionKind
  14482. * - VertexBuffer.NormalKind
  14483. * - VertexBuffer.UVKind
  14484. * - VertexBuffer.UV2Kind
  14485. * - VertexBuffer.UV3Kind
  14486. * - VertexBuffer.UV4Kind
  14487. * - VertexBuffer.UV5Kind
  14488. * - VertexBuffer.UV6Kind
  14489. * - VertexBuffer.ColorKind
  14490. * - VertexBuffer.MatricesIndicesKind
  14491. * - VertexBuffer.MatricesIndicesExtraKind
  14492. * - VertexBuffer.MatricesWeightsKind
  14493. * - VertexBuffer.MatricesWeightsExtraKind
  14494. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14495. */
  14496. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14497. /**
  14498. * Tests if a specific vertex buffer is associated with this mesh
  14499. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14500. * - VertexBuffer.PositionKind
  14501. * - VertexBuffer.NormalKind
  14502. * - VertexBuffer.UVKind
  14503. * - VertexBuffer.UV2Kind
  14504. * - VertexBuffer.UV3Kind
  14505. * - VertexBuffer.UV4Kind
  14506. * - VertexBuffer.UV5Kind
  14507. * - VertexBuffer.UV6Kind
  14508. * - VertexBuffer.ColorKind
  14509. * - VertexBuffer.MatricesIndicesKind
  14510. * - VertexBuffer.MatricesIndicesExtraKind
  14511. * - VertexBuffer.MatricesWeightsKind
  14512. * - VertexBuffer.MatricesWeightsExtraKind
  14513. * @returns a boolean
  14514. */
  14515. isVerticesDataPresent(kind: string): boolean;
  14516. /**
  14517. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14518. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14519. * - VertexBuffer.PositionKind
  14520. * - VertexBuffer.UVKind
  14521. * - VertexBuffer.UV2Kind
  14522. * - VertexBuffer.UV3Kind
  14523. * - VertexBuffer.UV4Kind
  14524. * - VertexBuffer.UV5Kind
  14525. * - VertexBuffer.UV6Kind
  14526. * - VertexBuffer.ColorKind
  14527. * - VertexBuffer.MatricesIndicesKind
  14528. * - VertexBuffer.MatricesIndicesExtraKind
  14529. * - VertexBuffer.MatricesWeightsKind
  14530. * - VertexBuffer.MatricesWeightsExtraKind
  14531. * @returns a boolean
  14532. */
  14533. isVertexBufferUpdatable(kind: string): boolean;
  14534. /**
  14535. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14536. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14537. * - VertexBuffer.PositionKind
  14538. * - VertexBuffer.NormalKind
  14539. * - VertexBuffer.UVKind
  14540. * - VertexBuffer.UV2Kind
  14541. * - VertexBuffer.UV3Kind
  14542. * - VertexBuffer.UV4Kind
  14543. * - VertexBuffer.UV5Kind
  14544. * - VertexBuffer.UV6Kind
  14545. * - VertexBuffer.ColorKind
  14546. * - VertexBuffer.MatricesIndicesKind
  14547. * - VertexBuffer.MatricesIndicesExtraKind
  14548. * - VertexBuffer.MatricesWeightsKind
  14549. * - VertexBuffer.MatricesWeightsExtraKind
  14550. * @returns an array of strings
  14551. */
  14552. getVerticesDataKinds(): string[];
  14553. /**
  14554. * Returns a positive integer : the total number of indices in this mesh geometry.
  14555. * @returns the numner of indices or zero if the mesh has no geometry.
  14556. */
  14557. getTotalIndices(): number;
  14558. /**
  14559. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14560. * @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.
  14561. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14562. * @returns the indices array or an empty array if the mesh has no geometry
  14563. */
  14564. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14565. readonly isBlocked: boolean;
  14566. /**
  14567. * Determine if the current mesh is ready to be rendered
  14568. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14569. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14570. * @returns true if all associated assets are ready (material, textures, shaders)
  14571. */
  14572. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14573. /**
  14574. * 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.
  14575. */
  14576. readonly areNormalsFrozen: boolean;
  14577. /**
  14578. * 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.
  14579. * @returns the current mesh
  14580. */
  14581. freezeNormals(): Mesh;
  14582. /**
  14583. * 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
  14584. * @returns the current mesh
  14585. */
  14586. unfreezeNormals(): Mesh;
  14587. /**
  14588. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14589. */
  14590. overridenInstanceCount: number;
  14591. /** @hidden */
  14592. _preActivate(): Mesh;
  14593. /** @hidden */
  14594. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14595. /** @hidden */
  14596. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14597. /**
  14598. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14599. * This means the mesh underlying bounding box and sphere are recomputed.
  14600. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14601. * @returns the current mesh
  14602. */
  14603. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14604. /** @hidden */
  14605. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14606. /**
  14607. * This function will subdivide the mesh into multiple submeshes
  14608. * @param count defines the expected number of submeshes
  14609. */
  14610. subdivide(count: number): void;
  14611. /**
  14612. * Copy a FloatArray into a specific associated vertex buffer
  14613. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14614. * - VertexBuffer.PositionKind
  14615. * - VertexBuffer.UVKind
  14616. * - VertexBuffer.UV2Kind
  14617. * - VertexBuffer.UV3Kind
  14618. * - VertexBuffer.UV4Kind
  14619. * - VertexBuffer.UV5Kind
  14620. * - VertexBuffer.UV6Kind
  14621. * - VertexBuffer.ColorKind
  14622. * - VertexBuffer.MatricesIndicesKind
  14623. * - VertexBuffer.MatricesIndicesExtraKind
  14624. * - VertexBuffer.MatricesWeightsKind
  14625. * - VertexBuffer.MatricesWeightsExtraKind
  14626. * @param data defines the data source
  14627. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14628. * @param stride defines the data stride size (can be null)
  14629. * @returns the current mesh
  14630. */
  14631. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14632. /**
  14633. * Flags an associated vertex buffer as updatable
  14634. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14635. * - VertexBuffer.PositionKind
  14636. * - VertexBuffer.UVKind
  14637. * - VertexBuffer.UV2Kind
  14638. * - VertexBuffer.UV3Kind
  14639. * - VertexBuffer.UV4Kind
  14640. * - VertexBuffer.UV5Kind
  14641. * - VertexBuffer.UV6Kind
  14642. * - VertexBuffer.ColorKind
  14643. * - VertexBuffer.MatricesIndicesKind
  14644. * - VertexBuffer.MatricesIndicesExtraKind
  14645. * - VertexBuffer.MatricesWeightsKind
  14646. * - VertexBuffer.MatricesWeightsExtraKind
  14647. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14648. */
  14649. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14650. /**
  14651. * Sets the mesh global Vertex Buffer
  14652. * @param buffer defines the buffer to use
  14653. * @returns the current mesh
  14654. */
  14655. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14656. /**
  14657. * Update a specific associated vertex buffer
  14658. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14659. * - VertexBuffer.PositionKind
  14660. * - VertexBuffer.UVKind
  14661. * - VertexBuffer.UV2Kind
  14662. * - VertexBuffer.UV3Kind
  14663. * - VertexBuffer.UV4Kind
  14664. * - VertexBuffer.UV5Kind
  14665. * - VertexBuffer.UV6Kind
  14666. * - VertexBuffer.ColorKind
  14667. * - VertexBuffer.MatricesIndicesKind
  14668. * - VertexBuffer.MatricesIndicesExtraKind
  14669. * - VertexBuffer.MatricesWeightsKind
  14670. * - VertexBuffer.MatricesWeightsExtraKind
  14671. * @param data defines the data source
  14672. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14673. * @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)
  14674. * @returns the current mesh
  14675. */
  14676. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14677. /**
  14678. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14679. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14680. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14681. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14682. * @returns the current mesh
  14683. */
  14684. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14685. /**
  14686. * Creates a un-shared specific occurence of the geometry for the mesh.
  14687. * @returns the current mesh
  14688. */
  14689. makeGeometryUnique(): Mesh;
  14690. /**
  14691. * Set the index buffer of this mesh
  14692. * @param indices defines the source data
  14693. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14694. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14695. * @returns the current mesh
  14696. */
  14697. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14698. /**
  14699. * Update the current index buffer
  14700. * @param indices defines the source data
  14701. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14702. * @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)
  14703. * @returns the current mesh
  14704. */
  14705. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14706. /**
  14707. * Invert the geometry to move from a right handed system to a left handed one.
  14708. * @returns the current mesh
  14709. */
  14710. toLeftHanded(): Mesh;
  14711. /** @hidden */
  14712. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14713. /** @hidden */
  14714. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14715. /**
  14716. * Registers for this mesh a javascript function called just before the rendering process
  14717. * @param func defines the function to call before rendering this mesh
  14718. * @returns the current mesh
  14719. */
  14720. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14721. /**
  14722. * Disposes a previously registered javascript function called before the rendering
  14723. * @param func defines the function to remove
  14724. * @returns the current mesh
  14725. */
  14726. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14727. /**
  14728. * Registers for this mesh a javascript function called just after the rendering is complete
  14729. * @param func defines the function to call after rendering this mesh
  14730. * @returns the current mesh
  14731. */
  14732. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14733. /**
  14734. * Disposes a previously registered javascript function called after the rendering.
  14735. * @param func defines the function to remove
  14736. * @returns the current mesh
  14737. */
  14738. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14739. /** @hidden */
  14740. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14741. /** @hidden */
  14742. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14743. /** @hidden */
  14744. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14745. /** @hidden */
  14746. _rebuild(): void;
  14747. /** @hidden */
  14748. _freeze(): void;
  14749. /** @hidden */
  14750. _unFreeze(): void;
  14751. /**
  14752. * 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
  14753. * @param subMesh defines the subMesh to render
  14754. * @param enableAlphaMode defines if alpha mode can be changed
  14755. * @returns the current mesh
  14756. */
  14757. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14758. private _onBeforeDraw;
  14759. /**
  14760. * Renormalize the mesh and patch it up if there are no weights
  14761. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14762. * However in the case of zero weights then we set just a single influence to 1.
  14763. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14764. */
  14765. cleanMatrixWeights(): void;
  14766. private normalizeSkinFourWeights;
  14767. private normalizeSkinWeightsAndExtra;
  14768. /**
  14769. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14770. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14771. * the user know there was an issue with importing the mesh
  14772. * @returns a validation object with skinned, valid and report string
  14773. */
  14774. validateSkinning(): {
  14775. skinned: boolean;
  14776. valid: boolean;
  14777. report: string;
  14778. };
  14779. /** @hidden */
  14780. _checkDelayState(): Mesh;
  14781. private _queueLoad;
  14782. /**
  14783. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14784. * A mesh is in the frustum if its bounding box intersects the frustum
  14785. * @param frustumPlanes defines the frustum to test
  14786. * @returns true if the mesh is in the frustum planes
  14787. */
  14788. isInFrustum(frustumPlanes: Plane[]): boolean;
  14789. /**
  14790. * Sets the mesh material by the material or multiMaterial `id` property
  14791. * @param id is a string identifying the material or the multiMaterial
  14792. * @returns the current mesh
  14793. */
  14794. setMaterialByID(id: string): Mesh;
  14795. /**
  14796. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14797. * @returns an array of IAnimatable
  14798. */
  14799. getAnimatables(): IAnimatable[];
  14800. /**
  14801. * Modifies the mesh geometry according to the passed transformation matrix.
  14802. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14803. * The mesh normals are modified using the same transformation.
  14804. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14805. * @param transform defines the transform matrix to use
  14806. * @see http://doc.babylonjs.com/resources/baking_transformations
  14807. * @returns the current mesh
  14808. */
  14809. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14810. /**
  14811. * Modifies the mesh geometry according to its own current World Matrix.
  14812. * The mesh World Matrix is then reset.
  14813. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14814. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14815. * @see http://doc.babylonjs.com/resources/baking_transformations
  14816. * @returns the current mesh
  14817. */
  14818. bakeCurrentTransformIntoVertices(): Mesh;
  14819. /** @hidden */
  14820. readonly _positions: Nullable<Vector3[]>;
  14821. /** @hidden */
  14822. _resetPointsArrayCache(): Mesh;
  14823. /** @hidden */
  14824. _generatePointsArray(): boolean;
  14825. /**
  14826. * Returns a new Mesh object generated from the current mesh properties.
  14827. * This method must not get confused with createInstance()
  14828. * @param name is a string, the name given to the new mesh
  14829. * @param newParent can be any Node object (default `null`)
  14830. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14831. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14832. * @returns a new mesh
  14833. */
  14834. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14835. /**
  14836. * Releases resources associated with this mesh.
  14837. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14838. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14839. */
  14840. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14841. /**
  14842. * Modifies the mesh geometry according to a displacement map.
  14843. * 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.
  14844. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14845. * @param url is a string, the URL from the image file is to be downloaded.
  14846. * @param minHeight is the lower limit of the displacement.
  14847. * @param maxHeight is the upper limit of the displacement.
  14848. * @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.
  14849. * @param uvOffset is an optional vector2 used to offset UV.
  14850. * @param uvScale is an optional vector2 used to scale UV.
  14851. * @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.
  14852. * @returns the Mesh.
  14853. */
  14854. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14855. /**
  14856. * Modifies the mesh geometry according to a displacementMap buffer.
  14857. * 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.
  14858. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14859. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14860. * @param heightMapWidth is the width of the buffer image.
  14861. * @param heightMapHeight is the height of the buffer image.
  14862. * @param minHeight is the lower limit of the displacement.
  14863. * @param maxHeight is the upper limit of the displacement.
  14864. * @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.
  14865. * @param uvOffset is an optional vector2 used to offset UV.
  14866. * @param uvScale is an optional vector2 used to scale UV.
  14867. * @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.
  14868. * @returns the Mesh.
  14869. */
  14870. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14871. /**
  14872. * Modify the mesh to get a flat shading rendering.
  14873. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14874. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14875. * @returns current mesh
  14876. */
  14877. convertToFlatShadedMesh(): Mesh;
  14878. /**
  14879. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14880. * In other words, more vertices, no more indices and a single bigger VBO.
  14881. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14882. * @returns current mesh
  14883. */
  14884. convertToUnIndexedMesh(): Mesh;
  14885. /**
  14886. * Inverses facet orientations.
  14887. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14888. * @param flipNormals will also inverts the normals
  14889. * @returns current mesh
  14890. */
  14891. flipFaces(flipNormals?: boolean): Mesh;
  14892. /**
  14893. * Increase the number of facets and hence vertices in a mesh
  14894. * Vertex normals are interpolated from existing vertex normals
  14895. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14896. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14897. */
  14898. increaseVertices(numberPerEdge: number): void;
  14899. /**
  14900. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14901. * This will undo any application of covertToFlatShadedMesh
  14902. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14903. */
  14904. forceSharedVertices(): void;
  14905. /** @hidden */
  14906. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14907. /** @hidden */
  14908. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14909. /**
  14910. * Creates a new InstancedMesh object from the mesh model.
  14911. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14912. * @param name defines the name of the new instance
  14913. * @returns a new InstancedMesh
  14914. */
  14915. createInstance(name: string): InstancedMesh;
  14916. /**
  14917. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14918. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14919. * @returns the current mesh
  14920. */
  14921. synchronizeInstances(): Mesh;
  14922. /**
  14923. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14924. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14925. * This should be used together with the simplification to avoid disappearing triangles.
  14926. * @param successCallback an optional success callback to be called after the optimization finished.
  14927. * @returns the current mesh
  14928. */
  14929. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14930. /**
  14931. * Serialize current mesh
  14932. * @param serializationObject defines the object which will receive the serialization data
  14933. */
  14934. serialize(serializationObject: any): void;
  14935. /** @hidden */
  14936. _syncGeometryWithMorphTargetManager(): void;
  14937. /** @hidden */
  14938. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14939. /**
  14940. * Returns a new Mesh object parsed from the source provided.
  14941. * @param parsedMesh is the source
  14942. * @param scene defines the hosting scene
  14943. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14944. * @returns a new Mesh
  14945. */
  14946. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14947. /**
  14948. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14949. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14950. * @param name defines the name of the mesh to create
  14951. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14952. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14953. * @param closePath creates a seam between the first and the last points of each path of the path array
  14954. * @param offset is taken in account only if the `pathArray` is containing a single path
  14955. * @param scene defines the hosting scene
  14956. * @param updatable defines if the mesh must be flagged as updatable
  14957. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14958. * @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)
  14959. * @returns a new Mesh
  14960. */
  14961. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14962. /**
  14963. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14964. * @param name defines the name of the mesh to create
  14965. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14966. * @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
  14967. * @param scene defines the hosting scene
  14968. * @param updatable defines if the mesh must be flagged as updatable
  14969. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14970. * @returns a new Mesh
  14971. */
  14972. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14973. /**
  14974. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14975. * @param name defines the name of the mesh to create
  14976. * @param size sets the size (float) of each box side (default 1)
  14977. * @param scene defines the hosting scene
  14978. * @param updatable defines if the mesh must be flagged as updatable
  14979. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14980. * @returns a new Mesh
  14981. */
  14982. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14983. /**
  14984. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14985. * @param name defines the name of the mesh to create
  14986. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14987. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14988. * @param scene defines the hosting scene
  14989. * @param updatable defines if the mesh must be flagged as updatable
  14990. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14991. * @returns a new Mesh
  14992. */
  14993. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14994. /**
  14995. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14996. * @param name defines the name of the mesh to create
  14997. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14998. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14999. * @param scene defines the hosting scene
  15000. * @returns a new Mesh
  15001. */
  15002. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  15003. /**
  15004. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  15005. * @param name defines the name of the mesh to create
  15006. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  15007. * @param diameterTop set the top cap diameter (floats, default 1)
  15008. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  15009. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  15010. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  15011. * @param scene defines the hosting scene
  15012. * @param updatable defines if the mesh must be flagged as updatable
  15013. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15014. * @returns a new Mesh
  15015. */
  15016. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  15017. /**
  15018. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  15019. * @param name defines the name of the mesh to create
  15020. * @param diameter sets the diameter size (float) of the torus (default 1)
  15021. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  15022. * @param tessellation sets the number of torus sides (postive integer, default 16)
  15023. * @param scene defines the hosting scene
  15024. * @param updatable defines if the mesh must be flagged as updatable
  15025. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15026. * @returns a new Mesh
  15027. */
  15028. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15029. /**
  15030. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  15031. * @param name defines the name of the mesh to create
  15032. * @param radius sets the global radius size (float) of the torus knot (default 2)
  15033. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  15034. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  15035. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  15036. * @param p the number of windings on X axis (positive integers, default 2)
  15037. * @param q the number of windings on Y axis (positive integers, default 3)
  15038. * @param scene defines the hosting scene
  15039. * @param updatable defines if the mesh must be flagged as updatable
  15040. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15041. * @returns a new Mesh
  15042. */
  15043. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15044. /**
  15045. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  15046. * @param name defines the name of the mesh to create
  15047. * @param points is an array successive Vector3
  15048. * @param scene defines the hosting scene
  15049. * @param updatable defines if the mesh must be flagged as updatable
  15050. * @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).
  15051. * @returns a new Mesh
  15052. */
  15053. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  15054. /**
  15055. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  15056. * @param name defines the name of the mesh to create
  15057. * @param points is an array successive Vector3
  15058. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  15059. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  15060. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  15061. * @param scene defines the hosting scene
  15062. * @param updatable defines if the mesh must be flagged as updatable
  15063. * @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)
  15064. * @returns a new Mesh
  15065. */
  15066. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  15067. /**
  15068. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  15069. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  15070. * 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.
  15071. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15072. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15073. * Remember you can only change the shape positions, not their number when updating a polygon.
  15074. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  15075. * @param name defines the name of the mesh to create
  15076. * @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
  15077. * @param scene defines the hosting scene
  15078. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15079. * @param updatable defines if the mesh must be flagged as updatable
  15080. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15081. * @param earcutInjection can be used to inject your own earcut reference
  15082. * @returns a new Mesh
  15083. */
  15084. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15085. /**
  15086. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  15087. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  15088. * @param name defines the name of the mesh to create
  15089. * @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
  15090. * @param depth defines the height of extrusion
  15091. * @param scene defines the hosting scene
  15092. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15093. * @param updatable defines if the mesh must be flagged as updatable
  15094. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15095. * @param earcutInjection can be used to inject your own earcut reference
  15096. * @returns a new Mesh
  15097. */
  15098. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15099. /**
  15100. * Creates an extruded shape mesh.
  15101. * 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
  15102. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15103. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15104. * @param name defines the name of the mesh to create
  15105. * @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
  15106. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15107. * @param scale is the value to scale the shape
  15108. * @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
  15109. * @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
  15110. * @param scene defines the hosting scene
  15111. * @param updatable defines if the mesh must be flagged as updatable
  15112. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15113. * @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)
  15114. * @returns a new Mesh
  15115. */
  15116. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15117. /**
  15118. * Creates an custom extruded shape mesh.
  15119. * The custom extrusion is a parametric shape.
  15120. * It has no predefined shape. Its final shape will depend on the input parameters.
  15121. * Please consider using the same method from the MeshBuilder class instead
  15122. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15123. * @param name defines the name of the mesh to create
  15124. * @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
  15125. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15126. * @param scaleFunction is a custom Javascript function called on each path point
  15127. * @param rotationFunction is a custom Javascript function called on each path point
  15128. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  15129. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  15130. * @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
  15131. * @param scene defines the hosting scene
  15132. * @param updatable defines if the mesh must be flagged as updatable
  15133. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15134. * @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)
  15135. * @returns a new Mesh
  15136. */
  15137. 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;
  15138. /**
  15139. * Creates lathe mesh.
  15140. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15141. * Please consider using the same method from the MeshBuilder class instead
  15142. * @param name defines the name of the mesh to create
  15143. * @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
  15144. * @param radius is the radius value of the lathe
  15145. * @param tessellation is the side number of the lathe.
  15146. * @param scene defines the hosting scene
  15147. * @param updatable defines if the mesh must be flagged as updatable
  15148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15149. * @returns a new Mesh
  15150. */
  15151. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15152. /**
  15153. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  15154. * @param name defines the name of the mesh to create
  15155. * @param size sets the size (float) of both sides of the plane at once (default 1)
  15156. * @param scene defines the hosting scene
  15157. * @param updatable defines if the mesh must be flagged as updatable
  15158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15159. * @returns a new Mesh
  15160. */
  15161. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15162. /**
  15163. * Creates a ground mesh.
  15164. * Please consider using the same method from the MeshBuilder class instead
  15165. * @param name defines the name of the mesh to create
  15166. * @param width set the width of the ground
  15167. * @param height set the height of the ground
  15168. * @param subdivisions sets the number of subdivisions per side
  15169. * @param scene defines the hosting scene
  15170. * @param updatable defines if the mesh must be flagged as updatable
  15171. * @returns a new Mesh
  15172. */
  15173. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15174. /**
  15175. * Creates a tiled ground mesh.
  15176. * Please consider using the same method from the MeshBuilder class instead
  15177. * @param name defines the name of the mesh to create
  15178. * @param xmin set the ground minimum X coordinate
  15179. * @param zmin set the ground minimum Y coordinate
  15180. * @param xmax set the ground maximum X coordinate
  15181. * @param zmax set the ground maximum Z coordinate
  15182. * @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
  15183. * @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
  15184. * @param scene defines the hosting scene
  15185. * @param updatable defines if the mesh must be flagged as updatable
  15186. * @returns a new Mesh
  15187. */
  15188. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15189. w: number;
  15190. h: number;
  15191. }, precision: {
  15192. w: number;
  15193. h: number;
  15194. }, scene: Scene, updatable?: boolean): Mesh;
  15195. /**
  15196. * Creates a ground mesh from a height map.
  15197. * Please consider using the same method from the MeshBuilder class instead
  15198. * @see http://doc.babylonjs.com/babylon101/height_map
  15199. * @param name defines the name of the mesh to create
  15200. * @param url sets the URL of the height map image resource
  15201. * @param width set the ground width size
  15202. * @param height set the ground height size
  15203. * @param subdivisions sets the number of subdivision per side
  15204. * @param minHeight is the minimum altitude on the ground
  15205. * @param maxHeight is the maximum altitude on the ground
  15206. * @param scene defines the hosting scene
  15207. * @param updatable defines if the mesh must be flagged as updatable
  15208. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  15209. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  15210. * @returns a new Mesh
  15211. */
  15212. 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;
  15213. /**
  15214. * Creates a tube mesh.
  15215. * The tube is a parametric shape.
  15216. * It has no predefined shape. Its final shape will depend on the input parameters.
  15217. * Please consider using the same method from the MeshBuilder class instead
  15218. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15219. * @param name defines the name of the mesh to create
  15220. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  15221. * @param radius sets the tube radius size
  15222. * @param tessellation is the number of sides on the tubular surface
  15223. * @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
  15224. * @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
  15225. * @param scene defines the hosting scene
  15226. * @param updatable defines if the mesh must be flagged as updatable
  15227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15228. * @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)
  15229. * @returns a new Mesh
  15230. */
  15231. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15232. (i: number, distance: number): number;
  15233. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15234. /**
  15235. * Creates a polyhedron mesh.
  15236. * Please consider using the same method from the MeshBuilder class instead.
  15237. * * 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
  15238. * * The parameter `size` (positive float, default 1) sets the polygon size
  15239. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  15240. * * 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`
  15241. * * 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
  15242. * * 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)`)
  15243. * * 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
  15244. * * 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
  15245. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15246. * * If you create a double-sided mesh, you can choose what parts of 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
  15247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15248. * @param name defines the name of the mesh to create
  15249. * @param options defines the options used to create the mesh
  15250. * @param scene defines the hosting scene
  15251. * @returns a new Mesh
  15252. */
  15253. static CreatePolyhedron(name: string, options: {
  15254. type?: number;
  15255. size?: number;
  15256. sizeX?: number;
  15257. sizeY?: number;
  15258. sizeZ?: number;
  15259. custom?: any;
  15260. faceUV?: Vector4[];
  15261. faceColors?: Color4[];
  15262. updatable?: boolean;
  15263. sideOrientation?: number;
  15264. }, scene: Scene): Mesh;
  15265. /**
  15266. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15267. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15268. * * 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`)
  15269. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15270. * * 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
  15271. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15272. * * If you create a double-sided mesh, you can choose what parts of 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
  15273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15274. * @param name defines the name of the mesh
  15275. * @param options defines the options used to create the mesh
  15276. * @param scene defines the hosting scene
  15277. * @returns a new Mesh
  15278. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15279. */
  15280. static CreateIcoSphere(name: string, options: {
  15281. radius?: number;
  15282. flat?: boolean;
  15283. subdivisions?: number;
  15284. sideOrientation?: number;
  15285. updatable?: boolean;
  15286. }, scene: Scene): Mesh;
  15287. /**
  15288. * Creates a decal mesh.
  15289. * Please consider using the same method from the MeshBuilder class instead.
  15290. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15291. * @param name defines the name of the mesh
  15292. * @param sourceMesh defines the mesh receiving the decal
  15293. * @param position sets the position of the decal in world coordinates
  15294. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15295. * @param size sets the decal scaling
  15296. * @param angle sets the angle to rotate the decal
  15297. * @returns a new Mesh
  15298. */
  15299. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15300. /**
  15301. * Prepare internal position array for software CPU skinning
  15302. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15303. */
  15304. setPositionsForCPUSkinning(): Float32Array;
  15305. /**
  15306. * Prepare internal normal array for software CPU skinning
  15307. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15308. */
  15309. setNormalsForCPUSkinning(): Float32Array;
  15310. /**
  15311. * Updates the vertex buffer by applying transformation from the bones
  15312. * @param skeleton defines the skeleton to apply to current mesh
  15313. * @returns the current mesh
  15314. */
  15315. applySkeleton(skeleton: Skeleton): Mesh;
  15316. /**
  15317. * 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
  15318. * @param meshes defines the list of meshes to scan
  15319. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15320. */
  15321. static MinMax(meshes: AbstractMesh[]): {
  15322. min: Vector3;
  15323. max: Vector3;
  15324. };
  15325. /**
  15326. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15327. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15328. * @returns a vector3
  15329. */
  15330. static Center(meshesOrMinMaxVector: {
  15331. min: Vector3;
  15332. max: Vector3;
  15333. } | AbstractMesh[]): Vector3;
  15334. /**
  15335. * Merge the array of meshes into a single mesh for performance reasons.
  15336. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15337. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15338. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15339. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15340. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15341. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15342. * @returns a new mesh
  15343. */
  15344. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15345. /** @hidden */
  15346. addInstance(instance: InstancedMesh): void;
  15347. /** @hidden */
  15348. removeInstance(instance: InstancedMesh): void;
  15349. }
  15350. }
  15351. declare module "babylonjs/Actions/action" {
  15352. import { Observable } from "babylonjs/Misc/observable";
  15353. import { Condition } from "babylonjs/Actions/condition";
  15354. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15355. import { ActionManager } from "babylonjs/Actions/actionManager";
  15356. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15357. /**
  15358. * Interface used to define Action
  15359. */
  15360. export interface IAction {
  15361. /**
  15362. * Trigger for the action
  15363. */
  15364. trigger: number;
  15365. /** Options of the trigger */
  15366. triggerOptions: any;
  15367. /**
  15368. * Gets the trigger parameters
  15369. * @returns the trigger parameters
  15370. */
  15371. getTriggerParameter(): any;
  15372. /**
  15373. * Internal only - executes current action event
  15374. * @hidden
  15375. */
  15376. _executeCurrent(evt?: ActionEvent): void;
  15377. /**
  15378. * Serialize placeholder for child classes
  15379. * @param parent of child
  15380. * @returns the serialized object
  15381. */
  15382. serialize(parent: any): any;
  15383. /**
  15384. * Internal only
  15385. * @hidden
  15386. */
  15387. _prepare(): void;
  15388. /**
  15389. * Internal only - manager for action
  15390. * @hidden
  15391. */
  15392. _actionManager: AbstractActionManager;
  15393. /**
  15394. * Adds action to chain of actions, may be a DoNothingAction
  15395. * @param action defines the next action to execute
  15396. * @returns The action passed in
  15397. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15398. */
  15399. then(action: IAction): IAction;
  15400. }
  15401. /**
  15402. * The action to be carried out following a trigger
  15403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15404. */
  15405. export class Action implements IAction {
  15406. /** the trigger, with or without parameters, for the action */
  15407. triggerOptions: any;
  15408. /**
  15409. * Trigger for the action
  15410. */
  15411. trigger: number;
  15412. /**
  15413. * Internal only - manager for action
  15414. * @hidden
  15415. */
  15416. _actionManager: ActionManager;
  15417. private _nextActiveAction;
  15418. private _child;
  15419. private _condition?;
  15420. private _triggerParameter;
  15421. /**
  15422. * An event triggered prior to action being executed.
  15423. */
  15424. onBeforeExecuteObservable: Observable<Action>;
  15425. /**
  15426. * Creates a new Action
  15427. * @param triggerOptions the trigger, with or without parameters, for the action
  15428. * @param condition an optional determinant of action
  15429. */
  15430. constructor(
  15431. /** the trigger, with or without parameters, for the action */
  15432. triggerOptions: any, condition?: Condition);
  15433. /**
  15434. * Internal only
  15435. * @hidden
  15436. */
  15437. _prepare(): void;
  15438. /**
  15439. * Gets the trigger parameters
  15440. * @returns the trigger parameters
  15441. */
  15442. getTriggerParameter(): any;
  15443. /**
  15444. * Internal only - executes current action event
  15445. * @hidden
  15446. */
  15447. _executeCurrent(evt?: ActionEvent): void;
  15448. /**
  15449. * Execute placeholder for child classes
  15450. * @param evt optional action event
  15451. */
  15452. execute(evt?: ActionEvent): void;
  15453. /**
  15454. * Skips to next active action
  15455. */
  15456. skipToNextActiveAction(): void;
  15457. /**
  15458. * Adds action to chain of actions, may be a DoNothingAction
  15459. * @param action defines the next action to execute
  15460. * @returns The action passed in
  15461. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15462. */
  15463. then(action: Action): Action;
  15464. /**
  15465. * Internal only
  15466. * @hidden
  15467. */
  15468. _getProperty(propertyPath: string): string;
  15469. /**
  15470. * Internal only
  15471. * @hidden
  15472. */
  15473. _getEffectiveTarget(target: any, propertyPath: string): any;
  15474. /**
  15475. * Serialize placeholder for child classes
  15476. * @param parent of child
  15477. * @returns the serialized object
  15478. */
  15479. serialize(parent: any): any;
  15480. /**
  15481. * Internal only called by serialize
  15482. * @hidden
  15483. */
  15484. protected _serialize(serializedAction: any, parent?: any): any;
  15485. /**
  15486. * Internal only
  15487. * @hidden
  15488. */
  15489. static _SerializeValueAsString: (value: any) => string;
  15490. /**
  15491. * Internal only
  15492. * @hidden
  15493. */
  15494. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  15495. name: string;
  15496. targetType: string;
  15497. value: string;
  15498. };
  15499. }
  15500. }
  15501. declare module "babylonjs/Actions/condition" {
  15502. import { ActionManager } from "babylonjs/Actions/actionManager";
  15503. /**
  15504. * A Condition applied to an Action
  15505. */
  15506. export class Condition {
  15507. /**
  15508. * Internal only - manager for action
  15509. * @hidden
  15510. */
  15511. _actionManager: ActionManager;
  15512. /**
  15513. * Internal only
  15514. * @hidden
  15515. */
  15516. _evaluationId: number;
  15517. /**
  15518. * Internal only
  15519. * @hidden
  15520. */
  15521. _currentResult: boolean;
  15522. /**
  15523. * Creates a new Condition
  15524. * @param actionManager the manager of the action the condition is applied to
  15525. */
  15526. constructor(actionManager: ActionManager);
  15527. /**
  15528. * Check if the current condition is valid
  15529. * @returns a boolean
  15530. */
  15531. isValid(): boolean;
  15532. /**
  15533. * Internal only
  15534. * @hidden
  15535. */
  15536. _getProperty(propertyPath: string): string;
  15537. /**
  15538. * Internal only
  15539. * @hidden
  15540. */
  15541. _getEffectiveTarget(target: any, propertyPath: string): any;
  15542. /**
  15543. * Serialize placeholder for child classes
  15544. * @returns the serialized object
  15545. */
  15546. serialize(): any;
  15547. /**
  15548. * Internal only
  15549. * @hidden
  15550. */
  15551. protected _serialize(serializedCondition: any): any;
  15552. }
  15553. /**
  15554. * Defines specific conditional operators as extensions of Condition
  15555. */
  15556. export class ValueCondition extends Condition {
  15557. /** path to specify the property of the target the conditional operator uses */
  15558. propertyPath: string;
  15559. /** the value compared by the conditional operator against the current value of the property */
  15560. value: any;
  15561. /** the conditional operator, default ValueCondition.IsEqual */
  15562. operator: number;
  15563. /**
  15564. * Internal only
  15565. * @hidden
  15566. */
  15567. private static _IsEqual;
  15568. /**
  15569. * Internal only
  15570. * @hidden
  15571. */
  15572. private static _IsDifferent;
  15573. /**
  15574. * Internal only
  15575. * @hidden
  15576. */
  15577. private static _IsGreater;
  15578. /**
  15579. * Internal only
  15580. * @hidden
  15581. */
  15582. private static _IsLesser;
  15583. /**
  15584. * returns the number for IsEqual
  15585. */
  15586. static readonly IsEqual: number;
  15587. /**
  15588. * Returns the number for IsDifferent
  15589. */
  15590. static readonly IsDifferent: number;
  15591. /**
  15592. * Returns the number for IsGreater
  15593. */
  15594. static readonly IsGreater: number;
  15595. /**
  15596. * Returns the number for IsLesser
  15597. */
  15598. static readonly IsLesser: number;
  15599. /**
  15600. * Internal only The action manager for the condition
  15601. * @hidden
  15602. */
  15603. _actionManager: ActionManager;
  15604. /**
  15605. * Internal only
  15606. * @hidden
  15607. */
  15608. private _target;
  15609. /**
  15610. * Internal only
  15611. * @hidden
  15612. */
  15613. private _effectiveTarget;
  15614. /**
  15615. * Internal only
  15616. * @hidden
  15617. */
  15618. private _property;
  15619. /**
  15620. * Creates a new ValueCondition
  15621. * @param actionManager manager for the action the condition applies to
  15622. * @param target for the action
  15623. * @param propertyPath path to specify the property of the target the conditional operator uses
  15624. * @param value the value compared by the conditional operator against the current value of the property
  15625. * @param operator the conditional operator, default ValueCondition.IsEqual
  15626. */
  15627. constructor(actionManager: ActionManager, target: any,
  15628. /** path to specify the property of the target the conditional operator uses */
  15629. propertyPath: string,
  15630. /** the value compared by the conditional operator against the current value of the property */
  15631. value: any,
  15632. /** the conditional operator, default ValueCondition.IsEqual */
  15633. operator?: number);
  15634. /**
  15635. * Compares the given value with the property value for the specified conditional operator
  15636. * @returns the result of the comparison
  15637. */
  15638. isValid(): boolean;
  15639. /**
  15640. * Serialize the ValueCondition into a JSON compatible object
  15641. * @returns serialization object
  15642. */
  15643. serialize(): any;
  15644. /**
  15645. * Gets the name of the conditional operator for the ValueCondition
  15646. * @param operator the conditional operator
  15647. * @returns the name
  15648. */
  15649. static GetOperatorName(operator: number): string;
  15650. }
  15651. /**
  15652. * Defines a predicate condition as an extension of Condition
  15653. */
  15654. export class PredicateCondition extends Condition {
  15655. /** defines the predicate function used to validate the condition */
  15656. predicate: () => boolean;
  15657. /**
  15658. * Internal only - manager for action
  15659. * @hidden
  15660. */
  15661. _actionManager: ActionManager;
  15662. /**
  15663. * Creates a new PredicateCondition
  15664. * @param actionManager manager for the action the condition applies to
  15665. * @param predicate defines the predicate function used to validate the condition
  15666. */
  15667. constructor(actionManager: ActionManager,
  15668. /** defines the predicate function used to validate the condition */
  15669. predicate: () => boolean);
  15670. /**
  15671. * @returns the validity of the predicate condition
  15672. */
  15673. isValid(): boolean;
  15674. }
  15675. /**
  15676. * Defines a state condition as an extension of Condition
  15677. */
  15678. export class StateCondition extends Condition {
  15679. /** Value to compare with target state */
  15680. value: string;
  15681. /**
  15682. * Internal only - manager for action
  15683. * @hidden
  15684. */
  15685. _actionManager: ActionManager;
  15686. /**
  15687. * Internal only
  15688. * @hidden
  15689. */
  15690. private _target;
  15691. /**
  15692. * Creates a new StateCondition
  15693. * @param actionManager manager for the action the condition applies to
  15694. * @param target of the condition
  15695. * @param value to compare with target state
  15696. */
  15697. constructor(actionManager: ActionManager, target: any,
  15698. /** Value to compare with target state */
  15699. value: string);
  15700. /**
  15701. * Gets a boolean indicating if the current condition is met
  15702. * @returns the validity of the state
  15703. */
  15704. isValid(): boolean;
  15705. /**
  15706. * Serialize the StateCondition into a JSON compatible object
  15707. * @returns serialization object
  15708. */
  15709. serialize(): any;
  15710. }
  15711. }
  15712. declare module "babylonjs/Actions/directActions" {
  15713. import { Action } from "babylonjs/Actions/action";
  15714. import { Condition } from "babylonjs/Actions/condition";
  15715. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15716. /**
  15717. * This defines an action responsible to toggle a boolean once triggered.
  15718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15719. */
  15720. export class SwitchBooleanAction extends Action {
  15721. /**
  15722. * The path to the boolean property in the target object
  15723. */
  15724. propertyPath: string;
  15725. private _target;
  15726. private _effectiveTarget;
  15727. private _property;
  15728. /**
  15729. * Instantiate the action
  15730. * @param triggerOptions defines the trigger options
  15731. * @param target defines the object containing the boolean
  15732. * @param propertyPath defines the path to the boolean property in the target object
  15733. * @param condition defines the trigger related conditions
  15734. */
  15735. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15736. /** @hidden */
  15737. _prepare(): void;
  15738. /**
  15739. * Execute the action toggle the boolean value.
  15740. */
  15741. execute(): void;
  15742. /**
  15743. * Serializes the actions and its related information.
  15744. * @param parent defines the object to serialize in
  15745. * @returns the serialized object
  15746. */
  15747. serialize(parent: any): any;
  15748. }
  15749. /**
  15750. * This defines an action responsible to set a the state field of the target
  15751. * to a desired value once triggered.
  15752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15753. */
  15754. export class SetStateAction extends Action {
  15755. /**
  15756. * The value to store in the state field.
  15757. */
  15758. value: string;
  15759. private _target;
  15760. /**
  15761. * Instantiate the action
  15762. * @param triggerOptions defines the trigger options
  15763. * @param target defines the object containing the state property
  15764. * @param value defines the value to store in the state field
  15765. * @param condition defines the trigger related conditions
  15766. */
  15767. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15768. /**
  15769. * Execute the action and store the value on the target state property.
  15770. */
  15771. execute(): void;
  15772. /**
  15773. * Serializes the actions and its related information.
  15774. * @param parent defines the object to serialize in
  15775. * @returns the serialized object
  15776. */
  15777. serialize(parent: any): any;
  15778. }
  15779. /**
  15780. * This defines an action responsible to set a property of the target
  15781. * to a desired value once triggered.
  15782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15783. */
  15784. export class SetValueAction extends Action {
  15785. /**
  15786. * The path of the property to set in the target.
  15787. */
  15788. propertyPath: string;
  15789. /**
  15790. * The value to set in the property
  15791. */
  15792. value: any;
  15793. private _target;
  15794. private _effectiveTarget;
  15795. private _property;
  15796. /**
  15797. * Instantiate the action
  15798. * @param triggerOptions defines the trigger options
  15799. * @param target defines the object containing the property
  15800. * @param propertyPath defines the path of the property to set in the target
  15801. * @param value defines the value to set in the property
  15802. * @param condition defines the trigger related conditions
  15803. */
  15804. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15805. /** @hidden */
  15806. _prepare(): void;
  15807. /**
  15808. * Execute the action and set the targetted property to the desired value.
  15809. */
  15810. execute(): void;
  15811. /**
  15812. * Serializes the actions and its related information.
  15813. * @param parent defines the object to serialize in
  15814. * @returns the serialized object
  15815. */
  15816. serialize(parent: any): any;
  15817. }
  15818. /**
  15819. * This defines an action responsible to increment the target value
  15820. * to a desired value once triggered.
  15821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15822. */
  15823. export class IncrementValueAction extends Action {
  15824. /**
  15825. * The path of the property to increment in the target.
  15826. */
  15827. propertyPath: string;
  15828. /**
  15829. * The value we should increment the property by.
  15830. */
  15831. value: any;
  15832. private _target;
  15833. private _effectiveTarget;
  15834. private _property;
  15835. /**
  15836. * Instantiate the action
  15837. * @param triggerOptions defines the trigger options
  15838. * @param target defines the object containing the property
  15839. * @param propertyPath defines the path of the property to increment in the target
  15840. * @param value defines the value value we should increment the property by
  15841. * @param condition defines the trigger related conditions
  15842. */
  15843. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15844. /** @hidden */
  15845. _prepare(): void;
  15846. /**
  15847. * Execute the action and increment the target of the value amount.
  15848. */
  15849. execute(): void;
  15850. /**
  15851. * Serializes the actions and its related information.
  15852. * @param parent defines the object to serialize in
  15853. * @returns the serialized object
  15854. */
  15855. serialize(parent: any): any;
  15856. }
  15857. /**
  15858. * This defines an action responsible to start an animation once triggered.
  15859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15860. */
  15861. export class PlayAnimationAction extends Action {
  15862. /**
  15863. * Where the animation should start (animation frame)
  15864. */
  15865. from: number;
  15866. /**
  15867. * Where the animation should stop (animation frame)
  15868. */
  15869. to: number;
  15870. /**
  15871. * Define if the animation should loop or stop after the first play.
  15872. */
  15873. loop?: boolean;
  15874. private _target;
  15875. /**
  15876. * Instantiate the action
  15877. * @param triggerOptions defines the trigger options
  15878. * @param target defines the target animation or animation name
  15879. * @param from defines from where the animation should start (animation frame)
  15880. * @param end defines where the animation should stop (animation frame)
  15881. * @param loop defines if the animation should loop or stop after the first play
  15882. * @param condition defines the trigger related conditions
  15883. */
  15884. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15885. /** @hidden */
  15886. _prepare(): void;
  15887. /**
  15888. * Execute the action and play the animation.
  15889. */
  15890. execute(): void;
  15891. /**
  15892. * Serializes the actions and its related information.
  15893. * @param parent defines the object to serialize in
  15894. * @returns the serialized object
  15895. */
  15896. serialize(parent: any): any;
  15897. }
  15898. /**
  15899. * This defines an action responsible to stop an animation once triggered.
  15900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15901. */
  15902. export class StopAnimationAction extends Action {
  15903. private _target;
  15904. /**
  15905. * Instantiate the action
  15906. * @param triggerOptions defines the trigger options
  15907. * @param target defines the target animation or animation name
  15908. * @param condition defines the trigger related conditions
  15909. */
  15910. constructor(triggerOptions: any, target: any, condition?: Condition);
  15911. /** @hidden */
  15912. _prepare(): void;
  15913. /**
  15914. * Execute the action and stop the animation.
  15915. */
  15916. execute(): void;
  15917. /**
  15918. * Serializes the actions and its related information.
  15919. * @param parent defines the object to serialize in
  15920. * @returns the serialized object
  15921. */
  15922. serialize(parent: any): any;
  15923. }
  15924. /**
  15925. * This defines an action responsible that does nothing once triggered.
  15926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15927. */
  15928. export class DoNothingAction extends Action {
  15929. /**
  15930. * Instantiate the action
  15931. * @param triggerOptions defines the trigger options
  15932. * @param condition defines the trigger related conditions
  15933. */
  15934. constructor(triggerOptions?: any, condition?: Condition);
  15935. /**
  15936. * Execute the action and do nothing.
  15937. */
  15938. execute(): void;
  15939. /**
  15940. * Serializes the actions and its related information.
  15941. * @param parent defines the object to serialize in
  15942. * @returns the serialized object
  15943. */
  15944. serialize(parent: any): any;
  15945. }
  15946. /**
  15947. * This defines an action responsible to trigger several actions once triggered.
  15948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15949. */
  15950. export class CombineAction extends Action {
  15951. /**
  15952. * The list of aggregated animations to run.
  15953. */
  15954. children: Action[];
  15955. /**
  15956. * Instantiate the action
  15957. * @param triggerOptions defines the trigger options
  15958. * @param children defines the list of aggregated animations to run
  15959. * @param condition defines the trigger related conditions
  15960. */
  15961. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15962. /** @hidden */
  15963. _prepare(): void;
  15964. /**
  15965. * Execute the action and executes all the aggregated actions.
  15966. */
  15967. execute(evt: ActionEvent): void;
  15968. /**
  15969. * Serializes the actions and its related information.
  15970. * @param parent defines the object to serialize in
  15971. * @returns the serialized object
  15972. */
  15973. serialize(parent: any): any;
  15974. }
  15975. /**
  15976. * This defines an action responsible to run code (external event) once triggered.
  15977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15978. */
  15979. export class ExecuteCodeAction extends Action {
  15980. /**
  15981. * The callback function to run.
  15982. */
  15983. func: (evt: ActionEvent) => void;
  15984. /**
  15985. * Instantiate the action
  15986. * @param triggerOptions defines the trigger options
  15987. * @param func defines the callback function to run
  15988. * @param condition defines the trigger related conditions
  15989. */
  15990. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15991. /**
  15992. * Execute the action and run the attached code.
  15993. */
  15994. execute(evt: ActionEvent): void;
  15995. }
  15996. /**
  15997. * This defines an action responsible to set the parent property of the target once triggered.
  15998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15999. */
  16000. export class SetParentAction extends Action {
  16001. private _parent;
  16002. private _target;
  16003. /**
  16004. * Instantiate the action
  16005. * @param triggerOptions defines the trigger options
  16006. * @param target defines the target containing the parent property
  16007. * @param parent defines from where the animation should start (animation frame)
  16008. * @param condition defines the trigger related conditions
  16009. */
  16010. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  16011. /** @hidden */
  16012. _prepare(): void;
  16013. /**
  16014. * Execute the action and set the parent property.
  16015. */
  16016. execute(): void;
  16017. /**
  16018. * Serializes the actions and its related information.
  16019. * @param parent defines the object to serialize in
  16020. * @returns the serialized object
  16021. */
  16022. serialize(parent: any): any;
  16023. }
  16024. }
  16025. declare module "babylonjs/Actions/actionManager" {
  16026. import { Nullable } from "babylonjs/types";
  16027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16028. import { Scene } from "babylonjs/scene";
  16029. import { IAction } from "babylonjs/Actions/action";
  16030. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  16031. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  16032. /**
  16033. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  16034. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  16035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16036. */
  16037. export class ActionManager extends AbstractActionManager {
  16038. /**
  16039. * Nothing
  16040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16041. */
  16042. static readonly NothingTrigger: number;
  16043. /**
  16044. * On pick
  16045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16046. */
  16047. static readonly OnPickTrigger: number;
  16048. /**
  16049. * On left pick
  16050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16051. */
  16052. static readonly OnLeftPickTrigger: number;
  16053. /**
  16054. * On right pick
  16055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16056. */
  16057. static readonly OnRightPickTrigger: number;
  16058. /**
  16059. * On center pick
  16060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16061. */
  16062. static readonly OnCenterPickTrigger: number;
  16063. /**
  16064. * On pick down
  16065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16066. */
  16067. static readonly OnPickDownTrigger: number;
  16068. /**
  16069. * On double pick
  16070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16071. */
  16072. static readonly OnDoublePickTrigger: number;
  16073. /**
  16074. * On pick up
  16075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16076. */
  16077. static readonly OnPickUpTrigger: number;
  16078. /**
  16079. * On pick out.
  16080. * This trigger will only be raised if you also declared a OnPickDown
  16081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16082. */
  16083. static readonly OnPickOutTrigger: number;
  16084. /**
  16085. * On long press
  16086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16087. */
  16088. static readonly OnLongPressTrigger: number;
  16089. /**
  16090. * On pointer over
  16091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16092. */
  16093. static readonly OnPointerOverTrigger: number;
  16094. /**
  16095. * On pointer out
  16096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16097. */
  16098. static readonly OnPointerOutTrigger: number;
  16099. /**
  16100. * On every frame
  16101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16102. */
  16103. static readonly OnEveryFrameTrigger: number;
  16104. /**
  16105. * On intersection enter
  16106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16107. */
  16108. static readonly OnIntersectionEnterTrigger: number;
  16109. /**
  16110. * On intersection exit
  16111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16112. */
  16113. static readonly OnIntersectionExitTrigger: number;
  16114. /**
  16115. * On key down
  16116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16117. */
  16118. static readonly OnKeyDownTrigger: number;
  16119. /**
  16120. * On key up
  16121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16122. */
  16123. static readonly OnKeyUpTrigger: number;
  16124. private _scene;
  16125. /**
  16126. * Creates a new action manager
  16127. * @param scene defines the hosting scene
  16128. */
  16129. constructor(scene: Scene);
  16130. /**
  16131. * Releases all associated resources
  16132. */
  16133. dispose(): void;
  16134. /**
  16135. * Gets hosting scene
  16136. * @returns the hosting scene
  16137. */
  16138. getScene(): Scene;
  16139. /**
  16140. * Does this action manager handles actions of any of the given triggers
  16141. * @param triggers defines the triggers to be tested
  16142. * @return a boolean indicating whether one (or more) of the triggers is handled
  16143. */
  16144. hasSpecificTriggers(triggers: number[]): boolean;
  16145. /**
  16146. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  16147. * speed.
  16148. * @param triggerA defines the trigger to be tested
  16149. * @param triggerB defines the trigger to be tested
  16150. * @return a boolean indicating whether one (or more) of the triggers is handled
  16151. */
  16152. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  16153. /**
  16154. * Does this action manager handles actions of a given trigger
  16155. * @param trigger defines the trigger to be tested
  16156. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  16157. * @return whether the trigger is handled
  16158. */
  16159. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  16160. /**
  16161. * Does this action manager has pointer triggers
  16162. */
  16163. readonly hasPointerTriggers: boolean;
  16164. /**
  16165. * Does this action manager has pick triggers
  16166. */
  16167. readonly hasPickTriggers: boolean;
  16168. /**
  16169. * Registers an action to this action manager
  16170. * @param action defines the action to be registered
  16171. * @return the action amended (prepared) after registration
  16172. */
  16173. registerAction(action: IAction): Nullable<IAction>;
  16174. /**
  16175. * Unregisters an action to this action manager
  16176. * @param action defines the action to be unregistered
  16177. * @return a boolean indicating whether the action has been unregistered
  16178. */
  16179. unregisterAction(action: IAction): Boolean;
  16180. /**
  16181. * Process a specific trigger
  16182. * @param trigger defines the trigger to process
  16183. * @param evt defines the event details to be processed
  16184. */
  16185. processTrigger(trigger: number, evt?: IActionEvent): void;
  16186. /** @hidden */
  16187. _getEffectiveTarget(target: any, propertyPath: string): any;
  16188. /** @hidden */
  16189. _getProperty(propertyPath: string): string;
  16190. /**
  16191. * Serialize this manager to a JSON object
  16192. * @param name defines the property name to store this manager
  16193. * @returns a JSON representation of this manager
  16194. */
  16195. serialize(name: string): any;
  16196. /**
  16197. * Creates a new ActionManager from a JSON data
  16198. * @param parsedActions defines the JSON data to read from
  16199. * @param object defines the hosting mesh
  16200. * @param scene defines the hosting scene
  16201. */
  16202. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  16203. /**
  16204. * Get a trigger name by index
  16205. * @param trigger defines the trigger index
  16206. * @returns a trigger name
  16207. */
  16208. static GetTriggerName(trigger: number): string;
  16209. }
  16210. }
  16211. declare module "babylonjs/Culling/ray" {
  16212. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  16213. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  16214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16215. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16216. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  16217. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  16218. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  16219. /**
  16220. * Class representing a ray with position and direction
  16221. */
  16222. export class Ray {
  16223. /** origin point */
  16224. origin: Vector3;
  16225. /** direction */
  16226. direction: Vector3;
  16227. /** length of the ray */
  16228. length: number;
  16229. private static readonly TmpVector3;
  16230. private _tmpRay;
  16231. /**
  16232. * Creates a new ray
  16233. * @param origin origin point
  16234. * @param direction direction
  16235. * @param length length of the ray
  16236. */
  16237. constructor(
  16238. /** origin point */
  16239. origin: Vector3,
  16240. /** direction */
  16241. direction: Vector3,
  16242. /** length of the ray */
  16243. length?: number);
  16244. /**
  16245. * Checks if the ray intersects a box
  16246. * @param minimum bound of the box
  16247. * @param maximum bound of the box
  16248. * @param intersectionTreshold extra extend to be added to the box in all direction
  16249. * @returns if the box was hit
  16250. */
  16251. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  16252. /**
  16253. * Checks if the ray intersects a box
  16254. * @param box the bounding box to check
  16255. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  16256. * @returns if the box was hit
  16257. */
  16258. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  16259. /**
  16260. * If the ray hits a sphere
  16261. * @param sphere the bounding sphere to check
  16262. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  16263. * @returns true if it hits the sphere
  16264. */
  16265. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  16266. /**
  16267. * If the ray hits a triange
  16268. * @param vertex0 triangle vertex
  16269. * @param vertex1 triangle vertex
  16270. * @param vertex2 triangle vertex
  16271. * @returns intersection information if hit
  16272. */
  16273. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  16274. /**
  16275. * Checks if ray intersects a plane
  16276. * @param plane the plane to check
  16277. * @returns the distance away it was hit
  16278. */
  16279. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  16280. /**
  16281. * Checks if ray intersects a mesh
  16282. * @param mesh the mesh to check
  16283. * @param fastCheck if only the bounding box should checked
  16284. * @returns picking info of the intersecton
  16285. */
  16286. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16287. /**
  16288. * Checks if ray intersects a mesh
  16289. * @param meshes the meshes to check
  16290. * @param fastCheck if only the bounding box should checked
  16291. * @param results array to store result in
  16292. * @returns Array of picking infos
  16293. */
  16294. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16295. private _comparePickingInfo;
  16296. private static smallnum;
  16297. private static rayl;
  16298. /**
  16299. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16300. * @param sega the first point of the segment to test the intersection against
  16301. * @param segb the second point of the segment to test the intersection against
  16302. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16303. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16304. */
  16305. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16306. /**
  16307. * Update the ray from viewport position
  16308. * @param x position
  16309. * @param y y position
  16310. * @param viewportWidth viewport width
  16311. * @param viewportHeight viewport height
  16312. * @param world world matrix
  16313. * @param view view matrix
  16314. * @param projection projection matrix
  16315. * @returns this ray updated
  16316. */
  16317. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16318. /**
  16319. * Creates a ray with origin and direction of 0,0,0
  16320. * @returns the new ray
  16321. */
  16322. static Zero(): Ray;
  16323. /**
  16324. * Creates a new ray from screen space and viewport
  16325. * @param x position
  16326. * @param y y position
  16327. * @param viewportWidth viewport width
  16328. * @param viewportHeight viewport height
  16329. * @param world world matrix
  16330. * @param view view matrix
  16331. * @param projection projection matrix
  16332. * @returns new ray
  16333. */
  16334. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16335. /**
  16336. * 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
  16337. * transformed to the given world matrix.
  16338. * @param origin The origin point
  16339. * @param end The end point
  16340. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16341. * @returns the new ray
  16342. */
  16343. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16344. /**
  16345. * Transforms a ray by a matrix
  16346. * @param ray ray to transform
  16347. * @param matrix matrix to apply
  16348. * @returns the resulting new ray
  16349. */
  16350. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16351. /**
  16352. * Transforms a ray by a matrix
  16353. * @param ray ray to transform
  16354. * @param matrix matrix to apply
  16355. * @param result ray to store result in
  16356. */
  16357. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16358. /**
  16359. * Unproject a ray from screen space to object space
  16360. * @param sourceX defines the screen space x coordinate to use
  16361. * @param sourceY defines the screen space y coordinate to use
  16362. * @param viewportWidth defines the current width of the viewport
  16363. * @param viewportHeight defines the current height of the viewport
  16364. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16365. * @param view defines the view matrix to use
  16366. * @param projection defines the projection matrix to use
  16367. */
  16368. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16369. }
  16370. /**
  16371. * Type used to define predicate used to select faces when a mesh intersection is detected
  16372. */
  16373. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16374. module "babylonjs/scene" {
  16375. interface Scene {
  16376. /** @hidden */
  16377. _tempPickingRay: Nullable<Ray>;
  16378. /** @hidden */
  16379. _cachedRayForTransform: Ray;
  16380. /** @hidden */
  16381. _pickWithRayInverseMatrix: Matrix;
  16382. /** @hidden */
  16383. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16384. /** @hidden */
  16385. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16386. }
  16387. }
  16388. }
  16389. declare module "babylonjs/Sprites/spriteSceneComponent" {
  16390. import { Nullable } from "babylonjs/types";
  16391. import { Observable } from "babylonjs/Misc/observable";
  16392. import { Scene } from "babylonjs/scene";
  16393. import { Sprite } from "babylonjs/Sprites/sprite";
  16394. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16395. import { Ray } from "babylonjs/Culling/ray";
  16396. import { Camera } from "babylonjs/Cameras/camera";
  16397. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16398. import { ISceneComponent } from "babylonjs/sceneComponent";
  16399. module "babylonjs/scene" {
  16400. interface Scene {
  16401. /** @hidden */
  16402. _pointerOverSprite: Nullable<Sprite>;
  16403. /** @hidden */
  16404. _pickedDownSprite: Nullable<Sprite>;
  16405. /** @hidden */
  16406. _tempSpritePickingRay: Nullable<Ray>;
  16407. /**
  16408. * All of the sprite managers added to this scene
  16409. * @see http://doc.babylonjs.com/babylon101/sprites
  16410. */
  16411. spriteManagers: Array<ISpriteManager>;
  16412. /**
  16413. * An event triggered when sprites rendering is about to start
  16414. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16415. */
  16416. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16417. /**
  16418. * An event triggered when sprites rendering is done
  16419. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16420. */
  16421. onAfterSpritesRenderingObservable: Observable<Scene>;
  16422. /** @hidden */
  16423. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16424. /** Launch a ray to try to pick a sprite in the scene
  16425. * @param x position on screen
  16426. * @param y position on screen
  16427. * @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
  16428. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16429. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16430. * @returns a PickingInfo
  16431. */
  16432. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16433. /** Use the given ray to pick a sprite in the scene
  16434. * @param ray The ray (in world space) to use to pick meshes
  16435. * @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
  16436. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16437. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16438. * @returns a PickingInfo
  16439. */
  16440. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16441. /**
  16442. * Force the sprite under the pointer
  16443. * @param sprite defines the sprite to use
  16444. */
  16445. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16446. /**
  16447. * Gets the sprite under the pointer
  16448. * @returns a Sprite or null if no sprite is under the pointer
  16449. */
  16450. getPointerOverSprite(): Nullable<Sprite>;
  16451. }
  16452. }
  16453. /**
  16454. * Defines the sprite scene component responsible to manage sprites
  16455. * in a given scene.
  16456. */
  16457. export class SpriteSceneComponent implements ISceneComponent {
  16458. /**
  16459. * The component name helpfull to identify the component in the list of scene components.
  16460. */
  16461. readonly name: string;
  16462. /**
  16463. * The scene the component belongs to.
  16464. */
  16465. scene: Scene;
  16466. /** @hidden */
  16467. private _spritePredicate;
  16468. /**
  16469. * Creates a new instance of the component for the given scene
  16470. * @param scene Defines the scene to register the component in
  16471. */
  16472. constructor(scene: Scene);
  16473. /**
  16474. * Registers the component in a given scene
  16475. */
  16476. register(): void;
  16477. /**
  16478. * Rebuilds the elements related to this component in case of
  16479. * context lost for instance.
  16480. */
  16481. rebuild(): void;
  16482. /**
  16483. * Disposes the component and the associated ressources.
  16484. */
  16485. dispose(): void;
  16486. private _pickSpriteButKeepRay;
  16487. private _pointerMove;
  16488. private _pointerDown;
  16489. private _pointerUp;
  16490. }
  16491. }
  16492. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  16493. /** @hidden */
  16494. export var fogFragmentDeclaration: {
  16495. name: string;
  16496. shader: string;
  16497. };
  16498. }
  16499. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  16500. /** @hidden */
  16501. export var fogFragment: {
  16502. name: string;
  16503. shader: string;
  16504. };
  16505. }
  16506. declare module "babylonjs/Shaders/sprites.fragment" {
  16507. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  16508. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  16509. /** @hidden */
  16510. export var spritesPixelShader: {
  16511. name: string;
  16512. shader: string;
  16513. };
  16514. }
  16515. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  16516. /** @hidden */
  16517. export var fogVertexDeclaration: {
  16518. name: string;
  16519. shader: string;
  16520. };
  16521. }
  16522. declare module "babylonjs/Shaders/sprites.vertex" {
  16523. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  16524. /** @hidden */
  16525. export var spritesVertexShader: {
  16526. name: string;
  16527. shader: string;
  16528. };
  16529. }
  16530. declare module "babylonjs/Sprites/spriteManager" {
  16531. import { IDisposable, Scene } from "babylonjs/scene";
  16532. import { Nullable } from "babylonjs/types";
  16533. import { Observable } from "babylonjs/Misc/observable";
  16534. import { Sprite } from "babylonjs/Sprites/sprite";
  16535. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16536. import { Camera } from "babylonjs/Cameras/camera";
  16537. import { Texture } from "babylonjs/Materials/Textures/texture";
  16538. import "babylonjs/Shaders/sprites.fragment";
  16539. import "babylonjs/Shaders/sprites.vertex";
  16540. import { Ray } from "babylonjs/Culling/ray";
  16541. /**
  16542. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16543. */
  16544. export interface ISpriteManager extends IDisposable {
  16545. /**
  16546. * Restricts the camera to viewing objects with the same layerMask.
  16547. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16548. */
  16549. layerMask: number;
  16550. /**
  16551. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16552. */
  16553. isPickable: boolean;
  16554. /**
  16555. * Specifies the rendering group id for this mesh (0 by default)
  16556. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16557. */
  16558. renderingGroupId: number;
  16559. /**
  16560. * Defines the list of sprites managed by the manager.
  16561. */
  16562. sprites: Array<Sprite>;
  16563. /**
  16564. * Tests the intersection of a sprite with a specific ray.
  16565. * @param ray The ray we are sending to test the collision
  16566. * @param camera The camera space we are sending rays in
  16567. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16568. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16569. * @returns picking info or null.
  16570. */
  16571. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16572. /**
  16573. * Renders the list of sprites on screen.
  16574. */
  16575. render(): void;
  16576. }
  16577. /**
  16578. * Class used to manage multiple sprites on the same spritesheet
  16579. * @see http://doc.babylonjs.com/babylon101/sprites
  16580. */
  16581. export class SpriteManager implements ISpriteManager {
  16582. /** defines the manager's name */
  16583. name: string;
  16584. /** Gets the list of sprites */
  16585. sprites: Sprite[];
  16586. /** Gets or sets the rendering group id (0 by default) */
  16587. renderingGroupId: number;
  16588. /** Gets or sets camera layer mask */
  16589. layerMask: number;
  16590. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16591. fogEnabled: boolean;
  16592. /** Gets or sets a boolean indicating if the sprites are pickable */
  16593. isPickable: boolean;
  16594. /** Defines the default width of a cell in the spritesheet */
  16595. cellWidth: number;
  16596. /** Defines the default height of a cell in the spritesheet */
  16597. cellHeight: number;
  16598. /**
  16599. * An event triggered when the manager is disposed.
  16600. */
  16601. onDisposeObservable: Observable<SpriteManager>;
  16602. private _onDisposeObserver;
  16603. /**
  16604. * Callback called when the manager is disposed
  16605. */
  16606. onDispose: () => void;
  16607. private _capacity;
  16608. private _spriteTexture;
  16609. private _epsilon;
  16610. private _scene;
  16611. private _vertexData;
  16612. private _buffer;
  16613. private _vertexBuffers;
  16614. private _indexBuffer;
  16615. private _effectBase;
  16616. private _effectFog;
  16617. /**
  16618. * Gets or sets the spritesheet texture
  16619. */
  16620. texture: Texture;
  16621. /**
  16622. * Creates a new sprite manager
  16623. * @param name defines the manager's name
  16624. * @param imgUrl defines the sprite sheet url
  16625. * @param capacity defines the maximum allowed number of sprites
  16626. * @param cellSize defines the size of a sprite cell
  16627. * @param scene defines the hosting scene
  16628. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16629. * @param samplingMode defines the smapling mode to use with spritesheet
  16630. */
  16631. constructor(
  16632. /** defines the manager's name */
  16633. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16634. private _appendSpriteVertex;
  16635. /**
  16636. * Intersects the sprites with a ray
  16637. * @param ray defines the ray to intersect with
  16638. * @param camera defines the current active camera
  16639. * @param predicate defines a predicate used to select candidate sprites
  16640. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16641. * @returns null if no hit or a PickingInfo
  16642. */
  16643. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16644. /**
  16645. * Render all child sprites
  16646. */
  16647. render(): void;
  16648. /**
  16649. * Release associated resources
  16650. */
  16651. dispose(): void;
  16652. }
  16653. }
  16654. declare module "babylonjs/Sprites/sprite" {
  16655. import { Vector3, Color4 } from "babylonjs/Maths/math";
  16656. import { Nullable } from "babylonjs/types";
  16657. import { ActionManager } from "babylonjs/Actions/actionManager";
  16658. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16659. /**
  16660. * Class used to represent a sprite
  16661. * @see http://doc.babylonjs.com/babylon101/sprites
  16662. */
  16663. export class Sprite {
  16664. /** defines the name */
  16665. name: string;
  16666. /** Gets or sets the current world position */
  16667. position: Vector3;
  16668. /** Gets or sets the main color */
  16669. color: Color4;
  16670. /** Gets or sets the width */
  16671. width: number;
  16672. /** Gets or sets the height */
  16673. height: number;
  16674. /** Gets or sets rotation angle */
  16675. angle: number;
  16676. /** Gets or sets the cell index in the sprite sheet */
  16677. cellIndex: number;
  16678. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16679. invertU: number;
  16680. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16681. invertV: number;
  16682. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16683. disposeWhenFinishedAnimating: boolean;
  16684. /** Gets the list of attached animations */
  16685. animations: Animation[];
  16686. /** Gets or sets a boolean indicating if the sprite can be picked */
  16687. isPickable: boolean;
  16688. /**
  16689. * Gets or sets the associated action manager
  16690. */
  16691. actionManager: Nullable<ActionManager>;
  16692. private _animationStarted;
  16693. private _loopAnimation;
  16694. private _fromIndex;
  16695. private _toIndex;
  16696. private _delay;
  16697. private _direction;
  16698. private _manager;
  16699. private _time;
  16700. private _onAnimationEnd;
  16701. /**
  16702. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16703. */
  16704. isVisible: boolean;
  16705. /**
  16706. * Gets or sets the sprite size
  16707. */
  16708. size: number;
  16709. /**
  16710. * Creates a new Sprite
  16711. * @param name defines the name
  16712. * @param manager defines the manager
  16713. */
  16714. constructor(
  16715. /** defines the name */
  16716. name: string, manager: ISpriteManager);
  16717. /**
  16718. * Starts an animation
  16719. * @param from defines the initial key
  16720. * @param to defines the end key
  16721. * @param loop defines if the animation must loop
  16722. * @param delay defines the start delay (in ms)
  16723. * @param onAnimationEnd defines a callback to call when animation ends
  16724. */
  16725. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16726. /** Stops current animation (if any) */
  16727. stopAnimation(): void;
  16728. /** @hidden */
  16729. _animate(deltaTime: number): void;
  16730. /** Release associated resources */
  16731. dispose(): void;
  16732. }
  16733. }
  16734. declare module "babylonjs/Collisions/pickingInfo" {
  16735. import { Nullable } from "babylonjs/types";
  16736. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  16737. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16738. import { Sprite } from "babylonjs/Sprites/sprite";
  16739. import { Ray } from "babylonjs/Culling/ray";
  16740. /**
  16741. * Information about the result of picking within a scene
  16742. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16743. */
  16744. export class PickingInfo {
  16745. /** @hidden */
  16746. _pickingUnavailable: boolean;
  16747. /**
  16748. * If the pick collided with an object
  16749. */
  16750. hit: boolean;
  16751. /**
  16752. * Distance away where the pick collided
  16753. */
  16754. distance: number;
  16755. /**
  16756. * The location of pick collision
  16757. */
  16758. pickedPoint: Nullable<Vector3>;
  16759. /**
  16760. * The mesh corresponding the the pick collision
  16761. */
  16762. pickedMesh: Nullable<AbstractMesh>;
  16763. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16764. bu: number;
  16765. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16766. bv: number;
  16767. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16768. faceId: number;
  16769. /** Id of the the submesh that was picked */
  16770. subMeshId: number;
  16771. /** If a sprite was picked, this will be the sprite the pick collided with */
  16772. pickedSprite: Nullable<Sprite>;
  16773. /**
  16774. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16775. */
  16776. originMesh: Nullable<AbstractMesh>;
  16777. /**
  16778. * The ray that was used to perform the picking.
  16779. */
  16780. ray: Nullable<Ray>;
  16781. /**
  16782. * Gets the normal correspodning to the face the pick collided with
  16783. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16784. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16785. * @returns The normal correspodning to the face the pick collided with
  16786. */
  16787. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16788. /**
  16789. * Gets the texture coordinates of where the pick occured
  16790. * @returns the vector containing the coordnates of the texture
  16791. */
  16792. getTextureCoordinates(): Nullable<Vector2>;
  16793. }
  16794. }
  16795. declare module "babylonjs/Events/pointerEvents" {
  16796. import { Nullable } from "babylonjs/types";
  16797. import { Vector2 } from "babylonjs/Maths/math";
  16798. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16799. import { Ray } from "babylonjs/Culling/ray";
  16800. /**
  16801. * Gather the list of pointer event types as constants.
  16802. */
  16803. export class PointerEventTypes {
  16804. /**
  16805. * 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.
  16806. */
  16807. static readonly POINTERDOWN: number;
  16808. /**
  16809. * The pointerup event is fired when a pointer is no longer active.
  16810. */
  16811. static readonly POINTERUP: number;
  16812. /**
  16813. * The pointermove event is fired when a pointer changes coordinates.
  16814. */
  16815. static readonly POINTERMOVE: number;
  16816. /**
  16817. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16818. */
  16819. static readonly POINTERWHEEL: number;
  16820. /**
  16821. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16822. */
  16823. static readonly POINTERPICK: number;
  16824. /**
  16825. * The pointertap event is fired when a the object has been touched and released without drag.
  16826. */
  16827. static readonly POINTERTAP: number;
  16828. /**
  16829. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16830. */
  16831. static readonly POINTERDOUBLETAP: number;
  16832. }
  16833. /**
  16834. * Base class of pointer info types.
  16835. */
  16836. export class PointerInfoBase {
  16837. /**
  16838. * Defines the type of event (PointerEventTypes)
  16839. */
  16840. type: number;
  16841. /**
  16842. * Defines the related dom event
  16843. */
  16844. event: PointerEvent | MouseWheelEvent;
  16845. /**
  16846. * Instantiates the base class of pointers info.
  16847. * @param type Defines the type of event (PointerEventTypes)
  16848. * @param event Defines the related dom event
  16849. */
  16850. constructor(
  16851. /**
  16852. * Defines the type of event (PointerEventTypes)
  16853. */
  16854. type: number,
  16855. /**
  16856. * Defines the related dom event
  16857. */
  16858. event: PointerEvent | MouseWheelEvent);
  16859. }
  16860. /**
  16861. * This class is used to store pointer related info for the onPrePointerObservable event.
  16862. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16863. */
  16864. export class PointerInfoPre extends PointerInfoBase {
  16865. /**
  16866. * Ray from a pointer if availible (eg. 6dof controller)
  16867. */
  16868. ray: Nullable<Ray>;
  16869. /**
  16870. * Defines the local position of the pointer on the canvas.
  16871. */
  16872. localPosition: Vector2;
  16873. /**
  16874. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16875. */
  16876. skipOnPointerObservable: boolean;
  16877. /**
  16878. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16879. * @param type Defines the type of event (PointerEventTypes)
  16880. * @param event Defines the related dom event
  16881. * @param localX Defines the local x coordinates of the pointer when the event occured
  16882. * @param localY Defines the local y coordinates of the pointer when the event occured
  16883. */
  16884. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16885. }
  16886. /**
  16887. * This type contains all the data related to a pointer event in Babylon.js.
  16888. * 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.
  16889. */
  16890. export class PointerInfo extends PointerInfoBase {
  16891. /**
  16892. * Defines the picking info associated to the info (if any)\
  16893. */
  16894. pickInfo: Nullable<PickingInfo>;
  16895. /**
  16896. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16897. * @param type Defines the type of event (PointerEventTypes)
  16898. * @param event Defines the related dom event
  16899. * @param pickInfo Defines the picking info associated to the info (if any)\
  16900. */
  16901. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16902. /**
  16903. * Defines the picking info associated to the info (if any)\
  16904. */
  16905. pickInfo: Nullable<PickingInfo>);
  16906. }
  16907. /**
  16908. * Data relating to a touch event on the screen.
  16909. */
  16910. export interface PointerTouch {
  16911. /**
  16912. * X coordinate of touch.
  16913. */
  16914. x: number;
  16915. /**
  16916. * Y coordinate of touch.
  16917. */
  16918. y: number;
  16919. /**
  16920. * Id of touch. Unique for each finger.
  16921. */
  16922. pointerId: number;
  16923. /**
  16924. * Event type passed from DOM.
  16925. */
  16926. type: any;
  16927. }
  16928. }
  16929. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  16930. import { Observable } from "babylonjs/Misc/observable";
  16931. import { Nullable } from "babylonjs/types";
  16932. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16933. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16934. /**
  16935. * Manage the mouse inputs to control the movement of a free camera.
  16936. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16937. */
  16938. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16939. /**
  16940. * Define if touch is enabled in the mouse input
  16941. */
  16942. touchEnabled: boolean;
  16943. /**
  16944. * Defines the camera the input is attached to.
  16945. */
  16946. camera: FreeCamera;
  16947. /**
  16948. * Defines the buttons associated with the input to handle camera move.
  16949. */
  16950. buttons: number[];
  16951. /**
  16952. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16953. */
  16954. angularSensibility: number;
  16955. private _pointerInput;
  16956. private _onMouseMove;
  16957. private _observer;
  16958. private previousPosition;
  16959. /**
  16960. * Observable for when a pointer move event occurs containing the move offset
  16961. */
  16962. onPointerMovedObservable: Observable<{
  16963. offsetX: number;
  16964. offsetY: number;
  16965. }>;
  16966. /**
  16967. * @hidden
  16968. * If the camera should be rotated automatically based on pointer movement
  16969. */
  16970. _allowCameraRotation: boolean;
  16971. /**
  16972. * Manage the mouse inputs to control the movement of a free camera.
  16973. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16974. * @param touchEnabled Defines if touch is enabled or not
  16975. */
  16976. constructor(
  16977. /**
  16978. * Define if touch is enabled in the mouse input
  16979. */
  16980. touchEnabled?: boolean);
  16981. /**
  16982. * Attach the input controls to a specific dom element to get the input from.
  16983. * @param element Defines the element the controls should be listened from
  16984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16985. */
  16986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16987. /**
  16988. * Called on JS contextmenu event.
  16989. * Override this method to provide functionality.
  16990. */
  16991. protected onContextMenu(evt: PointerEvent): void;
  16992. /**
  16993. * Detach the current controls from the specified dom element.
  16994. * @param element Defines the element to stop listening the inputs from
  16995. */
  16996. detachControl(element: Nullable<HTMLElement>): void;
  16997. /**
  16998. * Gets the class name of the current intput.
  16999. * @returns the class name
  17000. */
  17001. getClassName(): string;
  17002. /**
  17003. * Get the friendly name associated with the input class.
  17004. * @returns the input friendly name
  17005. */
  17006. getSimpleName(): string;
  17007. }
  17008. }
  17009. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  17010. import { Nullable } from "babylonjs/types";
  17011. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  17012. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17013. /**
  17014. * Manage the touch inputs to control the movement of a free camera.
  17015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17016. */
  17017. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  17018. /**
  17019. * Defines the camera the input is attached to.
  17020. */
  17021. camera: FreeCamera;
  17022. /**
  17023. * Defines the touch sensibility for rotation.
  17024. * The higher the faster.
  17025. */
  17026. touchAngularSensibility: number;
  17027. /**
  17028. * Defines the touch sensibility for move.
  17029. * The higher the faster.
  17030. */
  17031. touchMoveSensibility: number;
  17032. private _offsetX;
  17033. private _offsetY;
  17034. private _pointerPressed;
  17035. private _pointerInput;
  17036. private _observer;
  17037. private _onLostFocus;
  17038. /**
  17039. * Attach the input controls to a specific dom element to get the input from.
  17040. * @param element Defines the element the controls should be listened from
  17041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17042. */
  17043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17044. /**
  17045. * Detach the current controls from the specified dom element.
  17046. * @param element Defines the element to stop listening the inputs from
  17047. */
  17048. detachControl(element: Nullable<HTMLElement>): void;
  17049. /**
  17050. * Update the current camera state depending on the inputs that have been used this frame.
  17051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  17052. */
  17053. checkInputs(): void;
  17054. /**
  17055. * Gets the class name of the current intput.
  17056. * @returns the class name
  17057. */
  17058. getClassName(): string;
  17059. /**
  17060. * Get the friendly name associated with the input class.
  17061. * @returns the input friendly name
  17062. */
  17063. getSimpleName(): string;
  17064. }
  17065. }
  17066. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  17067. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17068. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  17069. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  17070. import { Nullable } from "babylonjs/types";
  17071. /**
  17072. * Default Inputs manager for the FreeCamera.
  17073. * It groups all the default supported inputs for ease of use.
  17074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17075. */
  17076. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  17077. /**
  17078. * @hidden
  17079. */
  17080. _mouseInput: Nullable<FreeCameraMouseInput>;
  17081. /**
  17082. * Instantiates a new FreeCameraInputsManager.
  17083. * @param camera Defines the camera the inputs belong to
  17084. */
  17085. constructor(camera: FreeCamera);
  17086. /**
  17087. * Add keyboard input support to the input manager.
  17088. * @returns the current input manager
  17089. */
  17090. addKeyboard(): FreeCameraInputsManager;
  17091. /**
  17092. * Add mouse input support to the input manager.
  17093. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  17094. * @returns the current input manager
  17095. */
  17096. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  17097. /**
  17098. * Removes the mouse input support from the manager
  17099. * @returns the current input manager
  17100. */
  17101. removeMouse(): FreeCameraInputsManager;
  17102. /**
  17103. * Add touch input support to the input manager.
  17104. * @returns the current input manager
  17105. */
  17106. addTouch(): FreeCameraInputsManager;
  17107. /**
  17108. * Remove all attached input methods from a camera
  17109. */
  17110. clear(): void;
  17111. }
  17112. }
  17113. declare module "babylonjs/Cameras/freeCamera" {
  17114. import { Vector3 } from "babylonjs/Maths/math";
  17115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17116. import { Scene } from "babylonjs/scene";
  17117. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17118. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  17119. /**
  17120. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17121. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  17122. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17123. */
  17124. export class FreeCamera extends TargetCamera {
  17125. /**
  17126. * Define the collision ellipsoid of the camera.
  17127. * This is helpful to simulate a camera body like the player body around the camera
  17128. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  17129. */
  17130. ellipsoid: Vector3;
  17131. /**
  17132. * Define an offset for the position of the ellipsoid around the camera.
  17133. * This can be helpful to determine the center of the body near the gravity center of the body
  17134. * instead of its head.
  17135. */
  17136. ellipsoidOffset: Vector3;
  17137. /**
  17138. * Enable or disable collisions of the camera with the rest of the scene objects.
  17139. */
  17140. checkCollisions: boolean;
  17141. /**
  17142. * Enable or disable gravity on the camera.
  17143. */
  17144. applyGravity: boolean;
  17145. /**
  17146. * Define the input manager associated to the camera.
  17147. */
  17148. inputs: FreeCameraInputsManager;
  17149. /**
  17150. * Gets the input sensibility for a mouse input. (default is 2000.0)
  17151. * Higher values reduce sensitivity.
  17152. */
  17153. /**
  17154. * Sets the input sensibility for a mouse input. (default is 2000.0)
  17155. * Higher values reduce sensitivity.
  17156. */
  17157. angularSensibility: number;
  17158. /**
  17159. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  17160. */
  17161. keysUp: number[];
  17162. /**
  17163. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  17164. */
  17165. keysDown: number[];
  17166. /**
  17167. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  17168. */
  17169. keysLeft: number[];
  17170. /**
  17171. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  17172. */
  17173. keysRight: number[];
  17174. /**
  17175. * Event raised when the camera collide with a mesh in the scene.
  17176. */
  17177. onCollide: (collidedMesh: AbstractMesh) => void;
  17178. private _collider;
  17179. private _needMoveForGravity;
  17180. private _oldPosition;
  17181. private _diffPosition;
  17182. private _newPosition;
  17183. /** @hidden */
  17184. _localDirection: Vector3;
  17185. /** @hidden */
  17186. _transformedDirection: Vector3;
  17187. /**
  17188. * Instantiates a Free Camera.
  17189. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17190. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  17191. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17192. * @param name Define the name of the camera in the scene
  17193. * @param position Define the start position of the camera in the scene
  17194. * @param scene Define the scene the camera belongs to
  17195. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  17196. */
  17197. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  17198. /**
  17199. * Attached controls to the current camera.
  17200. * @param element Defines the element the controls should be listened from
  17201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17202. */
  17203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17204. /**
  17205. * Detach the current controls from the camera.
  17206. * The camera will stop reacting to inputs.
  17207. * @param element Defines the element to stop listening the inputs from
  17208. */
  17209. detachControl(element: HTMLElement): void;
  17210. private _collisionMask;
  17211. /**
  17212. * Define a collision mask to limit the list of object the camera can collide with
  17213. */
  17214. collisionMask: number;
  17215. /** @hidden */
  17216. _collideWithWorld(displacement: Vector3): void;
  17217. private _onCollisionPositionChange;
  17218. /** @hidden */
  17219. _checkInputs(): void;
  17220. /** @hidden */
  17221. _decideIfNeedsToMove(): boolean;
  17222. /** @hidden */
  17223. _updatePosition(): void;
  17224. /**
  17225. * Destroy the camera and release the current resources hold by it.
  17226. */
  17227. dispose(): void;
  17228. /**
  17229. * Gets the current object class name.
  17230. * @return the class name
  17231. */
  17232. getClassName(): string;
  17233. }
  17234. }
  17235. declare module "babylonjs/Gamepads/gamepad" {
  17236. import { Observable } from "babylonjs/Misc/observable";
  17237. /**
  17238. * Represents a gamepad control stick position
  17239. */
  17240. export class StickValues {
  17241. /**
  17242. * The x component of the control stick
  17243. */
  17244. x: number;
  17245. /**
  17246. * The y component of the control stick
  17247. */
  17248. y: number;
  17249. /**
  17250. * Initializes the gamepad x and y control stick values
  17251. * @param x The x component of the gamepad control stick value
  17252. * @param y The y component of the gamepad control stick value
  17253. */
  17254. constructor(
  17255. /**
  17256. * The x component of the control stick
  17257. */
  17258. x: number,
  17259. /**
  17260. * The y component of the control stick
  17261. */
  17262. y: number);
  17263. }
  17264. /**
  17265. * An interface which manages callbacks for gamepad button changes
  17266. */
  17267. export interface GamepadButtonChanges {
  17268. /**
  17269. * Called when a gamepad has been changed
  17270. */
  17271. changed: boolean;
  17272. /**
  17273. * Called when a gamepad press event has been triggered
  17274. */
  17275. pressChanged: boolean;
  17276. /**
  17277. * Called when a touch event has been triggered
  17278. */
  17279. touchChanged: boolean;
  17280. /**
  17281. * Called when a value has changed
  17282. */
  17283. valueChanged: boolean;
  17284. }
  17285. /**
  17286. * Represents a gamepad
  17287. */
  17288. export class Gamepad {
  17289. /**
  17290. * The id of the gamepad
  17291. */
  17292. id: string;
  17293. /**
  17294. * The index of the gamepad
  17295. */
  17296. index: number;
  17297. /**
  17298. * The browser gamepad
  17299. */
  17300. browserGamepad: any;
  17301. /**
  17302. * Specifies what type of gamepad this represents
  17303. */
  17304. type: number;
  17305. private _leftStick;
  17306. private _rightStick;
  17307. /** @hidden */
  17308. _isConnected: boolean;
  17309. private _leftStickAxisX;
  17310. private _leftStickAxisY;
  17311. private _rightStickAxisX;
  17312. private _rightStickAxisY;
  17313. /**
  17314. * Triggered when the left control stick has been changed
  17315. */
  17316. private _onleftstickchanged;
  17317. /**
  17318. * Triggered when the right control stick has been changed
  17319. */
  17320. private _onrightstickchanged;
  17321. /**
  17322. * Represents a gamepad controller
  17323. */
  17324. static GAMEPAD: number;
  17325. /**
  17326. * Represents a generic controller
  17327. */
  17328. static GENERIC: number;
  17329. /**
  17330. * Represents an XBox controller
  17331. */
  17332. static XBOX: number;
  17333. /**
  17334. * Represents a pose-enabled controller
  17335. */
  17336. static POSE_ENABLED: number;
  17337. /**
  17338. * Specifies whether the left control stick should be Y-inverted
  17339. */
  17340. protected _invertLeftStickY: boolean;
  17341. /**
  17342. * Specifies if the gamepad has been connected
  17343. */
  17344. readonly isConnected: boolean;
  17345. /**
  17346. * Initializes the gamepad
  17347. * @param id The id of the gamepad
  17348. * @param index The index of the gamepad
  17349. * @param browserGamepad The browser gamepad
  17350. * @param leftStickX The x component of the left joystick
  17351. * @param leftStickY The y component of the left joystick
  17352. * @param rightStickX The x component of the right joystick
  17353. * @param rightStickY The y component of the right joystick
  17354. */
  17355. constructor(
  17356. /**
  17357. * The id of the gamepad
  17358. */
  17359. id: string,
  17360. /**
  17361. * The index of the gamepad
  17362. */
  17363. index: number,
  17364. /**
  17365. * The browser gamepad
  17366. */
  17367. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17368. /**
  17369. * Callback triggered when the left joystick has changed
  17370. * @param callback
  17371. */
  17372. onleftstickchanged(callback: (values: StickValues) => void): void;
  17373. /**
  17374. * Callback triggered when the right joystick has changed
  17375. * @param callback
  17376. */
  17377. onrightstickchanged(callback: (values: StickValues) => void): void;
  17378. /**
  17379. * Gets the left joystick
  17380. */
  17381. /**
  17382. * Sets the left joystick values
  17383. */
  17384. leftStick: StickValues;
  17385. /**
  17386. * Gets the right joystick
  17387. */
  17388. /**
  17389. * Sets the right joystick value
  17390. */
  17391. rightStick: StickValues;
  17392. /**
  17393. * Updates the gamepad joystick positions
  17394. */
  17395. update(): void;
  17396. /**
  17397. * Disposes the gamepad
  17398. */
  17399. dispose(): void;
  17400. }
  17401. /**
  17402. * Represents a generic gamepad
  17403. */
  17404. export class GenericPad extends Gamepad {
  17405. private _buttons;
  17406. private _onbuttondown;
  17407. private _onbuttonup;
  17408. /**
  17409. * Observable triggered when a button has been pressed
  17410. */
  17411. onButtonDownObservable: Observable<number>;
  17412. /**
  17413. * Observable triggered when a button has been released
  17414. */
  17415. onButtonUpObservable: Observable<number>;
  17416. /**
  17417. * Callback triggered when a button has been pressed
  17418. * @param callback Called when a button has been pressed
  17419. */
  17420. onbuttondown(callback: (buttonPressed: number) => void): void;
  17421. /**
  17422. * Callback triggered when a button has been released
  17423. * @param callback Called when a button has been released
  17424. */
  17425. onbuttonup(callback: (buttonReleased: number) => void): void;
  17426. /**
  17427. * Initializes the generic gamepad
  17428. * @param id The id of the generic gamepad
  17429. * @param index The index of the generic gamepad
  17430. * @param browserGamepad The browser gamepad
  17431. */
  17432. constructor(id: string, index: number, browserGamepad: any);
  17433. private _setButtonValue;
  17434. /**
  17435. * Updates the generic gamepad
  17436. */
  17437. update(): void;
  17438. /**
  17439. * Disposes the generic gamepad
  17440. */
  17441. dispose(): void;
  17442. }
  17443. }
  17444. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  17445. import { Observable } from "babylonjs/Misc/observable";
  17446. import { Nullable } from "babylonjs/types";
  17447. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17448. import { TransformNode } from "babylonjs/Meshes/transformNode";
  17449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17450. import { Ray } from "babylonjs/Culling/ray";
  17451. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  17452. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  17453. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17454. /**
  17455. * Defines the types of pose enabled controllers that are supported
  17456. */
  17457. export enum PoseEnabledControllerType {
  17458. /**
  17459. * HTC Vive
  17460. */
  17461. VIVE = 0,
  17462. /**
  17463. * Oculus Rift
  17464. */
  17465. OCULUS = 1,
  17466. /**
  17467. * Windows mixed reality
  17468. */
  17469. WINDOWS = 2,
  17470. /**
  17471. * Samsung gear VR
  17472. */
  17473. GEAR_VR = 3,
  17474. /**
  17475. * Google Daydream
  17476. */
  17477. DAYDREAM = 4,
  17478. /**
  17479. * Generic
  17480. */
  17481. GENERIC = 5
  17482. }
  17483. /**
  17484. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17485. */
  17486. export interface MutableGamepadButton {
  17487. /**
  17488. * Value of the button/trigger
  17489. */
  17490. value: number;
  17491. /**
  17492. * If the button/trigger is currently touched
  17493. */
  17494. touched: boolean;
  17495. /**
  17496. * If the button/trigger is currently pressed
  17497. */
  17498. pressed: boolean;
  17499. }
  17500. /**
  17501. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17502. * @hidden
  17503. */
  17504. export interface ExtendedGamepadButton extends GamepadButton {
  17505. /**
  17506. * If the button/trigger is currently pressed
  17507. */
  17508. readonly pressed: boolean;
  17509. /**
  17510. * If the button/trigger is currently touched
  17511. */
  17512. readonly touched: boolean;
  17513. /**
  17514. * Value of the button/trigger
  17515. */
  17516. readonly value: number;
  17517. }
  17518. /** @hidden */
  17519. export interface _GamePadFactory {
  17520. /**
  17521. * Returns wether or not the current gamepad can be created for this type of controller.
  17522. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17523. * @returns true if it can be created, otherwise false
  17524. */
  17525. canCreate(gamepadInfo: any): boolean;
  17526. /**
  17527. * Creates a new instance of the Gamepad.
  17528. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17529. * @returns the new gamepad instance
  17530. */
  17531. create(gamepadInfo: any): Gamepad;
  17532. }
  17533. /**
  17534. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17535. */
  17536. export class PoseEnabledControllerHelper {
  17537. /** @hidden */
  17538. static _ControllerFactories: _GamePadFactory[];
  17539. /** @hidden */
  17540. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17541. /**
  17542. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17543. * @param vrGamepad the gamepad to initialized
  17544. * @returns a vr controller of the type the gamepad identified as
  17545. */
  17546. static InitiateController(vrGamepad: any): Gamepad;
  17547. }
  17548. /**
  17549. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17550. */
  17551. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17552. private _deviceRoomPosition;
  17553. private _deviceRoomRotationQuaternion;
  17554. /**
  17555. * The device position in babylon space
  17556. */
  17557. devicePosition: Vector3;
  17558. /**
  17559. * The device rotation in babylon space
  17560. */
  17561. deviceRotationQuaternion: Quaternion;
  17562. /**
  17563. * The scale factor of the device in babylon space
  17564. */
  17565. deviceScaleFactor: number;
  17566. /**
  17567. * (Likely devicePosition should be used instead) The device position in its room space
  17568. */
  17569. position: Vector3;
  17570. /**
  17571. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17572. */
  17573. rotationQuaternion: Quaternion;
  17574. /**
  17575. * The type of controller (Eg. Windows mixed reality)
  17576. */
  17577. controllerType: PoseEnabledControllerType;
  17578. protected _calculatedPosition: Vector3;
  17579. private _calculatedRotation;
  17580. /**
  17581. * The raw pose from the device
  17582. */
  17583. rawPose: DevicePose;
  17584. private _trackPosition;
  17585. private _maxRotationDistFromHeadset;
  17586. private _draggedRoomRotation;
  17587. /**
  17588. * @hidden
  17589. */
  17590. _disableTrackPosition(fixedPosition: Vector3): void;
  17591. /**
  17592. * Internal, the mesh attached to the controller
  17593. * @hidden
  17594. */
  17595. _mesh: Nullable<AbstractMesh>;
  17596. private _poseControlledCamera;
  17597. private _leftHandSystemQuaternion;
  17598. /**
  17599. * Internal, matrix used to convert room space to babylon space
  17600. * @hidden
  17601. */
  17602. _deviceToWorld: Matrix;
  17603. /**
  17604. * Node to be used when casting a ray from the controller
  17605. * @hidden
  17606. */
  17607. _pointingPoseNode: Nullable<TransformNode>;
  17608. /**
  17609. * Name of the child mesh that can be used to cast a ray from the controller
  17610. */
  17611. static readonly POINTING_POSE: string;
  17612. /**
  17613. * Creates a new PoseEnabledController from a gamepad
  17614. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17615. */
  17616. constructor(browserGamepad: any);
  17617. private _workingMatrix;
  17618. /**
  17619. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17620. */
  17621. update(): void;
  17622. /**
  17623. * Updates only the pose device and mesh without doing any button event checking
  17624. */
  17625. protected _updatePoseAndMesh(): void;
  17626. /**
  17627. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17628. * @param poseData raw pose fromthe device
  17629. */
  17630. updateFromDevice(poseData: DevicePose): void;
  17631. /**
  17632. * @hidden
  17633. */
  17634. _meshAttachedObservable: Observable<AbstractMesh>;
  17635. /**
  17636. * Attaches a mesh to the controller
  17637. * @param mesh the mesh to be attached
  17638. */
  17639. attachToMesh(mesh: AbstractMesh): void;
  17640. /**
  17641. * Attaches the controllers mesh to a camera
  17642. * @param camera the camera the mesh should be attached to
  17643. */
  17644. attachToPoseControlledCamera(camera: TargetCamera): void;
  17645. /**
  17646. * Disposes of the controller
  17647. */
  17648. dispose(): void;
  17649. /**
  17650. * The mesh that is attached to the controller
  17651. */
  17652. readonly mesh: Nullable<AbstractMesh>;
  17653. /**
  17654. * Gets the ray of the controller in the direction the controller is pointing
  17655. * @param length the length the resulting ray should be
  17656. * @returns a ray in the direction the controller is pointing
  17657. */
  17658. getForwardRay(length?: number): Ray;
  17659. }
  17660. }
  17661. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  17662. import { Observable } from "babylonjs/Misc/observable";
  17663. import { Scene } from "babylonjs/scene";
  17664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17665. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  17666. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  17667. /**
  17668. * Defines the WebVRController object that represents controllers tracked in 3D space
  17669. */
  17670. export abstract class WebVRController extends PoseEnabledController {
  17671. /**
  17672. * Internal, the default controller model for the controller
  17673. */
  17674. protected _defaultModel: AbstractMesh;
  17675. /**
  17676. * Fired when the trigger state has changed
  17677. */
  17678. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17679. /**
  17680. * Fired when the main button state has changed
  17681. */
  17682. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17683. /**
  17684. * Fired when the secondary button state has changed
  17685. */
  17686. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17687. /**
  17688. * Fired when the pad state has changed
  17689. */
  17690. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17691. /**
  17692. * Fired when controllers stick values have changed
  17693. */
  17694. onPadValuesChangedObservable: Observable<StickValues>;
  17695. /**
  17696. * Array of button availible on the controller
  17697. */
  17698. protected _buttons: Array<MutableGamepadButton>;
  17699. private _onButtonStateChange;
  17700. /**
  17701. * Fired when a controller button's state has changed
  17702. * @param callback the callback containing the button that was modified
  17703. */
  17704. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17705. /**
  17706. * X and Y axis corresponding to the controllers joystick
  17707. */
  17708. pad: StickValues;
  17709. /**
  17710. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17711. */
  17712. hand: string;
  17713. /**
  17714. * The default controller model for the controller
  17715. */
  17716. readonly defaultModel: AbstractMesh;
  17717. /**
  17718. * Creates a new WebVRController from a gamepad
  17719. * @param vrGamepad the gamepad that the WebVRController should be created from
  17720. */
  17721. constructor(vrGamepad: any);
  17722. /**
  17723. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17724. */
  17725. update(): void;
  17726. /**
  17727. * Function to be called when a button is modified
  17728. */
  17729. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17730. /**
  17731. * Loads a mesh and attaches it to the controller
  17732. * @param scene the scene the mesh should be added to
  17733. * @param meshLoaded callback for when the mesh has been loaded
  17734. */
  17735. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17736. private _setButtonValue;
  17737. private _changes;
  17738. private _checkChanges;
  17739. /**
  17740. * Disposes of th webVRCOntroller
  17741. */
  17742. dispose(): void;
  17743. }
  17744. }
  17745. declare module "babylonjs/Lights/hemisphericLight" {
  17746. import { Nullable } from "babylonjs/types";
  17747. import { Scene } from "babylonjs/scene";
  17748. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  17749. import { Effect } from "babylonjs/Materials/effect";
  17750. import { Light } from "babylonjs/Lights/light";
  17751. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17752. /**
  17753. * The HemisphericLight simulates the ambient environment light,
  17754. * so the passed direction is the light reflection direction, not the incoming direction.
  17755. */
  17756. export class HemisphericLight extends Light {
  17757. /**
  17758. * The groundColor is the light in the opposite direction to the one specified during creation.
  17759. * 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.
  17760. */
  17761. groundColor: Color3;
  17762. /**
  17763. * The light reflection direction, not the incoming direction.
  17764. */
  17765. direction: Vector3;
  17766. /**
  17767. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17768. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17769. * The HemisphericLight can't cast shadows.
  17770. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17771. * @param name The friendly name of the light
  17772. * @param direction The direction of the light reflection
  17773. * @param scene The scene the light belongs to
  17774. */
  17775. constructor(name: string, direction: Vector3, scene: Scene);
  17776. protected _buildUniformLayout(): void;
  17777. /**
  17778. * Returns the string "HemisphericLight".
  17779. * @return The class name
  17780. */
  17781. getClassName(): string;
  17782. /**
  17783. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17784. * Returns the updated direction.
  17785. * @param target The target the direction should point to
  17786. * @return The computed direction
  17787. */
  17788. setDirectionToTarget(target: Vector3): Vector3;
  17789. /**
  17790. * Returns the shadow generator associated to the light.
  17791. * @returns Always null for hemispheric lights because it does not support shadows.
  17792. */
  17793. getShadowGenerator(): Nullable<IShadowGenerator>;
  17794. /**
  17795. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17796. * @param effect The effect to update
  17797. * @param lightIndex The index of the light in the effect to update
  17798. * @returns The hemispheric light
  17799. */
  17800. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17801. /**
  17802. * Computes the world matrix of the node
  17803. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17804. * @param useWasUpdatedFlag defines a reserved property
  17805. * @returns the world matrix
  17806. */
  17807. computeWorldMatrix(): Matrix;
  17808. /**
  17809. * Returns the integer 3.
  17810. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17811. */
  17812. getTypeID(): number;
  17813. /**
  17814. * Prepares the list of defines specific to the light type.
  17815. * @param defines the list of defines
  17816. * @param lightIndex defines the index of the light for the effect
  17817. */
  17818. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17819. }
  17820. }
  17821. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  17822. /** @hidden */
  17823. export var vrMultiviewToSingleviewPixelShader: {
  17824. name: string;
  17825. shader: string;
  17826. };
  17827. }
  17828. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  17829. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17830. import { Scene } from "babylonjs/scene";
  17831. /**
  17832. * Renders to multiple views with a single draw call
  17833. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17834. */
  17835. export class MultiviewRenderTarget extends RenderTargetTexture {
  17836. /**
  17837. * Creates a multiview render target
  17838. * @param scene scene used with the render target
  17839. * @param size the size of the render target (used for each view)
  17840. */
  17841. constructor(scene: Scene, size?: number | {
  17842. width: number;
  17843. height: number;
  17844. } | {
  17845. ratio: number;
  17846. });
  17847. /**
  17848. * @hidden
  17849. * @param faceIndex the face index, if its a cube texture
  17850. */
  17851. _bindFrameBuffer(faceIndex?: number): void;
  17852. /**
  17853. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17854. * @returns the view count
  17855. */
  17856. getViewCount(): number;
  17857. }
  17858. }
  17859. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  17860. import { Camera } from "babylonjs/Cameras/camera";
  17861. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17862. import { Nullable } from "babylonjs/types";
  17863. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17864. import { Matrix } from "babylonjs/Maths/math";
  17865. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17866. module "babylonjs/Engines/engine" {
  17867. interface Engine {
  17868. /**
  17869. * Creates a new multiview render target
  17870. * @param width defines the width of the texture
  17871. * @param height defines the height of the texture
  17872. * @returns the created multiview texture
  17873. */
  17874. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17875. /**
  17876. * Binds a multiview framebuffer to be drawn to
  17877. * @param multiviewTexture texture to bind
  17878. */
  17879. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17880. }
  17881. }
  17882. module "babylonjs/Cameras/camera" {
  17883. interface Camera {
  17884. /**
  17885. * @hidden
  17886. * 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)
  17887. */
  17888. _useMultiviewToSingleView: boolean;
  17889. /**
  17890. * @hidden
  17891. * 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)
  17892. */
  17893. _multiviewTexture: Nullable<RenderTargetTexture>;
  17894. /**
  17895. * @hidden
  17896. * ensures the multiview texture of the camera exists and has the specified width/height
  17897. * @param width height to set on the multiview texture
  17898. * @param height width to set on the multiview texture
  17899. */
  17900. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17901. }
  17902. }
  17903. module "babylonjs/scene" {
  17904. interface Scene {
  17905. /** @hidden */
  17906. _transformMatrixR: Matrix;
  17907. /** @hidden */
  17908. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17909. /** @hidden */
  17910. _createMultiviewUbo(): void;
  17911. /** @hidden */
  17912. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17913. /** @hidden */
  17914. _renderMultiviewToSingleView(camera: Camera): void;
  17915. }
  17916. }
  17917. }
  17918. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  17919. import { Camera } from "babylonjs/Cameras/camera";
  17920. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17921. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  17922. import "babylonjs/Engines/Extensions/engine.multiview";
  17923. /**
  17924. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17925. * This will not be used for webXR as it supports displaying texture arrays directly
  17926. */
  17927. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17928. /**
  17929. * Initializes a VRMultiviewToSingleview
  17930. * @param name name of the post process
  17931. * @param camera camera to be applied to
  17932. * @param scaleFactor scaling factor to the size of the output texture
  17933. */
  17934. constructor(name: string, camera: Camera, scaleFactor: number);
  17935. }
  17936. }
  17937. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  17938. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  17939. import { Nullable } from "babylonjs/types";
  17940. import { Size } from "babylonjs/Maths/math";
  17941. import { Observable } from "babylonjs/Misc/observable";
  17942. module "babylonjs/Engines/engine" {
  17943. interface Engine {
  17944. /** @hidden */
  17945. _vrDisplay: any;
  17946. /** @hidden */
  17947. _vrSupported: boolean;
  17948. /** @hidden */
  17949. _oldSize: Size;
  17950. /** @hidden */
  17951. _oldHardwareScaleFactor: number;
  17952. /** @hidden */
  17953. _vrExclusivePointerMode: boolean;
  17954. /** @hidden */
  17955. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17956. /** @hidden */
  17957. _onVRDisplayPointerRestricted: () => void;
  17958. /** @hidden */
  17959. _onVRDisplayPointerUnrestricted: () => void;
  17960. /** @hidden */
  17961. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17962. /** @hidden */
  17963. _onVrDisplayDisconnect: Nullable<() => void>;
  17964. /** @hidden */
  17965. _onVrDisplayPresentChange: Nullable<() => void>;
  17966. /**
  17967. * Observable signaled when VR display mode changes
  17968. */
  17969. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17970. /**
  17971. * Observable signaled when VR request present is complete
  17972. */
  17973. onVRRequestPresentComplete: Observable<boolean>;
  17974. /**
  17975. * Observable signaled when VR request present starts
  17976. */
  17977. onVRRequestPresentStart: Observable<Engine>;
  17978. /**
  17979. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17980. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17981. */
  17982. isInVRExclusivePointerMode: boolean;
  17983. /**
  17984. * Gets a boolean indicating if a webVR device was detected
  17985. * @returns true if a webVR device was detected
  17986. */
  17987. isVRDevicePresent(): boolean;
  17988. /**
  17989. * Gets the current webVR device
  17990. * @returns the current webVR device (or null)
  17991. */
  17992. getVRDevice(): any;
  17993. /**
  17994. * Initializes a webVR display and starts listening to display change events
  17995. * The onVRDisplayChangedObservable will be notified upon these changes
  17996. * @returns A promise containing a VRDisplay and if vr is supported
  17997. */
  17998. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17999. /** @hidden */
  18000. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  18001. /**
  18002. * Call this function to switch to webVR mode
  18003. * Will do nothing if webVR is not supported or if there is no webVR device
  18004. * @see http://doc.babylonjs.com/how_to/webvr_camera
  18005. */
  18006. enableVR(): void;
  18007. /** @hidden */
  18008. _onVRFullScreenTriggered(): void;
  18009. }
  18010. }
  18011. }
  18012. declare module "babylonjs/Cameras/VR/webVRCamera" {
  18013. import { Nullable } from "babylonjs/types";
  18014. import { Observable } from "babylonjs/Misc/observable";
  18015. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18016. import { Scene } from "babylonjs/scene";
  18017. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  18018. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  18019. import { Node } from "babylonjs/node";
  18020. import { Ray } from "babylonjs/Culling/ray";
  18021. import "babylonjs/Cameras/RigModes/webVRRigMode";
  18022. import "babylonjs/Engines/Extensions/engine.webVR";
  18023. /**
  18024. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  18025. * IMPORTANT!! The data is right-hand data.
  18026. * @export
  18027. * @interface DevicePose
  18028. */
  18029. export interface DevicePose {
  18030. /**
  18031. * The position of the device, values in array are [x,y,z].
  18032. */
  18033. readonly position: Nullable<Float32Array>;
  18034. /**
  18035. * The linearVelocity of the device, values in array are [x,y,z].
  18036. */
  18037. readonly linearVelocity: Nullable<Float32Array>;
  18038. /**
  18039. * The linearAcceleration of the device, values in array are [x,y,z].
  18040. */
  18041. readonly linearAcceleration: Nullable<Float32Array>;
  18042. /**
  18043. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  18044. */
  18045. readonly orientation: Nullable<Float32Array>;
  18046. /**
  18047. * The angularVelocity of the device, values in array are [x,y,z].
  18048. */
  18049. readonly angularVelocity: Nullable<Float32Array>;
  18050. /**
  18051. * The angularAcceleration of the device, values in array are [x,y,z].
  18052. */
  18053. readonly angularAcceleration: Nullable<Float32Array>;
  18054. }
  18055. /**
  18056. * Interface representing a pose controlled object in Babylon.
  18057. * A pose controlled object has both regular pose values as well as pose values
  18058. * from an external device such as a VR head mounted display
  18059. */
  18060. export interface PoseControlled {
  18061. /**
  18062. * The position of the object in babylon space.
  18063. */
  18064. position: Vector3;
  18065. /**
  18066. * The rotation quaternion of the object in babylon space.
  18067. */
  18068. rotationQuaternion: Quaternion;
  18069. /**
  18070. * The position of the device in babylon space.
  18071. */
  18072. devicePosition?: Vector3;
  18073. /**
  18074. * The rotation quaternion of the device in babylon space.
  18075. */
  18076. deviceRotationQuaternion: Quaternion;
  18077. /**
  18078. * The raw pose coming from the device.
  18079. */
  18080. rawPose: Nullable<DevicePose>;
  18081. /**
  18082. * The scale of the device to be used when translating from device space to babylon space.
  18083. */
  18084. deviceScaleFactor: number;
  18085. /**
  18086. * Updates the poseControlled values based on the input device pose.
  18087. * @param poseData the pose data to update the object with
  18088. */
  18089. updateFromDevice(poseData: DevicePose): void;
  18090. }
  18091. /**
  18092. * Set of options to customize the webVRCamera
  18093. */
  18094. export interface WebVROptions {
  18095. /**
  18096. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  18097. */
  18098. trackPosition?: boolean;
  18099. /**
  18100. * Sets the scale of the vrDevice in babylon space. (default: 1)
  18101. */
  18102. positionScale?: number;
  18103. /**
  18104. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  18105. */
  18106. displayName?: string;
  18107. /**
  18108. * Should the native controller meshes be initialized. (default: true)
  18109. */
  18110. controllerMeshes?: boolean;
  18111. /**
  18112. * Creating a default HemiLight only on controllers. (default: true)
  18113. */
  18114. defaultLightingOnControllers?: boolean;
  18115. /**
  18116. * If you don't want to use the default VR button of the helper. (default: false)
  18117. */
  18118. useCustomVRButton?: boolean;
  18119. /**
  18120. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  18121. */
  18122. customVRButton?: HTMLButtonElement;
  18123. /**
  18124. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  18125. */
  18126. rayLength?: number;
  18127. /**
  18128. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  18129. */
  18130. defaultHeight?: number;
  18131. /**
  18132. * If multiview should be used if availible (default: false)
  18133. */
  18134. useMultiview?: boolean;
  18135. }
  18136. /**
  18137. * This represents a WebVR camera.
  18138. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  18139. * @example http://doc.babylonjs.com/how_to/webvr_camera
  18140. */
  18141. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  18142. private webVROptions;
  18143. /**
  18144. * @hidden
  18145. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  18146. */
  18147. _vrDevice: any;
  18148. /**
  18149. * The rawPose of the vrDevice.
  18150. */
  18151. rawPose: Nullable<DevicePose>;
  18152. private _onVREnabled;
  18153. private _specsVersion;
  18154. private _attached;
  18155. private _frameData;
  18156. protected _descendants: Array<Node>;
  18157. private _deviceRoomPosition;
  18158. /** @hidden */
  18159. _deviceRoomRotationQuaternion: Quaternion;
  18160. private _standingMatrix;
  18161. /**
  18162. * Represents device position in babylon space.
  18163. */
  18164. devicePosition: Vector3;
  18165. /**
  18166. * Represents device rotation in babylon space.
  18167. */
  18168. deviceRotationQuaternion: Quaternion;
  18169. /**
  18170. * The scale of the device to be used when translating from device space to babylon space.
  18171. */
  18172. deviceScaleFactor: number;
  18173. private _deviceToWorld;
  18174. private _worldToDevice;
  18175. /**
  18176. * References to the webVR controllers for the vrDevice.
  18177. */
  18178. controllers: Array<WebVRController>;
  18179. /**
  18180. * Emits an event when a controller is attached.
  18181. */
  18182. onControllersAttachedObservable: Observable<WebVRController[]>;
  18183. /**
  18184. * Emits an event when a controller's mesh has been loaded;
  18185. */
  18186. onControllerMeshLoadedObservable: Observable<WebVRController>;
  18187. /**
  18188. * Emits an event when the HMD's pose has been updated.
  18189. */
  18190. onPoseUpdatedFromDeviceObservable: Observable<any>;
  18191. private _poseSet;
  18192. /**
  18193. * If the rig cameras be used as parent instead of this camera.
  18194. */
  18195. rigParenting: boolean;
  18196. private _lightOnControllers;
  18197. private _defaultHeight?;
  18198. /**
  18199. * Instantiates a WebVRFreeCamera.
  18200. * @param name The name of the WebVRFreeCamera
  18201. * @param position The starting anchor position for the camera
  18202. * @param scene The scene the camera belongs to
  18203. * @param webVROptions a set of customizable options for the webVRCamera
  18204. */
  18205. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  18206. /**
  18207. * Gets the device distance from the ground in meters.
  18208. * @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.
  18209. */
  18210. deviceDistanceToRoomGround(): number;
  18211. /**
  18212. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18213. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18214. */
  18215. useStandingMatrix(callback?: (bool: boolean) => void): void;
  18216. /**
  18217. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18218. * @returns A promise with a boolean set to if the standing matrix is supported.
  18219. */
  18220. useStandingMatrixAsync(): Promise<boolean>;
  18221. /**
  18222. * Disposes the camera
  18223. */
  18224. dispose(): void;
  18225. /**
  18226. * Gets a vrController by name.
  18227. * @param name The name of the controller to retreive
  18228. * @returns the controller matching the name specified or null if not found
  18229. */
  18230. getControllerByName(name: string): Nullable<WebVRController>;
  18231. private _leftController;
  18232. /**
  18233. * The controller corresponding to the users left hand.
  18234. */
  18235. readonly leftController: Nullable<WebVRController>;
  18236. private _rightController;
  18237. /**
  18238. * The controller corresponding to the users right hand.
  18239. */
  18240. readonly rightController: Nullable<WebVRController>;
  18241. /**
  18242. * Casts a ray forward from the vrCamera's gaze.
  18243. * @param length Length of the ray (default: 100)
  18244. * @returns the ray corresponding to the gaze
  18245. */
  18246. getForwardRay(length?: number): Ray;
  18247. /**
  18248. * @hidden
  18249. * Updates the camera based on device's frame data
  18250. */
  18251. _checkInputs(): void;
  18252. /**
  18253. * Updates the poseControlled values based on the input device pose.
  18254. * @param poseData Pose coming from the device
  18255. */
  18256. updateFromDevice(poseData: DevicePose): void;
  18257. private _htmlElementAttached;
  18258. private _detachIfAttached;
  18259. /**
  18260. * WebVR's attach control will start broadcasting frames to the device.
  18261. * Note that in certain browsers (chrome for example) this function must be called
  18262. * within a user-interaction callback. Example:
  18263. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18264. *
  18265. * @param element html element to attach the vrDevice to
  18266. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18267. */
  18268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18269. /**
  18270. * Detaches the camera from the html element and disables VR
  18271. *
  18272. * @param element html element to detach from
  18273. */
  18274. detachControl(element: HTMLElement): void;
  18275. /**
  18276. * @returns the name of this class
  18277. */
  18278. getClassName(): string;
  18279. /**
  18280. * Calls resetPose on the vrDisplay
  18281. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18282. */
  18283. resetToCurrentRotation(): void;
  18284. /**
  18285. * @hidden
  18286. * Updates the rig cameras (left and right eye)
  18287. */
  18288. _updateRigCameras(): void;
  18289. private _workingVector;
  18290. private _oneVector;
  18291. private _workingMatrix;
  18292. private updateCacheCalled;
  18293. private _correctPositionIfNotTrackPosition;
  18294. /**
  18295. * @hidden
  18296. * Updates the cached values of the camera
  18297. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18298. */
  18299. _updateCache(ignoreParentClass?: boolean): void;
  18300. /**
  18301. * @hidden
  18302. * Get current device position in babylon world
  18303. */
  18304. _computeDevicePosition(): void;
  18305. /**
  18306. * Updates the current device position and rotation in the babylon world
  18307. */
  18308. update(): void;
  18309. /**
  18310. * @hidden
  18311. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18312. * @returns an identity matrix
  18313. */
  18314. _getViewMatrix(): Matrix;
  18315. private _tmpMatrix;
  18316. /**
  18317. * This function is called by the two RIG cameras.
  18318. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18319. * @hidden
  18320. */
  18321. _getWebVRViewMatrix(): Matrix;
  18322. /** @hidden */
  18323. _getWebVRProjectionMatrix(): Matrix;
  18324. private _onGamepadConnectedObserver;
  18325. private _onGamepadDisconnectedObserver;
  18326. private _updateCacheWhenTrackingDisabledObserver;
  18327. /**
  18328. * Initializes the controllers and their meshes
  18329. */
  18330. initControllers(): void;
  18331. }
  18332. }
  18333. declare module "babylonjs/PostProcesses/postProcess" {
  18334. import { Nullable } from "babylonjs/types";
  18335. import { SmartArray } from "babylonjs/Misc/smartArray";
  18336. import { Observable } from "babylonjs/Misc/observable";
  18337. import { Color4, Vector2 } from "babylonjs/Maths/math";
  18338. import { Camera } from "babylonjs/Cameras/camera";
  18339. import { Effect } from "babylonjs/Materials/effect";
  18340. import "babylonjs/Shaders/postprocess.vertex";
  18341. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18342. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18343. import { Engine } from "babylonjs/Engines/engine";
  18344. /**
  18345. * Size options for a post process
  18346. */
  18347. export type PostProcessOptions = {
  18348. width: number;
  18349. height: number;
  18350. };
  18351. /**
  18352. * PostProcess can be used to apply a shader to a texture after it has been rendered
  18353. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18354. */
  18355. export class PostProcess {
  18356. /** Name of the PostProcess. */
  18357. name: string;
  18358. /**
  18359. * Gets or sets the unique id of the post process
  18360. */
  18361. uniqueId: number;
  18362. /**
  18363. * Width of the texture to apply the post process on
  18364. */
  18365. width: number;
  18366. /**
  18367. * Height of the texture to apply the post process on
  18368. */
  18369. height: number;
  18370. /**
  18371. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  18372. * @hidden
  18373. */
  18374. _outputTexture: Nullable<InternalTexture>;
  18375. /**
  18376. * Sampling mode used by the shader
  18377. * See https://doc.babylonjs.com/classes/3.1/texture
  18378. */
  18379. renderTargetSamplingMode: number;
  18380. /**
  18381. * Clear color to use when screen clearing
  18382. */
  18383. clearColor: Color4;
  18384. /**
  18385. * If the buffer needs to be cleared before applying the post process. (default: true)
  18386. * Should be set to false if shader will overwrite all previous pixels.
  18387. */
  18388. autoClear: boolean;
  18389. /**
  18390. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18391. */
  18392. alphaMode: number;
  18393. /**
  18394. * Sets the setAlphaBlendConstants of the babylon engine
  18395. */
  18396. alphaConstants: Color4;
  18397. /**
  18398. * Animations to be used for the post processing
  18399. */
  18400. animations: import("babylonjs/Animations/animation").Animation[];
  18401. /**
  18402. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18403. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18404. */
  18405. enablePixelPerfectMode: boolean;
  18406. /**
  18407. * Force the postprocess to be applied without taking in account viewport
  18408. */
  18409. forceFullscreenViewport: boolean;
  18410. /**
  18411. * List of inspectable custom properties (used by the Inspector)
  18412. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18413. */
  18414. inspectableCustomProperties: IInspectable[];
  18415. /**
  18416. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18417. *
  18418. * | Value | Type | Description |
  18419. * | ----- | ----------------------------------- | ----------- |
  18420. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18421. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18422. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18423. *
  18424. */
  18425. scaleMode: number;
  18426. /**
  18427. * Force textures to be a power of two (default: false)
  18428. */
  18429. alwaysForcePOT: boolean;
  18430. private _samples;
  18431. /**
  18432. * Number of sample textures (default: 1)
  18433. */
  18434. samples: number;
  18435. /**
  18436. * Modify the scale of the post process to be the same as the viewport (default: false)
  18437. */
  18438. adaptScaleToCurrentViewport: boolean;
  18439. private _camera;
  18440. private _scene;
  18441. private _engine;
  18442. private _options;
  18443. private _reusable;
  18444. private _textureType;
  18445. /**
  18446. * Smart array of input and output textures for the post process.
  18447. * @hidden
  18448. */
  18449. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  18450. /**
  18451. * The index in _textures that corresponds to the output texture.
  18452. * @hidden
  18453. */
  18454. _currentRenderTextureInd: number;
  18455. private _effect;
  18456. private _samplers;
  18457. private _fragmentUrl;
  18458. private _vertexUrl;
  18459. private _parameters;
  18460. private _scaleRatio;
  18461. protected _indexParameters: any;
  18462. private _shareOutputWithPostProcess;
  18463. private _texelSize;
  18464. private _forcedOutputTexture;
  18465. /**
  18466. * Returns the fragment url or shader name used in the post process.
  18467. * @returns the fragment url or name in the shader store.
  18468. */
  18469. getEffectName(): string;
  18470. /**
  18471. * An event triggered when the postprocess is activated.
  18472. */
  18473. onActivateObservable: Observable<Camera>;
  18474. private _onActivateObserver;
  18475. /**
  18476. * A function that is added to the onActivateObservable
  18477. */
  18478. onActivate: Nullable<(camera: Camera) => void>;
  18479. /**
  18480. * An event triggered when the postprocess changes its size.
  18481. */
  18482. onSizeChangedObservable: Observable<PostProcess>;
  18483. private _onSizeChangedObserver;
  18484. /**
  18485. * A function that is added to the onSizeChangedObservable
  18486. */
  18487. onSizeChanged: (postProcess: PostProcess) => void;
  18488. /**
  18489. * An event triggered when the postprocess applies its effect.
  18490. */
  18491. onApplyObservable: Observable<Effect>;
  18492. private _onApplyObserver;
  18493. /**
  18494. * A function that is added to the onApplyObservable
  18495. */
  18496. onApply: (effect: Effect) => void;
  18497. /**
  18498. * An event triggered before rendering the postprocess
  18499. */
  18500. onBeforeRenderObservable: Observable<Effect>;
  18501. private _onBeforeRenderObserver;
  18502. /**
  18503. * A function that is added to the onBeforeRenderObservable
  18504. */
  18505. onBeforeRender: (effect: Effect) => void;
  18506. /**
  18507. * An event triggered after rendering the postprocess
  18508. */
  18509. onAfterRenderObservable: Observable<Effect>;
  18510. private _onAfterRenderObserver;
  18511. /**
  18512. * A function that is added to the onAfterRenderObservable
  18513. */
  18514. onAfterRender: (efect: Effect) => void;
  18515. /**
  18516. * 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
  18517. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18518. */
  18519. inputTexture: InternalTexture;
  18520. /**
  18521. * Gets the camera which post process is applied to.
  18522. * @returns The camera the post process is applied to.
  18523. */
  18524. getCamera(): Camera;
  18525. /**
  18526. * Gets the texel size of the postprocess.
  18527. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18528. */
  18529. readonly texelSize: Vector2;
  18530. /**
  18531. * Creates a new instance PostProcess
  18532. * @param name The name of the PostProcess.
  18533. * @param fragmentUrl The url of the fragment shader to be used.
  18534. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18535. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18536. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18537. * @param camera The camera to apply the render pass to.
  18538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18539. * @param engine The engine which the post process will be applied. (default: current engine)
  18540. * @param reusable If the post process can be reused on the same frame. (default: false)
  18541. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18542. * @param textureType Type of textures used when performing the post process. (default: 0)
  18543. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18544. * @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
  18545. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18546. */
  18547. constructor(
  18548. /** Name of the PostProcess. */
  18549. 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);
  18550. /**
  18551. * Gets a string idenfifying the name of the class
  18552. * @returns "PostProcess" string
  18553. */
  18554. getClassName(): string;
  18555. /**
  18556. * Gets the engine which this post process belongs to.
  18557. * @returns The engine the post process was enabled with.
  18558. */
  18559. getEngine(): Engine;
  18560. /**
  18561. * The effect that is created when initializing the post process.
  18562. * @returns The created effect corresponding the the postprocess.
  18563. */
  18564. getEffect(): Effect;
  18565. /**
  18566. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18567. * @param postProcess The post process to share the output with.
  18568. * @returns This post process.
  18569. */
  18570. shareOutputWith(postProcess: PostProcess): PostProcess;
  18571. /**
  18572. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18573. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18574. */
  18575. useOwnOutput(): void;
  18576. /**
  18577. * Updates the effect with the current post process compile time values and recompiles the shader.
  18578. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18579. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18580. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18581. * @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
  18582. * @param onCompiled Called when the shader has been compiled.
  18583. * @param onError Called if there is an error when compiling a shader.
  18584. */
  18585. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18586. /**
  18587. * The post process is reusable if it can be used multiple times within one frame.
  18588. * @returns If the post process is reusable
  18589. */
  18590. isReusable(): boolean;
  18591. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18592. markTextureDirty(): void;
  18593. /**
  18594. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18595. * 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.
  18596. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18597. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18598. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18599. * @returns The target texture that was bound to be written to.
  18600. */
  18601. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18602. /**
  18603. * If the post process is supported.
  18604. */
  18605. readonly isSupported: boolean;
  18606. /**
  18607. * The aspect ratio of the output texture.
  18608. */
  18609. readonly aspectRatio: number;
  18610. /**
  18611. * Get a value indicating if the post-process is ready to be used
  18612. * @returns true if the post-process is ready (shader is compiled)
  18613. */
  18614. isReady(): boolean;
  18615. /**
  18616. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18617. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18618. */
  18619. apply(): Nullable<Effect>;
  18620. private _disposeTextures;
  18621. /**
  18622. * Disposes the post process.
  18623. * @param camera The camera to dispose the post process on.
  18624. */
  18625. dispose(camera?: Camera): void;
  18626. }
  18627. }
  18628. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  18629. /** @hidden */
  18630. export var kernelBlurVaryingDeclaration: {
  18631. name: string;
  18632. shader: string;
  18633. };
  18634. }
  18635. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  18636. /** @hidden */
  18637. export var kernelBlurFragment: {
  18638. name: string;
  18639. shader: string;
  18640. };
  18641. }
  18642. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  18643. /** @hidden */
  18644. export var kernelBlurFragment2: {
  18645. name: string;
  18646. shader: string;
  18647. };
  18648. }
  18649. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  18650. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18651. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  18652. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  18653. /** @hidden */
  18654. export var kernelBlurPixelShader: {
  18655. name: string;
  18656. shader: string;
  18657. };
  18658. }
  18659. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  18660. /** @hidden */
  18661. export var kernelBlurVertex: {
  18662. name: string;
  18663. shader: string;
  18664. };
  18665. }
  18666. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  18667. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18668. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  18669. /** @hidden */
  18670. export var kernelBlurVertexShader: {
  18671. name: string;
  18672. shader: string;
  18673. };
  18674. }
  18675. declare module "babylonjs/PostProcesses/blurPostProcess" {
  18676. import { Vector2 } from "babylonjs/Maths/math";
  18677. import { Nullable } from "babylonjs/types";
  18678. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18679. import { Camera } from "babylonjs/Cameras/camera";
  18680. import { Effect } from "babylonjs/Materials/effect";
  18681. import { Engine } from "babylonjs/Engines/engine";
  18682. import "babylonjs/Shaders/kernelBlur.fragment";
  18683. import "babylonjs/Shaders/kernelBlur.vertex";
  18684. /**
  18685. * The Blur Post Process which blurs an image based on a kernel and direction.
  18686. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18687. */
  18688. export class BlurPostProcess extends PostProcess {
  18689. /** The direction in which to blur the image. */
  18690. direction: Vector2;
  18691. private blockCompilation;
  18692. protected _kernel: number;
  18693. protected _idealKernel: number;
  18694. protected _packedFloat: boolean;
  18695. private _staticDefines;
  18696. /**
  18697. * Sets the length in pixels of the blur sample region
  18698. */
  18699. /**
  18700. * Gets the length in pixels of the blur sample region
  18701. */
  18702. kernel: number;
  18703. /**
  18704. * Sets wether or not the blur needs to unpack/repack floats
  18705. */
  18706. /**
  18707. * Gets wether or not the blur is unpacking/repacking floats
  18708. */
  18709. packedFloat: boolean;
  18710. /**
  18711. * Creates a new instance BlurPostProcess
  18712. * @param name The name of the effect.
  18713. * @param direction The direction in which to blur the image.
  18714. * @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.
  18715. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18716. * @param camera The camera to apply the render pass to.
  18717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18718. * @param engine The engine which the post process will be applied. (default: current engine)
  18719. * @param reusable If the post process can be reused on the same frame. (default: false)
  18720. * @param textureType Type of textures used when performing the post process. (default: 0)
  18721. * @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)
  18722. */
  18723. constructor(name: string,
  18724. /** The direction in which to blur the image. */
  18725. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18726. /**
  18727. * Updates the effect with the current post process compile time values and recompiles the shader.
  18728. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18729. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18730. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18731. * @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
  18732. * @param onCompiled Called when the shader has been compiled.
  18733. * @param onError Called if there is an error when compiling a shader.
  18734. */
  18735. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18736. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18737. /**
  18738. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18739. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18740. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18741. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18742. * The gaps between physical kernels are compensated for in the weighting of the samples
  18743. * @param idealKernel Ideal blur kernel.
  18744. * @return Nearest best kernel.
  18745. */
  18746. protected _nearestBestKernel(idealKernel: number): number;
  18747. /**
  18748. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18749. * @param x The point on the Gaussian distribution to sample.
  18750. * @return the value of the Gaussian function at x.
  18751. */
  18752. protected _gaussianWeight(x: number): number;
  18753. /**
  18754. * Generates a string that can be used as a floating point number in GLSL.
  18755. * @param x Value to print.
  18756. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18757. * @return GLSL float string.
  18758. */
  18759. protected _glslFloat(x: number, decimalFigures?: number): string;
  18760. }
  18761. }
  18762. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18763. import { Scene } from "babylonjs/scene";
  18764. import { Plane } from "babylonjs/Maths/math";
  18765. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18766. /**
  18767. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18768. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18769. * You can then easily use it as a reflectionTexture on a flat surface.
  18770. * In case the surface is not a plane, please consider relying on reflection probes.
  18771. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18772. */
  18773. export class MirrorTexture extends RenderTargetTexture {
  18774. private scene;
  18775. /**
  18776. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18777. * 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.
  18778. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18779. */
  18780. mirrorPlane: Plane;
  18781. /**
  18782. * Define the blur ratio used to blur the reflection if needed.
  18783. */
  18784. blurRatio: number;
  18785. /**
  18786. * Define the adaptive blur kernel used to blur the reflection if needed.
  18787. * This will autocompute the closest best match for the `blurKernel`
  18788. */
  18789. adaptiveBlurKernel: number;
  18790. /**
  18791. * Define the blur kernel used to blur the reflection if needed.
  18792. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18793. */
  18794. blurKernel: number;
  18795. /**
  18796. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18797. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18798. */
  18799. blurKernelX: number;
  18800. /**
  18801. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18802. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18803. */
  18804. blurKernelY: number;
  18805. private _autoComputeBlurKernel;
  18806. protected _onRatioRescale(): void;
  18807. private _updateGammaSpace;
  18808. private _imageProcessingConfigChangeObserver;
  18809. private _transformMatrix;
  18810. private _mirrorMatrix;
  18811. private _savedViewMatrix;
  18812. private _blurX;
  18813. private _blurY;
  18814. private _adaptiveBlurKernel;
  18815. private _blurKernelX;
  18816. private _blurKernelY;
  18817. private _blurRatio;
  18818. /**
  18819. * Instantiates a Mirror Texture.
  18820. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18821. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18822. * You can then easily use it as a reflectionTexture on a flat surface.
  18823. * In case the surface is not a plane, please consider relying on reflection probes.
  18824. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18825. * @param name
  18826. * @param size
  18827. * @param scene
  18828. * @param generateMipMaps
  18829. * @param type
  18830. * @param samplingMode
  18831. * @param generateDepthBuffer
  18832. */
  18833. constructor(name: string, size: number | {
  18834. width: number;
  18835. height: number;
  18836. } | {
  18837. ratio: number;
  18838. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18839. private _preparePostProcesses;
  18840. /**
  18841. * Clone the mirror texture.
  18842. * @returns the cloned texture
  18843. */
  18844. clone(): MirrorTexture;
  18845. /**
  18846. * Serialize the texture to a JSON representation you could use in Parse later on
  18847. * @returns the serialized JSON representation
  18848. */
  18849. serialize(): any;
  18850. /**
  18851. * Dispose the texture and release its associated resources.
  18852. */
  18853. dispose(): void;
  18854. }
  18855. }
  18856. declare module "babylonjs/Materials/Textures/texture" {
  18857. import { Observable } from "babylonjs/Misc/observable";
  18858. import { Nullable } from "babylonjs/types";
  18859. import { Scene } from "babylonjs/scene";
  18860. import { Matrix } from "babylonjs/Maths/math";
  18861. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18862. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18863. /**
  18864. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18865. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18866. */
  18867. export class Texture extends BaseTexture {
  18868. /** @hidden */
  18869. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18870. /** @hidden */
  18871. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18872. /** @hidden */
  18873. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18874. /** nearest is mag = nearest and min = nearest and mip = linear */
  18875. static readonly NEAREST_SAMPLINGMODE: number;
  18876. /** nearest is mag = nearest and min = nearest and mip = linear */
  18877. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18878. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18879. static readonly BILINEAR_SAMPLINGMODE: number;
  18880. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18881. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18882. /** Trilinear is mag = linear and min = linear and mip = linear */
  18883. static readonly TRILINEAR_SAMPLINGMODE: number;
  18884. /** Trilinear is mag = linear and min = linear and mip = linear */
  18885. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18886. /** mag = nearest and min = nearest and mip = nearest */
  18887. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18888. /** mag = nearest and min = linear and mip = nearest */
  18889. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18890. /** mag = nearest and min = linear and mip = linear */
  18891. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18892. /** mag = nearest and min = linear and mip = none */
  18893. static readonly NEAREST_LINEAR: number;
  18894. /** mag = nearest and min = nearest and mip = none */
  18895. static readonly NEAREST_NEAREST: number;
  18896. /** mag = linear and min = nearest and mip = nearest */
  18897. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18898. /** mag = linear and min = nearest and mip = linear */
  18899. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18900. /** mag = linear and min = linear and mip = none */
  18901. static readonly LINEAR_LINEAR: number;
  18902. /** mag = linear and min = nearest and mip = none */
  18903. static readonly LINEAR_NEAREST: number;
  18904. /** Explicit coordinates mode */
  18905. static readonly EXPLICIT_MODE: number;
  18906. /** Spherical coordinates mode */
  18907. static readonly SPHERICAL_MODE: number;
  18908. /** Planar coordinates mode */
  18909. static readonly PLANAR_MODE: number;
  18910. /** Cubic coordinates mode */
  18911. static readonly CUBIC_MODE: number;
  18912. /** Projection coordinates mode */
  18913. static readonly PROJECTION_MODE: number;
  18914. /** Inverse Cubic coordinates mode */
  18915. static readonly SKYBOX_MODE: number;
  18916. /** Inverse Cubic coordinates mode */
  18917. static readonly INVCUBIC_MODE: number;
  18918. /** Equirectangular coordinates mode */
  18919. static readonly EQUIRECTANGULAR_MODE: number;
  18920. /** Equirectangular Fixed coordinates mode */
  18921. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18922. /** Equirectangular Fixed Mirrored coordinates mode */
  18923. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18924. /** Texture is not repeating outside of 0..1 UVs */
  18925. static readonly CLAMP_ADDRESSMODE: number;
  18926. /** Texture is repeating outside of 0..1 UVs */
  18927. static readonly WRAP_ADDRESSMODE: number;
  18928. /** Texture is repeating and mirrored */
  18929. static readonly MIRROR_ADDRESSMODE: number;
  18930. /**
  18931. * 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
  18932. */
  18933. static UseSerializedUrlIfAny: boolean;
  18934. /**
  18935. * Define the url of the texture.
  18936. */
  18937. url: Nullable<string>;
  18938. /**
  18939. * Define an offset on the texture to offset the u coordinates of the UVs
  18940. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18941. */
  18942. uOffset: number;
  18943. /**
  18944. * Define an offset on the texture to offset the v coordinates of the UVs
  18945. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18946. */
  18947. vOffset: number;
  18948. /**
  18949. * Define an offset on the texture to scale the u coordinates of the UVs
  18950. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18951. */
  18952. uScale: number;
  18953. /**
  18954. * Define an offset on the texture to scale the v coordinates of the UVs
  18955. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18956. */
  18957. vScale: number;
  18958. /**
  18959. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18960. * @see http://doc.babylonjs.com/how_to/more_materials
  18961. */
  18962. uAng: number;
  18963. /**
  18964. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18965. * @see http://doc.babylonjs.com/how_to/more_materials
  18966. */
  18967. vAng: number;
  18968. /**
  18969. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18970. * @see http://doc.babylonjs.com/how_to/more_materials
  18971. */
  18972. wAng: number;
  18973. /**
  18974. * Defines the center of rotation (U)
  18975. */
  18976. uRotationCenter: number;
  18977. /**
  18978. * Defines the center of rotation (V)
  18979. */
  18980. vRotationCenter: number;
  18981. /**
  18982. * Defines the center of rotation (W)
  18983. */
  18984. wRotationCenter: number;
  18985. /**
  18986. * Are mip maps generated for this texture or not.
  18987. */
  18988. readonly noMipmap: boolean;
  18989. /**
  18990. * List of inspectable custom properties (used by the Inspector)
  18991. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18992. */
  18993. inspectableCustomProperties: Nullable<IInspectable[]>;
  18994. private _noMipmap;
  18995. /** @hidden */
  18996. _invertY: boolean;
  18997. private _rowGenerationMatrix;
  18998. private _cachedTextureMatrix;
  18999. private _projectionModeMatrix;
  19000. private _t0;
  19001. private _t1;
  19002. private _t2;
  19003. private _cachedUOffset;
  19004. private _cachedVOffset;
  19005. private _cachedUScale;
  19006. private _cachedVScale;
  19007. private _cachedUAng;
  19008. private _cachedVAng;
  19009. private _cachedWAng;
  19010. private _cachedProjectionMatrixId;
  19011. private _cachedCoordinatesMode;
  19012. /** @hidden */
  19013. protected _initialSamplingMode: number;
  19014. /** @hidden */
  19015. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  19016. private _deleteBuffer;
  19017. protected _format: Nullable<number>;
  19018. private _delayedOnLoad;
  19019. private _delayedOnError;
  19020. /**
  19021. * Observable triggered once the texture has been loaded.
  19022. */
  19023. onLoadObservable: Observable<Texture>;
  19024. protected _isBlocking: boolean;
  19025. /**
  19026. * Is the texture preventing material to render while loading.
  19027. * If false, a default texture will be used instead of the loading one during the preparation step.
  19028. */
  19029. isBlocking: boolean;
  19030. /**
  19031. * Get the current sampling mode associated with the texture.
  19032. */
  19033. readonly samplingMode: number;
  19034. /**
  19035. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  19036. */
  19037. readonly invertY: boolean;
  19038. /**
  19039. * Instantiates a new texture.
  19040. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  19041. * @see http://doc.babylonjs.com/babylon101/materials#texture
  19042. * @param url define the url of the picture to load as a texture
  19043. * @param scene define the scene the texture will belong to
  19044. * @param noMipmap define if the texture will require mip maps or not
  19045. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19046. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19047. * @param onLoad define a callback triggered when the texture has been loaded
  19048. * @param onError define a callback triggered when an error occurred during the loading session
  19049. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19050. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19051. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19052. */
  19053. 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);
  19054. /**
  19055. * Update the url (and optional buffer) of this texture if url was null during construction.
  19056. * @param url the url of the texture
  19057. * @param buffer the buffer of the texture (defaults to null)
  19058. * @param onLoad callback called when the texture is loaded (defaults to null)
  19059. */
  19060. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  19061. /**
  19062. * Finish the loading sequence of a texture flagged as delayed load.
  19063. * @hidden
  19064. */
  19065. delayLoad(): void;
  19066. private _prepareRowForTextureGeneration;
  19067. /**
  19068. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  19069. * @returns the transform matrix of the texture.
  19070. */
  19071. getTextureMatrix(): Matrix;
  19072. /**
  19073. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  19074. * @returns The reflection texture transform
  19075. */
  19076. getReflectionTextureMatrix(): Matrix;
  19077. /**
  19078. * Clones the texture.
  19079. * @returns the cloned texture
  19080. */
  19081. clone(): Texture;
  19082. /**
  19083. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19084. * @returns The JSON representation of the texture
  19085. */
  19086. serialize(): any;
  19087. /**
  19088. * Get the current class name of the texture useful for serialization or dynamic coding.
  19089. * @returns "Texture"
  19090. */
  19091. getClassName(): string;
  19092. /**
  19093. * Dispose the texture and release its associated resources.
  19094. */
  19095. dispose(): void;
  19096. /**
  19097. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  19098. * @param parsedTexture Define the JSON representation of the texture
  19099. * @param scene Define the scene the parsed texture should be instantiated in
  19100. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  19101. * @returns The parsed texture if successful
  19102. */
  19103. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  19104. /**
  19105. * Creates a texture from its base 64 representation.
  19106. * @param data Define the base64 payload without the data: prefix
  19107. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19108. * @param scene Define the scene the texture should belong to
  19109. * @param noMipmap Forces the texture to not create mip map information if true
  19110. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19111. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19112. * @param onLoad define a callback triggered when the texture has been loaded
  19113. * @param onError define a callback triggered when an error occurred during the loading session
  19114. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19115. * @returns the created texture
  19116. */
  19117. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  19118. /**
  19119. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  19120. * @param data Define the base64 payload without the data: prefix
  19121. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19122. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19123. * @param scene Define the scene the texture should belong to
  19124. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19125. * @param noMipmap Forces the texture to not create mip map information if true
  19126. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19127. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19128. * @param onLoad define a callback triggered when the texture has been loaded
  19129. * @param onError define a callback triggered when an error occurred during the loading session
  19130. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19131. * @returns the created texture
  19132. */
  19133. 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;
  19134. }
  19135. }
  19136. declare module "babylonjs/PostProcesses/postProcessManager" {
  19137. import { Nullable } from "babylonjs/types";
  19138. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19139. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19140. import { Scene } from "babylonjs/scene";
  19141. /**
  19142. * PostProcessManager is used to manage one or more post processes or post process pipelines
  19143. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19144. */
  19145. export class PostProcessManager {
  19146. private _scene;
  19147. private _indexBuffer;
  19148. private _vertexBuffers;
  19149. /**
  19150. * Creates a new instance PostProcess
  19151. * @param scene The scene that the post process is associated with.
  19152. */
  19153. constructor(scene: Scene);
  19154. private _prepareBuffers;
  19155. private _buildIndexBuffer;
  19156. /**
  19157. * Rebuilds the vertex buffers of the manager.
  19158. * @hidden
  19159. */
  19160. _rebuild(): void;
  19161. /**
  19162. * Prepares a frame to be run through a post process.
  19163. * @param sourceTexture The input texture to the post procesess. (default: null)
  19164. * @param postProcesses An array of post processes to be run. (default: null)
  19165. * @returns True if the post processes were able to be run.
  19166. * @hidden
  19167. */
  19168. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  19169. /**
  19170. * Manually render a set of post processes to a texture.
  19171. * @param postProcesses An array of post processes to be run.
  19172. * @param targetTexture The target texture to render to.
  19173. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  19174. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  19175. * @param lodLevel defines which lod of the texture to render to
  19176. */
  19177. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  19178. /**
  19179. * Finalize the result of the output of the postprocesses.
  19180. * @param doNotPresent If true the result will not be displayed to the screen.
  19181. * @param targetTexture The target texture to render to.
  19182. * @param faceIndex The index of the face to bind the target texture to.
  19183. * @param postProcesses The array of post processes to render.
  19184. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  19185. * @hidden
  19186. */
  19187. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  19188. /**
  19189. * Disposes of the post process manager.
  19190. */
  19191. dispose(): void;
  19192. }
  19193. }
  19194. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  19195. import { Scene } from "babylonjs/scene";
  19196. import { ISceneComponent } from "babylonjs/sceneComponent";
  19197. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19198. module "babylonjs/abstractScene" {
  19199. interface AbstractScene {
  19200. /**
  19201. * The list of procedural textures added to the scene
  19202. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19203. */
  19204. proceduralTextures: Array<ProceduralTexture>;
  19205. }
  19206. }
  19207. /**
  19208. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  19209. * in a given scene.
  19210. */
  19211. export class ProceduralTextureSceneComponent implements ISceneComponent {
  19212. /**
  19213. * The component name helpfull to identify the component in the list of scene components.
  19214. */
  19215. readonly name: string;
  19216. /**
  19217. * The scene the component belongs to.
  19218. */
  19219. scene: Scene;
  19220. /**
  19221. * Creates a new instance of the component for the given scene
  19222. * @param scene Defines the scene to register the component in
  19223. */
  19224. constructor(scene: Scene);
  19225. /**
  19226. * Registers the component in a given scene
  19227. */
  19228. register(): void;
  19229. /**
  19230. * Rebuilds the elements related to this component in case of
  19231. * context lost for instance.
  19232. */
  19233. rebuild(): void;
  19234. /**
  19235. * Disposes the component and the associated ressources.
  19236. */
  19237. dispose(): void;
  19238. private _beforeClear;
  19239. }
  19240. }
  19241. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  19242. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19243. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  19244. module "babylonjs/Engines/engine" {
  19245. interface Engine {
  19246. /**
  19247. * Creates a new render target cube texture
  19248. * @param size defines the size of the texture
  19249. * @param options defines the options used to create the texture
  19250. * @returns a new render target cube texture stored in an InternalTexture
  19251. */
  19252. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  19253. }
  19254. }
  19255. }
  19256. declare module "babylonjs/Shaders/procedural.vertex" {
  19257. /** @hidden */
  19258. export var proceduralVertexShader: {
  19259. name: string;
  19260. shader: string;
  19261. };
  19262. }
  19263. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  19264. import { Observable } from "babylonjs/Misc/observable";
  19265. import { Nullable } from "babylonjs/types";
  19266. import { Scene } from "babylonjs/scene";
  19267. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  19268. import { Effect } from "babylonjs/Materials/effect";
  19269. import { Texture } from "babylonjs/Materials/Textures/texture";
  19270. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19271. import "babylonjs/Shaders/procedural.vertex";
  19272. /**
  19273. * 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.
  19274. * This is the base class of any Procedural texture and contains most of the shareable code.
  19275. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19276. */
  19277. export class ProceduralTexture extends Texture {
  19278. isCube: boolean;
  19279. /**
  19280. * Define if the texture is enabled or not (disabled texture will not render)
  19281. */
  19282. isEnabled: boolean;
  19283. /**
  19284. * Define if the texture must be cleared before rendering (default is true)
  19285. */
  19286. autoClear: boolean;
  19287. /**
  19288. * Callback called when the texture is generated
  19289. */
  19290. onGenerated: () => void;
  19291. /**
  19292. * Event raised when the texture is generated
  19293. */
  19294. onGeneratedObservable: Observable<ProceduralTexture>;
  19295. /** @hidden */
  19296. _generateMipMaps: boolean;
  19297. /** @hidden **/
  19298. _effect: Effect;
  19299. /** @hidden */
  19300. _textures: {
  19301. [key: string]: Texture;
  19302. };
  19303. private _size;
  19304. private _currentRefreshId;
  19305. private _refreshRate;
  19306. private _vertexBuffers;
  19307. private _indexBuffer;
  19308. private _uniforms;
  19309. private _samplers;
  19310. private _fragment;
  19311. private _floats;
  19312. private _ints;
  19313. private _floatsArrays;
  19314. private _colors3;
  19315. private _colors4;
  19316. private _vectors2;
  19317. private _vectors3;
  19318. private _matrices;
  19319. private _fallbackTexture;
  19320. private _fallbackTextureUsed;
  19321. private _engine;
  19322. private _cachedDefines;
  19323. private _contentUpdateId;
  19324. private _contentData;
  19325. /**
  19326. * Instantiates a new procedural texture.
  19327. * 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.
  19328. * This is the base class of any Procedural texture and contains most of the shareable code.
  19329. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19330. * @param name Define the name of the texture
  19331. * @param size Define the size of the texture to create
  19332. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  19333. * @param scene Define the scene the texture belongs to
  19334. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  19335. * @param generateMipMaps Define if the texture should creates mip maps or not
  19336. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  19337. */
  19338. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  19339. /**
  19340. * The effect that is created when initializing the post process.
  19341. * @returns The created effect corresponding the the postprocess.
  19342. */
  19343. getEffect(): Effect;
  19344. /**
  19345. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  19346. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  19347. */
  19348. getContent(): Nullable<ArrayBufferView>;
  19349. private _createIndexBuffer;
  19350. /** @hidden */
  19351. _rebuild(): void;
  19352. /**
  19353. * Resets the texture in order to recreate its associated resources.
  19354. * This can be called in case of context loss
  19355. */
  19356. reset(): void;
  19357. protected _getDefines(): string;
  19358. /**
  19359. * Is the texture ready to be used ? (rendered at least once)
  19360. * @returns true if ready, otherwise, false.
  19361. */
  19362. isReady(): boolean;
  19363. /**
  19364. * Resets the refresh counter of the texture and start bak from scratch.
  19365. * Could be useful to regenerate the texture if it is setup to render only once.
  19366. */
  19367. resetRefreshCounter(): void;
  19368. /**
  19369. * Set the fragment shader to use in order to render the texture.
  19370. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  19371. */
  19372. setFragment(fragment: any): void;
  19373. /**
  19374. * Define the refresh rate of the texture or the rendering frequency.
  19375. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19376. */
  19377. refreshRate: number;
  19378. /** @hidden */
  19379. _shouldRender(): boolean;
  19380. /**
  19381. * Get the size the texture is rendering at.
  19382. * @returns the size (texture is always squared)
  19383. */
  19384. getRenderSize(): number;
  19385. /**
  19386. * Resize the texture to new value.
  19387. * @param size Define the new size the texture should have
  19388. * @param generateMipMaps Define whether the new texture should create mip maps
  19389. */
  19390. resize(size: number, generateMipMaps: boolean): void;
  19391. private _checkUniform;
  19392. /**
  19393. * Set a texture in the shader program used to render.
  19394. * @param name Define the name of the uniform samplers as defined in the shader
  19395. * @param texture Define the texture to bind to this sampler
  19396. * @return the texture itself allowing "fluent" like uniform updates
  19397. */
  19398. setTexture(name: string, texture: Texture): ProceduralTexture;
  19399. /**
  19400. * Set a float in the shader.
  19401. * @param name Define the name of the uniform as defined in the shader
  19402. * @param value Define the value to give to the uniform
  19403. * @return the texture itself allowing "fluent" like uniform updates
  19404. */
  19405. setFloat(name: string, value: number): ProceduralTexture;
  19406. /**
  19407. * Set a int in the shader.
  19408. * @param name Define the name of the uniform as defined in the shader
  19409. * @param value Define the value to give to the uniform
  19410. * @return the texture itself allowing "fluent" like uniform updates
  19411. */
  19412. setInt(name: string, value: number): ProceduralTexture;
  19413. /**
  19414. * Set an array of floats in the shader.
  19415. * @param name Define the name of the uniform as defined in the shader
  19416. * @param value Define the value to give to the uniform
  19417. * @return the texture itself allowing "fluent" like uniform updates
  19418. */
  19419. setFloats(name: string, value: number[]): ProceduralTexture;
  19420. /**
  19421. * Set a vec3 in the shader from a Color3.
  19422. * @param name Define the name of the uniform as defined in the shader
  19423. * @param value Define the value to give to the uniform
  19424. * @return the texture itself allowing "fluent" like uniform updates
  19425. */
  19426. setColor3(name: string, value: Color3): ProceduralTexture;
  19427. /**
  19428. * Set a vec4 in the shader from a Color4.
  19429. * @param name Define the name of the uniform as defined in the shader
  19430. * @param value Define the value to give to the uniform
  19431. * @return the texture itself allowing "fluent" like uniform updates
  19432. */
  19433. setColor4(name: string, value: Color4): ProceduralTexture;
  19434. /**
  19435. * Set a vec2 in the shader from a Vector2.
  19436. * @param name Define the name of the uniform as defined in the shader
  19437. * @param value Define the value to give to the uniform
  19438. * @return the texture itself allowing "fluent" like uniform updates
  19439. */
  19440. setVector2(name: string, value: Vector2): ProceduralTexture;
  19441. /**
  19442. * Set a vec3 in the shader from a Vector3.
  19443. * @param name Define the name of the uniform as defined in the shader
  19444. * @param value Define the value to give to the uniform
  19445. * @return the texture itself allowing "fluent" like uniform updates
  19446. */
  19447. setVector3(name: string, value: Vector3): ProceduralTexture;
  19448. /**
  19449. * Set a mat4 in the shader from a MAtrix.
  19450. * @param name Define the name of the uniform as defined in the shader
  19451. * @param value Define the value to give to the uniform
  19452. * @return the texture itself allowing "fluent" like uniform updates
  19453. */
  19454. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19455. /**
  19456. * Render the texture to its associated render target.
  19457. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19458. */
  19459. render(useCameraPostProcess?: boolean): void;
  19460. /**
  19461. * Clone the texture.
  19462. * @returns the cloned texture
  19463. */
  19464. clone(): ProceduralTexture;
  19465. /**
  19466. * Dispose the texture and release its asoociated resources.
  19467. */
  19468. dispose(): void;
  19469. }
  19470. }
  19471. declare module "babylonjs/Particles/baseParticleSystem" {
  19472. import { Nullable } from "babylonjs/types";
  19473. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  19474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19475. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19476. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19477. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19478. import { Scene } from "babylonjs/scene";
  19479. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  19480. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19481. import { Texture } from "babylonjs/Materials/Textures/texture";
  19482. import { Animation } from "babylonjs/Animations/animation";
  19483. /**
  19484. * This represents the base class for particle system in Babylon.
  19485. * 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.
  19486. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19487. * @example https://doc.babylonjs.com/babylon101/particles
  19488. */
  19489. export class BaseParticleSystem {
  19490. /**
  19491. * Source color is added to the destination color without alpha affecting the result
  19492. */
  19493. static BLENDMODE_ONEONE: number;
  19494. /**
  19495. * Blend current color and particle color using particle’s alpha
  19496. */
  19497. static BLENDMODE_STANDARD: number;
  19498. /**
  19499. * Add current color and particle color multiplied by particle’s alpha
  19500. */
  19501. static BLENDMODE_ADD: number;
  19502. /**
  19503. * Multiply current color with particle color
  19504. */
  19505. static BLENDMODE_MULTIPLY: number;
  19506. /**
  19507. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19508. */
  19509. static BLENDMODE_MULTIPLYADD: number;
  19510. /**
  19511. * List of animations used by the particle system.
  19512. */
  19513. animations: Animation[];
  19514. /**
  19515. * The id of the Particle system.
  19516. */
  19517. id: string;
  19518. /**
  19519. * The friendly name of the Particle system.
  19520. */
  19521. name: string;
  19522. /**
  19523. * The rendering group used by the Particle system to chose when to render.
  19524. */
  19525. renderingGroupId: number;
  19526. /**
  19527. * The emitter represents the Mesh or position we are attaching the particle system to.
  19528. */
  19529. emitter: Nullable<AbstractMesh | Vector3>;
  19530. /**
  19531. * The maximum number of particles to emit per frame
  19532. */
  19533. emitRate: number;
  19534. /**
  19535. * If you want to launch only a few particles at once, that can be done, as well.
  19536. */
  19537. manualEmitCount: number;
  19538. /**
  19539. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19540. */
  19541. updateSpeed: number;
  19542. /**
  19543. * The amount of time the particle system is running (depends of the overall update speed).
  19544. */
  19545. targetStopDuration: number;
  19546. /**
  19547. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19548. */
  19549. disposeOnStop: boolean;
  19550. /**
  19551. * Minimum power of emitting particles.
  19552. */
  19553. minEmitPower: number;
  19554. /**
  19555. * Maximum power of emitting particles.
  19556. */
  19557. maxEmitPower: number;
  19558. /**
  19559. * Minimum life time of emitting particles.
  19560. */
  19561. minLifeTime: number;
  19562. /**
  19563. * Maximum life time of emitting particles.
  19564. */
  19565. maxLifeTime: number;
  19566. /**
  19567. * Minimum Size of emitting particles.
  19568. */
  19569. minSize: number;
  19570. /**
  19571. * Maximum Size of emitting particles.
  19572. */
  19573. maxSize: number;
  19574. /**
  19575. * Minimum scale of emitting particles on X axis.
  19576. */
  19577. minScaleX: number;
  19578. /**
  19579. * Maximum scale of emitting particles on X axis.
  19580. */
  19581. maxScaleX: number;
  19582. /**
  19583. * Minimum scale of emitting particles on Y axis.
  19584. */
  19585. minScaleY: number;
  19586. /**
  19587. * Maximum scale of emitting particles on Y axis.
  19588. */
  19589. maxScaleY: number;
  19590. /**
  19591. * Gets or sets the minimal initial rotation in radians.
  19592. */
  19593. minInitialRotation: number;
  19594. /**
  19595. * Gets or sets the maximal initial rotation in radians.
  19596. */
  19597. maxInitialRotation: number;
  19598. /**
  19599. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19600. */
  19601. minAngularSpeed: number;
  19602. /**
  19603. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19604. */
  19605. maxAngularSpeed: number;
  19606. /**
  19607. * The texture used to render each particle. (this can be a spritesheet)
  19608. */
  19609. particleTexture: Nullable<Texture>;
  19610. /**
  19611. * The layer mask we are rendering the particles through.
  19612. */
  19613. layerMask: number;
  19614. /**
  19615. * This can help using your own shader to render the particle system.
  19616. * The according effect will be created
  19617. */
  19618. customShader: any;
  19619. /**
  19620. * By default particle system starts as soon as they are created. This prevents the
  19621. * automatic start to happen and let you decide when to start emitting particles.
  19622. */
  19623. preventAutoStart: boolean;
  19624. private _noiseTexture;
  19625. /**
  19626. * Gets or sets a texture used to add random noise to particle positions
  19627. */
  19628. noiseTexture: Nullable<ProceduralTexture>;
  19629. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19630. noiseStrength: Vector3;
  19631. /**
  19632. * Callback triggered when the particle animation is ending.
  19633. */
  19634. onAnimationEnd: Nullable<() => void>;
  19635. /**
  19636. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19637. */
  19638. blendMode: number;
  19639. /**
  19640. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19641. * to override the particles.
  19642. */
  19643. forceDepthWrite: boolean;
  19644. /** 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 */
  19645. preWarmCycles: number;
  19646. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19647. preWarmStepOffset: number;
  19648. /**
  19649. * 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)
  19650. */
  19651. spriteCellChangeSpeed: number;
  19652. /**
  19653. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19654. */
  19655. startSpriteCellID: number;
  19656. /**
  19657. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19658. */
  19659. endSpriteCellID: number;
  19660. /**
  19661. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19662. */
  19663. spriteCellWidth: number;
  19664. /**
  19665. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19666. */
  19667. spriteCellHeight: number;
  19668. /**
  19669. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19670. */
  19671. spriteRandomStartCell: boolean;
  19672. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19673. translationPivot: Vector2;
  19674. /** @hidden */
  19675. protected _isAnimationSheetEnabled: boolean;
  19676. /**
  19677. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19678. */
  19679. beginAnimationOnStart: boolean;
  19680. /**
  19681. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19682. */
  19683. beginAnimationFrom: number;
  19684. /**
  19685. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19686. */
  19687. beginAnimationTo: number;
  19688. /**
  19689. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19690. */
  19691. beginAnimationLoop: boolean;
  19692. /**
  19693. * Gets or sets a world offset applied to all particles
  19694. */
  19695. worldOffset: Vector3;
  19696. /**
  19697. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19698. */
  19699. isAnimationSheetEnabled: boolean;
  19700. /**
  19701. * Get hosting scene
  19702. * @returns the scene
  19703. */
  19704. getScene(): Scene;
  19705. /**
  19706. * You can use gravity if you want to give an orientation to your particles.
  19707. */
  19708. gravity: Vector3;
  19709. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19710. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19711. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19712. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19713. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19714. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19715. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19716. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19717. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19718. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19719. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19720. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19721. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19722. /**
  19723. * Defines the delay in milliseconds before starting the system (0 by default)
  19724. */
  19725. startDelay: number;
  19726. /**
  19727. * Gets the current list of drag gradients.
  19728. * You must use addDragGradient and removeDragGradient to udpate this list
  19729. * @returns the list of drag gradients
  19730. */
  19731. getDragGradients(): Nullable<Array<FactorGradient>>;
  19732. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19733. limitVelocityDamping: number;
  19734. /**
  19735. * Gets the current list of limit velocity gradients.
  19736. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19737. * @returns the list of limit velocity gradients
  19738. */
  19739. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19740. /**
  19741. * Gets the current list of color gradients.
  19742. * You must use addColorGradient and removeColorGradient to udpate this list
  19743. * @returns the list of color gradients
  19744. */
  19745. getColorGradients(): Nullable<Array<ColorGradient>>;
  19746. /**
  19747. * Gets the current list of size gradients.
  19748. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19749. * @returns the list of size gradients
  19750. */
  19751. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19752. /**
  19753. * Gets the current list of color remap gradients.
  19754. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19755. * @returns the list of color remap gradients
  19756. */
  19757. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19758. /**
  19759. * Gets the current list of alpha remap gradients.
  19760. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19761. * @returns the list of alpha remap gradients
  19762. */
  19763. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19764. /**
  19765. * Gets the current list of life time gradients.
  19766. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19767. * @returns the list of life time gradients
  19768. */
  19769. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19770. /**
  19771. * Gets the current list of angular speed gradients.
  19772. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19773. * @returns the list of angular speed gradients
  19774. */
  19775. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19776. /**
  19777. * Gets the current list of velocity gradients.
  19778. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19779. * @returns the list of velocity gradients
  19780. */
  19781. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19782. /**
  19783. * Gets the current list of start size gradients.
  19784. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19785. * @returns the list of start size gradients
  19786. */
  19787. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19788. /**
  19789. * Gets the current list of emit rate gradients.
  19790. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19791. * @returns the list of emit rate gradients
  19792. */
  19793. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19794. /**
  19795. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19796. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19797. */
  19798. direction1: Vector3;
  19799. /**
  19800. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19801. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19802. */
  19803. direction2: Vector3;
  19804. /**
  19805. * 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.
  19806. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19807. */
  19808. minEmitBox: Vector3;
  19809. /**
  19810. * 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.
  19811. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19812. */
  19813. maxEmitBox: Vector3;
  19814. /**
  19815. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19816. */
  19817. color1: Color4;
  19818. /**
  19819. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19820. */
  19821. color2: Color4;
  19822. /**
  19823. * Color the particle will have at the end of its lifetime
  19824. */
  19825. colorDead: Color4;
  19826. /**
  19827. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19828. */
  19829. textureMask: Color4;
  19830. /**
  19831. * The particle emitter type defines the emitter used by the particle system.
  19832. * It can be for example box, sphere, or cone...
  19833. */
  19834. particleEmitterType: IParticleEmitterType;
  19835. /** @hidden */
  19836. _isSubEmitter: boolean;
  19837. /**
  19838. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19839. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19840. */
  19841. billboardMode: number;
  19842. protected _isBillboardBased: boolean;
  19843. /**
  19844. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19845. */
  19846. isBillboardBased: boolean;
  19847. /**
  19848. * The scene the particle system belongs to.
  19849. */
  19850. protected _scene: Scene;
  19851. /**
  19852. * Local cache of defines for image processing.
  19853. */
  19854. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19855. /**
  19856. * Default configuration related to image processing available in the standard Material.
  19857. */
  19858. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19859. /**
  19860. * Gets the image processing configuration used either in this material.
  19861. */
  19862. /**
  19863. * Sets the Default image processing configuration used either in the this material.
  19864. *
  19865. * If sets to null, the scene one is in use.
  19866. */
  19867. imageProcessingConfiguration: ImageProcessingConfiguration;
  19868. /**
  19869. * Attaches a new image processing configuration to the Standard Material.
  19870. * @param configuration
  19871. */
  19872. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19873. /** @hidden */
  19874. protected _reset(): void;
  19875. /** @hidden */
  19876. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19877. /**
  19878. * Instantiates a particle system.
  19879. * 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.
  19880. * @param name The name of the particle system
  19881. */
  19882. constructor(name: string);
  19883. /**
  19884. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19885. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19886. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19887. * @returns the emitter
  19888. */
  19889. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19890. /**
  19891. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19892. * @param radius The radius of the hemisphere to emit from
  19893. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19894. * @returns the emitter
  19895. */
  19896. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19897. /**
  19898. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19899. * @param radius The radius of the sphere to emit from
  19900. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19901. * @returns the emitter
  19902. */
  19903. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19904. /**
  19905. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19906. * @param radius The radius of the sphere to emit from
  19907. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19908. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19909. * @returns the emitter
  19910. */
  19911. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19912. /**
  19913. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19914. * @param radius The radius of the emission cylinder
  19915. * @param height The height of the emission cylinder
  19916. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19917. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19918. * @returns the emitter
  19919. */
  19920. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19921. /**
  19922. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19923. * @param radius The radius of the cylinder to emit from
  19924. * @param height The height of the emission cylinder
  19925. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19926. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19927. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19928. * @returns the emitter
  19929. */
  19930. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19931. /**
  19932. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19933. * @param radius The radius of the cone to emit from
  19934. * @param angle The base angle of the cone
  19935. * @returns the emitter
  19936. */
  19937. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19938. /**
  19939. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19940. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19941. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19942. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19943. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19944. * @returns the emitter
  19945. */
  19946. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19947. }
  19948. }
  19949. declare module "babylonjs/Particles/subEmitter" {
  19950. import { Scene } from "babylonjs/scene";
  19951. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  19952. /**
  19953. * Type of sub emitter
  19954. */
  19955. export enum SubEmitterType {
  19956. /**
  19957. * Attached to the particle over it's lifetime
  19958. */
  19959. ATTACHED = 0,
  19960. /**
  19961. * Created when the particle dies
  19962. */
  19963. END = 1
  19964. }
  19965. /**
  19966. * Sub emitter class used to emit particles from an existing particle
  19967. */
  19968. export class SubEmitter {
  19969. /**
  19970. * the particle system to be used by the sub emitter
  19971. */
  19972. particleSystem: ParticleSystem;
  19973. /**
  19974. * Type of the submitter (Default: END)
  19975. */
  19976. type: SubEmitterType;
  19977. /**
  19978. * 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)
  19979. * Note: This only is supported when using an emitter of type Mesh
  19980. */
  19981. inheritDirection: boolean;
  19982. /**
  19983. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19984. */
  19985. inheritedVelocityAmount: number;
  19986. /**
  19987. * Creates a sub emitter
  19988. * @param particleSystem the particle system to be used by the sub emitter
  19989. */
  19990. constructor(
  19991. /**
  19992. * the particle system to be used by the sub emitter
  19993. */
  19994. particleSystem: ParticleSystem);
  19995. /**
  19996. * Clones the sub emitter
  19997. * @returns the cloned sub emitter
  19998. */
  19999. clone(): SubEmitter;
  20000. /**
  20001. * Serialize current object to a JSON object
  20002. * @returns the serialized object
  20003. */
  20004. serialize(): any;
  20005. /** @hidden */
  20006. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  20007. /**
  20008. * Creates a new SubEmitter from a serialized JSON version
  20009. * @param serializationObject defines the JSON object to read from
  20010. * @param scene defines the hosting scene
  20011. * @param rootUrl defines the rootUrl for data loading
  20012. * @returns a new SubEmitter
  20013. */
  20014. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  20015. /** Release associated resources */
  20016. dispose(): void;
  20017. }
  20018. }
  20019. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  20020. /** @hidden */
  20021. export var imageProcessingDeclaration: {
  20022. name: string;
  20023. shader: string;
  20024. };
  20025. }
  20026. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  20027. /** @hidden */
  20028. export var imageProcessingFunctions: {
  20029. name: string;
  20030. shader: string;
  20031. };
  20032. }
  20033. declare module "babylonjs/Shaders/particles.fragment" {
  20034. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20035. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  20036. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  20037. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  20038. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20039. /** @hidden */
  20040. export var particlesPixelShader: {
  20041. name: string;
  20042. shader: string;
  20043. };
  20044. }
  20045. declare module "babylonjs/Shaders/particles.vertex" {
  20046. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20047. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20048. /** @hidden */
  20049. export var particlesVertexShader: {
  20050. name: string;
  20051. shader: string;
  20052. };
  20053. }
  20054. declare module "babylonjs/Particles/particleSystem" {
  20055. import { Nullable } from "babylonjs/types";
  20056. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  20057. import { Observable } from "babylonjs/Misc/observable";
  20058. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  20059. import { Effect } from "babylonjs/Materials/effect";
  20060. import { Scene, IDisposable } from "babylonjs/scene";
  20061. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20062. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  20063. import { Particle } from "babylonjs/Particles/particle";
  20064. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20065. import "babylonjs/Shaders/particles.fragment";
  20066. import "babylonjs/Shaders/particles.vertex";
  20067. /**
  20068. * This represents a particle system in Babylon.
  20069. * 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.
  20070. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  20071. * @example https://doc.babylonjs.com/babylon101/particles
  20072. */
  20073. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  20074. /**
  20075. * Billboard mode will only apply to Y axis
  20076. */
  20077. static readonly BILLBOARDMODE_Y: number;
  20078. /**
  20079. * Billboard mode will apply to all axes
  20080. */
  20081. static readonly BILLBOARDMODE_ALL: number;
  20082. /**
  20083. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  20084. */
  20085. static readonly BILLBOARDMODE_STRETCHED: number;
  20086. /**
  20087. * This function can be defined to provide custom update for active particles.
  20088. * This function will be called instead of regular update (age, position, color, etc.).
  20089. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  20090. */
  20091. updateFunction: (particles: Particle[]) => void;
  20092. private _emitterWorldMatrix;
  20093. /**
  20094. * This function can be defined to specify initial direction for every new particle.
  20095. * It by default use the emitterType defined function
  20096. */
  20097. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  20098. /**
  20099. * This function can be defined to specify initial position for every new particle.
  20100. * It by default use the emitterType defined function
  20101. */
  20102. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  20103. /**
  20104. * @hidden
  20105. */
  20106. _inheritedVelocityOffset: Vector3;
  20107. /**
  20108. * An event triggered when the system is disposed
  20109. */
  20110. onDisposeObservable: Observable<ParticleSystem>;
  20111. private _onDisposeObserver;
  20112. /**
  20113. * Sets a callback that will be triggered when the system is disposed
  20114. */
  20115. onDispose: () => void;
  20116. private _particles;
  20117. private _epsilon;
  20118. private _capacity;
  20119. private _stockParticles;
  20120. private _newPartsExcess;
  20121. private _vertexData;
  20122. private _vertexBuffer;
  20123. private _vertexBuffers;
  20124. private _spriteBuffer;
  20125. private _indexBuffer;
  20126. private _effect;
  20127. private _customEffect;
  20128. private _cachedDefines;
  20129. private _scaledColorStep;
  20130. private _colorDiff;
  20131. private _scaledDirection;
  20132. private _scaledGravity;
  20133. private _currentRenderId;
  20134. private _alive;
  20135. private _useInstancing;
  20136. private _started;
  20137. private _stopped;
  20138. private _actualFrame;
  20139. private _scaledUpdateSpeed;
  20140. private _vertexBufferSize;
  20141. /** @hidden */
  20142. _currentEmitRateGradient: Nullable<FactorGradient>;
  20143. /** @hidden */
  20144. _currentEmitRate1: number;
  20145. /** @hidden */
  20146. _currentEmitRate2: number;
  20147. /** @hidden */
  20148. _currentStartSizeGradient: Nullable<FactorGradient>;
  20149. /** @hidden */
  20150. _currentStartSize1: number;
  20151. /** @hidden */
  20152. _currentStartSize2: number;
  20153. private readonly _rawTextureWidth;
  20154. private _rampGradientsTexture;
  20155. private _useRampGradients;
  20156. /** Gets or sets a boolean indicating that ramp gradients must be used
  20157. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20158. */
  20159. useRampGradients: boolean;
  20160. /**
  20161. * 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.
  20162. * 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: [])
  20163. */
  20164. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  20165. private _subEmitters;
  20166. /**
  20167. * @hidden
  20168. * If the particle systems emitter should be disposed when the particle system is disposed
  20169. */
  20170. _disposeEmitterOnDispose: boolean;
  20171. /**
  20172. * The current active Sub-systems, this property is used by the root particle system only.
  20173. */
  20174. activeSubSystems: Array<ParticleSystem>;
  20175. private _rootParticleSystem;
  20176. /**
  20177. * Gets the current list of active particles
  20178. */
  20179. readonly particles: Particle[];
  20180. /**
  20181. * Returns the string "ParticleSystem"
  20182. * @returns a string containing the class name
  20183. */
  20184. getClassName(): string;
  20185. /**
  20186. * Instantiates a particle system.
  20187. * 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.
  20188. * @param name The name of the particle system
  20189. * @param capacity The max number of particles alive at the same time
  20190. * @param scene The scene the particle system belongs to
  20191. * @param customEffect a custom effect used to change the way particles are rendered by default
  20192. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  20193. * @param epsilon Offset used to render the particles
  20194. */
  20195. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  20196. private _addFactorGradient;
  20197. private _removeFactorGradient;
  20198. /**
  20199. * Adds a new life time gradient
  20200. * @param gradient defines the gradient to use (between 0 and 1)
  20201. * @param factor defines the life time factor to affect to the specified gradient
  20202. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20203. * @returns the current particle system
  20204. */
  20205. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20206. /**
  20207. * Remove a specific life time gradient
  20208. * @param gradient defines the gradient to remove
  20209. * @returns the current particle system
  20210. */
  20211. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20212. /**
  20213. * Adds a new size gradient
  20214. * @param gradient defines the gradient to use (between 0 and 1)
  20215. * @param factor defines the size factor to affect to the specified gradient
  20216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20217. * @returns the current particle system
  20218. */
  20219. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20220. /**
  20221. * Remove a specific size gradient
  20222. * @param gradient defines the gradient to remove
  20223. * @returns the current particle system
  20224. */
  20225. removeSizeGradient(gradient: number): IParticleSystem;
  20226. /**
  20227. * Adds a new color remap gradient
  20228. * @param gradient defines the gradient to use (between 0 and 1)
  20229. * @param min defines the color remap minimal range
  20230. * @param max defines the color remap maximal range
  20231. * @returns the current particle system
  20232. */
  20233. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20234. /**
  20235. * Remove a specific color remap gradient
  20236. * @param gradient defines the gradient to remove
  20237. * @returns the current particle system
  20238. */
  20239. removeColorRemapGradient(gradient: number): IParticleSystem;
  20240. /**
  20241. * Adds a new alpha remap gradient
  20242. * @param gradient defines the gradient to use (between 0 and 1)
  20243. * @param min defines the alpha remap minimal range
  20244. * @param max defines the alpha remap maximal range
  20245. * @returns the current particle system
  20246. */
  20247. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20248. /**
  20249. * Remove a specific alpha remap gradient
  20250. * @param gradient defines the gradient to remove
  20251. * @returns the current particle system
  20252. */
  20253. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  20254. /**
  20255. * Adds a new angular speed gradient
  20256. * @param gradient defines the gradient to use (between 0 and 1)
  20257. * @param factor defines the angular speed to affect to the specified gradient
  20258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20259. * @returns the current particle system
  20260. */
  20261. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20262. /**
  20263. * Remove a specific angular speed gradient
  20264. * @param gradient defines the gradient to remove
  20265. * @returns the current particle system
  20266. */
  20267. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20268. /**
  20269. * Adds a new velocity gradient
  20270. * @param gradient defines the gradient to use (between 0 and 1)
  20271. * @param factor defines the velocity to affect to the specified gradient
  20272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20273. * @returns the current particle system
  20274. */
  20275. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20276. /**
  20277. * Remove a specific velocity gradient
  20278. * @param gradient defines the gradient to remove
  20279. * @returns the current particle system
  20280. */
  20281. removeVelocityGradient(gradient: number): IParticleSystem;
  20282. /**
  20283. * Adds a new limit velocity gradient
  20284. * @param gradient defines the gradient to use (between 0 and 1)
  20285. * @param factor defines the limit velocity value to affect to the specified gradient
  20286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20287. * @returns the current particle system
  20288. */
  20289. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20290. /**
  20291. * Remove a specific limit velocity gradient
  20292. * @param gradient defines the gradient to remove
  20293. * @returns the current particle system
  20294. */
  20295. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20296. /**
  20297. * Adds a new drag gradient
  20298. * @param gradient defines the gradient to use (between 0 and 1)
  20299. * @param factor defines the drag value to affect to the specified gradient
  20300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20301. * @returns the current particle system
  20302. */
  20303. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20304. /**
  20305. * Remove a specific drag gradient
  20306. * @param gradient defines the gradient to remove
  20307. * @returns the current particle system
  20308. */
  20309. removeDragGradient(gradient: number): IParticleSystem;
  20310. /**
  20311. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20312. * @param gradient defines the gradient to use (between 0 and 1)
  20313. * @param factor defines the emit rate value to affect to the specified gradient
  20314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20315. * @returns the current particle system
  20316. */
  20317. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20318. /**
  20319. * Remove a specific emit rate gradient
  20320. * @param gradient defines the gradient to remove
  20321. * @returns the current particle system
  20322. */
  20323. removeEmitRateGradient(gradient: number): IParticleSystem;
  20324. /**
  20325. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20326. * @param gradient defines the gradient to use (between 0 and 1)
  20327. * @param factor defines the start size value to affect to the specified gradient
  20328. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20329. * @returns the current particle system
  20330. */
  20331. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20332. /**
  20333. * Remove a specific start size gradient
  20334. * @param gradient defines the gradient to remove
  20335. * @returns the current particle system
  20336. */
  20337. removeStartSizeGradient(gradient: number): IParticleSystem;
  20338. private _createRampGradientTexture;
  20339. /**
  20340. * Gets the current list of ramp gradients.
  20341. * You must use addRampGradient and removeRampGradient to udpate this list
  20342. * @returns the list of ramp gradients
  20343. */
  20344. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20345. /**
  20346. * Adds a new ramp gradient used to remap particle colors
  20347. * @param gradient defines the gradient to use (between 0 and 1)
  20348. * @param color defines the color to affect to the specified gradient
  20349. * @returns the current particle system
  20350. */
  20351. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  20352. /**
  20353. * Remove a specific ramp gradient
  20354. * @param gradient defines the gradient to remove
  20355. * @returns the current particle system
  20356. */
  20357. removeRampGradient(gradient: number): ParticleSystem;
  20358. /**
  20359. * Adds a new color gradient
  20360. * @param gradient defines the gradient to use (between 0 and 1)
  20361. * @param color1 defines the color to affect to the specified gradient
  20362. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20363. * @returns this particle system
  20364. */
  20365. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20366. /**
  20367. * Remove a specific color gradient
  20368. * @param gradient defines the gradient to remove
  20369. * @returns this particle system
  20370. */
  20371. removeColorGradient(gradient: number): IParticleSystem;
  20372. private _fetchR;
  20373. protected _reset(): void;
  20374. private _resetEffect;
  20375. private _createVertexBuffers;
  20376. private _createIndexBuffer;
  20377. /**
  20378. * Gets the maximum number of particles active at the same time.
  20379. * @returns The max number of active particles.
  20380. */
  20381. getCapacity(): number;
  20382. /**
  20383. * Gets whether there are still active particles in the system.
  20384. * @returns True if it is alive, otherwise false.
  20385. */
  20386. isAlive(): boolean;
  20387. /**
  20388. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20389. * @returns True if it has been started, otherwise false.
  20390. */
  20391. isStarted(): boolean;
  20392. private _prepareSubEmitterInternalArray;
  20393. /**
  20394. * Starts the particle system and begins to emit
  20395. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  20396. */
  20397. start(delay?: number): void;
  20398. /**
  20399. * Stops the particle system.
  20400. * @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.
  20401. */
  20402. stop(stopSubEmitters?: boolean): void;
  20403. /**
  20404. * Remove all active particles
  20405. */
  20406. reset(): void;
  20407. /**
  20408. * @hidden (for internal use only)
  20409. */
  20410. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20411. /**
  20412. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  20413. * Its lifetime will start back at 0.
  20414. */
  20415. recycleParticle: (particle: Particle) => void;
  20416. private _stopSubEmitters;
  20417. private _createParticle;
  20418. private _removeFromRoot;
  20419. private _emitFromParticle;
  20420. private _update;
  20421. /** @hidden */
  20422. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  20423. /** @hidden */
  20424. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  20425. /** @hidden */
  20426. private _getEffect;
  20427. /**
  20428. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20429. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  20430. */
  20431. animate(preWarmOnly?: boolean): void;
  20432. private _appendParticleVertices;
  20433. /**
  20434. * Rebuilds the particle system.
  20435. */
  20436. rebuild(): void;
  20437. /**
  20438. * Is this system ready to be used/rendered
  20439. * @return true if the system is ready
  20440. */
  20441. isReady(): boolean;
  20442. private _render;
  20443. /**
  20444. * Renders the particle system in its current state.
  20445. * @returns the current number of particles
  20446. */
  20447. render(): number;
  20448. /**
  20449. * Disposes the particle system and free the associated resources
  20450. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20451. */
  20452. dispose(disposeTexture?: boolean): void;
  20453. /**
  20454. * Clones the particle system.
  20455. * @param name The name of the cloned object
  20456. * @param newEmitter The new emitter to use
  20457. * @returns the cloned particle system
  20458. */
  20459. clone(name: string, newEmitter: any): ParticleSystem;
  20460. /**
  20461. * Serializes the particle system to a JSON object.
  20462. * @returns the JSON object
  20463. */
  20464. serialize(): any;
  20465. /** @hidden */
  20466. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20467. /** @hidden */
  20468. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20469. /**
  20470. * Parses a JSON object to create a particle system.
  20471. * @param parsedParticleSystem The JSON object to parse
  20472. * @param scene The scene to create the particle system in
  20473. * @param rootUrl The root url to use to load external dependencies like texture
  20474. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  20475. * @returns the Parsed particle system
  20476. */
  20477. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  20478. }
  20479. }
  20480. declare module "babylonjs/Particles/particle" {
  20481. import { Nullable } from "babylonjs/types";
  20482. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  20483. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  20484. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20485. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  20486. /**
  20487. * A particle represents one of the element emitted by a particle system.
  20488. * This is mainly define by its coordinates, direction, velocity and age.
  20489. */
  20490. export class Particle {
  20491. /**
  20492. * The particle system the particle belongs to.
  20493. */
  20494. particleSystem: ParticleSystem;
  20495. private static _Count;
  20496. /**
  20497. * Unique ID of the particle
  20498. */
  20499. id: number;
  20500. /**
  20501. * The world position of the particle in the scene.
  20502. */
  20503. position: Vector3;
  20504. /**
  20505. * The world direction of the particle in the scene.
  20506. */
  20507. direction: Vector3;
  20508. /**
  20509. * The color of the particle.
  20510. */
  20511. color: Color4;
  20512. /**
  20513. * The color change of the particle per step.
  20514. */
  20515. colorStep: Color4;
  20516. /**
  20517. * Defines how long will the life of the particle be.
  20518. */
  20519. lifeTime: number;
  20520. /**
  20521. * The current age of the particle.
  20522. */
  20523. age: number;
  20524. /**
  20525. * The current size of the particle.
  20526. */
  20527. size: number;
  20528. /**
  20529. * The current scale of the particle.
  20530. */
  20531. scale: Vector2;
  20532. /**
  20533. * The current angle of the particle.
  20534. */
  20535. angle: number;
  20536. /**
  20537. * Defines how fast is the angle changing.
  20538. */
  20539. angularSpeed: number;
  20540. /**
  20541. * Defines the cell index used by the particle to be rendered from a sprite.
  20542. */
  20543. cellIndex: number;
  20544. /**
  20545. * The information required to support color remapping
  20546. */
  20547. remapData: Vector4;
  20548. /** @hidden */
  20549. _randomCellOffset?: number;
  20550. /** @hidden */
  20551. _initialDirection: Nullable<Vector3>;
  20552. /** @hidden */
  20553. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20554. /** @hidden */
  20555. _initialStartSpriteCellID: number;
  20556. /** @hidden */
  20557. _initialEndSpriteCellID: number;
  20558. /** @hidden */
  20559. _currentColorGradient: Nullable<ColorGradient>;
  20560. /** @hidden */
  20561. _currentColor1: Color4;
  20562. /** @hidden */
  20563. _currentColor2: Color4;
  20564. /** @hidden */
  20565. _currentSizeGradient: Nullable<FactorGradient>;
  20566. /** @hidden */
  20567. _currentSize1: number;
  20568. /** @hidden */
  20569. _currentSize2: number;
  20570. /** @hidden */
  20571. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20572. /** @hidden */
  20573. _currentAngularSpeed1: number;
  20574. /** @hidden */
  20575. _currentAngularSpeed2: number;
  20576. /** @hidden */
  20577. _currentVelocityGradient: Nullable<FactorGradient>;
  20578. /** @hidden */
  20579. _currentVelocity1: number;
  20580. /** @hidden */
  20581. _currentVelocity2: number;
  20582. /** @hidden */
  20583. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20584. /** @hidden */
  20585. _currentLimitVelocity1: number;
  20586. /** @hidden */
  20587. _currentLimitVelocity2: number;
  20588. /** @hidden */
  20589. _currentDragGradient: Nullable<FactorGradient>;
  20590. /** @hidden */
  20591. _currentDrag1: number;
  20592. /** @hidden */
  20593. _currentDrag2: number;
  20594. /** @hidden */
  20595. _randomNoiseCoordinates1: Vector3;
  20596. /** @hidden */
  20597. _randomNoiseCoordinates2: Vector3;
  20598. /**
  20599. * Creates a new instance Particle
  20600. * @param particleSystem the particle system the particle belongs to
  20601. */
  20602. constructor(
  20603. /**
  20604. * The particle system the particle belongs to.
  20605. */
  20606. particleSystem: ParticleSystem);
  20607. private updateCellInfoFromSystem;
  20608. /**
  20609. * Defines how the sprite cell index is updated for the particle
  20610. */
  20611. updateCellIndex(): void;
  20612. /** @hidden */
  20613. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20614. /** @hidden */
  20615. _inheritParticleInfoToSubEmitters(): void;
  20616. /** @hidden */
  20617. _reset(): void;
  20618. /**
  20619. * Copy the properties of particle to another one.
  20620. * @param other the particle to copy the information to.
  20621. */
  20622. copyTo(other: Particle): void;
  20623. }
  20624. }
  20625. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  20626. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20627. import { Effect } from "babylonjs/Materials/effect";
  20628. import { Particle } from "babylonjs/Particles/particle";
  20629. /**
  20630. * Particle emitter represents a volume emitting particles.
  20631. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20632. */
  20633. export interface IParticleEmitterType {
  20634. /**
  20635. * Called by the particle System when the direction is computed for the created particle.
  20636. * @param worldMatrix is the world matrix of the particle system
  20637. * @param directionToUpdate is the direction vector to update with the result
  20638. * @param particle is the particle we are computed the direction for
  20639. */
  20640. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20641. /**
  20642. * Called by the particle System when the position is computed for the created particle.
  20643. * @param worldMatrix is the world matrix of the particle system
  20644. * @param positionToUpdate is the position vector to update with the result
  20645. * @param particle is the particle we are computed the position for
  20646. */
  20647. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20648. /**
  20649. * Clones the current emitter and returns a copy of it
  20650. * @returns the new emitter
  20651. */
  20652. clone(): IParticleEmitterType;
  20653. /**
  20654. * Called by the GPUParticleSystem to setup the update shader
  20655. * @param effect defines the update shader
  20656. */
  20657. applyToShader(effect: Effect): void;
  20658. /**
  20659. * Returns a string to use to update the GPU particles update shader
  20660. * @returns the effect defines string
  20661. */
  20662. getEffectDefines(): string;
  20663. /**
  20664. * Returns a string representing the class name
  20665. * @returns a string containing the class name
  20666. */
  20667. getClassName(): string;
  20668. /**
  20669. * Serializes the particle system to a JSON object.
  20670. * @returns the JSON object
  20671. */
  20672. serialize(): any;
  20673. /**
  20674. * Parse properties from a JSON object
  20675. * @param serializationObject defines the JSON object
  20676. */
  20677. parse(serializationObject: any): void;
  20678. }
  20679. }
  20680. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  20681. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20682. import { Effect } from "babylonjs/Materials/effect";
  20683. import { Particle } from "babylonjs/Particles/particle";
  20684. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20685. /**
  20686. * Particle emitter emitting particles from the inside of a box.
  20687. * It emits the particles randomly between 2 given directions.
  20688. */
  20689. export class BoxParticleEmitter implements IParticleEmitterType {
  20690. /**
  20691. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20692. */
  20693. direction1: Vector3;
  20694. /**
  20695. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20696. */
  20697. direction2: Vector3;
  20698. /**
  20699. * 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.
  20700. */
  20701. minEmitBox: Vector3;
  20702. /**
  20703. * 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.
  20704. */
  20705. maxEmitBox: Vector3;
  20706. /**
  20707. * Creates a new instance BoxParticleEmitter
  20708. */
  20709. constructor();
  20710. /**
  20711. * Called by the particle System when the direction is computed for the created particle.
  20712. * @param worldMatrix is the world matrix of the particle system
  20713. * @param directionToUpdate is the direction vector to update with the result
  20714. * @param particle is the particle we are computed the direction for
  20715. */
  20716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20717. /**
  20718. * Called by the particle System when the position is computed for the created particle.
  20719. * @param worldMatrix is the world matrix of the particle system
  20720. * @param positionToUpdate is the position vector to update with the result
  20721. * @param particle is the particle we are computed the position for
  20722. */
  20723. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20724. /**
  20725. * Clones the current emitter and returns a copy of it
  20726. * @returns the new emitter
  20727. */
  20728. clone(): BoxParticleEmitter;
  20729. /**
  20730. * Called by the GPUParticleSystem to setup the update shader
  20731. * @param effect defines the update shader
  20732. */
  20733. applyToShader(effect: Effect): void;
  20734. /**
  20735. * Returns a string to use to update the GPU particles update shader
  20736. * @returns a string containng the defines string
  20737. */
  20738. getEffectDefines(): string;
  20739. /**
  20740. * Returns the string "BoxParticleEmitter"
  20741. * @returns a string containing the class name
  20742. */
  20743. getClassName(): string;
  20744. /**
  20745. * Serializes the particle system to a JSON object.
  20746. * @returns the JSON object
  20747. */
  20748. serialize(): any;
  20749. /**
  20750. * Parse properties from a JSON object
  20751. * @param serializationObject defines the JSON object
  20752. */
  20753. parse(serializationObject: any): void;
  20754. }
  20755. }
  20756. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  20757. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20758. import { Effect } from "babylonjs/Materials/effect";
  20759. import { Particle } from "babylonjs/Particles/particle";
  20760. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20761. /**
  20762. * Particle emitter emitting particles from the inside of a cone.
  20763. * It emits the particles alongside the cone volume from the base to the particle.
  20764. * The emission direction might be randomized.
  20765. */
  20766. export class ConeParticleEmitter implements IParticleEmitterType {
  20767. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20768. directionRandomizer: number;
  20769. private _radius;
  20770. private _angle;
  20771. private _height;
  20772. /**
  20773. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20774. */
  20775. radiusRange: number;
  20776. /**
  20777. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20778. */
  20779. heightRange: number;
  20780. /**
  20781. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20782. */
  20783. emitFromSpawnPointOnly: boolean;
  20784. /**
  20785. * Gets or sets the radius of the emission cone
  20786. */
  20787. radius: number;
  20788. /**
  20789. * Gets or sets the angle of the emission cone
  20790. */
  20791. angle: number;
  20792. private _buildHeight;
  20793. /**
  20794. * Creates a new instance ConeParticleEmitter
  20795. * @param radius the radius of the emission cone (1 by default)
  20796. * @param angle the cone base angle (PI by default)
  20797. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20798. */
  20799. constructor(radius?: number, angle?: number,
  20800. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20801. directionRandomizer?: number);
  20802. /**
  20803. * Called by the particle System when the direction is computed for the created particle.
  20804. * @param worldMatrix is the world matrix of the particle system
  20805. * @param directionToUpdate is the direction vector to update with the result
  20806. * @param particle is the particle we are computed the direction for
  20807. */
  20808. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20809. /**
  20810. * Called by the particle System when the position is computed for the created particle.
  20811. * @param worldMatrix is the world matrix of the particle system
  20812. * @param positionToUpdate is the position vector to update with the result
  20813. * @param particle is the particle we are computed the position for
  20814. */
  20815. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20816. /**
  20817. * Clones the current emitter and returns a copy of it
  20818. * @returns the new emitter
  20819. */
  20820. clone(): ConeParticleEmitter;
  20821. /**
  20822. * Called by the GPUParticleSystem to setup the update shader
  20823. * @param effect defines the update shader
  20824. */
  20825. applyToShader(effect: Effect): void;
  20826. /**
  20827. * Returns a string to use to update the GPU particles update shader
  20828. * @returns a string containng the defines string
  20829. */
  20830. getEffectDefines(): string;
  20831. /**
  20832. * Returns the string "ConeParticleEmitter"
  20833. * @returns a string containing the class name
  20834. */
  20835. getClassName(): string;
  20836. /**
  20837. * Serializes the particle system to a JSON object.
  20838. * @returns the JSON object
  20839. */
  20840. serialize(): any;
  20841. /**
  20842. * Parse properties from a JSON object
  20843. * @param serializationObject defines the JSON object
  20844. */
  20845. parse(serializationObject: any): void;
  20846. }
  20847. }
  20848. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  20849. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20850. import { Effect } from "babylonjs/Materials/effect";
  20851. import { Particle } from "babylonjs/Particles/particle";
  20852. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20853. /**
  20854. * Particle emitter emitting particles from the inside of a cylinder.
  20855. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20856. */
  20857. export class CylinderParticleEmitter implements IParticleEmitterType {
  20858. /**
  20859. * The radius of the emission cylinder.
  20860. */
  20861. radius: number;
  20862. /**
  20863. * The height of the emission cylinder.
  20864. */
  20865. height: number;
  20866. /**
  20867. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20868. */
  20869. radiusRange: number;
  20870. /**
  20871. * How much to randomize the particle direction [0-1].
  20872. */
  20873. directionRandomizer: number;
  20874. /**
  20875. * Creates a new instance CylinderParticleEmitter
  20876. * @param radius the radius of the emission cylinder (1 by default)
  20877. * @param height the height of the emission cylinder (1 by default)
  20878. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20879. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20880. */
  20881. constructor(
  20882. /**
  20883. * The radius of the emission cylinder.
  20884. */
  20885. radius?: number,
  20886. /**
  20887. * The height of the emission cylinder.
  20888. */
  20889. height?: number,
  20890. /**
  20891. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20892. */
  20893. radiusRange?: number,
  20894. /**
  20895. * How much to randomize the particle direction [0-1].
  20896. */
  20897. directionRandomizer?: number);
  20898. /**
  20899. * Called by the particle System when the direction is computed for the created particle.
  20900. * @param worldMatrix is the world matrix of the particle system
  20901. * @param directionToUpdate is the direction vector to update with the result
  20902. * @param particle is the particle we are computed the direction for
  20903. */
  20904. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20905. /**
  20906. * Called by the particle System when the position is computed for the created particle.
  20907. * @param worldMatrix is the world matrix of the particle system
  20908. * @param positionToUpdate is the position vector to update with the result
  20909. * @param particle is the particle we are computed the position for
  20910. */
  20911. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20912. /**
  20913. * Clones the current emitter and returns a copy of it
  20914. * @returns the new emitter
  20915. */
  20916. clone(): CylinderParticleEmitter;
  20917. /**
  20918. * Called by the GPUParticleSystem to setup the update shader
  20919. * @param effect defines the update shader
  20920. */
  20921. applyToShader(effect: Effect): void;
  20922. /**
  20923. * Returns a string to use to update the GPU particles update shader
  20924. * @returns a string containng the defines string
  20925. */
  20926. getEffectDefines(): string;
  20927. /**
  20928. * Returns the string "CylinderParticleEmitter"
  20929. * @returns a string containing the class name
  20930. */
  20931. getClassName(): string;
  20932. /**
  20933. * Serializes the particle system to a JSON object.
  20934. * @returns the JSON object
  20935. */
  20936. serialize(): any;
  20937. /**
  20938. * Parse properties from a JSON object
  20939. * @param serializationObject defines the JSON object
  20940. */
  20941. parse(serializationObject: any): void;
  20942. }
  20943. /**
  20944. * Particle emitter emitting particles from the inside of a cylinder.
  20945. * It emits the particles randomly between two vectors.
  20946. */
  20947. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20948. /**
  20949. * The min limit of the emission direction.
  20950. */
  20951. direction1: Vector3;
  20952. /**
  20953. * The max limit of the emission direction.
  20954. */
  20955. direction2: Vector3;
  20956. /**
  20957. * Creates a new instance CylinderDirectedParticleEmitter
  20958. * @param radius the radius of the emission cylinder (1 by default)
  20959. * @param height the height of the emission cylinder (1 by default)
  20960. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20961. * @param direction1 the min limit of the emission direction (up vector by default)
  20962. * @param direction2 the max limit of the emission direction (up vector by default)
  20963. */
  20964. constructor(radius?: number, height?: number, radiusRange?: number,
  20965. /**
  20966. * The min limit of the emission direction.
  20967. */
  20968. direction1?: Vector3,
  20969. /**
  20970. * The max limit of the emission direction.
  20971. */
  20972. direction2?: Vector3);
  20973. /**
  20974. * Called by the particle System when the direction is computed for the created particle.
  20975. * @param worldMatrix is the world matrix of the particle system
  20976. * @param directionToUpdate is the direction vector to update with the result
  20977. * @param particle is the particle we are computed the direction for
  20978. */
  20979. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20980. /**
  20981. * Clones the current emitter and returns a copy of it
  20982. * @returns the new emitter
  20983. */
  20984. clone(): CylinderDirectedParticleEmitter;
  20985. /**
  20986. * Called by the GPUParticleSystem to setup the update shader
  20987. * @param effect defines the update shader
  20988. */
  20989. applyToShader(effect: Effect): void;
  20990. /**
  20991. * Returns a string to use to update the GPU particles update shader
  20992. * @returns a string containng the defines string
  20993. */
  20994. getEffectDefines(): string;
  20995. /**
  20996. * Returns the string "CylinderDirectedParticleEmitter"
  20997. * @returns a string containing the class name
  20998. */
  20999. getClassName(): string;
  21000. /**
  21001. * Serializes the particle system to a JSON object.
  21002. * @returns the JSON object
  21003. */
  21004. serialize(): any;
  21005. /**
  21006. * Parse properties from a JSON object
  21007. * @param serializationObject defines the JSON object
  21008. */
  21009. parse(serializationObject: any): void;
  21010. }
  21011. }
  21012. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  21013. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21014. import { Effect } from "babylonjs/Materials/effect";
  21015. import { Particle } from "babylonjs/Particles/particle";
  21016. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21017. /**
  21018. * Particle emitter emitting particles from the inside of a hemisphere.
  21019. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  21020. */
  21021. export class HemisphericParticleEmitter implements IParticleEmitterType {
  21022. /**
  21023. * The radius of the emission hemisphere.
  21024. */
  21025. radius: number;
  21026. /**
  21027. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21028. */
  21029. radiusRange: number;
  21030. /**
  21031. * How much to randomize the particle direction [0-1].
  21032. */
  21033. directionRandomizer: number;
  21034. /**
  21035. * Creates a new instance HemisphericParticleEmitter
  21036. * @param radius the radius of the emission hemisphere (1 by default)
  21037. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21038. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21039. */
  21040. constructor(
  21041. /**
  21042. * The radius of the emission hemisphere.
  21043. */
  21044. radius?: number,
  21045. /**
  21046. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21047. */
  21048. radiusRange?: number,
  21049. /**
  21050. * How much to randomize the particle direction [0-1].
  21051. */
  21052. directionRandomizer?: number);
  21053. /**
  21054. * Called by the particle System when the direction is computed for the created particle.
  21055. * @param worldMatrix is the world matrix of the particle system
  21056. * @param directionToUpdate is the direction vector to update with the result
  21057. * @param particle is the particle we are computed the direction for
  21058. */
  21059. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21060. /**
  21061. * Called by the particle System when the position is computed for the created particle.
  21062. * @param worldMatrix is the world matrix of the particle system
  21063. * @param positionToUpdate is the position vector to update with the result
  21064. * @param particle is the particle we are computed the position for
  21065. */
  21066. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21067. /**
  21068. * Clones the current emitter and returns a copy of it
  21069. * @returns the new emitter
  21070. */
  21071. clone(): HemisphericParticleEmitter;
  21072. /**
  21073. * Called by the GPUParticleSystem to setup the update shader
  21074. * @param effect defines the update shader
  21075. */
  21076. applyToShader(effect: Effect): void;
  21077. /**
  21078. * Returns a string to use to update the GPU particles update shader
  21079. * @returns a string containng the defines string
  21080. */
  21081. getEffectDefines(): string;
  21082. /**
  21083. * Returns the string "HemisphericParticleEmitter"
  21084. * @returns a string containing the class name
  21085. */
  21086. getClassName(): string;
  21087. /**
  21088. * Serializes the particle system to a JSON object.
  21089. * @returns the JSON object
  21090. */
  21091. serialize(): any;
  21092. /**
  21093. * Parse properties from a JSON object
  21094. * @param serializationObject defines the JSON object
  21095. */
  21096. parse(serializationObject: any): void;
  21097. }
  21098. }
  21099. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  21100. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21101. import { Effect } from "babylonjs/Materials/effect";
  21102. import { Particle } from "babylonjs/Particles/particle";
  21103. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21104. /**
  21105. * Particle emitter emitting particles from a point.
  21106. * It emits the particles randomly between 2 given directions.
  21107. */
  21108. export class PointParticleEmitter implements IParticleEmitterType {
  21109. /**
  21110. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21111. */
  21112. direction1: Vector3;
  21113. /**
  21114. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21115. */
  21116. direction2: Vector3;
  21117. /**
  21118. * Creates a new instance PointParticleEmitter
  21119. */
  21120. constructor();
  21121. /**
  21122. * Called by the particle System when the direction is computed for the created particle.
  21123. * @param worldMatrix is the world matrix of the particle system
  21124. * @param directionToUpdate is the direction vector to update with the result
  21125. * @param particle is the particle we are computed the direction for
  21126. */
  21127. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21128. /**
  21129. * Called by the particle System when the position is computed for the created particle.
  21130. * @param worldMatrix is the world matrix of the particle system
  21131. * @param positionToUpdate is the position vector to update with the result
  21132. * @param particle is the particle we are computed the position for
  21133. */
  21134. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21135. /**
  21136. * Clones the current emitter and returns a copy of it
  21137. * @returns the new emitter
  21138. */
  21139. clone(): PointParticleEmitter;
  21140. /**
  21141. * Called by the GPUParticleSystem to setup the update shader
  21142. * @param effect defines the update shader
  21143. */
  21144. applyToShader(effect: Effect): void;
  21145. /**
  21146. * Returns a string to use to update the GPU particles update shader
  21147. * @returns a string containng the defines string
  21148. */
  21149. getEffectDefines(): string;
  21150. /**
  21151. * Returns the string "PointParticleEmitter"
  21152. * @returns a string containing the class name
  21153. */
  21154. getClassName(): string;
  21155. /**
  21156. * Serializes the particle system to a JSON object.
  21157. * @returns the JSON object
  21158. */
  21159. serialize(): any;
  21160. /**
  21161. * Parse properties from a JSON object
  21162. * @param serializationObject defines the JSON object
  21163. */
  21164. parse(serializationObject: any): void;
  21165. }
  21166. }
  21167. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  21168. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21169. import { Effect } from "babylonjs/Materials/effect";
  21170. import { Particle } from "babylonjs/Particles/particle";
  21171. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21172. /**
  21173. * Particle emitter emitting particles from the inside of a sphere.
  21174. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  21175. */
  21176. export class SphereParticleEmitter implements IParticleEmitterType {
  21177. /**
  21178. * The radius of the emission sphere.
  21179. */
  21180. radius: number;
  21181. /**
  21182. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21183. */
  21184. radiusRange: number;
  21185. /**
  21186. * How much to randomize the particle direction [0-1].
  21187. */
  21188. directionRandomizer: number;
  21189. /**
  21190. * Creates a new instance SphereParticleEmitter
  21191. * @param radius the radius of the emission sphere (1 by default)
  21192. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21193. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21194. */
  21195. constructor(
  21196. /**
  21197. * The radius of the emission sphere.
  21198. */
  21199. radius?: number,
  21200. /**
  21201. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21202. */
  21203. radiusRange?: number,
  21204. /**
  21205. * How much to randomize the particle direction [0-1].
  21206. */
  21207. directionRandomizer?: number);
  21208. /**
  21209. * Called by the particle System when the direction is computed for the created particle.
  21210. * @param worldMatrix is the world matrix of the particle system
  21211. * @param directionToUpdate is the direction vector to update with the result
  21212. * @param particle is the particle we are computed the direction for
  21213. */
  21214. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21215. /**
  21216. * Called by the particle System when the position is computed for the created particle.
  21217. * @param worldMatrix is the world matrix of the particle system
  21218. * @param positionToUpdate is the position vector to update with the result
  21219. * @param particle is the particle we are computed the position for
  21220. */
  21221. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21222. /**
  21223. * Clones the current emitter and returns a copy of it
  21224. * @returns the new emitter
  21225. */
  21226. clone(): SphereParticleEmitter;
  21227. /**
  21228. * Called by the GPUParticleSystem to setup the update shader
  21229. * @param effect defines the update shader
  21230. */
  21231. applyToShader(effect: Effect): void;
  21232. /**
  21233. * Returns a string to use to update the GPU particles update shader
  21234. * @returns a string containng the defines string
  21235. */
  21236. getEffectDefines(): string;
  21237. /**
  21238. * Returns the string "SphereParticleEmitter"
  21239. * @returns a string containing the class name
  21240. */
  21241. getClassName(): string;
  21242. /**
  21243. * Serializes the particle system to a JSON object.
  21244. * @returns the JSON object
  21245. */
  21246. serialize(): any;
  21247. /**
  21248. * Parse properties from a JSON object
  21249. * @param serializationObject defines the JSON object
  21250. */
  21251. parse(serializationObject: any): void;
  21252. }
  21253. /**
  21254. * Particle emitter emitting particles from the inside of a sphere.
  21255. * It emits the particles randomly between two vectors.
  21256. */
  21257. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  21258. /**
  21259. * The min limit of the emission direction.
  21260. */
  21261. direction1: Vector3;
  21262. /**
  21263. * The max limit of the emission direction.
  21264. */
  21265. direction2: Vector3;
  21266. /**
  21267. * Creates a new instance SphereDirectedParticleEmitter
  21268. * @param radius the radius of the emission sphere (1 by default)
  21269. * @param direction1 the min limit of the emission direction (up vector by default)
  21270. * @param direction2 the max limit of the emission direction (up vector by default)
  21271. */
  21272. constructor(radius?: number,
  21273. /**
  21274. * The min limit of the emission direction.
  21275. */
  21276. direction1?: Vector3,
  21277. /**
  21278. * The max limit of the emission direction.
  21279. */
  21280. direction2?: Vector3);
  21281. /**
  21282. * Called by the particle System when the direction is computed for the created particle.
  21283. * @param worldMatrix is the world matrix of the particle system
  21284. * @param directionToUpdate is the direction vector to update with the result
  21285. * @param particle is the particle we are computed the direction for
  21286. */
  21287. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21288. /**
  21289. * Clones the current emitter and returns a copy of it
  21290. * @returns the new emitter
  21291. */
  21292. clone(): SphereDirectedParticleEmitter;
  21293. /**
  21294. * Called by the GPUParticleSystem to setup the update shader
  21295. * @param effect defines the update shader
  21296. */
  21297. applyToShader(effect: Effect): void;
  21298. /**
  21299. * Returns a string to use to update the GPU particles update shader
  21300. * @returns a string containng the defines string
  21301. */
  21302. getEffectDefines(): string;
  21303. /**
  21304. * Returns the string "SphereDirectedParticleEmitter"
  21305. * @returns a string containing the class name
  21306. */
  21307. getClassName(): string;
  21308. /**
  21309. * Serializes the particle system to a JSON object.
  21310. * @returns the JSON object
  21311. */
  21312. serialize(): any;
  21313. /**
  21314. * Parse properties from a JSON object
  21315. * @param serializationObject defines the JSON object
  21316. */
  21317. parse(serializationObject: any): void;
  21318. }
  21319. }
  21320. declare module "babylonjs/Particles/EmitterTypes/index" {
  21321. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  21322. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  21323. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  21324. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  21325. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21326. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  21327. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  21328. }
  21329. declare module "babylonjs/Particles/IParticleSystem" {
  21330. import { Nullable } from "babylonjs/types";
  21331. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  21332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21333. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21334. import { Texture } from "babylonjs/Materials/Textures/texture";
  21335. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  21336. import { Scene } from "babylonjs/scene";
  21337. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  21338. import { Animation } from "babylonjs/Animations/animation";
  21339. /**
  21340. * Interface representing a particle system in Babylon.js.
  21341. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  21342. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  21343. */
  21344. export interface IParticleSystem {
  21345. /**
  21346. * List of animations used by the particle system.
  21347. */
  21348. animations: Animation[];
  21349. /**
  21350. * The id of the Particle system.
  21351. */
  21352. id: string;
  21353. /**
  21354. * The name of the Particle system.
  21355. */
  21356. name: string;
  21357. /**
  21358. * The emitter represents the Mesh or position we are attaching the particle system to.
  21359. */
  21360. emitter: Nullable<AbstractMesh | Vector3>;
  21361. /**
  21362. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  21363. */
  21364. isBillboardBased: boolean;
  21365. /**
  21366. * The rendering group used by the Particle system to chose when to render.
  21367. */
  21368. renderingGroupId: number;
  21369. /**
  21370. * The layer mask we are rendering the particles through.
  21371. */
  21372. layerMask: number;
  21373. /**
  21374. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  21375. */
  21376. updateSpeed: number;
  21377. /**
  21378. * The amount of time the particle system is running (depends of the overall update speed).
  21379. */
  21380. targetStopDuration: number;
  21381. /**
  21382. * The texture used to render each particle. (this can be a spritesheet)
  21383. */
  21384. particleTexture: Nullable<Texture>;
  21385. /**
  21386. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  21387. */
  21388. blendMode: number;
  21389. /**
  21390. * Minimum life time of emitting particles.
  21391. */
  21392. minLifeTime: number;
  21393. /**
  21394. * Maximum life time of emitting particles.
  21395. */
  21396. maxLifeTime: number;
  21397. /**
  21398. * Minimum Size of emitting particles.
  21399. */
  21400. minSize: number;
  21401. /**
  21402. * Maximum Size of emitting particles.
  21403. */
  21404. maxSize: number;
  21405. /**
  21406. * Minimum scale of emitting particles on X axis.
  21407. */
  21408. minScaleX: number;
  21409. /**
  21410. * Maximum scale of emitting particles on X axis.
  21411. */
  21412. maxScaleX: number;
  21413. /**
  21414. * Minimum scale of emitting particles on Y axis.
  21415. */
  21416. minScaleY: number;
  21417. /**
  21418. * Maximum scale of emitting particles on Y axis.
  21419. */
  21420. maxScaleY: number;
  21421. /**
  21422. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21423. */
  21424. color1: Color4;
  21425. /**
  21426. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21427. */
  21428. color2: Color4;
  21429. /**
  21430. * Color the particle will have at the end of its lifetime.
  21431. */
  21432. colorDead: Color4;
  21433. /**
  21434. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  21435. */
  21436. emitRate: number;
  21437. /**
  21438. * You can use gravity if you want to give an orientation to your particles.
  21439. */
  21440. gravity: Vector3;
  21441. /**
  21442. * Minimum power of emitting particles.
  21443. */
  21444. minEmitPower: number;
  21445. /**
  21446. * Maximum power of emitting particles.
  21447. */
  21448. maxEmitPower: number;
  21449. /**
  21450. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  21451. */
  21452. minAngularSpeed: number;
  21453. /**
  21454. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  21455. */
  21456. maxAngularSpeed: number;
  21457. /**
  21458. * Gets or sets the minimal initial rotation in radians.
  21459. */
  21460. minInitialRotation: number;
  21461. /**
  21462. * Gets or sets the maximal initial rotation in radians.
  21463. */
  21464. maxInitialRotation: number;
  21465. /**
  21466. * The particle emitter type defines the emitter used by the particle system.
  21467. * It can be for example box, sphere, or cone...
  21468. */
  21469. particleEmitterType: Nullable<IParticleEmitterType>;
  21470. /**
  21471. * Defines the delay in milliseconds before starting the system (0 by default)
  21472. */
  21473. startDelay: number;
  21474. /**
  21475. * 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
  21476. */
  21477. preWarmCycles: number;
  21478. /**
  21479. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  21480. */
  21481. preWarmStepOffset: number;
  21482. /**
  21483. * 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)
  21484. */
  21485. spriteCellChangeSpeed: number;
  21486. /**
  21487. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  21488. */
  21489. startSpriteCellID: number;
  21490. /**
  21491. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  21492. */
  21493. endSpriteCellID: number;
  21494. /**
  21495. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  21496. */
  21497. spriteCellWidth: number;
  21498. /**
  21499. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  21500. */
  21501. spriteCellHeight: number;
  21502. /**
  21503. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  21504. */
  21505. spriteRandomStartCell: boolean;
  21506. /**
  21507. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  21508. */
  21509. isAnimationSheetEnabled: boolean;
  21510. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  21511. translationPivot: Vector2;
  21512. /**
  21513. * Gets or sets a texture used to add random noise to particle positions
  21514. */
  21515. noiseTexture: Nullable<BaseTexture>;
  21516. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21517. noiseStrength: Vector3;
  21518. /**
  21519. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21520. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  21521. */
  21522. billboardMode: number;
  21523. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21524. limitVelocityDamping: number;
  21525. /**
  21526. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  21527. */
  21528. beginAnimationOnStart: boolean;
  21529. /**
  21530. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21531. */
  21532. beginAnimationFrom: number;
  21533. /**
  21534. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21535. */
  21536. beginAnimationTo: number;
  21537. /**
  21538. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21539. */
  21540. beginAnimationLoop: boolean;
  21541. /**
  21542. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21543. */
  21544. disposeOnStop: boolean;
  21545. /**
  21546. * Gets the maximum number of particles active at the same time.
  21547. * @returns The max number of active particles.
  21548. */
  21549. getCapacity(): number;
  21550. /**
  21551. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21552. * @returns True if it has been started, otherwise false.
  21553. */
  21554. isStarted(): boolean;
  21555. /**
  21556. * Animates the particle system for this frame.
  21557. */
  21558. animate(): void;
  21559. /**
  21560. * Renders the particle system in its current state.
  21561. * @returns the current number of particles
  21562. */
  21563. render(): number;
  21564. /**
  21565. * Dispose the particle system and frees its associated resources.
  21566. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21567. */
  21568. dispose(disposeTexture?: boolean): void;
  21569. /**
  21570. * Clones the particle system.
  21571. * @param name The name of the cloned object
  21572. * @param newEmitter The new emitter to use
  21573. * @returns the cloned particle system
  21574. */
  21575. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21576. /**
  21577. * Serializes the particle system to a JSON object.
  21578. * @returns the JSON object
  21579. */
  21580. serialize(): any;
  21581. /**
  21582. * Rebuild the particle system
  21583. */
  21584. rebuild(): void;
  21585. /**
  21586. * Starts the particle system and begins to emit
  21587. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21588. */
  21589. start(delay?: number): void;
  21590. /**
  21591. * Stops the particle system.
  21592. */
  21593. stop(): void;
  21594. /**
  21595. * Remove all active particles
  21596. */
  21597. reset(): void;
  21598. /**
  21599. * Is this system ready to be used/rendered
  21600. * @return true if the system is ready
  21601. */
  21602. isReady(): boolean;
  21603. /**
  21604. * Adds a new color gradient
  21605. * @param gradient defines the gradient to use (between 0 and 1)
  21606. * @param color1 defines the color to affect to the specified gradient
  21607. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21608. * @returns the current particle system
  21609. */
  21610. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21611. /**
  21612. * Remove a specific color gradient
  21613. * @param gradient defines the gradient to remove
  21614. * @returns the current particle system
  21615. */
  21616. removeColorGradient(gradient: number): IParticleSystem;
  21617. /**
  21618. * Adds a new size gradient
  21619. * @param gradient defines the gradient to use (between 0 and 1)
  21620. * @param factor defines the size factor to affect to the specified gradient
  21621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21622. * @returns the current particle system
  21623. */
  21624. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21625. /**
  21626. * Remove a specific size gradient
  21627. * @param gradient defines the gradient to remove
  21628. * @returns the current particle system
  21629. */
  21630. removeSizeGradient(gradient: number): IParticleSystem;
  21631. /**
  21632. * Gets the current list of color gradients.
  21633. * You must use addColorGradient and removeColorGradient to udpate this list
  21634. * @returns the list of color gradients
  21635. */
  21636. getColorGradients(): Nullable<Array<ColorGradient>>;
  21637. /**
  21638. * Gets the current list of size gradients.
  21639. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21640. * @returns the list of size gradients
  21641. */
  21642. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21643. /**
  21644. * Gets the current list of angular speed gradients.
  21645. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21646. * @returns the list of angular speed gradients
  21647. */
  21648. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21649. /**
  21650. * Adds a new angular speed gradient
  21651. * @param gradient defines the gradient to use (between 0 and 1)
  21652. * @param factor defines the angular speed to affect to the specified gradient
  21653. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21654. * @returns the current particle system
  21655. */
  21656. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21657. /**
  21658. * Remove a specific angular speed gradient
  21659. * @param gradient defines the gradient to remove
  21660. * @returns the current particle system
  21661. */
  21662. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21663. /**
  21664. * Gets the current list of velocity gradients.
  21665. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21666. * @returns the list of velocity gradients
  21667. */
  21668. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21669. /**
  21670. * Adds a new velocity gradient
  21671. * @param gradient defines the gradient to use (between 0 and 1)
  21672. * @param factor defines the velocity to affect to the specified gradient
  21673. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21674. * @returns the current particle system
  21675. */
  21676. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21677. /**
  21678. * Remove a specific velocity gradient
  21679. * @param gradient defines the gradient to remove
  21680. * @returns the current particle system
  21681. */
  21682. removeVelocityGradient(gradient: number): IParticleSystem;
  21683. /**
  21684. * Gets the current list of limit velocity gradients.
  21685. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21686. * @returns the list of limit velocity gradients
  21687. */
  21688. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21689. /**
  21690. * Adds a new limit velocity gradient
  21691. * @param gradient defines the gradient to use (between 0 and 1)
  21692. * @param factor defines the limit velocity to affect to the specified gradient
  21693. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21694. * @returns the current particle system
  21695. */
  21696. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21697. /**
  21698. * Remove a specific limit velocity gradient
  21699. * @param gradient defines the gradient to remove
  21700. * @returns the current particle system
  21701. */
  21702. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21703. /**
  21704. * Adds a new drag gradient
  21705. * @param gradient defines the gradient to use (between 0 and 1)
  21706. * @param factor defines the drag to affect to the specified gradient
  21707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21708. * @returns the current particle system
  21709. */
  21710. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21711. /**
  21712. * Remove a specific drag gradient
  21713. * @param gradient defines the gradient to remove
  21714. * @returns the current particle system
  21715. */
  21716. removeDragGradient(gradient: number): IParticleSystem;
  21717. /**
  21718. * Gets the current list of drag gradients.
  21719. * You must use addDragGradient and removeDragGradient to udpate this list
  21720. * @returns the list of drag gradients
  21721. */
  21722. getDragGradients(): Nullable<Array<FactorGradient>>;
  21723. /**
  21724. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21725. * @param gradient defines the gradient to use (between 0 and 1)
  21726. * @param factor defines the emit rate to affect to the specified gradient
  21727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21728. * @returns the current particle system
  21729. */
  21730. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21731. /**
  21732. * Remove a specific emit rate gradient
  21733. * @param gradient defines the gradient to remove
  21734. * @returns the current particle system
  21735. */
  21736. removeEmitRateGradient(gradient: number): IParticleSystem;
  21737. /**
  21738. * Gets the current list of emit rate gradients.
  21739. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21740. * @returns the list of emit rate gradients
  21741. */
  21742. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21743. /**
  21744. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21745. * @param gradient defines the gradient to use (between 0 and 1)
  21746. * @param factor defines the start size to affect to the specified gradient
  21747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21748. * @returns the current particle system
  21749. */
  21750. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21751. /**
  21752. * Remove a specific start size gradient
  21753. * @param gradient defines the gradient to remove
  21754. * @returns the current particle system
  21755. */
  21756. removeStartSizeGradient(gradient: number): IParticleSystem;
  21757. /**
  21758. * Gets the current list of start size gradients.
  21759. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21760. * @returns the list of start size gradients
  21761. */
  21762. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21763. /**
  21764. * Adds a new life time gradient
  21765. * @param gradient defines the gradient to use (between 0 and 1)
  21766. * @param factor defines the life time factor to affect to the specified gradient
  21767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21768. * @returns the current particle system
  21769. */
  21770. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21771. /**
  21772. * Remove a specific life time gradient
  21773. * @param gradient defines the gradient to remove
  21774. * @returns the current particle system
  21775. */
  21776. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21777. /**
  21778. * Gets the current list of life time gradients.
  21779. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21780. * @returns the list of life time gradients
  21781. */
  21782. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21783. /**
  21784. * Gets the current list of color gradients.
  21785. * You must use addColorGradient and removeColorGradient to udpate this list
  21786. * @returns the list of color gradients
  21787. */
  21788. getColorGradients(): Nullable<Array<ColorGradient>>;
  21789. /**
  21790. * Adds a new ramp gradient used to remap particle colors
  21791. * @param gradient defines the gradient to use (between 0 and 1)
  21792. * @param color defines the color to affect to the specified gradient
  21793. * @returns the current particle system
  21794. */
  21795. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21796. /**
  21797. * Gets the current list of ramp gradients.
  21798. * You must use addRampGradient and removeRampGradient to udpate this list
  21799. * @returns the list of ramp gradients
  21800. */
  21801. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21802. /** Gets or sets a boolean indicating that ramp gradients must be used
  21803. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21804. */
  21805. useRampGradients: boolean;
  21806. /**
  21807. * Adds a new color remap gradient
  21808. * @param gradient defines the gradient to use (between 0 and 1)
  21809. * @param min defines the color remap minimal range
  21810. * @param max defines the color remap maximal range
  21811. * @returns the current particle system
  21812. */
  21813. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21814. /**
  21815. * Gets the current list of color remap gradients.
  21816. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21817. * @returns the list of color remap gradients
  21818. */
  21819. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21820. /**
  21821. * Adds a new alpha remap gradient
  21822. * @param gradient defines the gradient to use (between 0 and 1)
  21823. * @param min defines the alpha remap minimal range
  21824. * @param max defines the alpha remap maximal range
  21825. * @returns the current particle system
  21826. */
  21827. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21828. /**
  21829. * Gets the current list of alpha remap gradients.
  21830. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21831. * @returns the list of alpha remap gradients
  21832. */
  21833. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21834. /**
  21835. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21836. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21837. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21838. * @returns the emitter
  21839. */
  21840. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21841. /**
  21842. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21843. * @param radius The radius of the hemisphere to emit from
  21844. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21845. * @returns the emitter
  21846. */
  21847. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21848. /**
  21849. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21850. * @param radius The radius of the sphere to emit from
  21851. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21852. * @returns the emitter
  21853. */
  21854. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21855. /**
  21856. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21857. * @param radius The radius of the sphere to emit from
  21858. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21859. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21860. * @returns the emitter
  21861. */
  21862. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21863. /**
  21864. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21865. * @param radius The radius of the emission cylinder
  21866. * @param height The height of the emission cylinder
  21867. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21868. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21869. * @returns the emitter
  21870. */
  21871. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21872. /**
  21873. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21874. * @param radius The radius of the cylinder to emit from
  21875. * @param height The height of the emission cylinder
  21876. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21877. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21878. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21879. * @returns the emitter
  21880. */
  21881. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21882. /**
  21883. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21884. * @param radius The radius of the cone to emit from
  21885. * @param angle The base angle of the cone
  21886. * @returns the emitter
  21887. */
  21888. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21889. /**
  21890. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21891. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21892. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21893. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21894. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21895. * @returns the emitter
  21896. */
  21897. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21898. /**
  21899. * Get hosting scene
  21900. * @returns the scene
  21901. */
  21902. getScene(): Scene;
  21903. }
  21904. }
  21905. declare module "babylonjs/Shaders/line.fragment" {
  21906. /** @hidden */
  21907. export var linePixelShader: {
  21908. name: string;
  21909. shader: string;
  21910. };
  21911. }
  21912. declare module "babylonjs/Shaders/line.vertex" {
  21913. /** @hidden */
  21914. export var lineVertexShader: {
  21915. name: string;
  21916. shader: string;
  21917. };
  21918. }
  21919. declare module "babylonjs/Rendering/edgesRenderer" {
  21920. import { Nullable } from "babylonjs/types";
  21921. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21923. import { Vector3 } from "babylonjs/Maths/math";
  21924. import { IDisposable } from "babylonjs/scene";
  21925. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  21926. import "babylonjs/Shaders/line.fragment";
  21927. import "babylonjs/Shaders/line.vertex";
  21928. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21929. module "babylonjs/Meshes/abstractMesh" {
  21930. interface AbstractMesh {
  21931. /**
  21932. * Gets the edgesRenderer associated with the mesh
  21933. */
  21934. edgesRenderer: Nullable<EdgesRenderer>;
  21935. }
  21936. }
  21937. module "babylonjs/Meshes/linesMesh" {
  21938. interface LinesMesh {
  21939. /**
  21940. * Enables the edge rendering mode on the mesh.
  21941. * This mode makes the mesh edges visible
  21942. * @param epsilon defines the maximal distance between two angles to detect a face
  21943. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21944. * @returns the currentAbstractMesh
  21945. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21946. */
  21947. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21948. }
  21949. }
  21950. module "babylonjs/Meshes/linesMesh" {
  21951. interface InstancedLinesMesh {
  21952. /**
  21953. * Enables the edge rendering mode on the mesh.
  21954. * This mode makes the mesh edges visible
  21955. * @param epsilon defines the maximal distance between two angles to detect a face
  21956. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21957. * @returns the current InstancedLinesMesh
  21958. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21959. */
  21960. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21961. }
  21962. }
  21963. /**
  21964. * Defines the minimum contract an Edges renderer should follow.
  21965. */
  21966. export interface IEdgesRenderer extends IDisposable {
  21967. /**
  21968. * Gets or sets a boolean indicating if the edgesRenderer is active
  21969. */
  21970. isEnabled: boolean;
  21971. /**
  21972. * Renders the edges of the attached mesh,
  21973. */
  21974. render(): void;
  21975. /**
  21976. * Checks wether or not the edges renderer is ready to render.
  21977. * @return true if ready, otherwise false.
  21978. */
  21979. isReady(): boolean;
  21980. }
  21981. /**
  21982. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21983. */
  21984. export class EdgesRenderer implements IEdgesRenderer {
  21985. /**
  21986. * Define the size of the edges with an orthographic camera
  21987. */
  21988. edgesWidthScalerForOrthographic: number;
  21989. /**
  21990. * Define the size of the edges with a perspective camera
  21991. */
  21992. edgesWidthScalerForPerspective: number;
  21993. protected _source: AbstractMesh;
  21994. protected _linesPositions: number[];
  21995. protected _linesNormals: number[];
  21996. protected _linesIndices: number[];
  21997. protected _epsilon: number;
  21998. protected _indicesCount: number;
  21999. protected _lineShader: ShaderMaterial;
  22000. protected _ib: DataBuffer;
  22001. protected _buffers: {
  22002. [key: string]: Nullable<VertexBuffer>;
  22003. };
  22004. protected _checkVerticesInsteadOfIndices: boolean;
  22005. private _meshRebuildObserver;
  22006. private _meshDisposeObserver;
  22007. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  22008. isEnabled: boolean;
  22009. /**
  22010. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  22011. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  22012. * @param source Mesh used to create edges
  22013. * @param epsilon sum of angles in adjacency to check for edge
  22014. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  22015. * @param generateEdgesLines - should generate Lines or only prepare resources.
  22016. */
  22017. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  22018. protected _prepareRessources(): void;
  22019. /** @hidden */
  22020. _rebuild(): void;
  22021. /**
  22022. * Releases the required resources for the edges renderer
  22023. */
  22024. dispose(): void;
  22025. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  22026. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  22027. /**
  22028. * Checks if the pair of p0 and p1 is en edge
  22029. * @param faceIndex
  22030. * @param edge
  22031. * @param faceNormals
  22032. * @param p0
  22033. * @param p1
  22034. * @private
  22035. */
  22036. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  22037. /**
  22038. * push line into the position, normal and index buffer
  22039. * @protected
  22040. */
  22041. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  22042. /**
  22043. * Generates lines edges from adjacencjes
  22044. * @private
  22045. */
  22046. _generateEdgesLines(): void;
  22047. /**
  22048. * Checks wether or not the edges renderer is ready to render.
  22049. * @return true if ready, otherwise false.
  22050. */
  22051. isReady(): boolean;
  22052. /**
  22053. * Renders the edges of the attached mesh,
  22054. */
  22055. render(): void;
  22056. }
  22057. /**
  22058. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  22059. */
  22060. export class LineEdgesRenderer extends EdgesRenderer {
  22061. /**
  22062. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  22063. * @param source LineMesh used to generate edges
  22064. * @param epsilon not important (specified angle for edge detection)
  22065. * @param checkVerticesInsteadOfIndices not important for LineMesh
  22066. */
  22067. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  22068. /**
  22069. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  22070. */
  22071. _generateEdgesLines(): void;
  22072. }
  22073. }
  22074. declare module "babylonjs/Rendering/renderingGroup" {
  22075. import { SmartArray } from "babylonjs/Misc/smartArray";
  22076. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22078. import { Nullable } from "babylonjs/types";
  22079. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22080. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  22081. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22082. import { Material } from "babylonjs/Materials/material";
  22083. import { Scene } from "babylonjs/scene";
  22084. /**
  22085. * This represents the object necessary to create a rendering group.
  22086. * This is exclusively used and created by the rendering manager.
  22087. * To modify the behavior, you use the available helpers in your scene or meshes.
  22088. * @hidden
  22089. */
  22090. export class RenderingGroup {
  22091. index: number;
  22092. private static _zeroVector;
  22093. private _scene;
  22094. private _opaqueSubMeshes;
  22095. private _transparentSubMeshes;
  22096. private _alphaTestSubMeshes;
  22097. private _depthOnlySubMeshes;
  22098. private _particleSystems;
  22099. private _spriteManagers;
  22100. private _opaqueSortCompareFn;
  22101. private _alphaTestSortCompareFn;
  22102. private _transparentSortCompareFn;
  22103. private _renderOpaque;
  22104. private _renderAlphaTest;
  22105. private _renderTransparent;
  22106. /** @hidden */
  22107. _edgesRenderers: SmartArray<IEdgesRenderer>;
  22108. onBeforeTransparentRendering: () => void;
  22109. /**
  22110. * Set the opaque sort comparison function.
  22111. * If null the sub meshes will be render in the order they were created
  22112. */
  22113. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22114. /**
  22115. * Set the alpha test sort comparison function.
  22116. * If null the sub meshes will be render in the order they were created
  22117. */
  22118. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22119. /**
  22120. * Set the transparent sort comparison function.
  22121. * If null the sub meshes will be render in the order they were created
  22122. */
  22123. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22124. /**
  22125. * Creates a new rendering group.
  22126. * @param index The rendering group index
  22127. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  22128. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  22129. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  22130. */
  22131. 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>);
  22132. /**
  22133. * Render all the sub meshes contained in the group.
  22134. * @param customRenderFunction Used to override the default render behaviour of the group.
  22135. * @returns true if rendered some submeshes.
  22136. */
  22137. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  22138. /**
  22139. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  22140. * @param subMeshes The submeshes to render
  22141. */
  22142. private renderOpaqueSorted;
  22143. /**
  22144. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  22145. * @param subMeshes The submeshes to render
  22146. */
  22147. private renderAlphaTestSorted;
  22148. /**
  22149. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  22150. * @param subMeshes The submeshes to render
  22151. */
  22152. private renderTransparentSorted;
  22153. /**
  22154. * Renders the submeshes in a specified order.
  22155. * @param subMeshes The submeshes to sort before render
  22156. * @param sortCompareFn The comparison function use to sort
  22157. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  22158. * @param transparent Specifies to activate blending if true
  22159. */
  22160. private static renderSorted;
  22161. /**
  22162. * Renders the submeshes in the order they were dispatched (no sort applied).
  22163. * @param subMeshes The submeshes to render
  22164. */
  22165. private static renderUnsorted;
  22166. /**
  22167. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22168. * are rendered back to front if in the same alpha index.
  22169. *
  22170. * @param a The first submesh
  22171. * @param b The second submesh
  22172. * @returns The result of the comparison
  22173. */
  22174. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  22175. /**
  22176. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22177. * are rendered back to front.
  22178. *
  22179. * @param a The first submesh
  22180. * @param b The second submesh
  22181. * @returns The result of the comparison
  22182. */
  22183. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  22184. /**
  22185. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22186. * are rendered front to back (prevent overdraw).
  22187. *
  22188. * @param a The first submesh
  22189. * @param b The second submesh
  22190. * @returns The result of the comparison
  22191. */
  22192. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  22193. /**
  22194. * Resets the different lists of submeshes to prepare a new frame.
  22195. */
  22196. prepare(): void;
  22197. dispose(): void;
  22198. /**
  22199. * Inserts the submesh in its correct queue depending on its material.
  22200. * @param subMesh The submesh to dispatch
  22201. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22202. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22203. */
  22204. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22205. dispatchSprites(spriteManager: ISpriteManager): void;
  22206. dispatchParticles(particleSystem: IParticleSystem): void;
  22207. private _renderParticles;
  22208. private _renderSprites;
  22209. }
  22210. }
  22211. declare module "babylonjs/Rendering/renderingManager" {
  22212. import { Nullable } from "babylonjs/types";
  22213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22214. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22215. import { SmartArray } from "babylonjs/Misc/smartArray";
  22216. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22217. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22218. import { Material } from "babylonjs/Materials/material";
  22219. import { Scene } from "babylonjs/scene";
  22220. import { Camera } from "babylonjs/Cameras/camera";
  22221. /**
  22222. * Interface describing the different options available in the rendering manager
  22223. * regarding Auto Clear between groups.
  22224. */
  22225. export interface IRenderingManagerAutoClearSetup {
  22226. /**
  22227. * Defines whether or not autoclear is enable.
  22228. */
  22229. autoClear: boolean;
  22230. /**
  22231. * Defines whether or not to autoclear the depth buffer.
  22232. */
  22233. depth: boolean;
  22234. /**
  22235. * Defines whether or not to autoclear the stencil buffer.
  22236. */
  22237. stencil: boolean;
  22238. }
  22239. /**
  22240. * This class is used by the onRenderingGroupObservable
  22241. */
  22242. export class RenderingGroupInfo {
  22243. /**
  22244. * The Scene that being rendered
  22245. */
  22246. scene: Scene;
  22247. /**
  22248. * The camera currently used for the rendering pass
  22249. */
  22250. camera: Nullable<Camera>;
  22251. /**
  22252. * The ID of the renderingGroup being processed
  22253. */
  22254. renderingGroupId: number;
  22255. }
  22256. /**
  22257. * This is the manager responsible of all the rendering for meshes sprites and particles.
  22258. * It is enable to manage the different groups as well as the different necessary sort functions.
  22259. * This should not be used directly aside of the few static configurations
  22260. */
  22261. export class RenderingManager {
  22262. /**
  22263. * The max id used for rendering groups (not included)
  22264. */
  22265. static MAX_RENDERINGGROUPS: number;
  22266. /**
  22267. * The min id used for rendering groups (included)
  22268. */
  22269. static MIN_RENDERINGGROUPS: number;
  22270. /**
  22271. * Used to globally prevent autoclearing scenes.
  22272. */
  22273. static AUTOCLEAR: boolean;
  22274. /**
  22275. * @hidden
  22276. */
  22277. _useSceneAutoClearSetup: boolean;
  22278. private _scene;
  22279. private _renderingGroups;
  22280. private _depthStencilBufferAlreadyCleaned;
  22281. private _autoClearDepthStencil;
  22282. private _customOpaqueSortCompareFn;
  22283. private _customAlphaTestSortCompareFn;
  22284. private _customTransparentSortCompareFn;
  22285. private _renderingGroupInfo;
  22286. /**
  22287. * Instantiates a new rendering group for a particular scene
  22288. * @param scene Defines the scene the groups belongs to
  22289. */
  22290. constructor(scene: Scene);
  22291. private _clearDepthStencilBuffer;
  22292. /**
  22293. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  22294. * @hidden
  22295. */
  22296. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  22297. /**
  22298. * Resets the different information of the group to prepare a new frame
  22299. * @hidden
  22300. */
  22301. reset(): void;
  22302. /**
  22303. * Dispose and release the group and its associated resources.
  22304. * @hidden
  22305. */
  22306. dispose(): void;
  22307. /**
  22308. * Clear the info related to rendering groups preventing retention points during dispose.
  22309. */
  22310. freeRenderingGroups(): void;
  22311. private _prepareRenderingGroup;
  22312. /**
  22313. * Add a sprite manager to the rendering manager in order to render it this frame.
  22314. * @param spriteManager Define the sprite manager to render
  22315. */
  22316. dispatchSprites(spriteManager: ISpriteManager): void;
  22317. /**
  22318. * Add a particle system to the rendering manager in order to render it this frame.
  22319. * @param particleSystem Define the particle system to render
  22320. */
  22321. dispatchParticles(particleSystem: IParticleSystem): void;
  22322. /**
  22323. * Add a submesh to the manager in order to render it this frame
  22324. * @param subMesh The submesh to dispatch
  22325. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22326. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22327. */
  22328. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22329. /**
  22330. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22331. * This allowed control for front to back rendering or reversly depending of the special needs.
  22332. *
  22333. * @param renderingGroupId The rendering group id corresponding to its index
  22334. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22335. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22336. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22337. */
  22338. 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;
  22339. /**
  22340. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22341. *
  22342. * @param renderingGroupId The rendering group id corresponding to its index
  22343. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22344. * @param depth Automatically clears depth between groups if true and autoClear is true.
  22345. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  22346. */
  22347. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  22348. /**
  22349. * Gets the current auto clear configuration for one rendering group of the rendering
  22350. * manager.
  22351. * @param index the rendering group index to get the information for
  22352. * @returns The auto clear setup for the requested rendering group
  22353. */
  22354. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  22355. }
  22356. }
  22357. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  22358. import { Observable } from "babylonjs/Misc/observable";
  22359. import { SmartArray } from "babylonjs/Misc/smartArray";
  22360. import { Nullable } from "babylonjs/types";
  22361. import { Camera } from "babylonjs/Cameras/camera";
  22362. import { Scene } from "babylonjs/scene";
  22363. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  22364. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  22365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22366. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22367. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22368. import { Texture } from "babylonjs/Materials/Textures/texture";
  22369. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  22370. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  22371. import "babylonjs/Engines/Extensions/engine.renderTarget";
  22372. import { Engine } from "babylonjs/Engines/engine";
  22373. /**
  22374. * This Helps creating a texture that will be created from a camera in your scene.
  22375. * It is basically a dynamic texture that could be used to create special effects for instance.
  22376. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  22377. */
  22378. export class RenderTargetTexture extends Texture {
  22379. isCube: boolean;
  22380. /**
  22381. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  22382. */
  22383. static readonly REFRESHRATE_RENDER_ONCE: number;
  22384. /**
  22385. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  22386. */
  22387. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  22388. /**
  22389. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  22390. * the central point of your effect and can save a lot of performances.
  22391. */
  22392. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  22393. /**
  22394. * Use this predicate to dynamically define the list of mesh you want to render.
  22395. * If set, the renderList property will be overwritten.
  22396. */
  22397. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  22398. private _renderList;
  22399. /**
  22400. * Use this list to define the list of mesh you want to render.
  22401. */
  22402. renderList: Nullable<Array<AbstractMesh>>;
  22403. private _hookArray;
  22404. /**
  22405. * Define if particles should be rendered in your texture.
  22406. */
  22407. renderParticles: boolean;
  22408. /**
  22409. * Define if sprites should be rendered in your texture.
  22410. */
  22411. renderSprites: boolean;
  22412. /**
  22413. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  22414. */
  22415. coordinatesMode: number;
  22416. /**
  22417. * Define the camera used to render the texture.
  22418. */
  22419. activeCamera: Nullable<Camera>;
  22420. /**
  22421. * Override the render function of the texture with your own one.
  22422. */
  22423. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  22424. /**
  22425. * Define if camera post processes should be use while rendering the texture.
  22426. */
  22427. useCameraPostProcesses: boolean;
  22428. /**
  22429. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  22430. */
  22431. ignoreCameraViewport: boolean;
  22432. private _postProcessManager;
  22433. private _postProcesses;
  22434. private _resizeObserver;
  22435. /**
  22436. * An event triggered when the texture is unbind.
  22437. */
  22438. onBeforeBindObservable: Observable<RenderTargetTexture>;
  22439. /**
  22440. * An event triggered when the texture is unbind.
  22441. */
  22442. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  22443. private _onAfterUnbindObserver;
  22444. /**
  22445. * Set a after unbind callback in the texture.
  22446. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  22447. */
  22448. onAfterUnbind: () => void;
  22449. /**
  22450. * An event triggered before rendering the texture
  22451. */
  22452. onBeforeRenderObservable: Observable<number>;
  22453. private _onBeforeRenderObserver;
  22454. /**
  22455. * Set a before render callback in the texture.
  22456. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  22457. */
  22458. onBeforeRender: (faceIndex: number) => void;
  22459. /**
  22460. * An event triggered after rendering the texture
  22461. */
  22462. onAfterRenderObservable: Observable<number>;
  22463. private _onAfterRenderObserver;
  22464. /**
  22465. * Set a after render callback in the texture.
  22466. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  22467. */
  22468. onAfterRender: (faceIndex: number) => void;
  22469. /**
  22470. * An event triggered after the texture clear
  22471. */
  22472. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  22473. private _onClearObserver;
  22474. /**
  22475. * Set a clear callback in the texture.
  22476. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  22477. */
  22478. onClear: (Engine: Engine) => void;
  22479. /**
  22480. * Define the clear color of the Render Target if it should be different from the scene.
  22481. */
  22482. clearColor: Color4;
  22483. protected _size: number | {
  22484. width: number;
  22485. height: number;
  22486. };
  22487. protected _initialSizeParameter: number | {
  22488. width: number;
  22489. height: number;
  22490. } | {
  22491. ratio: number;
  22492. };
  22493. protected _sizeRatio: Nullable<number>;
  22494. /** @hidden */
  22495. _generateMipMaps: boolean;
  22496. protected _renderingManager: RenderingManager;
  22497. /** @hidden */
  22498. _waitingRenderList: string[];
  22499. protected _doNotChangeAspectRatio: boolean;
  22500. protected _currentRefreshId: number;
  22501. protected _refreshRate: number;
  22502. protected _textureMatrix: Matrix;
  22503. protected _samples: number;
  22504. protected _renderTargetOptions: RenderTargetCreationOptions;
  22505. /**
  22506. * Gets render target creation options that were used.
  22507. */
  22508. readonly renderTargetOptions: RenderTargetCreationOptions;
  22509. protected _engine: Engine;
  22510. protected _onRatioRescale(): void;
  22511. /**
  22512. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  22513. * It must define where the camera used to render the texture is set
  22514. */
  22515. boundingBoxPosition: Vector3;
  22516. private _boundingBoxSize;
  22517. /**
  22518. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  22519. * When defined, the cubemap will switch to local mode
  22520. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  22521. * @example https://www.babylonjs-playground.com/#RNASML
  22522. */
  22523. boundingBoxSize: Vector3;
  22524. /**
  22525. * In case the RTT has been created with a depth texture, get the associated
  22526. * depth texture.
  22527. * Otherwise, return null.
  22528. */
  22529. depthStencilTexture: Nullable<InternalTexture>;
  22530. /**
  22531. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  22532. * or used a shadow, depth texture...
  22533. * @param name The friendly name of the texture
  22534. * @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)
  22535. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  22536. * @param generateMipMaps True if mip maps need to be generated after render.
  22537. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  22538. * @param type The type of the buffer in the RTT (int, half float, float...)
  22539. * @param isCube True if a cube texture needs to be created
  22540. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  22541. * @param generateDepthBuffer True to generate a depth buffer
  22542. * @param generateStencilBuffer True to generate a stencil buffer
  22543. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  22544. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  22545. * @param delayAllocation if the texture allocation should be delayed (default: false)
  22546. */
  22547. constructor(name: string, size: number | {
  22548. width: number;
  22549. height: number;
  22550. } | {
  22551. ratio: number;
  22552. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  22553. /**
  22554. * Creates a depth stencil texture.
  22555. * This is only available in WebGL 2 or with the depth texture extension available.
  22556. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  22557. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  22558. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  22559. */
  22560. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  22561. private _processSizeParameter;
  22562. /**
  22563. * Define the number of samples to use in case of MSAA.
  22564. * It defaults to one meaning no MSAA has been enabled.
  22565. */
  22566. samples: number;
  22567. /**
  22568. * Resets the refresh counter of the texture and start bak from scratch.
  22569. * Could be useful to regenerate the texture if it is setup to render only once.
  22570. */
  22571. resetRefreshCounter(): void;
  22572. /**
  22573. * Define the refresh rate of the texture or the rendering frequency.
  22574. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  22575. */
  22576. refreshRate: number;
  22577. /**
  22578. * Adds a post process to the render target rendering passes.
  22579. * @param postProcess define the post process to add
  22580. */
  22581. addPostProcess(postProcess: PostProcess): void;
  22582. /**
  22583. * Clear all the post processes attached to the render target
  22584. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22585. */
  22586. clearPostProcesses(dispose?: boolean): void;
  22587. /**
  22588. * Remove one of the post process from the list of attached post processes to the texture
  22589. * @param postProcess define the post process to remove from the list
  22590. */
  22591. removePostProcess(postProcess: PostProcess): void;
  22592. /** @hidden */
  22593. _shouldRender(): boolean;
  22594. /**
  22595. * Gets the actual render size of the texture.
  22596. * @returns the width of the render size
  22597. */
  22598. getRenderSize(): number;
  22599. /**
  22600. * Gets the actual render width of the texture.
  22601. * @returns the width of the render size
  22602. */
  22603. getRenderWidth(): number;
  22604. /**
  22605. * Gets the actual render height of the texture.
  22606. * @returns the height of the render size
  22607. */
  22608. getRenderHeight(): number;
  22609. /**
  22610. * Get if the texture can be rescaled or not.
  22611. */
  22612. readonly canRescale: boolean;
  22613. /**
  22614. * Resize the texture using a ratio.
  22615. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22616. */
  22617. scale(ratio: number): void;
  22618. /**
  22619. * Get the texture reflection matrix used to rotate/transform the reflection.
  22620. * @returns the reflection matrix
  22621. */
  22622. getReflectionTextureMatrix(): Matrix;
  22623. /**
  22624. * Resize the texture to a new desired size.
  22625. * Be carrefull as it will recreate all the data in the new texture.
  22626. * @param size Define the new size. It can be:
  22627. * - a number for squared texture,
  22628. * - an object containing { width: number, height: number }
  22629. * - or an object containing a ratio { ratio: number }
  22630. */
  22631. resize(size: number | {
  22632. width: number;
  22633. height: number;
  22634. } | {
  22635. ratio: number;
  22636. }): void;
  22637. /**
  22638. * Renders all the objects from the render list into the texture.
  22639. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22640. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22641. */
  22642. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22643. private _bestReflectionRenderTargetDimension;
  22644. /**
  22645. * @hidden
  22646. * @param faceIndex face index to bind to if this is a cubetexture
  22647. */
  22648. _bindFrameBuffer(faceIndex?: number): void;
  22649. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22650. private renderToTarget;
  22651. /**
  22652. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22653. * This allowed control for front to back rendering or reversly depending of the special needs.
  22654. *
  22655. * @param renderingGroupId The rendering group id corresponding to its index
  22656. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22657. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22658. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22659. */
  22660. 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;
  22661. /**
  22662. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22663. *
  22664. * @param renderingGroupId The rendering group id corresponding to its index
  22665. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22666. */
  22667. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22668. /**
  22669. * Clones the texture.
  22670. * @returns the cloned texture
  22671. */
  22672. clone(): RenderTargetTexture;
  22673. /**
  22674. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22675. * @returns The JSON representation of the texture
  22676. */
  22677. serialize(): any;
  22678. /**
  22679. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22680. */
  22681. disposeFramebufferObjects(): void;
  22682. /**
  22683. * Dispose the texture and release its associated resources.
  22684. */
  22685. dispose(): void;
  22686. /** @hidden */
  22687. _rebuild(): void;
  22688. /**
  22689. * Clear the info related to rendering groups preventing retention point in material dispose.
  22690. */
  22691. freeRenderingGroups(): void;
  22692. /**
  22693. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22694. * @returns the view count
  22695. */
  22696. getViewCount(): number;
  22697. }
  22698. }
  22699. declare module "babylonjs/Materials/material" {
  22700. import { IAnimatable } from "babylonjs/Misc/tools";
  22701. import { SmartArray } from "babylonjs/Misc/smartArray";
  22702. import { Observable } from "babylonjs/Misc/observable";
  22703. import { Nullable } from "babylonjs/types";
  22704. import { Scene } from "babylonjs/scene";
  22705. import { Matrix } from "babylonjs/Maths/math";
  22706. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22708. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22709. import { Effect } from "babylonjs/Materials/effect";
  22710. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22711. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22712. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22713. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22714. import { Mesh } from "babylonjs/Meshes/mesh";
  22715. import { Animation } from "babylonjs/Animations/animation";
  22716. /**
  22717. * Base class for the main features of a material in Babylon.js
  22718. */
  22719. export class Material implements IAnimatable {
  22720. /**
  22721. * Returns the triangle fill mode
  22722. */
  22723. static readonly TriangleFillMode: number;
  22724. /**
  22725. * Returns the wireframe mode
  22726. */
  22727. static readonly WireFrameFillMode: number;
  22728. /**
  22729. * Returns the point fill mode
  22730. */
  22731. static readonly PointFillMode: number;
  22732. /**
  22733. * Returns the point list draw mode
  22734. */
  22735. static readonly PointListDrawMode: number;
  22736. /**
  22737. * Returns the line list draw mode
  22738. */
  22739. static readonly LineListDrawMode: number;
  22740. /**
  22741. * Returns the line loop draw mode
  22742. */
  22743. static readonly LineLoopDrawMode: number;
  22744. /**
  22745. * Returns the line strip draw mode
  22746. */
  22747. static readonly LineStripDrawMode: number;
  22748. /**
  22749. * Returns the triangle strip draw mode
  22750. */
  22751. static readonly TriangleStripDrawMode: number;
  22752. /**
  22753. * Returns the triangle fan draw mode
  22754. */
  22755. static readonly TriangleFanDrawMode: number;
  22756. /**
  22757. * Stores the clock-wise side orientation
  22758. */
  22759. static readonly ClockWiseSideOrientation: number;
  22760. /**
  22761. * Stores the counter clock-wise side orientation
  22762. */
  22763. static readonly CounterClockWiseSideOrientation: number;
  22764. /**
  22765. * The dirty texture flag value
  22766. */
  22767. static readonly TextureDirtyFlag: number;
  22768. /**
  22769. * The dirty light flag value
  22770. */
  22771. static readonly LightDirtyFlag: number;
  22772. /**
  22773. * The dirty fresnel flag value
  22774. */
  22775. static readonly FresnelDirtyFlag: number;
  22776. /**
  22777. * The dirty attribute flag value
  22778. */
  22779. static readonly AttributesDirtyFlag: number;
  22780. /**
  22781. * The dirty misc flag value
  22782. */
  22783. static readonly MiscDirtyFlag: number;
  22784. /**
  22785. * The all dirty flag value
  22786. */
  22787. static readonly AllDirtyFlag: number;
  22788. /**
  22789. * The ID of the material
  22790. */
  22791. id: string;
  22792. /**
  22793. * Gets or sets the unique id of the material
  22794. */
  22795. uniqueId: number;
  22796. /**
  22797. * The name of the material
  22798. */
  22799. name: string;
  22800. /**
  22801. * Gets or sets user defined metadata
  22802. */
  22803. metadata: any;
  22804. /**
  22805. * For internal use only. Please do not use.
  22806. */
  22807. reservedDataStore: any;
  22808. /**
  22809. * Specifies if the ready state should be checked on each call
  22810. */
  22811. checkReadyOnEveryCall: boolean;
  22812. /**
  22813. * Specifies if the ready state should be checked once
  22814. */
  22815. checkReadyOnlyOnce: boolean;
  22816. /**
  22817. * The state of the material
  22818. */
  22819. state: string;
  22820. /**
  22821. * The alpha value of the material
  22822. */
  22823. protected _alpha: number;
  22824. /**
  22825. * List of inspectable custom properties (used by the Inspector)
  22826. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22827. */
  22828. inspectableCustomProperties: IInspectable[];
  22829. /**
  22830. * Sets the alpha value of the material
  22831. */
  22832. /**
  22833. * Gets the alpha value of the material
  22834. */
  22835. alpha: number;
  22836. /**
  22837. * Specifies if back face culling is enabled
  22838. */
  22839. protected _backFaceCulling: boolean;
  22840. /**
  22841. * Sets the back-face culling state
  22842. */
  22843. /**
  22844. * Gets the back-face culling state
  22845. */
  22846. backFaceCulling: boolean;
  22847. /**
  22848. * Stores the value for side orientation
  22849. */
  22850. sideOrientation: number;
  22851. /**
  22852. * Callback triggered when the material is compiled
  22853. */
  22854. onCompiled: Nullable<(effect: Effect) => void>;
  22855. /**
  22856. * Callback triggered when an error occurs
  22857. */
  22858. onError: Nullable<(effect: Effect, errors: string) => void>;
  22859. /**
  22860. * Callback triggered to get the render target textures
  22861. */
  22862. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22863. /**
  22864. * Gets a boolean indicating that current material needs to register RTT
  22865. */
  22866. readonly hasRenderTargetTextures: boolean;
  22867. /**
  22868. * Specifies if the material should be serialized
  22869. */
  22870. doNotSerialize: boolean;
  22871. /**
  22872. * @hidden
  22873. */
  22874. _storeEffectOnSubMeshes: boolean;
  22875. /**
  22876. * Stores the animations for the material
  22877. */
  22878. animations: Nullable<Array<Animation>>;
  22879. /**
  22880. * An event triggered when the material is disposed
  22881. */
  22882. onDisposeObservable: Observable<Material>;
  22883. /**
  22884. * An observer which watches for dispose events
  22885. */
  22886. private _onDisposeObserver;
  22887. private _onUnBindObservable;
  22888. /**
  22889. * Called during a dispose event
  22890. */
  22891. onDispose: () => void;
  22892. private _onBindObservable;
  22893. /**
  22894. * An event triggered when the material is bound
  22895. */
  22896. readonly onBindObservable: Observable<AbstractMesh>;
  22897. /**
  22898. * An observer which watches for bind events
  22899. */
  22900. private _onBindObserver;
  22901. /**
  22902. * Called during a bind event
  22903. */
  22904. onBind: (Mesh: AbstractMesh) => void;
  22905. /**
  22906. * An event triggered when the material is unbound
  22907. */
  22908. readonly onUnBindObservable: Observable<Material>;
  22909. /**
  22910. * Stores the value of the alpha mode
  22911. */
  22912. private _alphaMode;
  22913. /**
  22914. * Sets the value of the alpha mode.
  22915. *
  22916. * | Value | Type | Description |
  22917. * | --- | --- | --- |
  22918. * | 0 | ALPHA_DISABLE | |
  22919. * | 1 | ALPHA_ADD | |
  22920. * | 2 | ALPHA_COMBINE | |
  22921. * | 3 | ALPHA_SUBTRACT | |
  22922. * | 4 | ALPHA_MULTIPLY | |
  22923. * | 5 | ALPHA_MAXIMIZED | |
  22924. * | 6 | ALPHA_ONEONE | |
  22925. * | 7 | ALPHA_PREMULTIPLIED | |
  22926. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22927. * | 9 | ALPHA_INTERPOLATE | |
  22928. * | 10 | ALPHA_SCREENMODE | |
  22929. *
  22930. */
  22931. /**
  22932. * Gets the value of the alpha mode
  22933. */
  22934. alphaMode: number;
  22935. /**
  22936. * Stores the state of the need depth pre-pass value
  22937. */
  22938. private _needDepthPrePass;
  22939. /**
  22940. * Sets the need depth pre-pass value
  22941. */
  22942. /**
  22943. * Gets the depth pre-pass value
  22944. */
  22945. needDepthPrePass: boolean;
  22946. /**
  22947. * Specifies if depth writing should be disabled
  22948. */
  22949. disableDepthWrite: boolean;
  22950. /**
  22951. * Specifies if depth writing should be forced
  22952. */
  22953. forceDepthWrite: boolean;
  22954. /**
  22955. * Specifies if there should be a separate pass for culling
  22956. */
  22957. separateCullingPass: boolean;
  22958. /**
  22959. * Stores the state specifing if fog should be enabled
  22960. */
  22961. private _fogEnabled;
  22962. /**
  22963. * Sets the state for enabling fog
  22964. */
  22965. /**
  22966. * Gets the value of the fog enabled state
  22967. */
  22968. fogEnabled: boolean;
  22969. /**
  22970. * Stores the size of points
  22971. */
  22972. pointSize: number;
  22973. /**
  22974. * Stores the z offset value
  22975. */
  22976. zOffset: number;
  22977. /**
  22978. * Gets a value specifying if wireframe mode is enabled
  22979. */
  22980. /**
  22981. * Sets the state of wireframe mode
  22982. */
  22983. wireframe: boolean;
  22984. /**
  22985. * Gets the value specifying if point clouds are enabled
  22986. */
  22987. /**
  22988. * Sets the state of point cloud mode
  22989. */
  22990. pointsCloud: boolean;
  22991. /**
  22992. * Gets the material fill mode
  22993. */
  22994. /**
  22995. * Sets the material fill mode
  22996. */
  22997. fillMode: number;
  22998. /**
  22999. * @hidden
  23000. * Stores the effects for the material
  23001. */
  23002. _effect: Nullable<Effect>;
  23003. /**
  23004. * @hidden
  23005. * Specifies if the material was previously ready
  23006. */
  23007. _wasPreviouslyReady: boolean;
  23008. /**
  23009. * Specifies if uniform buffers should be used
  23010. */
  23011. private _useUBO;
  23012. /**
  23013. * Stores a reference to the scene
  23014. */
  23015. private _scene;
  23016. /**
  23017. * Stores the fill mode state
  23018. */
  23019. private _fillMode;
  23020. /**
  23021. * Specifies if the depth write state should be cached
  23022. */
  23023. private _cachedDepthWriteState;
  23024. /**
  23025. * Stores the uniform buffer
  23026. */
  23027. protected _uniformBuffer: UniformBuffer;
  23028. /** @hidden */
  23029. _indexInSceneMaterialArray: number;
  23030. /** @hidden */
  23031. meshMap: Nullable<{
  23032. [id: string]: AbstractMesh | undefined;
  23033. }>;
  23034. /**
  23035. * Creates a material instance
  23036. * @param name defines the name of the material
  23037. * @param scene defines the scene to reference
  23038. * @param doNotAdd specifies if the material should be added to the scene
  23039. */
  23040. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  23041. /**
  23042. * Returns a string representation of the current material
  23043. * @param fullDetails defines a boolean indicating which levels of logging is desired
  23044. * @returns a string with material information
  23045. */
  23046. toString(fullDetails?: boolean): string;
  23047. /**
  23048. * Gets the class name of the material
  23049. * @returns a string with the class name of the material
  23050. */
  23051. getClassName(): string;
  23052. /**
  23053. * Specifies if updates for the material been locked
  23054. */
  23055. readonly isFrozen: boolean;
  23056. /**
  23057. * Locks updates for the material
  23058. */
  23059. freeze(): void;
  23060. /**
  23061. * Unlocks updates for the material
  23062. */
  23063. unfreeze(): void;
  23064. /**
  23065. * Specifies if the material is ready to be used
  23066. * @param mesh defines the mesh to check
  23067. * @param useInstances specifies if instances should be used
  23068. * @returns a boolean indicating if the material is ready to be used
  23069. */
  23070. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23071. /**
  23072. * Specifies that the submesh is ready to be used
  23073. * @param mesh defines the mesh to check
  23074. * @param subMesh defines which submesh to check
  23075. * @param useInstances specifies that instances should be used
  23076. * @returns a boolean indicating that the submesh is ready or not
  23077. */
  23078. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23079. /**
  23080. * Returns the material effect
  23081. * @returns the effect associated with the material
  23082. */
  23083. getEffect(): Nullable<Effect>;
  23084. /**
  23085. * Returns the current scene
  23086. * @returns a Scene
  23087. */
  23088. getScene(): Scene;
  23089. /**
  23090. * Specifies if the material will require alpha blending
  23091. * @returns a boolean specifying if alpha blending is needed
  23092. */
  23093. needAlphaBlending(): boolean;
  23094. /**
  23095. * Specifies if the mesh will require alpha blending
  23096. * @param mesh defines the mesh to check
  23097. * @returns a boolean specifying if alpha blending is needed for the mesh
  23098. */
  23099. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23100. /**
  23101. * Specifies if this material should be rendered in alpha test mode
  23102. * @returns a boolean specifying if an alpha test is needed.
  23103. */
  23104. needAlphaTesting(): boolean;
  23105. /**
  23106. * Gets the texture used for the alpha test
  23107. * @returns the texture to use for alpha testing
  23108. */
  23109. getAlphaTestTexture(): Nullable<BaseTexture>;
  23110. /**
  23111. * Marks the material to indicate that it needs to be re-calculated
  23112. */
  23113. markDirty(): void;
  23114. /** @hidden */
  23115. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23116. /**
  23117. * Binds the material to the mesh
  23118. * @param world defines the world transformation matrix
  23119. * @param mesh defines the mesh to bind the material to
  23120. */
  23121. bind(world: Matrix, mesh?: Mesh): void;
  23122. /**
  23123. * Binds the submesh to the material
  23124. * @param world defines the world transformation matrix
  23125. * @param mesh defines the mesh containing the submesh
  23126. * @param subMesh defines the submesh to bind the material to
  23127. */
  23128. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23129. /**
  23130. * Binds the world matrix to the material
  23131. * @param world defines the world transformation matrix
  23132. */
  23133. bindOnlyWorldMatrix(world: Matrix): void;
  23134. /**
  23135. * Binds the scene's uniform buffer to the effect.
  23136. * @param effect defines the effect to bind to the scene uniform buffer
  23137. * @param sceneUbo defines the uniform buffer storing scene data
  23138. */
  23139. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23140. /**
  23141. * Binds the view matrix to the effect
  23142. * @param effect defines the effect to bind the view matrix to
  23143. */
  23144. bindView(effect: Effect): void;
  23145. /**
  23146. * Binds the view projection matrix to the effect
  23147. * @param effect defines the effect to bind the view projection matrix to
  23148. */
  23149. bindViewProjection(effect: Effect): void;
  23150. /**
  23151. * Specifies if material alpha testing should be turned on for the mesh
  23152. * @param mesh defines the mesh to check
  23153. */
  23154. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23155. /**
  23156. * Processes to execute after binding the material to a mesh
  23157. * @param mesh defines the rendered mesh
  23158. */
  23159. protected _afterBind(mesh?: Mesh): void;
  23160. /**
  23161. * Unbinds the material from the mesh
  23162. */
  23163. unbind(): void;
  23164. /**
  23165. * Gets the active textures from the material
  23166. * @returns an array of textures
  23167. */
  23168. getActiveTextures(): BaseTexture[];
  23169. /**
  23170. * Specifies if the material uses a texture
  23171. * @param texture defines the texture to check against the material
  23172. * @returns a boolean specifying if the material uses the texture
  23173. */
  23174. hasTexture(texture: BaseTexture): boolean;
  23175. /**
  23176. * Makes a duplicate of the material, and gives it a new name
  23177. * @param name defines the new name for the duplicated material
  23178. * @returns the cloned material
  23179. */
  23180. clone(name: string): Nullable<Material>;
  23181. /**
  23182. * Gets the meshes bound to the material
  23183. * @returns an array of meshes bound to the material
  23184. */
  23185. getBindedMeshes(): AbstractMesh[];
  23186. /**
  23187. * Force shader compilation
  23188. * @param mesh defines the mesh associated with this material
  23189. * @param onCompiled defines a function to execute once the material is compiled
  23190. * @param options defines the options to configure the compilation
  23191. */
  23192. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23193. clipPlane: boolean;
  23194. }>): void;
  23195. /**
  23196. * Force shader compilation
  23197. * @param mesh defines the mesh that will use this material
  23198. * @param options defines additional options for compiling the shaders
  23199. * @returns a promise that resolves when the compilation completes
  23200. */
  23201. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23202. clipPlane: boolean;
  23203. }>): Promise<void>;
  23204. private static readonly _AllDirtyCallBack;
  23205. private static readonly _ImageProcessingDirtyCallBack;
  23206. private static readonly _TextureDirtyCallBack;
  23207. private static readonly _FresnelDirtyCallBack;
  23208. private static readonly _MiscDirtyCallBack;
  23209. private static readonly _LightsDirtyCallBack;
  23210. private static readonly _AttributeDirtyCallBack;
  23211. private static _FresnelAndMiscDirtyCallBack;
  23212. private static _TextureAndMiscDirtyCallBack;
  23213. private static readonly _DirtyCallbackArray;
  23214. private static readonly _RunDirtyCallBacks;
  23215. /**
  23216. * Marks a define in the material to indicate that it needs to be re-computed
  23217. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23218. */
  23219. markAsDirty(flag: number): void;
  23220. /**
  23221. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23222. * @param func defines a function which checks material defines against the submeshes
  23223. */
  23224. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23225. /**
  23226. * Indicates that we need to re-calculated for all submeshes
  23227. */
  23228. protected _markAllSubMeshesAsAllDirty(): void;
  23229. /**
  23230. * Indicates that image processing needs to be re-calculated for all submeshes
  23231. */
  23232. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23233. /**
  23234. * Indicates that textures need to be re-calculated for all submeshes
  23235. */
  23236. protected _markAllSubMeshesAsTexturesDirty(): void;
  23237. /**
  23238. * Indicates that fresnel needs to be re-calculated for all submeshes
  23239. */
  23240. protected _markAllSubMeshesAsFresnelDirty(): void;
  23241. /**
  23242. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23243. */
  23244. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23245. /**
  23246. * Indicates that lights need to be re-calculated for all submeshes
  23247. */
  23248. protected _markAllSubMeshesAsLightsDirty(): void;
  23249. /**
  23250. * Indicates that attributes need to be re-calculated for all submeshes
  23251. */
  23252. protected _markAllSubMeshesAsAttributesDirty(): void;
  23253. /**
  23254. * Indicates that misc needs to be re-calculated for all submeshes
  23255. */
  23256. protected _markAllSubMeshesAsMiscDirty(): void;
  23257. /**
  23258. * Indicates that textures and misc need to be re-calculated for all submeshes
  23259. */
  23260. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23261. /**
  23262. * Disposes the material
  23263. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23264. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23265. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23266. */
  23267. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23268. /** @hidden */
  23269. private releaseVertexArrayObject;
  23270. /**
  23271. * Serializes this material
  23272. * @returns the serialized material object
  23273. */
  23274. serialize(): any;
  23275. /**
  23276. * Creates a material from parsed material data
  23277. * @param parsedMaterial defines parsed material data
  23278. * @param scene defines the hosting scene
  23279. * @param rootUrl defines the root URL to use to load textures
  23280. * @returns a new material
  23281. */
  23282. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23283. }
  23284. }
  23285. declare module "babylonjs/Meshes/subMesh" {
  23286. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23287. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23288. import { Engine } from "babylonjs/Engines/engine";
  23289. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23290. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23291. import { Effect } from "babylonjs/Materials/effect";
  23292. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23293. import { Collider } from "babylonjs/Collisions/collider";
  23294. import { Material } from "babylonjs/Materials/material";
  23295. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23297. import { Mesh } from "babylonjs/Meshes/mesh";
  23298. import { Ray } from "babylonjs/Culling/ray";
  23299. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23300. /**
  23301. * Base class for submeshes
  23302. */
  23303. export class BaseSubMesh {
  23304. /** @hidden */
  23305. _materialDefines: Nullable<MaterialDefines>;
  23306. /** @hidden */
  23307. _materialEffect: Nullable<Effect>;
  23308. /**
  23309. * Gets associated effect
  23310. */
  23311. readonly effect: Nullable<Effect>;
  23312. /**
  23313. * Sets associated effect (effect used to render this submesh)
  23314. * @param effect defines the effect to associate with
  23315. * @param defines defines the set of defines used to compile this effect
  23316. */
  23317. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23318. }
  23319. /**
  23320. * Defines a subdivision inside a mesh
  23321. */
  23322. export class SubMesh extends BaseSubMesh implements ICullable {
  23323. /** the material index to use */
  23324. materialIndex: number;
  23325. /** vertex index start */
  23326. verticesStart: number;
  23327. /** vertices count */
  23328. verticesCount: number;
  23329. /** index start */
  23330. indexStart: number;
  23331. /** indices count */
  23332. indexCount: number;
  23333. /** @hidden */
  23334. _linesIndexCount: number;
  23335. private _mesh;
  23336. private _renderingMesh;
  23337. private _boundingInfo;
  23338. private _linesIndexBuffer;
  23339. /** @hidden */
  23340. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23341. /** @hidden */
  23342. _trianglePlanes: Plane[];
  23343. /** @hidden */
  23344. _lastColliderTransformMatrix: Nullable<Matrix>;
  23345. /** @hidden */
  23346. _renderId: number;
  23347. /** @hidden */
  23348. _alphaIndex: number;
  23349. /** @hidden */
  23350. _distanceToCamera: number;
  23351. /** @hidden */
  23352. _id: number;
  23353. private _currentMaterial;
  23354. /**
  23355. * Add a new submesh to a mesh
  23356. * @param materialIndex defines the material index to use
  23357. * @param verticesStart defines vertex index start
  23358. * @param verticesCount defines vertices count
  23359. * @param indexStart defines index start
  23360. * @param indexCount defines indices count
  23361. * @param mesh defines the parent mesh
  23362. * @param renderingMesh defines an optional rendering mesh
  23363. * @param createBoundingBox defines if bounding box should be created for this submesh
  23364. * @returns the new submesh
  23365. */
  23366. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23367. /**
  23368. * Creates a new submesh
  23369. * @param materialIndex defines the material index to use
  23370. * @param verticesStart defines vertex index start
  23371. * @param verticesCount defines vertices count
  23372. * @param indexStart defines index start
  23373. * @param indexCount defines indices count
  23374. * @param mesh defines the parent mesh
  23375. * @param renderingMesh defines an optional rendering mesh
  23376. * @param createBoundingBox defines if bounding box should be created for this submesh
  23377. */
  23378. constructor(
  23379. /** the material index to use */
  23380. materialIndex: number,
  23381. /** vertex index start */
  23382. verticesStart: number,
  23383. /** vertices count */
  23384. verticesCount: number,
  23385. /** index start */
  23386. indexStart: number,
  23387. /** indices count */
  23388. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23389. /**
  23390. * Returns true if this submesh covers the entire parent mesh
  23391. * @ignorenaming
  23392. */
  23393. readonly IsGlobal: boolean;
  23394. /**
  23395. * Returns the submesh BoudingInfo object
  23396. * @returns current bounding info (or mesh's one if the submesh is global)
  23397. */
  23398. getBoundingInfo(): BoundingInfo;
  23399. /**
  23400. * Sets the submesh BoundingInfo
  23401. * @param boundingInfo defines the new bounding info to use
  23402. * @returns the SubMesh
  23403. */
  23404. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23405. /**
  23406. * Returns the mesh of the current submesh
  23407. * @return the parent mesh
  23408. */
  23409. getMesh(): AbstractMesh;
  23410. /**
  23411. * Returns the rendering mesh of the submesh
  23412. * @returns the rendering mesh (could be different from parent mesh)
  23413. */
  23414. getRenderingMesh(): Mesh;
  23415. /**
  23416. * Returns the submesh material
  23417. * @returns null or the current material
  23418. */
  23419. getMaterial(): Nullable<Material>;
  23420. /**
  23421. * Sets a new updated BoundingInfo object to the submesh
  23422. * @param data defines an optional position array to use to determine the bounding info
  23423. * @returns the SubMesh
  23424. */
  23425. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23426. /** @hidden */
  23427. _checkCollision(collider: Collider): boolean;
  23428. /**
  23429. * Updates the submesh BoundingInfo
  23430. * @param world defines the world matrix to use to update the bounding info
  23431. * @returns the submesh
  23432. */
  23433. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23434. /**
  23435. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23436. * @param frustumPlanes defines the frustum planes
  23437. * @returns true if the submesh is intersecting with the frustum
  23438. */
  23439. isInFrustum(frustumPlanes: Plane[]): boolean;
  23440. /**
  23441. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23442. * @param frustumPlanes defines the frustum planes
  23443. * @returns true if the submesh is inside the frustum
  23444. */
  23445. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23446. /**
  23447. * Renders the submesh
  23448. * @param enableAlphaMode defines if alpha needs to be used
  23449. * @returns the submesh
  23450. */
  23451. render(enableAlphaMode: boolean): SubMesh;
  23452. /**
  23453. * @hidden
  23454. */
  23455. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23456. /**
  23457. * Checks if the submesh intersects with a ray
  23458. * @param ray defines the ray to test
  23459. * @returns true is the passed ray intersects the submesh bounding box
  23460. */
  23461. canIntersects(ray: Ray): boolean;
  23462. /**
  23463. * Intersects current submesh with a ray
  23464. * @param ray defines the ray to test
  23465. * @param positions defines mesh's positions array
  23466. * @param indices defines mesh's indices array
  23467. * @param fastCheck defines if only bounding info should be used
  23468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23469. * @returns intersection info or null if no intersection
  23470. */
  23471. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23472. /** @hidden */
  23473. private _intersectLines;
  23474. /** @hidden */
  23475. private _intersectUnIndexedLines;
  23476. /** @hidden */
  23477. private _intersectTriangles;
  23478. /** @hidden */
  23479. private _intersectUnIndexedTriangles;
  23480. /** @hidden */
  23481. _rebuild(): void;
  23482. /**
  23483. * Creates a new submesh from the passed mesh
  23484. * @param newMesh defines the new hosting mesh
  23485. * @param newRenderingMesh defines an optional rendering mesh
  23486. * @returns the new submesh
  23487. */
  23488. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23489. /**
  23490. * Release associated resources
  23491. */
  23492. dispose(): void;
  23493. /**
  23494. * Gets the class name
  23495. * @returns the string "SubMesh".
  23496. */
  23497. getClassName(): string;
  23498. /**
  23499. * Creates a new submesh from indices data
  23500. * @param materialIndex the index of the main mesh material
  23501. * @param startIndex the index where to start the copy in the mesh indices array
  23502. * @param indexCount the number of indices to copy then from the startIndex
  23503. * @param mesh the main mesh to create the submesh from
  23504. * @param renderingMesh the optional rendering mesh
  23505. * @returns a new submesh
  23506. */
  23507. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23508. }
  23509. }
  23510. declare module "babylonjs/Meshes/geometry" {
  23511. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23512. import { Scene } from "babylonjs/scene";
  23513. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23514. import { Engine } from "babylonjs/Engines/engine";
  23515. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23516. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23517. import { Effect } from "babylonjs/Materials/effect";
  23518. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23519. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23520. import { Mesh } from "babylonjs/Meshes/mesh";
  23521. /**
  23522. * Class used to store geometry data (vertex buffers + index buffer)
  23523. */
  23524. export class Geometry implements IGetSetVerticesData {
  23525. /**
  23526. * Gets or sets the ID of the geometry
  23527. */
  23528. id: string;
  23529. /**
  23530. * Gets or sets the unique ID of the geometry
  23531. */
  23532. uniqueId: number;
  23533. /**
  23534. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23535. */
  23536. delayLoadState: number;
  23537. /**
  23538. * Gets the file containing the data to load when running in delay load state
  23539. */
  23540. delayLoadingFile: Nullable<string>;
  23541. /**
  23542. * Callback called when the geometry is updated
  23543. */
  23544. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23545. private _scene;
  23546. private _engine;
  23547. private _meshes;
  23548. private _totalVertices;
  23549. /** @hidden */
  23550. _indices: IndicesArray;
  23551. /** @hidden */
  23552. _vertexBuffers: {
  23553. [key: string]: VertexBuffer;
  23554. };
  23555. private _isDisposed;
  23556. private _extend;
  23557. private _boundingBias;
  23558. /** @hidden */
  23559. _delayInfo: Array<string>;
  23560. private _indexBuffer;
  23561. private _indexBufferIsUpdatable;
  23562. /** @hidden */
  23563. _boundingInfo: Nullable<BoundingInfo>;
  23564. /** @hidden */
  23565. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23566. /** @hidden */
  23567. _softwareSkinningFrameId: number;
  23568. private _vertexArrayObjects;
  23569. private _updatable;
  23570. /** @hidden */
  23571. _positions: Nullable<Vector3[]>;
  23572. /**
  23573. * 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
  23574. */
  23575. /**
  23576. * 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
  23577. */
  23578. boundingBias: Vector2;
  23579. /**
  23580. * Static function used to attach a new empty geometry to a mesh
  23581. * @param mesh defines the mesh to attach the geometry to
  23582. * @returns the new Geometry
  23583. */
  23584. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23585. /**
  23586. * Creates a new geometry
  23587. * @param id defines the unique ID
  23588. * @param scene defines the hosting scene
  23589. * @param vertexData defines the VertexData used to get geometry data
  23590. * @param updatable defines if geometry must be updatable (false by default)
  23591. * @param mesh defines the mesh that will be associated with the geometry
  23592. */
  23593. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23594. /**
  23595. * Gets the current extend of the geometry
  23596. */
  23597. readonly extend: {
  23598. minimum: Vector3;
  23599. maximum: Vector3;
  23600. };
  23601. /**
  23602. * Gets the hosting scene
  23603. * @returns the hosting Scene
  23604. */
  23605. getScene(): Scene;
  23606. /**
  23607. * Gets the hosting engine
  23608. * @returns the hosting Engine
  23609. */
  23610. getEngine(): Engine;
  23611. /**
  23612. * Defines if the geometry is ready to use
  23613. * @returns true if the geometry is ready to be used
  23614. */
  23615. isReady(): boolean;
  23616. /**
  23617. * Gets a value indicating that the geometry should not be serialized
  23618. */
  23619. readonly doNotSerialize: boolean;
  23620. /** @hidden */
  23621. _rebuild(): void;
  23622. /**
  23623. * Affects all geometry data in one call
  23624. * @param vertexData defines the geometry data
  23625. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23626. */
  23627. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23628. /**
  23629. * Set specific vertex data
  23630. * @param kind defines the data kind (Position, normal, etc...)
  23631. * @param data defines the vertex data to use
  23632. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23633. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23634. */
  23635. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23636. /**
  23637. * Removes a specific vertex data
  23638. * @param kind defines the data kind (Position, normal, etc...)
  23639. */
  23640. removeVerticesData(kind: string): void;
  23641. /**
  23642. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23643. * @param buffer defines the vertex buffer to use
  23644. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23645. */
  23646. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23647. /**
  23648. * Update a specific vertex buffer
  23649. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23650. * It will do nothing if the buffer is not updatable
  23651. * @param kind defines the data kind (Position, normal, etc...)
  23652. * @param data defines the data to use
  23653. * @param offset defines the offset in the target buffer where to store the data
  23654. * @param useBytes set to true if the offset is in bytes
  23655. */
  23656. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23657. /**
  23658. * Update a specific vertex buffer
  23659. * This function will create a new buffer if the current one is not updatable
  23660. * @param kind defines the data kind (Position, normal, etc...)
  23661. * @param data defines the data to use
  23662. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23663. */
  23664. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23665. private _updateBoundingInfo;
  23666. /** @hidden */
  23667. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23668. /**
  23669. * Gets total number of vertices
  23670. * @returns the total number of vertices
  23671. */
  23672. getTotalVertices(): number;
  23673. /**
  23674. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23675. * @param kind defines the data kind (Position, normal, etc...)
  23676. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23677. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23678. * @returns a float array containing vertex data
  23679. */
  23680. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23681. /**
  23682. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23683. * @param kind defines the data kind (Position, normal, etc...)
  23684. * @returns true if the vertex buffer with the specified kind is updatable
  23685. */
  23686. isVertexBufferUpdatable(kind: string): boolean;
  23687. /**
  23688. * Gets a specific vertex buffer
  23689. * @param kind defines the data kind (Position, normal, etc...)
  23690. * @returns a VertexBuffer
  23691. */
  23692. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23693. /**
  23694. * Returns all vertex buffers
  23695. * @return an object holding all vertex buffers indexed by kind
  23696. */
  23697. getVertexBuffers(): Nullable<{
  23698. [key: string]: VertexBuffer;
  23699. }>;
  23700. /**
  23701. * Gets a boolean indicating if specific vertex buffer is present
  23702. * @param kind defines the data kind (Position, normal, etc...)
  23703. * @returns true if data is present
  23704. */
  23705. isVerticesDataPresent(kind: string): boolean;
  23706. /**
  23707. * Gets a list of all attached data kinds (Position, normal, etc...)
  23708. * @returns a list of string containing all kinds
  23709. */
  23710. getVerticesDataKinds(): string[];
  23711. /**
  23712. * Update index buffer
  23713. * @param indices defines the indices to store in the index buffer
  23714. * @param offset defines the offset in the target buffer where to store the data
  23715. * @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)
  23716. */
  23717. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23718. /**
  23719. * Creates a new index buffer
  23720. * @param indices defines the indices to store in the index buffer
  23721. * @param totalVertices defines the total number of vertices (could be null)
  23722. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23723. */
  23724. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23725. /**
  23726. * Return the total number of indices
  23727. * @returns the total number of indices
  23728. */
  23729. getTotalIndices(): number;
  23730. /**
  23731. * Gets the index buffer array
  23732. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23733. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23734. * @returns the index buffer array
  23735. */
  23736. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23737. /**
  23738. * Gets the index buffer
  23739. * @return the index buffer
  23740. */
  23741. getIndexBuffer(): Nullable<DataBuffer>;
  23742. /** @hidden */
  23743. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23744. /**
  23745. * Release the associated resources for a specific mesh
  23746. * @param mesh defines the source mesh
  23747. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23748. */
  23749. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23750. /**
  23751. * Apply current geometry to a given mesh
  23752. * @param mesh defines the mesh to apply geometry to
  23753. */
  23754. applyToMesh(mesh: Mesh): void;
  23755. private _updateExtend;
  23756. private _applyToMesh;
  23757. private notifyUpdate;
  23758. /**
  23759. * Load the geometry if it was flagged as delay loaded
  23760. * @param scene defines the hosting scene
  23761. * @param onLoaded defines a callback called when the geometry is loaded
  23762. */
  23763. load(scene: Scene, onLoaded?: () => void): void;
  23764. private _queueLoad;
  23765. /**
  23766. * Invert the geometry to move from a right handed system to a left handed one.
  23767. */
  23768. toLeftHanded(): void;
  23769. /** @hidden */
  23770. _resetPointsArrayCache(): void;
  23771. /** @hidden */
  23772. _generatePointsArray(): boolean;
  23773. /**
  23774. * Gets a value indicating if the geometry is disposed
  23775. * @returns true if the geometry was disposed
  23776. */
  23777. isDisposed(): boolean;
  23778. private _disposeVertexArrayObjects;
  23779. /**
  23780. * Free all associated resources
  23781. */
  23782. dispose(): void;
  23783. /**
  23784. * Clone the current geometry into a new geometry
  23785. * @param id defines the unique ID of the new geometry
  23786. * @returns a new geometry object
  23787. */
  23788. copy(id: string): Geometry;
  23789. /**
  23790. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23791. * @return a JSON representation of the current geometry data (without the vertices data)
  23792. */
  23793. serialize(): any;
  23794. private toNumberArray;
  23795. /**
  23796. * Serialize all vertices data into a JSON oject
  23797. * @returns a JSON representation of the current geometry data
  23798. */
  23799. serializeVerticeData(): any;
  23800. /**
  23801. * Extracts a clone of a mesh geometry
  23802. * @param mesh defines the source mesh
  23803. * @param id defines the unique ID of the new geometry object
  23804. * @returns the new geometry object
  23805. */
  23806. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23807. /**
  23808. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23809. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23810. * Be aware Math.random() could cause collisions, but:
  23811. * "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"
  23812. * @returns a string containing a new GUID
  23813. */
  23814. static RandomId(): string;
  23815. /** @hidden */
  23816. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23817. private static _CleanMatricesWeights;
  23818. /**
  23819. * Create a new geometry from persisted data (Using .babylon file format)
  23820. * @param parsedVertexData defines the persisted data
  23821. * @param scene defines the hosting scene
  23822. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23823. * @returns the new geometry object
  23824. */
  23825. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23826. }
  23827. }
  23828. declare module "babylonjs/Meshes/mesh.vertexData" {
  23829. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23830. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23831. import { Geometry } from "babylonjs/Meshes/geometry";
  23832. import { Mesh } from "babylonjs/Meshes/mesh";
  23833. /**
  23834. * Define an interface for all classes that will get and set the data on vertices
  23835. */
  23836. export interface IGetSetVerticesData {
  23837. /**
  23838. * Gets a boolean indicating if specific vertex data is present
  23839. * @param kind defines the vertex data kind to use
  23840. * @returns true is data kind is present
  23841. */
  23842. isVerticesDataPresent(kind: string): boolean;
  23843. /**
  23844. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23845. * @param kind defines the data kind (Position, normal, etc...)
  23846. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23847. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23848. * @returns a float array containing vertex data
  23849. */
  23850. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23851. /**
  23852. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23853. * @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.
  23854. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23855. * @returns the indices array or an empty array if the mesh has no geometry
  23856. */
  23857. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23858. /**
  23859. * Set specific vertex data
  23860. * @param kind defines the data kind (Position, normal, etc...)
  23861. * @param data defines the vertex data to use
  23862. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23863. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23864. */
  23865. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23866. /**
  23867. * Update a specific associated vertex buffer
  23868. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23869. * - VertexBuffer.PositionKind
  23870. * - VertexBuffer.UVKind
  23871. * - VertexBuffer.UV2Kind
  23872. * - VertexBuffer.UV3Kind
  23873. * - VertexBuffer.UV4Kind
  23874. * - VertexBuffer.UV5Kind
  23875. * - VertexBuffer.UV6Kind
  23876. * - VertexBuffer.ColorKind
  23877. * - VertexBuffer.MatricesIndicesKind
  23878. * - VertexBuffer.MatricesIndicesExtraKind
  23879. * - VertexBuffer.MatricesWeightsKind
  23880. * - VertexBuffer.MatricesWeightsExtraKind
  23881. * @param data defines the data source
  23882. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23883. * @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)
  23884. */
  23885. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23886. /**
  23887. * Creates a new index buffer
  23888. * @param indices defines the indices to store in the index buffer
  23889. * @param totalVertices defines the total number of vertices (could be null)
  23890. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23891. */
  23892. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23893. }
  23894. /**
  23895. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23896. */
  23897. export class VertexData {
  23898. /**
  23899. * Mesh side orientation : usually the external or front surface
  23900. */
  23901. static readonly FRONTSIDE: number;
  23902. /**
  23903. * Mesh side orientation : usually the internal or back surface
  23904. */
  23905. static readonly BACKSIDE: number;
  23906. /**
  23907. * Mesh side orientation : both internal and external or front and back surfaces
  23908. */
  23909. static readonly DOUBLESIDE: number;
  23910. /**
  23911. * Mesh side orientation : by default, `FRONTSIDE`
  23912. */
  23913. static readonly DEFAULTSIDE: number;
  23914. /**
  23915. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23916. */
  23917. positions: Nullable<FloatArray>;
  23918. /**
  23919. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23920. */
  23921. normals: Nullable<FloatArray>;
  23922. /**
  23923. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23924. */
  23925. tangents: Nullable<FloatArray>;
  23926. /**
  23927. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23928. */
  23929. uvs: Nullable<FloatArray>;
  23930. /**
  23931. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23932. */
  23933. uvs2: Nullable<FloatArray>;
  23934. /**
  23935. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23936. */
  23937. uvs3: Nullable<FloatArray>;
  23938. /**
  23939. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23940. */
  23941. uvs4: Nullable<FloatArray>;
  23942. /**
  23943. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23944. */
  23945. uvs5: Nullable<FloatArray>;
  23946. /**
  23947. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23948. */
  23949. uvs6: Nullable<FloatArray>;
  23950. /**
  23951. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23952. */
  23953. colors: Nullable<FloatArray>;
  23954. /**
  23955. * 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).
  23956. */
  23957. matricesIndices: Nullable<FloatArray>;
  23958. /**
  23959. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23960. */
  23961. matricesWeights: Nullable<FloatArray>;
  23962. /**
  23963. * An array extending the number of possible indices
  23964. */
  23965. matricesIndicesExtra: Nullable<FloatArray>;
  23966. /**
  23967. * An array extending the number of possible weights when the number of indices is extended
  23968. */
  23969. matricesWeightsExtra: Nullable<FloatArray>;
  23970. /**
  23971. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23972. */
  23973. indices: Nullable<IndicesArray>;
  23974. /**
  23975. * Uses the passed data array to set the set the values for the specified kind of data
  23976. * @param data a linear array of floating numbers
  23977. * @param kind the type of data that is being set, eg positions, colors etc
  23978. */
  23979. set(data: FloatArray, kind: string): void;
  23980. /**
  23981. * Associates the vertexData to the passed Mesh.
  23982. * Sets it as updatable or not (default `false`)
  23983. * @param mesh the mesh the vertexData is applied to
  23984. * @param updatable when used and having the value true allows new data to update the vertexData
  23985. * @returns the VertexData
  23986. */
  23987. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23988. /**
  23989. * Associates the vertexData to the passed Geometry.
  23990. * Sets it as updatable or not (default `false`)
  23991. * @param geometry the geometry the vertexData is applied to
  23992. * @param updatable when used and having the value true allows new data to update the vertexData
  23993. * @returns VertexData
  23994. */
  23995. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23996. /**
  23997. * Updates the associated mesh
  23998. * @param mesh the mesh to be updated
  23999. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24000. * @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
  24001. * @returns VertexData
  24002. */
  24003. updateMesh(mesh: Mesh): VertexData;
  24004. /**
  24005. * Updates the associated geometry
  24006. * @param geometry the geometry to be updated
  24007. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24008. * @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
  24009. * @returns VertexData.
  24010. */
  24011. updateGeometry(geometry: Geometry): VertexData;
  24012. private _applyTo;
  24013. private _update;
  24014. /**
  24015. * Transforms each position and each normal of the vertexData according to the passed Matrix
  24016. * @param matrix the transforming matrix
  24017. * @returns the VertexData
  24018. */
  24019. transform(matrix: Matrix): VertexData;
  24020. /**
  24021. * Merges the passed VertexData into the current one
  24022. * @param other the VertexData to be merged into the current one
  24023. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  24024. * @returns the modified VertexData
  24025. */
  24026. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  24027. private _mergeElement;
  24028. private _validate;
  24029. /**
  24030. * Serializes the VertexData
  24031. * @returns a serialized object
  24032. */
  24033. serialize(): any;
  24034. /**
  24035. * Extracts the vertexData from a mesh
  24036. * @param mesh the mesh from which to extract the VertexData
  24037. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  24038. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24039. * @returns the object VertexData associated to the passed mesh
  24040. */
  24041. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24042. /**
  24043. * Extracts the vertexData from the geometry
  24044. * @param geometry the geometry from which to extract the VertexData
  24045. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  24046. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24047. * @returns the object VertexData associated to the passed mesh
  24048. */
  24049. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24050. private static _ExtractFrom;
  24051. /**
  24052. * Creates the VertexData for a Ribbon
  24053. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  24054. * * pathArray array of paths, each of which an array of successive Vector3
  24055. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  24056. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  24057. * * 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
  24058. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24059. * * 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)
  24060. * * 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)
  24061. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  24062. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  24063. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  24064. * @returns the VertexData of the ribbon
  24065. */
  24066. static CreateRibbon(options: {
  24067. pathArray: Vector3[][];
  24068. closeArray?: boolean;
  24069. closePath?: boolean;
  24070. offset?: number;
  24071. sideOrientation?: number;
  24072. frontUVs?: Vector4;
  24073. backUVs?: Vector4;
  24074. invertUV?: boolean;
  24075. uvs?: Vector2[];
  24076. colors?: Color4[];
  24077. }): VertexData;
  24078. /**
  24079. * Creates the VertexData for a box
  24080. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24081. * * size sets the width, height and depth of the box to the value of size, optional default 1
  24082. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  24083. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  24084. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  24085. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24086. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24087. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24088. * * 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)
  24089. * * 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)
  24090. * @returns the VertexData of the box
  24091. */
  24092. static CreateBox(options: {
  24093. size?: number;
  24094. width?: number;
  24095. height?: number;
  24096. depth?: number;
  24097. faceUV?: Vector4[];
  24098. faceColors?: Color4[];
  24099. sideOrientation?: number;
  24100. frontUVs?: Vector4;
  24101. backUVs?: Vector4;
  24102. }): VertexData;
  24103. /**
  24104. * Creates the VertexData for a tiled box
  24105. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24106. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24107. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24108. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24109. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24110. * @returns the VertexData of the box
  24111. */
  24112. static CreateTiledBox(options: {
  24113. pattern?: number;
  24114. width?: number;
  24115. height?: number;
  24116. depth?: number;
  24117. tileSize?: number;
  24118. tileWidth?: number;
  24119. tileHeight?: number;
  24120. alignHorizontal?: number;
  24121. alignVertical?: number;
  24122. faceUV?: Vector4[];
  24123. faceColors?: Color4[];
  24124. sideOrientation?: number;
  24125. }): VertexData;
  24126. /**
  24127. * Creates the VertexData for a tiled plane
  24128. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24129. * * pattern a limited pattern arrangement depending on the number
  24130. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24131. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24132. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24133. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24134. * * 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)
  24135. * * 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)
  24136. * @returns the VertexData of the tiled plane
  24137. */
  24138. static CreateTiledPlane(options: {
  24139. pattern?: number;
  24140. tileSize?: number;
  24141. tileWidth?: number;
  24142. tileHeight?: number;
  24143. size?: number;
  24144. width?: number;
  24145. height?: number;
  24146. alignHorizontal?: number;
  24147. alignVertical?: number;
  24148. sideOrientation?: number;
  24149. frontUVs?: Vector4;
  24150. backUVs?: Vector4;
  24151. }): VertexData;
  24152. /**
  24153. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24154. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24155. * * segments sets the number of horizontal strips optional, default 32
  24156. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24157. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24158. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24159. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24160. * * 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
  24161. * * 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
  24162. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24163. * * 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)
  24164. * * 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)
  24165. * @returns the VertexData of the ellipsoid
  24166. */
  24167. static CreateSphere(options: {
  24168. segments?: number;
  24169. diameter?: number;
  24170. diameterX?: number;
  24171. diameterY?: number;
  24172. diameterZ?: number;
  24173. arc?: number;
  24174. slice?: number;
  24175. sideOrientation?: number;
  24176. frontUVs?: Vector4;
  24177. backUVs?: Vector4;
  24178. }): VertexData;
  24179. /**
  24180. * Creates the VertexData for a cylinder, cone or prism
  24181. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24182. * * height sets the height (y direction) of the cylinder, optional, default 2
  24183. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24184. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24185. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24186. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24187. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24188. * * 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
  24189. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24190. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24191. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24192. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24193. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24194. * * 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)
  24195. * * 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)
  24196. * @returns the VertexData of the cylinder, cone or prism
  24197. */
  24198. static CreateCylinder(options: {
  24199. height?: number;
  24200. diameterTop?: number;
  24201. diameterBottom?: number;
  24202. diameter?: number;
  24203. tessellation?: number;
  24204. subdivisions?: number;
  24205. arc?: number;
  24206. faceColors?: Color4[];
  24207. faceUV?: Vector4[];
  24208. hasRings?: boolean;
  24209. enclose?: boolean;
  24210. sideOrientation?: number;
  24211. frontUVs?: Vector4;
  24212. backUVs?: Vector4;
  24213. }): VertexData;
  24214. /**
  24215. * Creates the VertexData for a torus
  24216. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24217. * * diameter the diameter of the torus, optional default 1
  24218. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24219. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24221. * * 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)
  24222. * * 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)
  24223. * @returns the VertexData of the torus
  24224. */
  24225. static CreateTorus(options: {
  24226. diameter?: number;
  24227. thickness?: number;
  24228. tessellation?: number;
  24229. sideOrientation?: number;
  24230. frontUVs?: Vector4;
  24231. backUVs?: Vector4;
  24232. }): VertexData;
  24233. /**
  24234. * Creates the VertexData of the LineSystem
  24235. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24236. * - lines an array of lines, each line being an array of successive Vector3
  24237. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24238. * @returns the VertexData of the LineSystem
  24239. */
  24240. static CreateLineSystem(options: {
  24241. lines: Vector3[][];
  24242. colors?: Nullable<Color4[][]>;
  24243. }): VertexData;
  24244. /**
  24245. * Create the VertexData for a DashedLines
  24246. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24247. * - points an array successive Vector3
  24248. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24249. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24250. * - dashNb the intended total number of dashes, optional, default 200
  24251. * @returns the VertexData for the DashedLines
  24252. */
  24253. static CreateDashedLines(options: {
  24254. points: Vector3[];
  24255. dashSize?: number;
  24256. gapSize?: number;
  24257. dashNb?: number;
  24258. }): VertexData;
  24259. /**
  24260. * Creates the VertexData for a Ground
  24261. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24262. * - width the width (x direction) of the ground, optional, default 1
  24263. * - height the height (z direction) of the ground, optional, default 1
  24264. * - subdivisions the number of subdivisions per side, optional, default 1
  24265. * @returns the VertexData of the Ground
  24266. */
  24267. static CreateGround(options: {
  24268. width?: number;
  24269. height?: number;
  24270. subdivisions?: number;
  24271. subdivisionsX?: number;
  24272. subdivisionsY?: number;
  24273. }): VertexData;
  24274. /**
  24275. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24276. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24277. * * xmin the ground minimum X coordinate, optional, default -1
  24278. * * zmin the ground minimum Z coordinate, optional, default -1
  24279. * * xmax the ground maximum X coordinate, optional, default 1
  24280. * * zmax the ground maximum Z coordinate, optional, default 1
  24281. * * 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}
  24282. * * 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}
  24283. * @returns the VertexData of the TiledGround
  24284. */
  24285. static CreateTiledGround(options: {
  24286. xmin: number;
  24287. zmin: number;
  24288. xmax: number;
  24289. zmax: number;
  24290. subdivisions?: {
  24291. w: number;
  24292. h: number;
  24293. };
  24294. precision?: {
  24295. w: number;
  24296. h: number;
  24297. };
  24298. }): VertexData;
  24299. /**
  24300. * Creates the VertexData of the Ground designed from a heightmap
  24301. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24302. * * width the width (x direction) of the ground
  24303. * * height the height (z direction) of the ground
  24304. * * subdivisions the number of subdivisions per side
  24305. * * minHeight the minimum altitude on the ground, optional, default 0
  24306. * * maxHeight the maximum altitude on the ground, optional default 1
  24307. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24308. * * buffer the array holding the image color data
  24309. * * bufferWidth the width of image
  24310. * * bufferHeight the height of image
  24311. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24312. * @returns the VertexData of the Ground designed from a heightmap
  24313. */
  24314. static CreateGroundFromHeightMap(options: {
  24315. width: number;
  24316. height: number;
  24317. subdivisions: number;
  24318. minHeight: number;
  24319. maxHeight: number;
  24320. colorFilter: Color3;
  24321. buffer: Uint8Array;
  24322. bufferWidth: number;
  24323. bufferHeight: number;
  24324. alphaFilter: number;
  24325. }): VertexData;
  24326. /**
  24327. * Creates the VertexData for a Plane
  24328. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24329. * * size sets the width and height of the plane to the value of size, optional default 1
  24330. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24331. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24332. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24333. * * 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)
  24334. * * 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)
  24335. * @returns the VertexData of the box
  24336. */
  24337. static CreatePlane(options: {
  24338. size?: number;
  24339. width?: number;
  24340. height?: number;
  24341. sideOrientation?: number;
  24342. frontUVs?: Vector4;
  24343. backUVs?: Vector4;
  24344. }): VertexData;
  24345. /**
  24346. * Creates the VertexData of the Disc or regular Polygon
  24347. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24348. * * radius the radius of the disc, optional default 0.5
  24349. * * tessellation the number of polygon sides, optional, default 64
  24350. * * 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
  24351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24352. * * 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)
  24353. * * 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)
  24354. * @returns the VertexData of the box
  24355. */
  24356. static CreateDisc(options: {
  24357. radius?: number;
  24358. tessellation?: number;
  24359. arc?: number;
  24360. sideOrientation?: number;
  24361. frontUVs?: Vector4;
  24362. backUVs?: Vector4;
  24363. }): VertexData;
  24364. /**
  24365. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24366. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24367. * @param polygon a mesh built from polygonTriangulation.build()
  24368. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24369. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24370. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24371. * @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)
  24372. * @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)
  24373. * @returns the VertexData of the Polygon
  24374. */
  24375. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24376. /**
  24377. * Creates the VertexData of the IcoSphere
  24378. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24379. * * radius the radius of the IcoSphere, optional default 1
  24380. * * radiusX allows stretching in the x direction, optional, default radius
  24381. * * radiusY allows stretching in the y direction, optional, default radius
  24382. * * radiusZ allows stretching in the z direction, optional, default radius
  24383. * * flat when true creates a flat shaded mesh, optional, default true
  24384. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24385. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24386. * * 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)
  24387. * * 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)
  24388. * @returns the VertexData of the IcoSphere
  24389. */
  24390. static CreateIcoSphere(options: {
  24391. radius?: number;
  24392. radiusX?: number;
  24393. radiusY?: number;
  24394. radiusZ?: number;
  24395. flat?: boolean;
  24396. subdivisions?: number;
  24397. sideOrientation?: number;
  24398. frontUVs?: Vector4;
  24399. backUVs?: Vector4;
  24400. }): VertexData;
  24401. /**
  24402. * Creates the VertexData for a Polyhedron
  24403. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24404. * * type provided types are:
  24405. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24406. * * 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)
  24407. * * size the size of the IcoSphere, optional default 1
  24408. * * sizeX allows stretching in the x direction, optional, default size
  24409. * * sizeY allows stretching in the y direction, optional, default size
  24410. * * sizeZ allows stretching in the z direction, optional, default size
  24411. * * 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
  24412. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24413. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24414. * * flat when true creates a flat shaded mesh, optional, default true
  24415. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24416. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24417. * * 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)
  24418. * * 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)
  24419. * @returns the VertexData of the Polyhedron
  24420. */
  24421. static CreatePolyhedron(options: {
  24422. type?: number;
  24423. size?: number;
  24424. sizeX?: number;
  24425. sizeY?: number;
  24426. sizeZ?: number;
  24427. custom?: any;
  24428. faceUV?: Vector4[];
  24429. faceColors?: Color4[];
  24430. flat?: boolean;
  24431. sideOrientation?: number;
  24432. frontUVs?: Vector4;
  24433. backUVs?: Vector4;
  24434. }): VertexData;
  24435. /**
  24436. * Creates the VertexData for a TorusKnot
  24437. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24438. * * radius the radius of the torus knot, optional, default 2
  24439. * * tube the thickness of the tube, optional, default 0.5
  24440. * * radialSegments the number of sides on each tube segments, optional, default 32
  24441. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24442. * * p the number of windings around the z axis, optional, default 2
  24443. * * q the number of windings around the x axis, optional, default 3
  24444. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24445. * * 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)
  24446. * * 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)
  24447. * @returns the VertexData of the Torus Knot
  24448. */
  24449. static CreateTorusKnot(options: {
  24450. radius?: number;
  24451. tube?: number;
  24452. radialSegments?: number;
  24453. tubularSegments?: number;
  24454. p?: number;
  24455. q?: number;
  24456. sideOrientation?: number;
  24457. frontUVs?: Vector4;
  24458. backUVs?: Vector4;
  24459. }): VertexData;
  24460. /**
  24461. * Compute normals for given positions and indices
  24462. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24463. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24464. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24465. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24466. * * facetNormals : optional array of facet normals (vector3)
  24467. * * facetPositions : optional array of facet positions (vector3)
  24468. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24469. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24470. * * bInfo : optional bounding info, required for facetPartitioning computation
  24471. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24472. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24473. * * useRightHandedSystem: optional boolean to for right handed system computation
  24474. * * depthSort : optional boolean to enable the facet depth sort computation
  24475. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24476. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24477. */
  24478. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24479. facetNormals?: any;
  24480. facetPositions?: any;
  24481. facetPartitioning?: any;
  24482. ratio?: number;
  24483. bInfo?: any;
  24484. bbSize?: Vector3;
  24485. subDiv?: any;
  24486. useRightHandedSystem?: boolean;
  24487. depthSort?: boolean;
  24488. distanceTo?: Vector3;
  24489. depthSortedFacets?: any;
  24490. }): void;
  24491. /** @hidden */
  24492. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24493. /**
  24494. * Applies VertexData created from the imported parameters to the geometry
  24495. * @param parsedVertexData the parsed data from an imported file
  24496. * @param geometry the geometry to apply the VertexData to
  24497. */
  24498. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24499. }
  24500. }
  24501. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24502. import { Nullable } from "babylonjs/types";
  24503. import { Scene } from "babylonjs/scene";
  24504. import { Vector4 } from "babylonjs/Maths/math";
  24505. import { Mesh } from "babylonjs/Meshes/mesh";
  24506. /**
  24507. * Class containing static functions to help procedurally build meshes
  24508. */
  24509. export class DiscBuilder {
  24510. /**
  24511. * Creates a plane polygonal mesh. By default, this is a disc
  24512. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24513. * * 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
  24514. * * 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
  24515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24518. * @param name defines the name of the mesh
  24519. * @param options defines the options used to create the mesh
  24520. * @param scene defines the hosting scene
  24521. * @returns the plane polygonal mesh
  24522. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24523. */
  24524. static CreateDisc(name: string, options: {
  24525. radius?: number;
  24526. tessellation?: number;
  24527. arc?: number;
  24528. updatable?: boolean;
  24529. sideOrientation?: number;
  24530. frontUVs?: Vector4;
  24531. backUVs?: Vector4;
  24532. }, scene?: Nullable<Scene>): Mesh;
  24533. }
  24534. }
  24535. declare module "babylonjs/Particles/solidParticleSystem" {
  24536. import { Vector3 } from "babylonjs/Maths/math";
  24537. import { Mesh } from "babylonjs/Meshes/mesh";
  24538. import { Scene, IDisposable } from "babylonjs/scene";
  24539. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24540. /**
  24541. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24542. *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.
  24543. * The SPS is also a particle system. It provides some methods to manage the particles.
  24544. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24545. *
  24546. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24547. */
  24548. export class SolidParticleSystem implements IDisposable {
  24549. /**
  24550. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24551. * Example : var p = SPS.particles[i];
  24552. */
  24553. particles: SolidParticle[];
  24554. /**
  24555. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24556. */
  24557. nbParticles: number;
  24558. /**
  24559. * If the particles must ever face the camera (default false). Useful for planar particles.
  24560. */
  24561. billboard: boolean;
  24562. /**
  24563. * Recompute normals when adding a shape
  24564. */
  24565. recomputeNormals: boolean;
  24566. /**
  24567. * This a counter ofr your own usage. It's not set by any SPS functions.
  24568. */
  24569. counter: number;
  24570. /**
  24571. * The SPS name. This name is also given to the underlying mesh.
  24572. */
  24573. name: string;
  24574. /**
  24575. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24576. */
  24577. mesh: Mesh;
  24578. /**
  24579. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24580. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24581. */
  24582. vars: any;
  24583. /**
  24584. * This array is populated when the SPS is set as 'pickable'.
  24585. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24586. * Each element of this array is an object `{idx: int, faceId: int}`.
  24587. * `idx` is the picked particle index in the `SPS.particles` array
  24588. * `faceId` is the picked face index counted within this particle.
  24589. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24590. */
  24591. pickedParticles: {
  24592. idx: number;
  24593. faceId: number;
  24594. }[];
  24595. /**
  24596. * This array is populated when `enableDepthSort` is set to true.
  24597. * Each element of this array is an instance of the class DepthSortedParticle.
  24598. */
  24599. depthSortedParticles: DepthSortedParticle[];
  24600. /**
  24601. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24602. * @hidden
  24603. */
  24604. _bSphereOnly: boolean;
  24605. /**
  24606. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24607. * @hidden
  24608. */
  24609. _bSphereRadiusFactor: number;
  24610. private _scene;
  24611. private _positions;
  24612. private _indices;
  24613. private _normals;
  24614. private _colors;
  24615. private _uvs;
  24616. private _indices32;
  24617. private _positions32;
  24618. private _normals32;
  24619. private _fixedNormal32;
  24620. private _colors32;
  24621. private _uvs32;
  24622. private _index;
  24623. private _updatable;
  24624. private _pickable;
  24625. private _isVisibilityBoxLocked;
  24626. private _alwaysVisible;
  24627. private _depthSort;
  24628. private _shapeCounter;
  24629. private _copy;
  24630. private _color;
  24631. private _computeParticleColor;
  24632. private _computeParticleTexture;
  24633. private _computeParticleRotation;
  24634. private _computeParticleVertex;
  24635. private _computeBoundingBox;
  24636. private _depthSortParticles;
  24637. private _camera;
  24638. private _mustUnrotateFixedNormals;
  24639. private _particlesIntersect;
  24640. private _needs32Bits;
  24641. /**
  24642. * Creates a SPS (Solid Particle System) object.
  24643. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24644. * @param scene (Scene) is the scene in which the SPS is added.
  24645. * @param options defines the options of the sps e.g.
  24646. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24647. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24648. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24649. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24650. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24651. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24652. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24653. */
  24654. constructor(name: string, scene: Scene, options?: {
  24655. updatable?: boolean;
  24656. isPickable?: boolean;
  24657. enableDepthSort?: boolean;
  24658. particleIntersection?: boolean;
  24659. boundingSphereOnly?: boolean;
  24660. bSphereRadiusFactor?: number;
  24661. });
  24662. /**
  24663. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24664. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24665. * @returns the created mesh
  24666. */
  24667. buildMesh(): Mesh;
  24668. /**
  24669. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24670. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24671. * Thus the particles generated from `digest()` have their property `position` set yet.
  24672. * @param mesh ( Mesh ) is the mesh to be digested
  24673. * @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
  24674. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24675. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24676. * @returns the current SPS
  24677. */
  24678. digest(mesh: Mesh, options?: {
  24679. facetNb?: number;
  24680. number?: number;
  24681. delta?: number;
  24682. }): SolidParticleSystem;
  24683. private _unrotateFixedNormals;
  24684. private _resetCopy;
  24685. private _meshBuilder;
  24686. private _posToShape;
  24687. private _uvsToShapeUV;
  24688. private _addParticle;
  24689. /**
  24690. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24691. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24692. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24693. * @param nb (positive integer) the number of particles to be created from this model
  24694. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24695. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24696. * @returns the number of shapes in the system
  24697. */
  24698. addShape(mesh: Mesh, nb: number, options?: {
  24699. positionFunction?: any;
  24700. vertexFunction?: any;
  24701. }): number;
  24702. private _rebuildParticle;
  24703. /**
  24704. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24705. * @returns the SPS.
  24706. */
  24707. rebuildMesh(): SolidParticleSystem;
  24708. /**
  24709. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24710. * This method calls `updateParticle()` for each particle of the SPS.
  24711. * For an animated SPS, it is usually called within the render loop.
  24712. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24713. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24714. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24715. * @returns the SPS.
  24716. */
  24717. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24718. /**
  24719. * Disposes the SPS.
  24720. */
  24721. dispose(): void;
  24722. /**
  24723. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24724. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24725. * @returns the SPS.
  24726. */
  24727. refreshVisibleSize(): SolidParticleSystem;
  24728. /**
  24729. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24730. * @param size the size (float) of the visibility box
  24731. * note : this doesn't lock the SPS mesh bounding box.
  24732. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24733. */
  24734. setVisibilityBox(size: number): void;
  24735. /**
  24736. * Gets whether the SPS as always visible or not
  24737. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24738. */
  24739. /**
  24740. * Sets the SPS as always visible or not
  24741. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24742. */
  24743. isAlwaysVisible: boolean;
  24744. /**
  24745. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24746. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24747. */
  24748. /**
  24749. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24750. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24751. */
  24752. isVisibilityBoxLocked: boolean;
  24753. /**
  24754. * Tells to `setParticles()` to compute the particle rotations or not.
  24755. * Default value : true. The SPS is faster when it's set to false.
  24756. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24757. */
  24758. /**
  24759. * Gets if `setParticles()` computes the particle rotations or not.
  24760. * Default value : true. The SPS is faster when it's set to false.
  24761. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24762. */
  24763. computeParticleRotation: boolean;
  24764. /**
  24765. * Tells to `setParticles()` to compute the particle colors or not.
  24766. * Default value : true. The SPS is faster when it's set to false.
  24767. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24768. */
  24769. /**
  24770. * Gets if `setParticles()` computes the particle colors or not.
  24771. * Default value : true. The SPS is faster when it's set to false.
  24772. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24773. */
  24774. computeParticleColor: boolean;
  24775. /**
  24776. * Gets if `setParticles()` computes the particle textures or not.
  24777. * Default value : true. The SPS is faster when it's set to false.
  24778. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24779. */
  24780. computeParticleTexture: boolean;
  24781. /**
  24782. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24783. * Default value : false. The SPS is faster when it's set to false.
  24784. * Note : the particle custom vertex positions aren't stored values.
  24785. */
  24786. /**
  24787. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24788. * Default value : false. The SPS is faster when it's set to false.
  24789. * Note : the particle custom vertex positions aren't stored values.
  24790. */
  24791. computeParticleVertex: boolean;
  24792. /**
  24793. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24794. */
  24795. /**
  24796. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24797. */
  24798. computeBoundingBox: boolean;
  24799. /**
  24800. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24801. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24802. * Default : `true`
  24803. */
  24804. /**
  24805. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24806. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24807. * Default : `true`
  24808. */
  24809. depthSortParticles: boolean;
  24810. /**
  24811. * This function does nothing. It may be overwritten to set all the particle first values.
  24812. * The SPS doesn't call this function, you may have to call it by your own.
  24813. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24814. */
  24815. initParticles(): void;
  24816. /**
  24817. * This function does nothing. It may be overwritten to recycle a particle.
  24818. * The SPS doesn't call this function, you may have to call it by your own.
  24819. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24820. * @param particle The particle to recycle
  24821. * @returns the recycled particle
  24822. */
  24823. recycleParticle(particle: SolidParticle): SolidParticle;
  24824. /**
  24825. * Updates a particle : this function should be overwritten by the user.
  24826. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24827. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24828. * @example : just set a particle position or velocity and recycle conditions
  24829. * @param particle The particle to update
  24830. * @returns the updated particle
  24831. */
  24832. updateParticle(particle: SolidParticle): SolidParticle;
  24833. /**
  24834. * Updates a vertex of a particle : it can be overwritten by the user.
  24835. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24836. * @param particle the current particle
  24837. * @param vertex the current index of the current particle
  24838. * @param pt the index of the current vertex in the particle shape
  24839. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24840. * @example : just set a vertex particle position
  24841. * @returns the updated vertex
  24842. */
  24843. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24844. /**
  24845. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24846. * This does nothing and may be overwritten by the user.
  24847. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24848. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24849. * @param update the boolean update value actually passed to setParticles()
  24850. */
  24851. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24852. /**
  24853. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24854. * This will be passed three parameters.
  24855. * This does nothing and may be overwritten by the user.
  24856. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24857. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24858. * @param update the boolean update value actually passed to setParticles()
  24859. */
  24860. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24861. }
  24862. }
  24863. declare module "babylonjs/Particles/solidParticle" {
  24864. import { Nullable } from "babylonjs/types";
  24865. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24866. import { Mesh } from "babylonjs/Meshes/mesh";
  24867. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24868. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24869. /**
  24870. * Represents one particle of a solid particle system.
  24871. */
  24872. export class SolidParticle {
  24873. /**
  24874. * particle global index
  24875. */
  24876. idx: number;
  24877. /**
  24878. * The color of the particle
  24879. */
  24880. color: Nullable<Color4>;
  24881. /**
  24882. * The world space position of the particle.
  24883. */
  24884. position: Vector3;
  24885. /**
  24886. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24887. */
  24888. rotation: Vector3;
  24889. /**
  24890. * The world space rotation quaternion of the particle.
  24891. */
  24892. rotationQuaternion: Nullable<Quaternion>;
  24893. /**
  24894. * The scaling of the particle.
  24895. */
  24896. scaling: Vector3;
  24897. /**
  24898. * The uvs of the particle.
  24899. */
  24900. uvs: Vector4;
  24901. /**
  24902. * The current speed of the particle.
  24903. */
  24904. velocity: Vector3;
  24905. /**
  24906. * The pivot point in the particle local space.
  24907. */
  24908. pivot: Vector3;
  24909. /**
  24910. * Must the particle be translated from its pivot point in its local space ?
  24911. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24912. * Default : false
  24913. */
  24914. translateFromPivot: boolean;
  24915. /**
  24916. * Is the particle active or not ?
  24917. */
  24918. alive: boolean;
  24919. /**
  24920. * Is the particle visible or not ?
  24921. */
  24922. isVisible: boolean;
  24923. /**
  24924. * Index of this particle in the global "positions" array (Internal use)
  24925. * @hidden
  24926. */
  24927. _pos: number;
  24928. /**
  24929. * @hidden Index of this particle in the global "indices" array (Internal use)
  24930. */
  24931. _ind: number;
  24932. /**
  24933. * @hidden ModelShape of this particle (Internal use)
  24934. */
  24935. _model: ModelShape;
  24936. /**
  24937. * ModelShape id of this particle
  24938. */
  24939. shapeId: number;
  24940. /**
  24941. * Index of the particle in its shape id (Internal use)
  24942. */
  24943. idxInShape: number;
  24944. /**
  24945. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24946. */
  24947. _modelBoundingInfo: BoundingInfo;
  24948. /**
  24949. * @hidden Particle BoundingInfo object (Internal use)
  24950. */
  24951. _boundingInfo: BoundingInfo;
  24952. /**
  24953. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24954. */
  24955. _sps: SolidParticleSystem;
  24956. /**
  24957. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24958. */
  24959. _stillInvisible: boolean;
  24960. /**
  24961. * @hidden Last computed particle rotation matrix
  24962. */
  24963. _rotationMatrix: number[];
  24964. /**
  24965. * Parent particle Id, if any.
  24966. * Default null.
  24967. */
  24968. parentId: Nullable<number>;
  24969. /**
  24970. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24971. * The possible values are :
  24972. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24973. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24974. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24975. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24976. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24977. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24978. * */
  24979. cullingStrategy: number;
  24980. /**
  24981. * @hidden Internal global position in the SPS.
  24982. */
  24983. _globalPosition: Vector3;
  24984. /**
  24985. * Creates a Solid Particle object.
  24986. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24987. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24988. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24989. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24990. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24991. * @param shapeId (integer) is the model shape identifier in the SPS.
  24992. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24993. * @param sps defines the sps it is associated to
  24994. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24995. */
  24996. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24997. /**
  24998. * Legacy support, changed scale to scaling
  24999. */
  25000. /**
  25001. * Legacy support, changed scale to scaling
  25002. */
  25003. scale: Vector3;
  25004. /**
  25005. * Legacy support, changed quaternion to rotationQuaternion
  25006. */
  25007. /**
  25008. * Legacy support, changed quaternion to rotationQuaternion
  25009. */
  25010. quaternion: Nullable<Quaternion>;
  25011. /**
  25012. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25013. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25014. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25015. * @returns true if it intersects
  25016. */
  25017. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25018. /**
  25019. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25020. * A particle is in the frustum if its bounding box intersects the frustum
  25021. * @param frustumPlanes defines the frustum to test
  25022. * @returns true if the particle is in the frustum planes
  25023. */
  25024. isInFrustum(frustumPlanes: Plane[]): boolean;
  25025. /**
  25026. * get the rotation matrix of the particle
  25027. * @hidden
  25028. */
  25029. getRotationMatrix(m: Matrix): void;
  25030. }
  25031. /**
  25032. * Represents the shape of the model used by one particle of a solid particle system.
  25033. * SPS internal tool, don't use it manually.
  25034. */
  25035. export class ModelShape {
  25036. /**
  25037. * The shape id
  25038. * @hidden
  25039. */
  25040. shapeID: number;
  25041. /**
  25042. * flat array of model positions (internal use)
  25043. * @hidden
  25044. */
  25045. _shape: Vector3[];
  25046. /**
  25047. * flat array of model UVs (internal use)
  25048. * @hidden
  25049. */
  25050. _shapeUV: number[];
  25051. /**
  25052. * length of the shape in the model indices array (internal use)
  25053. * @hidden
  25054. */
  25055. _indicesLength: number;
  25056. /**
  25057. * Custom position function (internal use)
  25058. * @hidden
  25059. */
  25060. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25061. /**
  25062. * Custom vertex function (internal use)
  25063. * @hidden
  25064. */
  25065. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25066. /**
  25067. * 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.
  25068. * SPS internal tool, don't use it manually.
  25069. * @hidden
  25070. */
  25071. 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>);
  25072. }
  25073. /**
  25074. * Represents a Depth Sorted Particle in the solid particle system.
  25075. */
  25076. export class DepthSortedParticle {
  25077. /**
  25078. * Index of the particle in the "indices" array
  25079. */
  25080. ind: number;
  25081. /**
  25082. * Length of the particle shape in the "indices" array
  25083. */
  25084. indicesLength: number;
  25085. /**
  25086. * Squared distance from the particle to the camera
  25087. */
  25088. sqDistance: number;
  25089. }
  25090. }
  25091. declare module "babylonjs/Collisions/meshCollisionData" {
  25092. import { Collider } from "babylonjs/Collisions/collider";
  25093. import { Vector3 } from "babylonjs/Maths/math";
  25094. import { Nullable } from "babylonjs/types";
  25095. import { Observer } from "babylonjs/Misc/observable";
  25096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25097. /**
  25098. * @hidden
  25099. */
  25100. export class _MeshCollisionData {
  25101. _checkCollisions: boolean;
  25102. _collisionMask: number;
  25103. _collisionGroup: number;
  25104. _collider: Nullable<Collider>;
  25105. _oldPositionForCollisions: Vector3;
  25106. _diffPositionForCollisions: Vector3;
  25107. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25108. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25109. }
  25110. }
  25111. declare module "babylonjs/Meshes/abstractMesh" {
  25112. import { Observable } from "babylonjs/Misc/observable";
  25113. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25114. import { Camera } from "babylonjs/Cameras/camera";
  25115. import { Scene, IDisposable } from "babylonjs/scene";
  25116. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25117. import { Node } from "babylonjs/node";
  25118. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25119. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25120. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25121. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25122. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25123. import { Material } from "babylonjs/Materials/material";
  25124. import { Light } from "babylonjs/Lights/light";
  25125. import { Skeleton } from "babylonjs/Bones/skeleton";
  25126. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25127. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25128. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25129. import { Ray } from "babylonjs/Culling/ray";
  25130. import { Collider } from "babylonjs/Collisions/collider";
  25131. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25132. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25133. /** @hidden */
  25134. class _FacetDataStorage {
  25135. facetPositions: Vector3[];
  25136. facetNormals: Vector3[];
  25137. facetPartitioning: number[][];
  25138. facetNb: number;
  25139. partitioningSubdivisions: number;
  25140. partitioningBBoxRatio: number;
  25141. facetDataEnabled: boolean;
  25142. facetParameters: any;
  25143. bbSize: Vector3;
  25144. subDiv: {
  25145. max: number;
  25146. X: number;
  25147. Y: number;
  25148. Z: number;
  25149. };
  25150. facetDepthSort: boolean;
  25151. facetDepthSortEnabled: boolean;
  25152. depthSortedIndices: IndicesArray;
  25153. depthSortedFacets: {
  25154. ind: number;
  25155. sqDistance: number;
  25156. }[];
  25157. facetDepthSortFunction: (f1: {
  25158. ind: number;
  25159. sqDistance: number;
  25160. }, f2: {
  25161. ind: number;
  25162. sqDistance: number;
  25163. }) => number;
  25164. facetDepthSortFrom: Vector3;
  25165. facetDepthSortOrigin: Vector3;
  25166. invertedMatrix: Matrix;
  25167. }
  25168. /**
  25169. * @hidden
  25170. **/
  25171. class _InternalAbstractMeshDataInfo {
  25172. _hasVertexAlpha: boolean;
  25173. _useVertexColors: boolean;
  25174. _numBoneInfluencers: number;
  25175. _applyFog: boolean;
  25176. _receiveShadows: boolean;
  25177. _facetData: _FacetDataStorage;
  25178. _visibility: number;
  25179. _skeleton: Nullable<Skeleton>;
  25180. _layerMask: number;
  25181. _computeBonesUsingShaders: boolean;
  25182. _isActive: boolean;
  25183. _onlyForInstances: boolean;
  25184. _isActiveIntermediate: boolean;
  25185. _onlyForInstancesIntermediate: boolean;
  25186. }
  25187. /**
  25188. * Class used to store all common mesh properties
  25189. */
  25190. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25191. /** No occlusion */
  25192. static OCCLUSION_TYPE_NONE: number;
  25193. /** Occlusion set to optimisitic */
  25194. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25195. /** Occlusion set to strict */
  25196. static OCCLUSION_TYPE_STRICT: number;
  25197. /** Use an accurante occlusion algorithm */
  25198. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25199. /** Use a conservative occlusion algorithm */
  25200. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25201. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25202. * Test order :
  25203. * Is the bounding sphere outside the frustum ?
  25204. * If not, are the bounding box vertices outside the frustum ?
  25205. * It not, then the cullable object is in the frustum.
  25206. */
  25207. static readonly CULLINGSTRATEGY_STANDARD: number;
  25208. /** Culling strategy : Bounding Sphere Only.
  25209. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25210. * It's also less accurate than the standard because some not visible objects can still be selected.
  25211. * Test : is the bounding sphere outside the frustum ?
  25212. * If not, then the cullable object is in the frustum.
  25213. */
  25214. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25215. /** Culling strategy : Optimistic Inclusion.
  25216. * This in an inclusion test first, then the standard exclusion test.
  25217. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25218. * 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.
  25219. * Anyway, it's as accurate as the standard strategy.
  25220. * Test :
  25221. * Is the cullable object bounding sphere center in the frustum ?
  25222. * If not, apply the default culling strategy.
  25223. */
  25224. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25225. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25226. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25227. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25228. * 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.
  25229. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25230. * Test :
  25231. * Is the cullable object bounding sphere center in the frustum ?
  25232. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25233. */
  25234. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25235. /**
  25236. * No billboard
  25237. */
  25238. static readonly BILLBOARDMODE_NONE: number;
  25239. /** Billboard on X axis */
  25240. static readonly BILLBOARDMODE_X: number;
  25241. /** Billboard on Y axis */
  25242. static readonly BILLBOARDMODE_Y: number;
  25243. /** Billboard on Z axis */
  25244. static readonly BILLBOARDMODE_Z: number;
  25245. /** Billboard on all axes */
  25246. static readonly BILLBOARDMODE_ALL: number;
  25247. /** @hidden */
  25248. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25249. /**
  25250. * The culling strategy to use to check whether the mesh must be rendered or not.
  25251. * This value can be changed at any time and will be used on the next render mesh selection.
  25252. * The possible values are :
  25253. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25254. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25255. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25256. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25257. * Please read each static variable documentation to get details about the culling process.
  25258. * */
  25259. cullingStrategy: number;
  25260. /**
  25261. * Gets the number of facets in the mesh
  25262. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25263. */
  25264. readonly facetNb: number;
  25265. /**
  25266. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25267. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25268. */
  25269. partitioningSubdivisions: number;
  25270. /**
  25271. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25272. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25273. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25274. */
  25275. partitioningBBoxRatio: number;
  25276. /**
  25277. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25278. * Works only for updatable meshes.
  25279. * Doesn't work with multi-materials
  25280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25281. */
  25282. mustDepthSortFacets: boolean;
  25283. /**
  25284. * The location (Vector3) where the facet depth sort must be computed from.
  25285. * By default, the active camera position.
  25286. * Used only when facet depth sort is enabled
  25287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25288. */
  25289. facetDepthSortFrom: Vector3;
  25290. /**
  25291. * gets a boolean indicating if facetData is enabled
  25292. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25293. */
  25294. readonly isFacetDataEnabled: boolean;
  25295. /** @hidden */
  25296. _updateNonUniformScalingState(value: boolean): boolean;
  25297. /**
  25298. * An event triggered when this mesh collides with another one
  25299. */
  25300. onCollideObservable: Observable<AbstractMesh>;
  25301. /** Set a function to call when this mesh collides with another one */
  25302. onCollide: () => void;
  25303. /**
  25304. * An event triggered when the collision's position changes
  25305. */
  25306. onCollisionPositionChangeObservable: Observable<Vector3>;
  25307. /** Set a function to call when the collision's position changes */
  25308. onCollisionPositionChange: () => void;
  25309. /**
  25310. * An event triggered when material is changed
  25311. */
  25312. onMaterialChangedObservable: Observable<AbstractMesh>;
  25313. /**
  25314. * Gets or sets the orientation for POV movement & rotation
  25315. */
  25316. definedFacingForward: boolean;
  25317. /** @hidden */
  25318. _occlusionQuery: Nullable<WebGLQuery>;
  25319. /** @hidden */
  25320. _renderingGroup: Nullable<RenderingGroup>;
  25321. /**
  25322. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25323. */
  25324. /**
  25325. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25326. */
  25327. visibility: number;
  25328. /** Gets or sets the alpha index used to sort transparent meshes
  25329. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25330. */
  25331. alphaIndex: number;
  25332. /**
  25333. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25334. */
  25335. isVisible: boolean;
  25336. /**
  25337. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25338. */
  25339. isPickable: boolean;
  25340. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25341. showSubMeshesBoundingBox: boolean;
  25342. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25343. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25344. */
  25345. isBlocker: boolean;
  25346. /**
  25347. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25348. */
  25349. enablePointerMoveEvents: boolean;
  25350. /**
  25351. * Specifies the rendering group id for this mesh (0 by default)
  25352. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25353. */
  25354. renderingGroupId: number;
  25355. private _material;
  25356. /** Gets or sets current material */
  25357. material: Nullable<Material>;
  25358. /**
  25359. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25360. * @see http://doc.babylonjs.com/babylon101/shadows
  25361. */
  25362. receiveShadows: boolean;
  25363. /** Defines color to use when rendering outline */
  25364. outlineColor: Color3;
  25365. /** Define width to use when rendering outline */
  25366. outlineWidth: number;
  25367. /** Defines color to use when rendering overlay */
  25368. overlayColor: Color3;
  25369. /** Defines alpha to use when rendering overlay */
  25370. overlayAlpha: number;
  25371. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25372. hasVertexAlpha: boolean;
  25373. /** 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) */
  25374. useVertexColors: boolean;
  25375. /**
  25376. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25377. */
  25378. computeBonesUsingShaders: boolean;
  25379. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25380. numBoneInfluencers: number;
  25381. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25382. applyFog: boolean;
  25383. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25384. useOctreeForRenderingSelection: boolean;
  25385. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25386. useOctreeForPicking: boolean;
  25387. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25388. useOctreeForCollisions: boolean;
  25389. /**
  25390. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25391. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25392. */
  25393. layerMask: number;
  25394. /**
  25395. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25396. */
  25397. alwaysSelectAsActiveMesh: boolean;
  25398. /**
  25399. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25400. */
  25401. doNotSyncBoundingInfo: boolean;
  25402. /**
  25403. * Gets or sets the current action manager
  25404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25405. */
  25406. actionManager: Nullable<AbstractActionManager>;
  25407. private _meshCollisionData;
  25408. /**
  25409. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25410. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25411. */
  25412. ellipsoid: Vector3;
  25413. /**
  25414. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25415. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25416. */
  25417. ellipsoidOffset: Vector3;
  25418. /**
  25419. * Gets or sets a collision mask used to mask collisions (default is -1).
  25420. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25421. */
  25422. collisionMask: number;
  25423. /**
  25424. * Gets or sets the current collision group mask (-1 by default).
  25425. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25426. */
  25427. collisionGroup: number;
  25428. /**
  25429. * Defines edge width used when edgesRenderer is enabled
  25430. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25431. */
  25432. edgesWidth: number;
  25433. /**
  25434. * Defines edge color used when edgesRenderer is enabled
  25435. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25436. */
  25437. edgesColor: Color4;
  25438. /** @hidden */
  25439. _edgesRenderer: Nullable<IEdgesRenderer>;
  25440. /** @hidden */
  25441. _masterMesh: Nullable<AbstractMesh>;
  25442. /** @hidden */
  25443. _boundingInfo: Nullable<BoundingInfo>;
  25444. /** @hidden */
  25445. _renderId: number;
  25446. /**
  25447. * Gets or sets the list of subMeshes
  25448. * @see http://doc.babylonjs.com/how_to/multi_materials
  25449. */
  25450. subMeshes: SubMesh[];
  25451. /** @hidden */
  25452. _intersectionsInProgress: AbstractMesh[];
  25453. /** @hidden */
  25454. _unIndexed: boolean;
  25455. /** @hidden */
  25456. _lightSources: Light[];
  25457. /** Gets the list of lights affecting that mesh */
  25458. readonly lightSources: Light[];
  25459. /** @hidden */
  25460. readonly _positions: Nullable<Vector3[]>;
  25461. /** @hidden */
  25462. _waitingData: {
  25463. lods: Nullable<any>;
  25464. actions: Nullable<any>;
  25465. freezeWorldMatrix: Nullable<boolean>;
  25466. };
  25467. /** @hidden */
  25468. _bonesTransformMatrices: Nullable<Float32Array>;
  25469. /**
  25470. * Gets or sets a skeleton to apply skining transformations
  25471. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25472. */
  25473. skeleton: Nullable<Skeleton>;
  25474. /**
  25475. * An event triggered when the mesh is rebuilt.
  25476. */
  25477. onRebuildObservable: Observable<AbstractMesh>;
  25478. /**
  25479. * Creates a new AbstractMesh
  25480. * @param name defines the name of the mesh
  25481. * @param scene defines the hosting scene
  25482. */
  25483. constructor(name: string, scene?: Nullable<Scene>);
  25484. /**
  25485. * Returns the string "AbstractMesh"
  25486. * @returns "AbstractMesh"
  25487. */
  25488. getClassName(): string;
  25489. /**
  25490. * Gets a string representation of the current mesh
  25491. * @param fullDetails defines a boolean indicating if full details must be included
  25492. * @returns a string representation of the current mesh
  25493. */
  25494. toString(fullDetails?: boolean): string;
  25495. /**
  25496. * @hidden
  25497. */
  25498. protected _getEffectiveParent(): Nullable<Node>;
  25499. /** @hidden */
  25500. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25501. /** @hidden */
  25502. _rebuild(): void;
  25503. /** @hidden */
  25504. _resyncLightSources(): void;
  25505. /** @hidden */
  25506. _resyncLighSource(light: Light): void;
  25507. /** @hidden */
  25508. _unBindEffect(): void;
  25509. /** @hidden */
  25510. _removeLightSource(light: Light): void;
  25511. private _markSubMeshesAsDirty;
  25512. /** @hidden */
  25513. _markSubMeshesAsLightDirty(): void;
  25514. /** @hidden */
  25515. _markSubMeshesAsAttributesDirty(): void;
  25516. /** @hidden */
  25517. _markSubMeshesAsMiscDirty(): void;
  25518. /**
  25519. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25520. */
  25521. scaling: Vector3;
  25522. /**
  25523. * Returns true if the mesh is blocked. Implemented by child classes
  25524. */
  25525. readonly isBlocked: boolean;
  25526. /**
  25527. * Returns the mesh itself by default. Implemented by child classes
  25528. * @param camera defines the camera to use to pick the right LOD level
  25529. * @returns the currentAbstractMesh
  25530. */
  25531. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25532. /**
  25533. * Returns 0 by default. Implemented by child classes
  25534. * @returns an integer
  25535. */
  25536. getTotalVertices(): number;
  25537. /**
  25538. * Returns a positive integer : the total number of indices in this mesh geometry.
  25539. * @returns the numner of indices or zero if the mesh has no geometry.
  25540. */
  25541. getTotalIndices(): number;
  25542. /**
  25543. * Returns null by default. Implemented by child classes
  25544. * @returns null
  25545. */
  25546. getIndices(): Nullable<IndicesArray>;
  25547. /**
  25548. * Returns the array of the requested vertex data kind. Implemented by child classes
  25549. * @param kind defines the vertex data kind to use
  25550. * @returns null
  25551. */
  25552. getVerticesData(kind: string): Nullable<FloatArray>;
  25553. /**
  25554. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25555. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25556. * Note that a new underlying VertexBuffer object is created each call.
  25557. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25558. * @param kind defines vertex data kind:
  25559. * * VertexBuffer.PositionKind
  25560. * * VertexBuffer.UVKind
  25561. * * VertexBuffer.UV2Kind
  25562. * * VertexBuffer.UV3Kind
  25563. * * VertexBuffer.UV4Kind
  25564. * * VertexBuffer.UV5Kind
  25565. * * VertexBuffer.UV6Kind
  25566. * * VertexBuffer.ColorKind
  25567. * * VertexBuffer.MatricesIndicesKind
  25568. * * VertexBuffer.MatricesIndicesExtraKind
  25569. * * VertexBuffer.MatricesWeightsKind
  25570. * * VertexBuffer.MatricesWeightsExtraKind
  25571. * @param data defines the data source
  25572. * @param updatable defines if the data must be flagged as updatable (or static)
  25573. * @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
  25574. * @returns the current mesh
  25575. */
  25576. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25577. /**
  25578. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25579. * If the mesh has no geometry, it is simply returned as it is.
  25580. * @param kind defines vertex data kind:
  25581. * * VertexBuffer.PositionKind
  25582. * * VertexBuffer.UVKind
  25583. * * VertexBuffer.UV2Kind
  25584. * * VertexBuffer.UV3Kind
  25585. * * VertexBuffer.UV4Kind
  25586. * * VertexBuffer.UV5Kind
  25587. * * VertexBuffer.UV6Kind
  25588. * * VertexBuffer.ColorKind
  25589. * * VertexBuffer.MatricesIndicesKind
  25590. * * VertexBuffer.MatricesIndicesExtraKind
  25591. * * VertexBuffer.MatricesWeightsKind
  25592. * * VertexBuffer.MatricesWeightsExtraKind
  25593. * @param data defines the data source
  25594. * @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
  25595. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25596. * @returns the current mesh
  25597. */
  25598. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25599. /**
  25600. * Sets the mesh indices,
  25601. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25602. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25603. * @param totalVertices Defines the total number of vertices
  25604. * @returns the current mesh
  25605. */
  25606. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25607. /**
  25608. * Gets a boolean indicating if specific vertex data is present
  25609. * @param kind defines the vertex data kind to use
  25610. * @returns true is data kind is present
  25611. */
  25612. isVerticesDataPresent(kind: string): boolean;
  25613. /**
  25614. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25615. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25616. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25617. * @returns a BoundingInfo
  25618. */
  25619. getBoundingInfo(): BoundingInfo;
  25620. /**
  25621. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25622. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25623. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25624. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25625. * @returns the current mesh
  25626. */
  25627. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25628. /**
  25629. * Overwrite the current bounding info
  25630. * @param boundingInfo defines the new bounding info
  25631. * @returns the current mesh
  25632. */
  25633. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25634. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25635. readonly useBones: boolean;
  25636. /** @hidden */
  25637. _preActivate(): void;
  25638. /** @hidden */
  25639. _preActivateForIntermediateRendering(renderId: number): void;
  25640. /** @hidden */
  25641. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25642. /** @hidden */
  25643. _postActivate(): void;
  25644. /** @hidden */
  25645. _freeze(): void;
  25646. /** @hidden */
  25647. _unFreeze(): void;
  25648. /**
  25649. * Gets the current world matrix
  25650. * @returns a Matrix
  25651. */
  25652. getWorldMatrix(): Matrix;
  25653. /** @hidden */
  25654. _getWorldMatrixDeterminant(): number;
  25655. /**
  25656. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25657. */
  25658. readonly isAnInstance: boolean;
  25659. /**
  25660. * Perform relative position change from the point of view of behind the front of the mesh.
  25661. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25662. * Supports definition of mesh facing forward or backward
  25663. * @param amountRight defines the distance on the right axis
  25664. * @param amountUp defines the distance on the up axis
  25665. * @param amountForward defines the distance on the forward axis
  25666. * @returns the current mesh
  25667. */
  25668. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25669. /**
  25670. * Calculate relative position change from the point of view of behind the front of the mesh.
  25671. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25672. * Supports definition of mesh facing forward or backward
  25673. * @param amountRight defines the distance on the right axis
  25674. * @param amountUp defines the distance on the up axis
  25675. * @param amountForward defines the distance on the forward axis
  25676. * @returns the new displacement vector
  25677. */
  25678. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25679. /**
  25680. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25681. * Supports definition of mesh facing forward or backward
  25682. * @param flipBack defines the flip
  25683. * @param twirlClockwise defines the twirl
  25684. * @param tiltRight defines the tilt
  25685. * @returns the current mesh
  25686. */
  25687. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25688. /**
  25689. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25690. * Supports definition of mesh facing forward or backward.
  25691. * @param flipBack defines the flip
  25692. * @param twirlClockwise defines the twirl
  25693. * @param tiltRight defines the tilt
  25694. * @returns the new rotation vector
  25695. */
  25696. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25697. /**
  25698. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25699. * This means the mesh underlying bounding box and sphere are recomputed.
  25700. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25701. * @returns the current mesh
  25702. */
  25703. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25704. /** @hidden */
  25705. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25706. /** @hidden */
  25707. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25708. /** @hidden */
  25709. _updateBoundingInfo(): AbstractMesh;
  25710. /** @hidden */
  25711. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25712. /** @hidden */
  25713. protected _afterComputeWorldMatrix(): void;
  25714. /** @hidden */
  25715. readonly _effectiveMesh: AbstractMesh;
  25716. /**
  25717. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25718. * A mesh is in the frustum if its bounding box intersects the frustum
  25719. * @param frustumPlanes defines the frustum to test
  25720. * @returns true if the mesh is in the frustum planes
  25721. */
  25722. isInFrustum(frustumPlanes: Plane[]): boolean;
  25723. /**
  25724. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25725. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25726. * @param frustumPlanes defines the frustum to test
  25727. * @returns true if the mesh is completely in the frustum planes
  25728. */
  25729. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25730. /**
  25731. * True if the mesh intersects another mesh or a SolidParticle object
  25732. * @param mesh defines a target mesh or SolidParticle to test
  25733. * @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)
  25734. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25735. * @returns true if there is an intersection
  25736. */
  25737. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25738. /**
  25739. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25740. * @param point defines the point to test
  25741. * @returns true if there is an intersection
  25742. */
  25743. intersectsPoint(point: Vector3): boolean;
  25744. /**
  25745. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25746. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25747. */
  25748. checkCollisions: boolean;
  25749. /**
  25750. * Gets Collider object used to compute collisions (not physics)
  25751. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25752. */
  25753. readonly collider: Nullable<Collider>;
  25754. /**
  25755. * Move the mesh using collision engine
  25756. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25757. * @param displacement defines the requested displacement vector
  25758. * @returns the current mesh
  25759. */
  25760. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25761. private _onCollisionPositionChange;
  25762. /** @hidden */
  25763. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25764. /** @hidden */
  25765. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25766. /** @hidden */
  25767. _checkCollision(collider: Collider): AbstractMesh;
  25768. /** @hidden */
  25769. _generatePointsArray(): boolean;
  25770. /**
  25771. * Checks if the passed Ray intersects with the mesh
  25772. * @param ray defines the ray to use
  25773. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25774. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25775. * @returns the picking info
  25776. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25777. */
  25778. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25779. /**
  25780. * Clones the current mesh
  25781. * @param name defines the mesh name
  25782. * @param newParent defines the new mesh parent
  25783. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25784. * @returns the new mesh
  25785. */
  25786. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25787. /**
  25788. * Disposes all the submeshes of the current meshnp
  25789. * @returns the current mesh
  25790. */
  25791. releaseSubMeshes(): AbstractMesh;
  25792. /**
  25793. * Releases resources associated with this abstract mesh.
  25794. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25795. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25796. */
  25797. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25798. /**
  25799. * Adds the passed mesh as a child to the current mesh
  25800. * @param mesh defines the child mesh
  25801. * @returns the current mesh
  25802. */
  25803. addChild(mesh: AbstractMesh): AbstractMesh;
  25804. /**
  25805. * Removes the passed mesh from the current mesh children list
  25806. * @param mesh defines the child mesh
  25807. * @returns the current mesh
  25808. */
  25809. removeChild(mesh: AbstractMesh): AbstractMesh;
  25810. /** @hidden */
  25811. private _initFacetData;
  25812. /**
  25813. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25814. * This method can be called within the render loop.
  25815. * 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
  25816. * @returns the current mesh
  25817. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25818. */
  25819. updateFacetData(): AbstractMesh;
  25820. /**
  25821. * Returns the facetLocalNormals array.
  25822. * The normals are expressed in the mesh local spac
  25823. * @returns an array of Vector3
  25824. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25825. */
  25826. getFacetLocalNormals(): Vector3[];
  25827. /**
  25828. * Returns the facetLocalPositions array.
  25829. * The facet positions are expressed in the mesh local space
  25830. * @returns an array of Vector3
  25831. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25832. */
  25833. getFacetLocalPositions(): Vector3[];
  25834. /**
  25835. * Returns the facetLocalPartioning array
  25836. * @returns an array of array of numbers
  25837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25838. */
  25839. getFacetLocalPartitioning(): number[][];
  25840. /**
  25841. * Returns the i-th facet position in the world system.
  25842. * This method allocates a new Vector3 per call
  25843. * @param i defines the facet index
  25844. * @returns a new Vector3
  25845. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25846. */
  25847. getFacetPosition(i: number): Vector3;
  25848. /**
  25849. * Sets the reference Vector3 with the i-th facet position in the world system
  25850. * @param i defines the facet index
  25851. * @param ref defines the target vector
  25852. * @returns the current mesh
  25853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25854. */
  25855. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25856. /**
  25857. * Returns the i-th facet normal in the world system.
  25858. * This method allocates a new Vector3 per call
  25859. * @param i defines the facet index
  25860. * @returns a new Vector3
  25861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25862. */
  25863. getFacetNormal(i: number): Vector3;
  25864. /**
  25865. * Sets the reference Vector3 with the i-th facet normal in the world system
  25866. * @param i defines the facet index
  25867. * @param ref defines the target vector
  25868. * @returns the current mesh
  25869. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25870. */
  25871. getFacetNormalToRef(i: number, ref: Vector3): this;
  25872. /**
  25873. * 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)
  25874. * @param x defines x coordinate
  25875. * @param y defines y coordinate
  25876. * @param z defines z coordinate
  25877. * @returns the array of facet indexes
  25878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25879. */
  25880. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25881. /**
  25882. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25883. * @param projected sets as the (x,y,z) world projection on the facet
  25884. * @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
  25885. * @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
  25886. * @param x defines x coordinate
  25887. * @param y defines y coordinate
  25888. * @param z defines z coordinate
  25889. * @returns the face index if found (or null instead)
  25890. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25891. */
  25892. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25893. /**
  25894. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25895. * @param projected sets as the (x,y,z) local projection on the facet
  25896. * @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
  25897. * @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
  25898. * @param x defines x coordinate
  25899. * @param y defines y coordinate
  25900. * @param z defines z coordinate
  25901. * @returns the face index if found (or null instead)
  25902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25903. */
  25904. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25905. /**
  25906. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25907. * @returns the parameters
  25908. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25909. */
  25910. getFacetDataParameters(): any;
  25911. /**
  25912. * Disables the feature FacetData and frees the related memory
  25913. * @returns the current mesh
  25914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25915. */
  25916. disableFacetData(): AbstractMesh;
  25917. /**
  25918. * Updates the AbstractMesh indices array
  25919. * @param indices defines the data source
  25920. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25921. * @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)
  25922. * @returns the current mesh
  25923. */
  25924. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25925. /**
  25926. * Creates new normals data for the mesh
  25927. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25928. * @returns the current mesh
  25929. */
  25930. createNormals(updatable: boolean): AbstractMesh;
  25931. /**
  25932. * Align the mesh with a normal
  25933. * @param normal defines the normal to use
  25934. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25935. * @returns the current mesh
  25936. */
  25937. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25938. /** @hidden */
  25939. _checkOcclusionQuery(): boolean;
  25940. /**
  25941. * Disables the mesh edge rendering mode
  25942. * @returns the currentAbstractMesh
  25943. */
  25944. disableEdgesRendering(): AbstractMesh;
  25945. /**
  25946. * Enables the edge rendering mode on the mesh.
  25947. * This mode makes the mesh edges visible
  25948. * @param epsilon defines the maximal distance between two angles to detect a face
  25949. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25950. * @returns the currentAbstractMesh
  25951. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25952. */
  25953. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25954. }
  25955. }
  25956. declare module "babylonjs/Actions/actionEvent" {
  25957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25958. import { Nullable } from "babylonjs/types";
  25959. import { Sprite } from "babylonjs/Sprites/sprite";
  25960. import { Scene } from "babylonjs/scene";
  25961. import { Vector2 } from "babylonjs/Maths/math";
  25962. /**
  25963. * Interface used to define ActionEvent
  25964. */
  25965. export interface IActionEvent {
  25966. /** The mesh or sprite that triggered the action */
  25967. source: any;
  25968. /** The X mouse cursor position at the time of the event */
  25969. pointerX: number;
  25970. /** The Y mouse cursor position at the time of the event */
  25971. pointerY: number;
  25972. /** The mesh that is currently pointed at (can be null) */
  25973. meshUnderPointer: Nullable<AbstractMesh>;
  25974. /** the original (browser) event that triggered the ActionEvent */
  25975. sourceEvent?: any;
  25976. /** additional data for the event */
  25977. additionalData?: any;
  25978. }
  25979. /**
  25980. * ActionEvent is the event being sent when an action is triggered.
  25981. */
  25982. export class ActionEvent implements IActionEvent {
  25983. /** The mesh or sprite that triggered the action */
  25984. source: any;
  25985. /** The X mouse cursor position at the time of the event */
  25986. pointerX: number;
  25987. /** The Y mouse cursor position at the time of the event */
  25988. pointerY: number;
  25989. /** The mesh that is currently pointed at (can be null) */
  25990. meshUnderPointer: Nullable<AbstractMesh>;
  25991. /** the original (browser) event that triggered the ActionEvent */
  25992. sourceEvent?: any;
  25993. /** additional data for the event */
  25994. additionalData?: any;
  25995. /**
  25996. * Creates a new ActionEvent
  25997. * @param source The mesh or sprite that triggered the action
  25998. * @param pointerX The X mouse cursor position at the time of the event
  25999. * @param pointerY The Y mouse cursor position at the time of the event
  26000. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26001. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26002. * @param additionalData additional data for the event
  26003. */
  26004. constructor(
  26005. /** The mesh or sprite that triggered the action */
  26006. source: any,
  26007. /** The X mouse cursor position at the time of the event */
  26008. pointerX: number,
  26009. /** The Y mouse cursor position at the time of the event */
  26010. pointerY: number,
  26011. /** The mesh that is currently pointed at (can be null) */
  26012. meshUnderPointer: Nullable<AbstractMesh>,
  26013. /** the original (browser) event that triggered the ActionEvent */
  26014. sourceEvent?: any,
  26015. /** additional data for the event */
  26016. additionalData?: any);
  26017. /**
  26018. * Helper function to auto-create an ActionEvent from a source mesh.
  26019. * @param source The source mesh that triggered the event
  26020. * @param evt The original (browser) event
  26021. * @param additionalData additional data for the event
  26022. * @returns the new ActionEvent
  26023. */
  26024. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26025. /**
  26026. * Helper function to auto-create an ActionEvent from a source sprite
  26027. * @param source The source sprite that triggered the event
  26028. * @param scene Scene associated with the sprite
  26029. * @param evt The original (browser) event
  26030. * @param additionalData additional data for the event
  26031. * @returns the new ActionEvent
  26032. */
  26033. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26034. /**
  26035. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26036. * @param scene the scene where the event occurred
  26037. * @param evt The original (browser) event
  26038. * @returns the new ActionEvent
  26039. */
  26040. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26041. /**
  26042. * Helper function to auto-create an ActionEvent from a primitive
  26043. * @param prim defines the target primitive
  26044. * @param pointerPos defines the pointer position
  26045. * @param evt The original (browser) event
  26046. * @param additionalData additional data for the event
  26047. * @returns the new ActionEvent
  26048. */
  26049. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26050. }
  26051. }
  26052. declare module "babylonjs/Actions/abstractActionManager" {
  26053. import { IDisposable } from "babylonjs/scene";
  26054. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  26055. import { IAction } from "babylonjs/Actions/action";
  26056. import { Nullable } from "babylonjs/types";
  26057. /**
  26058. * Abstract class used to decouple action Manager from scene and meshes.
  26059. * Do not instantiate.
  26060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26061. */
  26062. export abstract class AbstractActionManager implements IDisposable {
  26063. /** Gets the list of active triggers */
  26064. static Triggers: {
  26065. [key: string]: number;
  26066. };
  26067. /** Gets the cursor to use when hovering items */
  26068. hoverCursor: string;
  26069. /** Gets the list of actions */
  26070. actions: IAction[];
  26071. /**
  26072. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26073. */
  26074. isRecursive: boolean;
  26075. /**
  26076. * Releases all associated resources
  26077. */
  26078. abstract dispose(): void;
  26079. /**
  26080. * Does this action manager has pointer triggers
  26081. */
  26082. abstract readonly hasPointerTriggers: boolean;
  26083. /**
  26084. * Does this action manager has pick triggers
  26085. */
  26086. abstract readonly hasPickTriggers: boolean;
  26087. /**
  26088. * Process a specific trigger
  26089. * @param trigger defines the trigger to process
  26090. * @param evt defines the event details to be processed
  26091. */
  26092. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26093. /**
  26094. * Does this action manager handles actions of any of the given triggers
  26095. * @param triggers defines the triggers to be tested
  26096. * @return a boolean indicating whether one (or more) of the triggers is handled
  26097. */
  26098. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26099. /**
  26100. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26101. * speed.
  26102. * @param triggerA defines the trigger to be tested
  26103. * @param triggerB defines the trigger to be tested
  26104. * @return a boolean indicating whether one (or more) of the triggers is handled
  26105. */
  26106. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26107. /**
  26108. * Does this action manager handles actions of a given trigger
  26109. * @param trigger defines the trigger to be tested
  26110. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26111. * @return whether the trigger is handled
  26112. */
  26113. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26114. /**
  26115. * Serialize this manager to a JSON object
  26116. * @param name defines the property name to store this manager
  26117. * @returns a JSON representation of this manager
  26118. */
  26119. abstract serialize(name: string): any;
  26120. /**
  26121. * Registers an action to this action manager
  26122. * @param action defines the action to be registered
  26123. * @return the action amended (prepared) after registration
  26124. */
  26125. abstract registerAction(action: IAction): Nullable<IAction>;
  26126. /**
  26127. * Unregisters an action to this action manager
  26128. * @param action defines the action to be unregistered
  26129. * @return a boolean indicating whether the action has been unregistered
  26130. */
  26131. abstract unregisterAction(action: IAction): Boolean;
  26132. /**
  26133. * Does exist one action manager with at least one trigger
  26134. **/
  26135. static readonly HasTriggers: boolean;
  26136. /**
  26137. * Does exist one action manager with at least one pick trigger
  26138. **/
  26139. static readonly HasPickTriggers: boolean;
  26140. /**
  26141. * Does exist one action manager that handles actions of a given trigger
  26142. * @param trigger defines the trigger to be tested
  26143. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26144. **/
  26145. static HasSpecificTrigger(trigger: number): boolean;
  26146. }
  26147. }
  26148. declare module "babylonjs/node" {
  26149. import { Scene } from "babylonjs/scene";
  26150. import { Nullable } from "babylonjs/types";
  26151. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26152. import { Engine } from "babylonjs/Engines/engine";
  26153. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26154. import { Observable } from "babylonjs/Misc/observable";
  26155. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26156. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26157. import { Animatable } from "babylonjs/Animations/animatable";
  26158. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26159. import { Animation } from "babylonjs/Animations/animation";
  26160. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26162. /**
  26163. * Defines how a node can be built from a string name.
  26164. */
  26165. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26166. /**
  26167. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26168. */
  26169. export class Node implements IBehaviorAware<Node> {
  26170. /** @hidden */
  26171. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26172. private static _NodeConstructors;
  26173. /**
  26174. * Add a new node constructor
  26175. * @param type defines the type name of the node to construct
  26176. * @param constructorFunc defines the constructor function
  26177. */
  26178. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26179. /**
  26180. * Returns a node constructor based on type name
  26181. * @param type defines the type name
  26182. * @param name defines the new node name
  26183. * @param scene defines the hosting scene
  26184. * @param options defines optional options to transmit to constructors
  26185. * @returns the new constructor or null
  26186. */
  26187. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26188. /**
  26189. * Gets or sets the name of the node
  26190. */
  26191. name: string;
  26192. /**
  26193. * Gets or sets the id of the node
  26194. */
  26195. id: string;
  26196. /**
  26197. * Gets or sets the unique id of the node
  26198. */
  26199. uniqueId: number;
  26200. /**
  26201. * Gets or sets a string used to store user defined state for the node
  26202. */
  26203. state: string;
  26204. /**
  26205. * Gets or sets an object used to store user defined information for the node
  26206. */
  26207. metadata: any;
  26208. /**
  26209. * For internal use only. Please do not use.
  26210. */
  26211. reservedDataStore: any;
  26212. /**
  26213. * List of inspectable custom properties (used by the Inspector)
  26214. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26215. */
  26216. inspectableCustomProperties: IInspectable[];
  26217. /**
  26218. * Gets or sets a boolean used to define if the node must be serialized
  26219. */
  26220. doNotSerialize: boolean;
  26221. /** @hidden */
  26222. _isDisposed: boolean;
  26223. /**
  26224. * Gets a list of Animations associated with the node
  26225. */
  26226. animations: import("babylonjs/Animations/animation").Animation[];
  26227. protected _ranges: {
  26228. [name: string]: Nullable<AnimationRange>;
  26229. };
  26230. /**
  26231. * Callback raised when the node is ready to be used
  26232. */
  26233. onReady: Nullable<(node: Node) => void>;
  26234. private _isEnabled;
  26235. private _isParentEnabled;
  26236. private _isReady;
  26237. /** @hidden */
  26238. _currentRenderId: number;
  26239. private _parentUpdateId;
  26240. /** @hidden */
  26241. _childUpdateId: number;
  26242. /** @hidden */
  26243. _waitingParentId: Nullable<string>;
  26244. /** @hidden */
  26245. _scene: Scene;
  26246. /** @hidden */
  26247. _cache: any;
  26248. private _parentNode;
  26249. private _children;
  26250. /** @hidden */
  26251. _worldMatrix: Matrix;
  26252. /** @hidden */
  26253. _worldMatrixDeterminant: number;
  26254. /** @hidden */
  26255. _worldMatrixDeterminantIsDirty: boolean;
  26256. /** @hidden */
  26257. private _sceneRootNodesIndex;
  26258. /**
  26259. * Gets a boolean indicating if the node has been disposed
  26260. * @returns true if the node was disposed
  26261. */
  26262. isDisposed(): boolean;
  26263. /**
  26264. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26265. * @see https://doc.babylonjs.com/how_to/parenting
  26266. */
  26267. parent: Nullable<Node>;
  26268. private addToSceneRootNodes;
  26269. private removeFromSceneRootNodes;
  26270. private _animationPropertiesOverride;
  26271. /**
  26272. * Gets or sets the animation properties override
  26273. */
  26274. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26275. /**
  26276. * Gets a string idenfifying the name of the class
  26277. * @returns "Node" string
  26278. */
  26279. getClassName(): string;
  26280. /** @hidden */
  26281. readonly _isNode: boolean;
  26282. /**
  26283. * An event triggered when the mesh is disposed
  26284. */
  26285. onDisposeObservable: Observable<Node>;
  26286. private _onDisposeObserver;
  26287. /**
  26288. * Sets a callback that will be raised when the node will be disposed
  26289. */
  26290. onDispose: () => void;
  26291. /**
  26292. * Creates a new Node
  26293. * @param name the name and id to be given to this node
  26294. * @param scene the scene this node will be added to
  26295. * @param addToRootNodes the node will be added to scene.rootNodes
  26296. */
  26297. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26298. /**
  26299. * Gets the scene of the node
  26300. * @returns a scene
  26301. */
  26302. getScene(): Scene;
  26303. /**
  26304. * Gets the engine of the node
  26305. * @returns a Engine
  26306. */
  26307. getEngine(): Engine;
  26308. private _behaviors;
  26309. /**
  26310. * Attach a behavior to the node
  26311. * @see http://doc.babylonjs.com/features/behaviour
  26312. * @param behavior defines the behavior to attach
  26313. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26314. * @returns the current Node
  26315. */
  26316. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26317. /**
  26318. * Remove an attached behavior
  26319. * @see http://doc.babylonjs.com/features/behaviour
  26320. * @param behavior defines the behavior to attach
  26321. * @returns the current Node
  26322. */
  26323. removeBehavior(behavior: Behavior<Node>): Node;
  26324. /**
  26325. * Gets the list of attached behaviors
  26326. * @see http://doc.babylonjs.com/features/behaviour
  26327. */
  26328. readonly behaviors: Behavior<Node>[];
  26329. /**
  26330. * Gets an attached behavior by name
  26331. * @param name defines the name of the behavior to look for
  26332. * @see http://doc.babylonjs.com/features/behaviour
  26333. * @returns null if behavior was not found else the requested behavior
  26334. */
  26335. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26336. /**
  26337. * Returns the latest update of the World matrix
  26338. * @returns a Matrix
  26339. */
  26340. getWorldMatrix(): Matrix;
  26341. /** @hidden */
  26342. _getWorldMatrixDeterminant(): number;
  26343. /**
  26344. * Returns directly the latest state of the mesh World matrix.
  26345. * A Matrix is returned.
  26346. */
  26347. readonly worldMatrixFromCache: Matrix;
  26348. /** @hidden */
  26349. _initCache(): void;
  26350. /** @hidden */
  26351. updateCache(force?: boolean): void;
  26352. /** @hidden */
  26353. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26354. /** @hidden */
  26355. _updateCache(ignoreParentClass?: boolean): void;
  26356. /** @hidden */
  26357. _isSynchronized(): boolean;
  26358. /** @hidden */
  26359. _markSyncedWithParent(): void;
  26360. /** @hidden */
  26361. isSynchronizedWithParent(): boolean;
  26362. /** @hidden */
  26363. isSynchronized(): boolean;
  26364. /**
  26365. * Is this node ready to be used/rendered
  26366. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26367. * @return true if the node is ready
  26368. */
  26369. isReady(completeCheck?: boolean): boolean;
  26370. /**
  26371. * Is this node enabled?
  26372. * 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
  26373. * @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
  26374. * @return whether this node (and its parent) is enabled
  26375. */
  26376. isEnabled(checkAncestors?: boolean): boolean;
  26377. /** @hidden */
  26378. protected _syncParentEnabledState(): void;
  26379. /**
  26380. * Set the enabled state of this node
  26381. * @param value defines the new enabled state
  26382. */
  26383. setEnabled(value: boolean): void;
  26384. /**
  26385. * Is this node a descendant of the given node?
  26386. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26387. * @param ancestor defines the parent node to inspect
  26388. * @returns a boolean indicating if this node is a descendant of the given node
  26389. */
  26390. isDescendantOf(ancestor: Node): boolean;
  26391. /** @hidden */
  26392. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26393. /**
  26394. * Will return all nodes that have this node as ascendant
  26395. * @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
  26396. * @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
  26397. * @return all children nodes of all types
  26398. */
  26399. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26400. /**
  26401. * Get all child-meshes of this node
  26402. * @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)
  26403. * @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
  26404. * @returns an array of AbstractMesh
  26405. */
  26406. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26407. /**
  26408. * Get all direct children of this node
  26409. * @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
  26410. * @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)
  26411. * @returns an array of Node
  26412. */
  26413. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26414. /** @hidden */
  26415. _setReady(state: boolean): void;
  26416. /**
  26417. * Get an animation by name
  26418. * @param name defines the name of the animation to look for
  26419. * @returns null if not found else the requested animation
  26420. */
  26421. getAnimationByName(name: string): Nullable<Animation>;
  26422. /**
  26423. * Creates an animation range for this node
  26424. * @param name defines the name of the range
  26425. * @param from defines the starting key
  26426. * @param to defines the end key
  26427. */
  26428. createAnimationRange(name: string, from: number, to: number): void;
  26429. /**
  26430. * Delete a specific animation range
  26431. * @param name defines the name of the range to delete
  26432. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26433. */
  26434. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26435. /**
  26436. * Get an animation range by name
  26437. * @param name defines the name of the animation range to look for
  26438. * @returns null if not found else the requested animation range
  26439. */
  26440. getAnimationRange(name: string): Nullable<AnimationRange>;
  26441. /**
  26442. * Gets the list of all animation ranges defined on this node
  26443. * @returns an array
  26444. */
  26445. getAnimationRanges(): Nullable<AnimationRange>[];
  26446. /**
  26447. * Will start the animation sequence
  26448. * @param name defines the range frames for animation sequence
  26449. * @param loop defines if the animation should loop (false by default)
  26450. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26451. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26452. * @returns the object created for this animation. If range does not exist, it will return null
  26453. */
  26454. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26455. /**
  26456. * Serialize animation ranges into a JSON compatible object
  26457. * @returns serialization object
  26458. */
  26459. serializeAnimationRanges(): any;
  26460. /**
  26461. * Computes the world matrix of the node
  26462. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26463. * @returns the world matrix
  26464. */
  26465. computeWorldMatrix(force?: boolean): Matrix;
  26466. /**
  26467. * Releases resources associated with this node.
  26468. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26469. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26470. */
  26471. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26472. /**
  26473. * Parse animation range data from a serialization object and store them into a given node
  26474. * @param node defines where to store the animation ranges
  26475. * @param parsedNode defines the serialization object to read data from
  26476. * @param scene defines the hosting scene
  26477. */
  26478. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26479. /**
  26480. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26481. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26482. * @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
  26483. * @returns the new bounding vectors
  26484. */
  26485. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26486. min: Vector3;
  26487. max: Vector3;
  26488. };
  26489. }
  26490. }
  26491. declare module "babylonjs/Animations/animation" {
  26492. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26493. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26494. import { Nullable } from "babylonjs/types";
  26495. import { Scene } from "babylonjs/scene";
  26496. import { IAnimatable } from "babylonjs/Misc/tools";
  26497. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26498. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26499. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26500. import { Node } from "babylonjs/node";
  26501. import { Animatable } from "babylonjs/Animations/animatable";
  26502. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26503. /**
  26504. * @hidden
  26505. */
  26506. export class _IAnimationState {
  26507. key: number;
  26508. repeatCount: number;
  26509. workValue?: any;
  26510. loopMode?: number;
  26511. offsetValue?: any;
  26512. highLimitValue?: any;
  26513. }
  26514. /**
  26515. * Class used to store any kind of animation
  26516. */
  26517. export class Animation {
  26518. /**Name of the animation */
  26519. name: string;
  26520. /**Property to animate */
  26521. targetProperty: string;
  26522. /**The frames per second of the animation */
  26523. framePerSecond: number;
  26524. /**The data type of the animation */
  26525. dataType: number;
  26526. /**The loop mode of the animation */
  26527. loopMode?: number | undefined;
  26528. /**Specifies if blending should be enabled */
  26529. enableBlending?: boolean | undefined;
  26530. /**
  26531. * Use matrix interpolation instead of using direct key value when animating matrices
  26532. */
  26533. static AllowMatricesInterpolation: boolean;
  26534. /**
  26535. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26536. */
  26537. static AllowMatrixDecomposeForInterpolation: boolean;
  26538. /**
  26539. * Stores the key frames of the animation
  26540. */
  26541. private _keys;
  26542. /**
  26543. * Stores the easing function of the animation
  26544. */
  26545. private _easingFunction;
  26546. /**
  26547. * @hidden Internal use only
  26548. */
  26549. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26550. /**
  26551. * The set of event that will be linked to this animation
  26552. */
  26553. private _events;
  26554. /**
  26555. * Stores an array of target property paths
  26556. */
  26557. targetPropertyPath: string[];
  26558. /**
  26559. * Stores the blending speed of the animation
  26560. */
  26561. blendingSpeed: number;
  26562. /**
  26563. * Stores the animation ranges for the animation
  26564. */
  26565. private _ranges;
  26566. /**
  26567. * @hidden Internal use
  26568. */
  26569. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26570. /**
  26571. * Sets up an animation
  26572. * @param property The property to animate
  26573. * @param animationType The animation type to apply
  26574. * @param framePerSecond The frames per second of the animation
  26575. * @param easingFunction The easing function used in the animation
  26576. * @returns The created animation
  26577. */
  26578. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26579. /**
  26580. * Create and start an animation on a node
  26581. * @param name defines the name of the global animation that will be run on all nodes
  26582. * @param node defines the root node where the animation will take place
  26583. * @param targetProperty defines property to animate
  26584. * @param framePerSecond defines the number of frame per second yo use
  26585. * @param totalFrame defines the number of frames in total
  26586. * @param from defines the initial value
  26587. * @param to defines the final value
  26588. * @param loopMode defines which loop mode you want to use (off by default)
  26589. * @param easingFunction defines the easing function to use (linear by default)
  26590. * @param onAnimationEnd defines the callback to call when animation end
  26591. * @returns the animatable created for this animation
  26592. */
  26593. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26594. /**
  26595. * Create and start an animation on a node and its descendants
  26596. * @param name defines the name of the global animation that will be run on all nodes
  26597. * @param node defines the root node where the animation will take place
  26598. * @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
  26599. * @param targetProperty defines property to animate
  26600. * @param framePerSecond defines the number of frame per second to use
  26601. * @param totalFrame defines the number of frames in total
  26602. * @param from defines the initial value
  26603. * @param to defines the final value
  26604. * @param loopMode defines which loop mode you want to use (off by default)
  26605. * @param easingFunction defines the easing function to use (linear by default)
  26606. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26607. * @returns the list of animatables created for all nodes
  26608. * @example https://www.babylonjs-playground.com/#MH0VLI
  26609. */
  26610. 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[]>;
  26611. /**
  26612. * Creates a new animation, merges it with the existing animations and starts it
  26613. * @param name Name of the animation
  26614. * @param node Node which contains the scene that begins the animations
  26615. * @param targetProperty Specifies which property to animate
  26616. * @param framePerSecond The frames per second of the animation
  26617. * @param totalFrame The total number of frames
  26618. * @param from The frame at the beginning of the animation
  26619. * @param to The frame at the end of the animation
  26620. * @param loopMode Specifies the loop mode of the animation
  26621. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26622. * @param onAnimationEnd Callback to run once the animation is complete
  26623. * @returns Nullable animation
  26624. */
  26625. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26626. /**
  26627. * Transition property of an host to the target Value
  26628. * @param property The property to transition
  26629. * @param targetValue The target Value of the property
  26630. * @param host The object where the property to animate belongs
  26631. * @param scene Scene used to run the animation
  26632. * @param frameRate Framerate (in frame/s) to use
  26633. * @param transition The transition type we want to use
  26634. * @param duration The duration of the animation, in milliseconds
  26635. * @param onAnimationEnd Callback trigger at the end of the animation
  26636. * @returns Nullable animation
  26637. */
  26638. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26639. /**
  26640. * Return the array of runtime animations currently using this animation
  26641. */
  26642. readonly runtimeAnimations: RuntimeAnimation[];
  26643. /**
  26644. * Specifies if any of the runtime animations are currently running
  26645. */
  26646. readonly hasRunningRuntimeAnimations: boolean;
  26647. /**
  26648. * Initializes the animation
  26649. * @param name Name of the animation
  26650. * @param targetProperty Property to animate
  26651. * @param framePerSecond The frames per second of the animation
  26652. * @param dataType The data type of the animation
  26653. * @param loopMode The loop mode of the animation
  26654. * @param enableBlending Specifies if blending should be enabled
  26655. */
  26656. constructor(
  26657. /**Name of the animation */
  26658. name: string,
  26659. /**Property to animate */
  26660. targetProperty: string,
  26661. /**The frames per second of the animation */
  26662. framePerSecond: number,
  26663. /**The data type of the animation */
  26664. dataType: number,
  26665. /**The loop mode of the animation */
  26666. loopMode?: number | undefined,
  26667. /**Specifies if blending should be enabled */
  26668. enableBlending?: boolean | undefined);
  26669. /**
  26670. * Converts the animation to a string
  26671. * @param fullDetails support for multiple levels of logging within scene loading
  26672. * @returns String form of the animation
  26673. */
  26674. toString(fullDetails?: boolean): string;
  26675. /**
  26676. * Add an event to this animation
  26677. * @param event Event to add
  26678. */
  26679. addEvent(event: AnimationEvent): void;
  26680. /**
  26681. * Remove all events found at the given frame
  26682. * @param frame The frame to remove events from
  26683. */
  26684. removeEvents(frame: number): void;
  26685. /**
  26686. * Retrieves all the events from the animation
  26687. * @returns Events from the animation
  26688. */
  26689. getEvents(): AnimationEvent[];
  26690. /**
  26691. * Creates an animation range
  26692. * @param name Name of the animation range
  26693. * @param from Starting frame of the animation range
  26694. * @param to Ending frame of the animation
  26695. */
  26696. createRange(name: string, from: number, to: number): void;
  26697. /**
  26698. * Deletes an animation range by name
  26699. * @param name Name of the animation range to delete
  26700. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26701. */
  26702. deleteRange(name: string, deleteFrames?: boolean): void;
  26703. /**
  26704. * Gets the animation range by name, or null if not defined
  26705. * @param name Name of the animation range
  26706. * @returns Nullable animation range
  26707. */
  26708. getRange(name: string): Nullable<AnimationRange>;
  26709. /**
  26710. * Gets the key frames from the animation
  26711. * @returns The key frames of the animation
  26712. */
  26713. getKeys(): Array<IAnimationKey>;
  26714. /**
  26715. * Gets the highest frame rate of the animation
  26716. * @returns Highest frame rate of the animation
  26717. */
  26718. getHighestFrame(): number;
  26719. /**
  26720. * Gets the easing function of the animation
  26721. * @returns Easing function of the animation
  26722. */
  26723. getEasingFunction(): IEasingFunction;
  26724. /**
  26725. * Sets the easing function of the animation
  26726. * @param easingFunction A custom mathematical formula for animation
  26727. */
  26728. setEasingFunction(easingFunction: EasingFunction): void;
  26729. /**
  26730. * Interpolates a scalar linearly
  26731. * @param startValue Start value of the animation curve
  26732. * @param endValue End value of the animation curve
  26733. * @param gradient Scalar amount to interpolate
  26734. * @returns Interpolated scalar value
  26735. */
  26736. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26737. /**
  26738. * Interpolates a scalar cubically
  26739. * @param startValue Start value of the animation curve
  26740. * @param outTangent End tangent of the animation
  26741. * @param endValue End value of the animation curve
  26742. * @param inTangent Start tangent of the animation curve
  26743. * @param gradient Scalar amount to interpolate
  26744. * @returns Interpolated scalar value
  26745. */
  26746. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26747. /**
  26748. * Interpolates a quaternion using a spherical linear interpolation
  26749. * @param startValue Start value of the animation curve
  26750. * @param endValue End value of the animation curve
  26751. * @param gradient Scalar amount to interpolate
  26752. * @returns Interpolated quaternion value
  26753. */
  26754. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26755. /**
  26756. * Interpolates a quaternion cubically
  26757. * @param startValue Start value of the animation curve
  26758. * @param outTangent End tangent of the animation curve
  26759. * @param endValue End value of the animation curve
  26760. * @param inTangent Start tangent of the animation curve
  26761. * @param gradient Scalar amount to interpolate
  26762. * @returns Interpolated quaternion value
  26763. */
  26764. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26765. /**
  26766. * Interpolates a Vector3 linearl
  26767. * @param startValue Start value of the animation curve
  26768. * @param endValue End value of the animation curve
  26769. * @param gradient Scalar amount to interpolate
  26770. * @returns Interpolated scalar value
  26771. */
  26772. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26773. /**
  26774. * Interpolates a Vector3 cubically
  26775. * @param startValue Start value of the animation curve
  26776. * @param outTangent End tangent of the animation
  26777. * @param endValue End value of the animation curve
  26778. * @param inTangent Start tangent of the animation curve
  26779. * @param gradient Scalar amount to interpolate
  26780. * @returns InterpolatedVector3 value
  26781. */
  26782. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26783. /**
  26784. * Interpolates a Vector2 linearly
  26785. * @param startValue Start value of the animation curve
  26786. * @param endValue End value of the animation curve
  26787. * @param gradient Scalar amount to interpolate
  26788. * @returns Interpolated Vector2 value
  26789. */
  26790. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26791. /**
  26792. * Interpolates a Vector2 cubically
  26793. * @param startValue Start value of the animation curve
  26794. * @param outTangent End tangent of the animation
  26795. * @param endValue End value of the animation curve
  26796. * @param inTangent Start tangent of the animation curve
  26797. * @param gradient Scalar amount to interpolate
  26798. * @returns Interpolated Vector2 value
  26799. */
  26800. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26801. /**
  26802. * Interpolates a size linearly
  26803. * @param startValue Start value of the animation curve
  26804. * @param endValue End value of the animation curve
  26805. * @param gradient Scalar amount to interpolate
  26806. * @returns Interpolated Size value
  26807. */
  26808. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26809. /**
  26810. * Interpolates a Color3 linearly
  26811. * @param startValue Start value of the animation curve
  26812. * @param endValue End value of the animation curve
  26813. * @param gradient Scalar amount to interpolate
  26814. * @returns Interpolated Color3 value
  26815. */
  26816. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26817. /**
  26818. * @hidden Internal use only
  26819. */
  26820. _getKeyValue(value: any): any;
  26821. /**
  26822. * @hidden Internal use only
  26823. */
  26824. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26825. /**
  26826. * Defines the function to use to interpolate matrices
  26827. * @param startValue defines the start matrix
  26828. * @param endValue defines the end matrix
  26829. * @param gradient defines the gradient between both matrices
  26830. * @param result defines an optional target matrix where to store the interpolation
  26831. * @returns the interpolated matrix
  26832. */
  26833. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26834. /**
  26835. * Makes a copy of the animation
  26836. * @returns Cloned animation
  26837. */
  26838. clone(): Animation;
  26839. /**
  26840. * Sets the key frames of the animation
  26841. * @param values The animation key frames to set
  26842. */
  26843. setKeys(values: Array<IAnimationKey>): void;
  26844. /**
  26845. * Serializes the animation to an object
  26846. * @returns Serialized object
  26847. */
  26848. serialize(): any;
  26849. /**
  26850. * Float animation type
  26851. */
  26852. private static _ANIMATIONTYPE_FLOAT;
  26853. /**
  26854. * Vector3 animation type
  26855. */
  26856. private static _ANIMATIONTYPE_VECTOR3;
  26857. /**
  26858. * Quaternion animation type
  26859. */
  26860. private static _ANIMATIONTYPE_QUATERNION;
  26861. /**
  26862. * Matrix animation type
  26863. */
  26864. private static _ANIMATIONTYPE_MATRIX;
  26865. /**
  26866. * Color3 animation type
  26867. */
  26868. private static _ANIMATIONTYPE_COLOR3;
  26869. /**
  26870. * Vector2 animation type
  26871. */
  26872. private static _ANIMATIONTYPE_VECTOR2;
  26873. /**
  26874. * Size animation type
  26875. */
  26876. private static _ANIMATIONTYPE_SIZE;
  26877. /**
  26878. * Relative Loop Mode
  26879. */
  26880. private static _ANIMATIONLOOPMODE_RELATIVE;
  26881. /**
  26882. * Cycle Loop Mode
  26883. */
  26884. private static _ANIMATIONLOOPMODE_CYCLE;
  26885. /**
  26886. * Constant Loop Mode
  26887. */
  26888. private static _ANIMATIONLOOPMODE_CONSTANT;
  26889. /**
  26890. * Get the float animation type
  26891. */
  26892. static readonly ANIMATIONTYPE_FLOAT: number;
  26893. /**
  26894. * Get the Vector3 animation type
  26895. */
  26896. static readonly ANIMATIONTYPE_VECTOR3: number;
  26897. /**
  26898. * Get the Vector2 animation type
  26899. */
  26900. static readonly ANIMATIONTYPE_VECTOR2: number;
  26901. /**
  26902. * Get the Size animation type
  26903. */
  26904. static readonly ANIMATIONTYPE_SIZE: number;
  26905. /**
  26906. * Get the Quaternion animation type
  26907. */
  26908. static readonly ANIMATIONTYPE_QUATERNION: number;
  26909. /**
  26910. * Get the Matrix animation type
  26911. */
  26912. static readonly ANIMATIONTYPE_MATRIX: number;
  26913. /**
  26914. * Get the Color3 animation type
  26915. */
  26916. static readonly ANIMATIONTYPE_COLOR3: number;
  26917. /**
  26918. * Get the Relative Loop Mode
  26919. */
  26920. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26921. /**
  26922. * Get the Cycle Loop Mode
  26923. */
  26924. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26925. /**
  26926. * Get the Constant Loop Mode
  26927. */
  26928. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26929. /** @hidden */
  26930. static _UniversalLerp(left: any, right: any, amount: number): any;
  26931. /**
  26932. * Parses an animation object and creates an animation
  26933. * @param parsedAnimation Parsed animation object
  26934. * @returns Animation object
  26935. */
  26936. static Parse(parsedAnimation: any): Animation;
  26937. /**
  26938. * Appends the serialized animations from the source animations
  26939. * @param source Source containing the animations
  26940. * @param destination Target to store the animations
  26941. */
  26942. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26943. }
  26944. }
  26945. declare module "babylonjs/Materials/Textures/baseTexture" {
  26946. import { Observable } from "babylonjs/Misc/observable";
  26947. import { IAnimatable } from "babylonjs/Misc/tools";
  26948. import { Nullable } from "babylonjs/types";
  26949. import { Scene } from "babylonjs/scene";
  26950. import { Matrix, ISize } from "babylonjs/Maths/math";
  26951. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26952. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26953. /**
  26954. * Base class of all the textures in babylon.
  26955. * It groups all the common properties the materials, post process, lights... might need
  26956. * in order to make a correct use of the texture.
  26957. */
  26958. export class BaseTexture implements IAnimatable {
  26959. /**
  26960. * Default anisotropic filtering level for the application.
  26961. * It is set to 4 as a good tradeoff between perf and quality.
  26962. */
  26963. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26964. /**
  26965. * Gets or sets the unique id of the texture
  26966. */
  26967. uniqueId: number;
  26968. /**
  26969. * Define the name of the texture.
  26970. */
  26971. name: string;
  26972. /**
  26973. * Gets or sets an object used to store user defined information.
  26974. */
  26975. metadata: any;
  26976. /**
  26977. * For internal use only. Please do not use.
  26978. */
  26979. reservedDataStore: any;
  26980. private _hasAlpha;
  26981. /**
  26982. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26983. */
  26984. hasAlpha: boolean;
  26985. /**
  26986. * Defines if the alpha value should be determined via the rgb values.
  26987. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26988. */
  26989. getAlphaFromRGB: boolean;
  26990. /**
  26991. * Intensity or strength of the texture.
  26992. * It is commonly used by materials to fine tune the intensity of the texture
  26993. */
  26994. level: number;
  26995. /**
  26996. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26997. * This is part of the texture as textures usually maps to one uv set.
  26998. */
  26999. coordinatesIndex: number;
  27000. private _coordinatesMode;
  27001. /**
  27002. * How a texture is mapped.
  27003. *
  27004. * | Value | Type | Description |
  27005. * | ----- | ----------------------------------- | ----------- |
  27006. * | 0 | EXPLICIT_MODE | |
  27007. * | 1 | SPHERICAL_MODE | |
  27008. * | 2 | PLANAR_MODE | |
  27009. * | 3 | CUBIC_MODE | |
  27010. * | 4 | PROJECTION_MODE | |
  27011. * | 5 | SKYBOX_MODE | |
  27012. * | 6 | INVCUBIC_MODE | |
  27013. * | 7 | EQUIRECTANGULAR_MODE | |
  27014. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27015. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27016. */
  27017. coordinatesMode: number;
  27018. /**
  27019. * | Value | Type | Description |
  27020. * | ----- | ------------------ | ----------- |
  27021. * | 0 | CLAMP_ADDRESSMODE | |
  27022. * | 1 | WRAP_ADDRESSMODE | |
  27023. * | 2 | MIRROR_ADDRESSMODE | |
  27024. */
  27025. wrapU: number;
  27026. /**
  27027. * | Value | Type | Description |
  27028. * | ----- | ------------------ | ----------- |
  27029. * | 0 | CLAMP_ADDRESSMODE | |
  27030. * | 1 | WRAP_ADDRESSMODE | |
  27031. * | 2 | MIRROR_ADDRESSMODE | |
  27032. */
  27033. wrapV: number;
  27034. /**
  27035. * | Value | Type | Description |
  27036. * | ----- | ------------------ | ----------- |
  27037. * | 0 | CLAMP_ADDRESSMODE | |
  27038. * | 1 | WRAP_ADDRESSMODE | |
  27039. * | 2 | MIRROR_ADDRESSMODE | |
  27040. */
  27041. wrapR: number;
  27042. /**
  27043. * With compliant hardware and browser (supporting anisotropic filtering)
  27044. * this defines the level of anisotropic filtering in the texture.
  27045. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27046. */
  27047. anisotropicFilteringLevel: number;
  27048. /**
  27049. * Define if the texture is a cube texture or if false a 2d texture.
  27050. */
  27051. isCube: boolean;
  27052. /**
  27053. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27054. */
  27055. is3D: boolean;
  27056. /**
  27057. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27058. * HDR texture are usually stored in linear space.
  27059. * This only impacts the PBR and Background materials
  27060. */
  27061. gammaSpace: boolean;
  27062. /**
  27063. * Gets whether or not the texture contains RGBD data.
  27064. */
  27065. readonly isRGBD: boolean;
  27066. /**
  27067. * Is Z inverted in the texture (useful in a cube texture).
  27068. */
  27069. invertZ: boolean;
  27070. /**
  27071. * Are mip maps generated for this texture or not.
  27072. */
  27073. readonly noMipmap: boolean;
  27074. /**
  27075. * @hidden
  27076. */
  27077. lodLevelInAlpha: boolean;
  27078. /**
  27079. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27080. */
  27081. lodGenerationOffset: number;
  27082. /**
  27083. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27084. */
  27085. lodGenerationScale: number;
  27086. /**
  27087. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27088. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27089. * average roughness values.
  27090. */
  27091. linearSpecularLOD: boolean;
  27092. /**
  27093. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27094. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27095. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27096. */
  27097. irradianceTexture: Nullable<BaseTexture>;
  27098. /**
  27099. * Define if the texture is a render target.
  27100. */
  27101. isRenderTarget: boolean;
  27102. /**
  27103. * Define the unique id of the texture in the scene.
  27104. */
  27105. readonly uid: string;
  27106. /**
  27107. * Return a string representation of the texture.
  27108. * @returns the texture as a string
  27109. */
  27110. toString(): string;
  27111. /**
  27112. * Get the class name of the texture.
  27113. * @returns "BaseTexture"
  27114. */
  27115. getClassName(): string;
  27116. /**
  27117. * Define the list of animation attached to the texture.
  27118. */
  27119. animations: import("babylonjs/Animations/animation").Animation[];
  27120. /**
  27121. * An event triggered when the texture is disposed.
  27122. */
  27123. onDisposeObservable: Observable<BaseTexture>;
  27124. private _onDisposeObserver;
  27125. /**
  27126. * Callback triggered when the texture has been disposed.
  27127. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27128. */
  27129. onDispose: () => void;
  27130. /**
  27131. * Define the current state of the loading sequence when in delayed load mode.
  27132. */
  27133. delayLoadState: number;
  27134. private _scene;
  27135. /** @hidden */
  27136. _texture: Nullable<InternalTexture>;
  27137. private _uid;
  27138. /**
  27139. * Define if the texture is preventinga material to render or not.
  27140. * If not and the texture is not ready, the engine will use a default black texture instead.
  27141. */
  27142. readonly isBlocking: boolean;
  27143. /**
  27144. * Instantiates a new BaseTexture.
  27145. * Base class of all the textures in babylon.
  27146. * It groups all the common properties the materials, post process, lights... might need
  27147. * in order to make a correct use of the texture.
  27148. * @param scene Define the scene the texture blongs to
  27149. */
  27150. constructor(scene: Nullable<Scene>);
  27151. /**
  27152. * Get the scene the texture belongs to.
  27153. * @returns the scene or null if undefined
  27154. */
  27155. getScene(): Nullable<Scene>;
  27156. /**
  27157. * Get the texture transform matrix used to offset tile the texture for istance.
  27158. * @returns the transformation matrix
  27159. */
  27160. getTextureMatrix(): Matrix;
  27161. /**
  27162. * Get the texture reflection matrix used to rotate/transform the reflection.
  27163. * @returns the reflection matrix
  27164. */
  27165. getReflectionTextureMatrix(): Matrix;
  27166. /**
  27167. * Get the underlying lower level texture from Babylon.
  27168. * @returns the insternal texture
  27169. */
  27170. getInternalTexture(): Nullable<InternalTexture>;
  27171. /**
  27172. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27173. * @returns true if ready or not blocking
  27174. */
  27175. isReadyOrNotBlocking(): boolean;
  27176. /**
  27177. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27178. * @returns true if fully ready
  27179. */
  27180. isReady(): boolean;
  27181. private _cachedSize;
  27182. /**
  27183. * Get the size of the texture.
  27184. * @returns the texture size.
  27185. */
  27186. getSize(): ISize;
  27187. /**
  27188. * Get the base size of the texture.
  27189. * It can be different from the size if the texture has been resized for POT for instance
  27190. * @returns the base size
  27191. */
  27192. getBaseSize(): ISize;
  27193. /**
  27194. * Update the sampling mode of the texture.
  27195. * Default is Trilinear mode.
  27196. *
  27197. * | Value | Type | Description |
  27198. * | ----- | ------------------ | ----------- |
  27199. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27200. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27201. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27202. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27203. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27204. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27205. * | 7 | NEAREST_LINEAR | |
  27206. * | 8 | NEAREST_NEAREST | |
  27207. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27208. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27209. * | 11 | LINEAR_LINEAR | |
  27210. * | 12 | LINEAR_NEAREST | |
  27211. *
  27212. * > _mag_: magnification filter (close to the viewer)
  27213. * > _min_: minification filter (far from the viewer)
  27214. * > _mip_: filter used between mip map levels
  27215. *@param samplingMode Define the new sampling mode of the texture
  27216. */
  27217. updateSamplingMode(samplingMode: number): void;
  27218. /**
  27219. * Scales the texture if is `canRescale()`
  27220. * @param ratio the resize factor we want to use to rescale
  27221. */
  27222. scale(ratio: number): void;
  27223. /**
  27224. * Get if the texture can rescale.
  27225. */
  27226. readonly canRescale: boolean;
  27227. /** @hidden */
  27228. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27229. /** @hidden */
  27230. _rebuild(): void;
  27231. /**
  27232. * Triggers the load sequence in delayed load mode.
  27233. */
  27234. delayLoad(): void;
  27235. /**
  27236. * Clones the texture.
  27237. * @returns the cloned texture
  27238. */
  27239. clone(): Nullable<BaseTexture>;
  27240. /**
  27241. * Get the texture underlying type (INT, FLOAT...)
  27242. */
  27243. readonly textureType: number;
  27244. /**
  27245. * Get the texture underlying format (RGB, RGBA...)
  27246. */
  27247. readonly textureFormat: number;
  27248. /**
  27249. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27250. * This will returns an RGBA array buffer containing either in values (0-255) or
  27251. * float values (0-1) depending of the underlying buffer type.
  27252. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27253. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27254. * @param buffer defines a user defined buffer to fill with data (can be null)
  27255. * @returns The Array buffer containing the pixels data.
  27256. */
  27257. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27258. /**
  27259. * Release and destroy the underlying lower level texture aka internalTexture.
  27260. */
  27261. releaseInternalTexture(): void;
  27262. /**
  27263. * Get the polynomial representation of the texture data.
  27264. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27265. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27266. */
  27267. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27268. /** @hidden */
  27269. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27270. /** @hidden */
  27271. readonly _lodTextureMid: Nullable<BaseTexture>;
  27272. /** @hidden */
  27273. readonly _lodTextureLow: Nullable<BaseTexture>;
  27274. /**
  27275. * Dispose the texture and release its associated resources.
  27276. */
  27277. dispose(): void;
  27278. /**
  27279. * Serialize the texture into a JSON representation that can be parsed later on.
  27280. * @returns the JSON representation of the texture
  27281. */
  27282. serialize(): any;
  27283. /**
  27284. * Helper function to be called back once a list of texture contains only ready textures.
  27285. * @param textures Define the list of textures to wait for
  27286. * @param callback Define the callback triggered once the entire list will be ready
  27287. */
  27288. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27289. }
  27290. }
  27291. declare module "babylonjs/Materials/uniformBuffer" {
  27292. import { Nullable, FloatArray } from "babylonjs/types";
  27293. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27294. import { Engine } from "babylonjs/Engines/engine";
  27295. import { Effect } from "babylonjs/Materials/effect";
  27296. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27297. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27298. /**
  27299. * Uniform buffer objects.
  27300. *
  27301. * Handles blocks of uniform on the GPU.
  27302. *
  27303. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27304. *
  27305. * For more information, please refer to :
  27306. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27307. */
  27308. export class UniformBuffer {
  27309. private _engine;
  27310. private _buffer;
  27311. private _data;
  27312. private _bufferData;
  27313. private _dynamic?;
  27314. private _uniformLocations;
  27315. private _uniformSizes;
  27316. private _uniformLocationPointer;
  27317. private _needSync;
  27318. private _noUBO;
  27319. private _currentEffect;
  27320. private static _MAX_UNIFORM_SIZE;
  27321. private static _tempBuffer;
  27322. /**
  27323. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27324. * This is dynamic to allow compat with webgl 1 and 2.
  27325. * You will need to pass the name of the uniform as well as the value.
  27326. */
  27327. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27328. /**
  27329. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27330. * This is dynamic to allow compat with webgl 1 and 2.
  27331. * You will need to pass the name of the uniform as well as the value.
  27332. */
  27333. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27334. /**
  27335. * Lambda to Update a single float in a uniform buffer.
  27336. * This is dynamic to allow compat with webgl 1 and 2.
  27337. * You will need to pass the name of the uniform as well as the value.
  27338. */
  27339. updateFloat: (name: string, x: number) => void;
  27340. /**
  27341. * Lambda to Update a vec2 of float in a uniform buffer.
  27342. * This is dynamic to allow compat with webgl 1 and 2.
  27343. * You will need to pass the name of the uniform as well as the value.
  27344. */
  27345. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27346. /**
  27347. * Lambda to Update a vec3 of float in a uniform buffer.
  27348. * This is dynamic to allow compat with webgl 1 and 2.
  27349. * You will need to pass the name of the uniform as well as the value.
  27350. */
  27351. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27352. /**
  27353. * Lambda to Update a vec4 of float in a uniform buffer.
  27354. * This is dynamic to allow compat with webgl 1 and 2.
  27355. * You will need to pass the name of the uniform as well as the value.
  27356. */
  27357. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27358. /**
  27359. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27360. * This is dynamic to allow compat with webgl 1 and 2.
  27361. * You will need to pass the name of the uniform as well as the value.
  27362. */
  27363. updateMatrix: (name: string, mat: Matrix) => void;
  27364. /**
  27365. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27366. * This is dynamic to allow compat with webgl 1 and 2.
  27367. * You will need to pass the name of the uniform as well as the value.
  27368. */
  27369. updateVector3: (name: string, vector: Vector3) => void;
  27370. /**
  27371. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27372. * This is dynamic to allow compat with webgl 1 and 2.
  27373. * You will need to pass the name of the uniform as well as the value.
  27374. */
  27375. updateVector4: (name: string, vector: Vector4) => void;
  27376. /**
  27377. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27378. * This is dynamic to allow compat with webgl 1 and 2.
  27379. * You will need to pass the name of the uniform as well as the value.
  27380. */
  27381. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27382. /**
  27383. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27384. * This is dynamic to allow compat with webgl 1 and 2.
  27385. * You will need to pass the name of the uniform as well as the value.
  27386. */
  27387. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27388. /**
  27389. * Instantiates a new Uniform buffer objects.
  27390. *
  27391. * Handles blocks of uniform on the GPU.
  27392. *
  27393. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27394. *
  27395. * For more information, please refer to :
  27396. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27397. * @param engine Define the engine the buffer is associated with
  27398. * @param data Define the data contained in the buffer
  27399. * @param dynamic Define if the buffer is updatable
  27400. */
  27401. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27402. /**
  27403. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27404. * or just falling back on setUniformXXX calls.
  27405. */
  27406. readonly useUbo: boolean;
  27407. /**
  27408. * Indicates if the WebGL underlying uniform buffer is in sync
  27409. * with the javascript cache data.
  27410. */
  27411. readonly isSync: boolean;
  27412. /**
  27413. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27414. * Also, a dynamic UniformBuffer will disable cache verification and always
  27415. * update the underlying WebGL uniform buffer to the GPU.
  27416. * @returns if Dynamic, otherwise false
  27417. */
  27418. isDynamic(): boolean;
  27419. /**
  27420. * The data cache on JS side.
  27421. * @returns the underlying data as a float array
  27422. */
  27423. getData(): Float32Array;
  27424. /**
  27425. * The underlying WebGL Uniform buffer.
  27426. * @returns the webgl buffer
  27427. */
  27428. getBuffer(): Nullable<DataBuffer>;
  27429. /**
  27430. * std140 layout specifies how to align data within an UBO structure.
  27431. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27432. * for specs.
  27433. */
  27434. private _fillAlignment;
  27435. /**
  27436. * Adds an uniform in the buffer.
  27437. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27438. * for the layout to be correct !
  27439. * @param name Name of the uniform, as used in the uniform block in the shader.
  27440. * @param size Data size, or data directly.
  27441. */
  27442. addUniform(name: string, size: number | number[]): void;
  27443. /**
  27444. * Adds a Matrix 4x4 to the uniform buffer.
  27445. * @param name Name of the uniform, as used in the uniform block in the shader.
  27446. * @param mat A 4x4 matrix.
  27447. */
  27448. addMatrix(name: string, mat: Matrix): void;
  27449. /**
  27450. * Adds a vec2 to the uniform buffer.
  27451. * @param name Name of the uniform, as used in the uniform block in the shader.
  27452. * @param x Define the x component value of the vec2
  27453. * @param y Define the y component value of the vec2
  27454. */
  27455. addFloat2(name: string, x: number, y: number): void;
  27456. /**
  27457. * Adds a vec3 to the uniform buffer.
  27458. * @param name Name of the uniform, as used in the uniform block in the shader.
  27459. * @param x Define the x component value of the vec3
  27460. * @param y Define the y component value of the vec3
  27461. * @param z Define the z component value of the vec3
  27462. */
  27463. addFloat3(name: string, x: number, y: number, z: number): void;
  27464. /**
  27465. * Adds a vec3 to the uniform buffer.
  27466. * @param name Name of the uniform, as used in the uniform block in the shader.
  27467. * @param color Define the vec3 from a Color
  27468. */
  27469. addColor3(name: string, color: Color3): void;
  27470. /**
  27471. * Adds a vec4 to the uniform buffer.
  27472. * @param name Name of the uniform, as used in the uniform block in the shader.
  27473. * @param color Define the rgb components from a Color
  27474. * @param alpha Define the a component of the vec4
  27475. */
  27476. addColor4(name: string, color: Color3, alpha: number): void;
  27477. /**
  27478. * Adds a vec3 to the uniform buffer.
  27479. * @param name Name of the uniform, as used in the uniform block in the shader.
  27480. * @param vector Define the vec3 components from a Vector
  27481. */
  27482. addVector3(name: string, vector: Vector3): void;
  27483. /**
  27484. * Adds a Matrix 3x3 to the uniform buffer.
  27485. * @param name Name of the uniform, as used in the uniform block in the shader.
  27486. */
  27487. addMatrix3x3(name: string): void;
  27488. /**
  27489. * Adds a Matrix 2x2 to the uniform buffer.
  27490. * @param name Name of the uniform, as used in the uniform block in the shader.
  27491. */
  27492. addMatrix2x2(name: string): void;
  27493. /**
  27494. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27495. */
  27496. create(): void;
  27497. /** @hidden */
  27498. _rebuild(): void;
  27499. /**
  27500. * Updates the WebGL Uniform Buffer on the GPU.
  27501. * If the `dynamic` flag is set to true, no cache comparison is done.
  27502. * Otherwise, the buffer will be updated only if the cache differs.
  27503. */
  27504. update(): void;
  27505. /**
  27506. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27507. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27508. * @param data Define the flattened data
  27509. * @param size Define the size of the data.
  27510. */
  27511. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27512. private _updateMatrix3x3ForUniform;
  27513. private _updateMatrix3x3ForEffect;
  27514. private _updateMatrix2x2ForEffect;
  27515. private _updateMatrix2x2ForUniform;
  27516. private _updateFloatForEffect;
  27517. private _updateFloatForUniform;
  27518. private _updateFloat2ForEffect;
  27519. private _updateFloat2ForUniform;
  27520. private _updateFloat3ForEffect;
  27521. private _updateFloat3ForUniform;
  27522. private _updateFloat4ForEffect;
  27523. private _updateFloat4ForUniform;
  27524. private _updateMatrixForEffect;
  27525. private _updateMatrixForUniform;
  27526. private _updateVector3ForEffect;
  27527. private _updateVector3ForUniform;
  27528. private _updateVector4ForEffect;
  27529. private _updateVector4ForUniform;
  27530. private _updateColor3ForEffect;
  27531. private _updateColor3ForUniform;
  27532. private _updateColor4ForEffect;
  27533. private _updateColor4ForUniform;
  27534. /**
  27535. * Sets a sampler uniform on the effect.
  27536. * @param name Define the name of the sampler.
  27537. * @param texture Define the texture to set in the sampler
  27538. */
  27539. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27540. /**
  27541. * Directly updates the value of the uniform in the cache AND on the GPU.
  27542. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27543. * @param data Define the flattened data
  27544. */
  27545. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27546. /**
  27547. * Binds this uniform buffer to an effect.
  27548. * @param effect Define the effect to bind the buffer to
  27549. * @param name Name of the uniform block in the shader.
  27550. */
  27551. bindToEffect(effect: Effect, name: string): void;
  27552. /**
  27553. * Disposes the uniform buffer.
  27554. */
  27555. dispose(): void;
  27556. }
  27557. }
  27558. declare module "babylonjs/Audio/analyser" {
  27559. import { Scene } from "babylonjs/scene";
  27560. /**
  27561. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27562. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27563. */
  27564. export class Analyser {
  27565. /**
  27566. * Gets or sets the smoothing
  27567. * @ignorenaming
  27568. */
  27569. SMOOTHING: number;
  27570. /**
  27571. * Gets or sets the FFT table size
  27572. * @ignorenaming
  27573. */
  27574. FFT_SIZE: number;
  27575. /**
  27576. * Gets or sets the bar graph amplitude
  27577. * @ignorenaming
  27578. */
  27579. BARGRAPHAMPLITUDE: number;
  27580. /**
  27581. * Gets or sets the position of the debug canvas
  27582. * @ignorenaming
  27583. */
  27584. DEBUGCANVASPOS: {
  27585. x: number;
  27586. y: number;
  27587. };
  27588. /**
  27589. * Gets or sets the debug canvas size
  27590. * @ignorenaming
  27591. */
  27592. DEBUGCANVASSIZE: {
  27593. width: number;
  27594. height: number;
  27595. };
  27596. private _byteFreqs;
  27597. private _byteTime;
  27598. private _floatFreqs;
  27599. private _webAudioAnalyser;
  27600. private _debugCanvas;
  27601. private _debugCanvasContext;
  27602. private _scene;
  27603. private _registerFunc;
  27604. private _audioEngine;
  27605. /**
  27606. * Creates a new analyser
  27607. * @param scene defines hosting scene
  27608. */
  27609. constructor(scene: Scene);
  27610. /**
  27611. * Get the number of data values you will have to play with for the visualization
  27612. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27613. * @returns a number
  27614. */
  27615. getFrequencyBinCount(): number;
  27616. /**
  27617. * Gets the current frequency data as a byte array
  27618. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27619. * @returns a Uint8Array
  27620. */
  27621. getByteFrequencyData(): Uint8Array;
  27622. /**
  27623. * Gets the current waveform as a byte array
  27624. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27625. * @returns a Uint8Array
  27626. */
  27627. getByteTimeDomainData(): Uint8Array;
  27628. /**
  27629. * Gets the current frequency data as a float array
  27630. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27631. * @returns a Float32Array
  27632. */
  27633. getFloatFrequencyData(): Float32Array;
  27634. /**
  27635. * Renders the debug canvas
  27636. */
  27637. drawDebugCanvas(): void;
  27638. /**
  27639. * Stops rendering the debug canvas and removes it
  27640. */
  27641. stopDebugCanvas(): void;
  27642. /**
  27643. * Connects two audio nodes
  27644. * @param inputAudioNode defines first node to connect
  27645. * @param outputAudioNode defines second node to connect
  27646. */
  27647. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27648. /**
  27649. * Releases all associated resources
  27650. */
  27651. dispose(): void;
  27652. }
  27653. }
  27654. declare module "babylonjs/Audio/audioEngine" {
  27655. import { IDisposable } from "babylonjs/scene";
  27656. import { Analyser } from "babylonjs/Audio/analyser";
  27657. import { Nullable } from "babylonjs/types";
  27658. import { Observable } from "babylonjs/Misc/observable";
  27659. /**
  27660. * This represents an audio engine and it is responsible
  27661. * to play, synchronize and analyse sounds throughout the application.
  27662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27663. */
  27664. export interface IAudioEngine extends IDisposable {
  27665. /**
  27666. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27667. */
  27668. readonly canUseWebAudio: boolean;
  27669. /**
  27670. * Gets the current AudioContext if available.
  27671. */
  27672. readonly audioContext: Nullable<AudioContext>;
  27673. /**
  27674. * The master gain node defines the global audio volume of your audio engine.
  27675. */
  27676. readonly masterGain: GainNode;
  27677. /**
  27678. * Gets whether or not mp3 are supported by your browser.
  27679. */
  27680. readonly isMP3supported: boolean;
  27681. /**
  27682. * Gets whether or not ogg are supported by your browser.
  27683. */
  27684. readonly isOGGsupported: boolean;
  27685. /**
  27686. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27687. * @ignoreNaming
  27688. */
  27689. WarnedWebAudioUnsupported: boolean;
  27690. /**
  27691. * Defines if the audio engine relies on a custom unlocked button.
  27692. * In this case, the embedded button will not be displayed.
  27693. */
  27694. useCustomUnlockedButton: boolean;
  27695. /**
  27696. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27697. */
  27698. readonly unlocked: boolean;
  27699. /**
  27700. * Event raised when audio has been unlocked on the browser.
  27701. */
  27702. onAudioUnlockedObservable: Observable<AudioEngine>;
  27703. /**
  27704. * Event raised when audio has been locked on the browser.
  27705. */
  27706. onAudioLockedObservable: Observable<AudioEngine>;
  27707. /**
  27708. * Flags the audio engine in Locked state.
  27709. * This happens due to new browser policies preventing audio to autoplay.
  27710. */
  27711. lock(): void;
  27712. /**
  27713. * Unlocks the audio engine once a user action has been done on the dom.
  27714. * This is helpful to resume play once browser policies have been satisfied.
  27715. */
  27716. unlock(): void;
  27717. }
  27718. /**
  27719. * This represents the default audio engine used in babylon.
  27720. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27722. */
  27723. export class AudioEngine implements IAudioEngine {
  27724. private _audioContext;
  27725. private _audioContextInitialized;
  27726. private _muteButton;
  27727. private _hostElement;
  27728. /**
  27729. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27730. */
  27731. canUseWebAudio: boolean;
  27732. /**
  27733. * The master gain node defines the global audio volume of your audio engine.
  27734. */
  27735. masterGain: GainNode;
  27736. /**
  27737. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27738. * @ignoreNaming
  27739. */
  27740. WarnedWebAudioUnsupported: boolean;
  27741. /**
  27742. * Gets whether or not mp3 are supported by your browser.
  27743. */
  27744. isMP3supported: boolean;
  27745. /**
  27746. * Gets whether or not ogg are supported by your browser.
  27747. */
  27748. isOGGsupported: boolean;
  27749. /**
  27750. * Gets whether audio has been unlocked on the device.
  27751. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27752. * a user interaction has happened.
  27753. */
  27754. unlocked: boolean;
  27755. /**
  27756. * Defines if the audio engine relies on a custom unlocked button.
  27757. * In this case, the embedded button will not be displayed.
  27758. */
  27759. useCustomUnlockedButton: boolean;
  27760. /**
  27761. * Event raised when audio has been unlocked on the browser.
  27762. */
  27763. onAudioUnlockedObservable: Observable<AudioEngine>;
  27764. /**
  27765. * Event raised when audio has been locked on the browser.
  27766. */
  27767. onAudioLockedObservable: Observable<AudioEngine>;
  27768. /**
  27769. * Gets the current AudioContext if available.
  27770. */
  27771. readonly audioContext: Nullable<AudioContext>;
  27772. private _connectedAnalyser;
  27773. /**
  27774. * Instantiates a new audio engine.
  27775. *
  27776. * There should be only one per page as some browsers restrict the number
  27777. * of audio contexts you can create.
  27778. * @param hostElement defines the host element where to display the mute icon if necessary
  27779. */
  27780. constructor(hostElement?: Nullable<HTMLElement>);
  27781. /**
  27782. * Flags the audio engine in Locked state.
  27783. * This happens due to new browser policies preventing audio to autoplay.
  27784. */
  27785. lock(): void;
  27786. /**
  27787. * Unlocks the audio engine once a user action has been done on the dom.
  27788. * This is helpful to resume play once browser policies have been satisfied.
  27789. */
  27790. unlock(): void;
  27791. private _resumeAudioContext;
  27792. private _initializeAudioContext;
  27793. private _tryToRun;
  27794. private _triggerRunningState;
  27795. private _triggerSuspendedState;
  27796. private _displayMuteButton;
  27797. private _moveButtonToTopLeft;
  27798. private _onResize;
  27799. private _hideMuteButton;
  27800. /**
  27801. * Destroy and release the resources associated with the audio ccontext.
  27802. */
  27803. dispose(): void;
  27804. /**
  27805. * Gets the global volume sets on the master gain.
  27806. * @returns the global volume if set or -1 otherwise
  27807. */
  27808. getGlobalVolume(): number;
  27809. /**
  27810. * Sets the global volume of your experience (sets on the master gain).
  27811. * @param newVolume Defines the new global volume of the application
  27812. */
  27813. setGlobalVolume(newVolume: number): void;
  27814. /**
  27815. * Connect the audio engine to an audio analyser allowing some amazing
  27816. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27817. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27818. * @param analyser The analyser to connect to the engine
  27819. */
  27820. connectToAnalyser(analyser: Analyser): void;
  27821. }
  27822. }
  27823. declare module "babylonjs/Loading/loadingScreen" {
  27824. /**
  27825. * Interface used to present a loading screen while loading a scene
  27826. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27827. */
  27828. export interface ILoadingScreen {
  27829. /**
  27830. * Function called to display the loading screen
  27831. */
  27832. displayLoadingUI: () => void;
  27833. /**
  27834. * Function called to hide the loading screen
  27835. */
  27836. hideLoadingUI: () => void;
  27837. /**
  27838. * Gets or sets the color to use for the background
  27839. */
  27840. loadingUIBackgroundColor: string;
  27841. /**
  27842. * Gets or sets the text to display while loading
  27843. */
  27844. loadingUIText: string;
  27845. }
  27846. /**
  27847. * Class used for the default loading screen
  27848. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27849. */
  27850. export class DefaultLoadingScreen implements ILoadingScreen {
  27851. private _renderingCanvas;
  27852. private _loadingText;
  27853. private _loadingDivBackgroundColor;
  27854. private _loadingDiv;
  27855. private _loadingTextDiv;
  27856. /** Gets or sets the logo url to use for the default loading screen */
  27857. static DefaultLogoUrl: string;
  27858. /** Gets or sets the spinner url to use for the default loading screen */
  27859. static DefaultSpinnerUrl: string;
  27860. /**
  27861. * Creates a new default loading screen
  27862. * @param _renderingCanvas defines the canvas used to render the scene
  27863. * @param _loadingText defines the default text to display
  27864. * @param _loadingDivBackgroundColor defines the default background color
  27865. */
  27866. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27867. /**
  27868. * Function called to display the loading screen
  27869. */
  27870. displayLoadingUI(): void;
  27871. /**
  27872. * Function called to hide the loading screen
  27873. */
  27874. hideLoadingUI(): void;
  27875. /**
  27876. * Gets or sets the text to display while loading
  27877. */
  27878. loadingUIText: string;
  27879. /**
  27880. * Gets or sets the color to use for the background
  27881. */
  27882. loadingUIBackgroundColor: string;
  27883. private _resizeLoadingUI;
  27884. }
  27885. }
  27886. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27887. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27888. import { Engine } from "babylonjs/Engines/engine";
  27889. import { Nullable } from "babylonjs/types";
  27890. /** @hidden */
  27891. export class WebGLPipelineContext implements IPipelineContext {
  27892. engine: Engine;
  27893. program: Nullable<WebGLProgram>;
  27894. context?: WebGLRenderingContext;
  27895. vertexShader?: WebGLShader;
  27896. fragmentShader?: WebGLShader;
  27897. isParallelCompiled: boolean;
  27898. onCompiled?: () => void;
  27899. transformFeedback?: WebGLTransformFeedback | null;
  27900. readonly isAsync: boolean;
  27901. readonly isReady: boolean;
  27902. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27903. }
  27904. }
  27905. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27906. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27907. /** @hidden */
  27908. export class WebGLDataBuffer extends DataBuffer {
  27909. private _buffer;
  27910. constructor(resource: WebGLBuffer);
  27911. readonly underlyingResource: any;
  27912. }
  27913. }
  27914. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27915. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27916. /** @hidden */
  27917. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27918. attributeProcessor(attribute: string): string;
  27919. varyingProcessor(varying: string, isFragment: boolean): string;
  27920. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27921. }
  27922. }
  27923. declare module "babylonjs/Materials/Textures/videoTexture" {
  27924. import { Observable } from "babylonjs/Misc/observable";
  27925. import { Nullable } from "babylonjs/types";
  27926. import { Scene } from "babylonjs/scene";
  27927. import { Texture } from "babylonjs/Materials/Textures/texture";
  27928. /**
  27929. * Settings for finer control over video usage
  27930. */
  27931. export interface VideoTextureSettings {
  27932. /**
  27933. * Applies `autoplay` to video, if specified
  27934. */
  27935. autoPlay?: boolean;
  27936. /**
  27937. * Applies `loop` to video, if specified
  27938. */
  27939. loop?: boolean;
  27940. /**
  27941. * Automatically updates internal texture from video at every frame in the render loop
  27942. */
  27943. autoUpdateTexture: boolean;
  27944. /**
  27945. * Image src displayed during the video loading or until the user interacts with the video.
  27946. */
  27947. poster?: string;
  27948. }
  27949. /**
  27950. * If you want to display a video in your scene, this is the special texture for that.
  27951. * This special texture works similar to other textures, with the exception of a few parameters.
  27952. * @see https://doc.babylonjs.com/how_to/video_texture
  27953. */
  27954. export class VideoTexture extends Texture {
  27955. /**
  27956. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27957. */
  27958. readonly autoUpdateTexture: boolean;
  27959. /**
  27960. * The video instance used by the texture internally
  27961. */
  27962. readonly video: HTMLVideoElement;
  27963. private _onUserActionRequestedObservable;
  27964. /**
  27965. * Event triggerd when a dom action is required by the user to play the video.
  27966. * This happens due to recent changes in browser policies preventing video to auto start.
  27967. */
  27968. readonly onUserActionRequestedObservable: Observable<Texture>;
  27969. private _generateMipMaps;
  27970. private _engine;
  27971. private _stillImageCaptured;
  27972. private _displayingPosterTexture;
  27973. private _settings;
  27974. private _createInternalTextureOnEvent;
  27975. /**
  27976. * Creates a video texture.
  27977. * If you want to display a video in your scene, this is the special texture for that.
  27978. * This special texture works similar to other textures, with the exception of a few parameters.
  27979. * @see https://doc.babylonjs.com/how_to/video_texture
  27980. * @param name optional name, will detect from video source, if not defined
  27981. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27982. * @param scene is obviously the current scene.
  27983. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27984. * @param invertY is false by default but can be used to invert video on Y axis
  27985. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27986. * @param settings allows finer control over video usage
  27987. */
  27988. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27989. private _getName;
  27990. private _getVideo;
  27991. private _createInternalTexture;
  27992. private reset;
  27993. /**
  27994. * @hidden Internal method to initiate `update`.
  27995. */
  27996. _rebuild(): void;
  27997. /**
  27998. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27999. */
  28000. update(): void;
  28001. /**
  28002. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28003. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28004. */
  28005. updateTexture(isVisible: boolean): void;
  28006. protected _updateInternalTexture: () => void;
  28007. /**
  28008. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28009. * @param url New url.
  28010. */
  28011. updateURL(url: string): void;
  28012. /**
  28013. * Dispose the texture and release its associated resources.
  28014. */
  28015. dispose(): void;
  28016. /**
  28017. * Creates a video texture straight from a stream.
  28018. * @param scene Define the scene the texture should be created in
  28019. * @param stream Define the stream the texture should be created from
  28020. * @returns The created video texture as a promise
  28021. */
  28022. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28023. /**
  28024. * Creates a video texture straight from your WebCam video feed.
  28025. * @param scene Define the scene the texture should be created in
  28026. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28027. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28028. * @returns The created video texture as a promise
  28029. */
  28030. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28031. minWidth: number;
  28032. maxWidth: number;
  28033. minHeight: number;
  28034. maxHeight: number;
  28035. deviceId: string;
  28036. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28037. /**
  28038. * Creates a video texture straight from your WebCam video feed.
  28039. * @param scene Define the scene the texture should be created in
  28040. * @param onReady Define a callback to triggered once the texture will be ready
  28041. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28042. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28043. */
  28044. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28045. minWidth: number;
  28046. maxWidth: number;
  28047. minHeight: number;
  28048. maxHeight: number;
  28049. deviceId: string;
  28050. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28051. }
  28052. }
  28053. declare module "babylonjs/Engines/engine" {
  28054. import { Observable } from "babylonjs/Misc/observable";
  28055. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  28056. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  28057. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  28058. import { Camera } from "babylonjs/Cameras/camera";
  28059. import { Scene } from "babylonjs/scene";
  28060. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  28061. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28062. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28063. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  28064. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  28065. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28066. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28067. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  28068. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  28069. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  28070. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  28071. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  28072. import { WebRequest } from "babylonjs/Misc/webRequest";
  28073. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  28074. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28075. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28076. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  28077. import { Material } from "babylonjs/Materials/material";
  28078. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28079. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28080. /**
  28081. * Interface for attribute information associated with buffer instanciation
  28082. */
  28083. export class InstancingAttributeInfo {
  28084. /**
  28085. * Index/offset of the attribute in the vertex shader
  28086. */
  28087. index: number;
  28088. /**
  28089. * size of the attribute, 1, 2, 3 or 4
  28090. */
  28091. attributeSize: number;
  28092. /**
  28093. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28094. * default is FLOAT
  28095. */
  28096. attribyteType: number;
  28097. /**
  28098. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28099. */
  28100. normalized: boolean;
  28101. /**
  28102. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28103. */
  28104. offset: number;
  28105. /**
  28106. * Name of the GLSL attribute, for debugging purpose only
  28107. */
  28108. attributeName: string;
  28109. }
  28110. /**
  28111. * Define options used to create a depth texture
  28112. */
  28113. export class DepthTextureCreationOptions {
  28114. /** Specifies whether or not a stencil should be allocated in the texture */
  28115. generateStencil?: boolean;
  28116. /** Specifies whether or not bilinear filtering is enable on the texture */
  28117. bilinearFiltering?: boolean;
  28118. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28119. comparisonFunction?: number;
  28120. /** Specifies if the created texture is a cube texture */
  28121. isCube?: boolean;
  28122. }
  28123. /**
  28124. * Class used to describe the capabilities of the engine relatively to the current browser
  28125. */
  28126. export class EngineCapabilities {
  28127. /** Maximum textures units per fragment shader */
  28128. maxTexturesImageUnits: number;
  28129. /** Maximum texture units per vertex shader */
  28130. maxVertexTextureImageUnits: number;
  28131. /** Maximum textures units in the entire pipeline */
  28132. maxCombinedTexturesImageUnits: number;
  28133. /** Maximum texture size */
  28134. maxTextureSize: number;
  28135. /** Maximum cube texture size */
  28136. maxCubemapTextureSize: number;
  28137. /** Maximum render texture size */
  28138. maxRenderTextureSize: number;
  28139. /** Maximum number of vertex attributes */
  28140. maxVertexAttribs: number;
  28141. /** Maximum number of varyings */
  28142. maxVaryingVectors: number;
  28143. /** Maximum number of uniforms per vertex shader */
  28144. maxVertexUniformVectors: number;
  28145. /** Maximum number of uniforms per fragment shader */
  28146. maxFragmentUniformVectors: number;
  28147. /** Defines if standard derivates (dx/dy) are supported */
  28148. standardDerivatives: boolean;
  28149. /** Defines if s3tc texture compression is supported */
  28150. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28151. /** Defines if pvrtc texture compression is supported */
  28152. pvrtc: any;
  28153. /** Defines if etc1 texture compression is supported */
  28154. etc1: any;
  28155. /** Defines if etc2 texture compression is supported */
  28156. etc2: any;
  28157. /** Defines if astc texture compression is supported */
  28158. astc: any;
  28159. /** Defines if float textures are supported */
  28160. textureFloat: boolean;
  28161. /** Defines if vertex array objects are supported */
  28162. vertexArrayObject: boolean;
  28163. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28164. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28165. /** Gets the maximum level of anisotropy supported */
  28166. maxAnisotropy: number;
  28167. /** Defines if instancing is supported */
  28168. instancedArrays: boolean;
  28169. /** Defines if 32 bits indices are supported */
  28170. uintIndices: boolean;
  28171. /** Defines if high precision shaders are supported */
  28172. highPrecisionShaderSupported: boolean;
  28173. /** Defines if depth reading in the fragment shader is supported */
  28174. fragmentDepthSupported: boolean;
  28175. /** Defines if float texture linear filtering is supported*/
  28176. textureFloatLinearFiltering: boolean;
  28177. /** Defines if rendering to float textures is supported */
  28178. textureFloatRender: boolean;
  28179. /** Defines if half float textures are supported*/
  28180. textureHalfFloat: boolean;
  28181. /** Defines if half float texture linear filtering is supported*/
  28182. textureHalfFloatLinearFiltering: boolean;
  28183. /** Defines if rendering to half float textures is supported */
  28184. textureHalfFloatRender: boolean;
  28185. /** Defines if textureLOD shader command is supported */
  28186. textureLOD: boolean;
  28187. /** Defines if draw buffers extension is supported */
  28188. drawBuffersExtension: boolean;
  28189. /** Defines if depth textures are supported */
  28190. depthTextureExtension: boolean;
  28191. /** Defines if float color buffer are supported */
  28192. colorBufferFloat: boolean;
  28193. /** Gets disjoint timer query extension (null if not supported) */
  28194. timerQuery: EXT_disjoint_timer_query;
  28195. /** Defines if timestamp can be used with timer query */
  28196. canUseTimestampForTimerQuery: boolean;
  28197. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28198. multiview: any;
  28199. /** Function used to let the system compiles shaders in background */
  28200. parallelShaderCompile: {
  28201. COMPLETION_STATUS_KHR: number;
  28202. };
  28203. }
  28204. /** Interface defining initialization parameters for Engine class */
  28205. export interface EngineOptions extends WebGLContextAttributes {
  28206. /**
  28207. * Defines if the engine should no exceed a specified device ratio
  28208. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28209. */
  28210. limitDeviceRatio?: number;
  28211. /**
  28212. * Defines if webvr should be enabled automatically
  28213. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28214. */
  28215. autoEnableWebVR?: boolean;
  28216. /**
  28217. * Defines if webgl2 should be turned off even if supported
  28218. * @see http://doc.babylonjs.com/features/webgl2
  28219. */
  28220. disableWebGL2Support?: boolean;
  28221. /**
  28222. * Defines if webaudio should be initialized as well
  28223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28224. */
  28225. audioEngine?: boolean;
  28226. /**
  28227. * Defines if animations should run using a deterministic lock step
  28228. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28229. */
  28230. deterministicLockstep?: boolean;
  28231. /** Defines the maximum steps to use with deterministic lock step mode */
  28232. lockstepMaxSteps?: number;
  28233. /**
  28234. * Defines that engine should ignore context lost events
  28235. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28236. */
  28237. doNotHandleContextLost?: boolean;
  28238. /**
  28239. * Defines that engine should ignore modifying touch action attribute and style
  28240. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28241. */
  28242. doNotHandleTouchAction?: boolean;
  28243. /**
  28244. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28245. */
  28246. useHighPrecisionFloats?: boolean;
  28247. }
  28248. /**
  28249. * Defines the interface used by display changed events
  28250. */
  28251. export interface IDisplayChangedEventArgs {
  28252. /** Gets the vrDisplay object (if any) */
  28253. vrDisplay: Nullable<any>;
  28254. /** Gets a boolean indicating if webVR is supported */
  28255. vrSupported: boolean;
  28256. }
  28257. /**
  28258. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28259. */
  28260. export class Engine {
  28261. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28262. static ExceptionList: ({
  28263. key: string;
  28264. capture: string;
  28265. captureConstraint: number;
  28266. targets: string[];
  28267. } | {
  28268. key: string;
  28269. capture: null;
  28270. captureConstraint: null;
  28271. targets: string[];
  28272. })[];
  28273. /** Gets the list of created engines */
  28274. static readonly Instances: Engine[];
  28275. /**
  28276. * Gets the latest created engine
  28277. */
  28278. static readonly LastCreatedEngine: Nullable<Engine>;
  28279. /**
  28280. * Gets the latest created scene
  28281. */
  28282. static readonly LastCreatedScene: Nullable<Scene>;
  28283. /**
  28284. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28285. * @param flag defines which part of the materials must be marked as dirty
  28286. * @param predicate defines a predicate used to filter which materials should be affected
  28287. */
  28288. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28289. /** @hidden */
  28290. static _TextureLoaders: IInternalTextureLoader[];
  28291. /** Defines that alpha blending is disabled */
  28292. static readonly ALPHA_DISABLE: number;
  28293. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28294. static readonly ALPHA_ADD: number;
  28295. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28296. static readonly ALPHA_COMBINE: number;
  28297. /** Defines that alpha blending to DEST - SRC * DEST */
  28298. static readonly ALPHA_SUBTRACT: number;
  28299. /** Defines that alpha blending to SRC * DEST */
  28300. static readonly ALPHA_MULTIPLY: number;
  28301. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28302. static readonly ALPHA_MAXIMIZED: number;
  28303. /** Defines that alpha blending to SRC + DEST */
  28304. static readonly ALPHA_ONEONE: number;
  28305. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28306. static readonly ALPHA_PREMULTIPLIED: number;
  28307. /**
  28308. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28309. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28310. */
  28311. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28312. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28313. static readonly ALPHA_INTERPOLATE: number;
  28314. /**
  28315. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28316. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28317. */
  28318. static readonly ALPHA_SCREENMODE: number;
  28319. /** Defines that the ressource is not delayed*/
  28320. static readonly DELAYLOADSTATE_NONE: number;
  28321. /** Defines that the ressource was successfully delay loaded */
  28322. static readonly DELAYLOADSTATE_LOADED: number;
  28323. /** Defines that the ressource is currently delay loading */
  28324. static readonly DELAYLOADSTATE_LOADING: number;
  28325. /** Defines that the ressource is delayed and has not started loading */
  28326. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28327. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28328. static readonly NEVER: number;
  28329. /** 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 */
  28330. static readonly ALWAYS: number;
  28331. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28332. static readonly LESS: number;
  28333. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28334. static readonly EQUAL: number;
  28335. /** 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 */
  28336. static readonly LEQUAL: number;
  28337. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28338. static readonly GREATER: number;
  28339. /** 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 */
  28340. static readonly GEQUAL: number;
  28341. /** 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 */
  28342. static readonly NOTEQUAL: number;
  28343. /** Passed to stencilOperation to specify that stencil value must be kept */
  28344. static readonly KEEP: number;
  28345. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28346. static readonly REPLACE: number;
  28347. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28348. static readonly INCR: number;
  28349. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28350. static readonly DECR: number;
  28351. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28352. static readonly INVERT: number;
  28353. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28354. static readonly INCR_WRAP: number;
  28355. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28356. static readonly DECR_WRAP: number;
  28357. /** Texture is not repeating outside of 0..1 UVs */
  28358. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28359. /** Texture is repeating outside of 0..1 UVs */
  28360. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28361. /** Texture is repeating and mirrored */
  28362. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28363. /** ALPHA */
  28364. static readonly TEXTUREFORMAT_ALPHA: number;
  28365. /** LUMINANCE */
  28366. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28367. /** LUMINANCE_ALPHA */
  28368. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28369. /** RGB */
  28370. static readonly TEXTUREFORMAT_RGB: number;
  28371. /** RGBA */
  28372. static readonly TEXTUREFORMAT_RGBA: number;
  28373. /** RED */
  28374. static readonly TEXTUREFORMAT_RED: number;
  28375. /** RED (2nd reference) */
  28376. static readonly TEXTUREFORMAT_R: number;
  28377. /** RG */
  28378. static readonly TEXTUREFORMAT_RG: number;
  28379. /** RED_INTEGER */
  28380. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28381. /** RED_INTEGER (2nd reference) */
  28382. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28383. /** RG_INTEGER */
  28384. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28385. /** RGB_INTEGER */
  28386. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28387. /** RGBA_INTEGER */
  28388. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28389. /** UNSIGNED_BYTE */
  28390. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28391. /** UNSIGNED_BYTE (2nd reference) */
  28392. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28393. /** FLOAT */
  28394. static readonly TEXTURETYPE_FLOAT: number;
  28395. /** HALF_FLOAT */
  28396. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28397. /** BYTE */
  28398. static readonly TEXTURETYPE_BYTE: number;
  28399. /** SHORT */
  28400. static readonly TEXTURETYPE_SHORT: number;
  28401. /** UNSIGNED_SHORT */
  28402. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28403. /** INT */
  28404. static readonly TEXTURETYPE_INT: number;
  28405. /** UNSIGNED_INT */
  28406. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28407. /** UNSIGNED_SHORT_4_4_4_4 */
  28408. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28409. /** UNSIGNED_SHORT_5_5_5_1 */
  28410. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28411. /** UNSIGNED_SHORT_5_6_5 */
  28412. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28413. /** UNSIGNED_INT_2_10_10_10_REV */
  28414. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28415. /** UNSIGNED_INT_24_8 */
  28416. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28417. /** UNSIGNED_INT_10F_11F_11F_REV */
  28418. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28419. /** UNSIGNED_INT_5_9_9_9_REV */
  28420. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28421. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28422. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28423. /** nearest is mag = nearest and min = nearest and mip = linear */
  28424. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28425. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28426. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28427. /** Trilinear is mag = linear and min = linear and mip = linear */
  28428. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28429. /** nearest is mag = nearest and min = nearest and mip = linear */
  28430. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28431. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28432. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28433. /** Trilinear is mag = linear and min = linear and mip = linear */
  28434. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28435. /** mag = nearest and min = nearest and mip = nearest */
  28436. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28437. /** mag = nearest and min = linear and mip = nearest */
  28438. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28439. /** mag = nearest and min = linear and mip = linear */
  28440. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28441. /** mag = nearest and min = linear and mip = none */
  28442. static readonly TEXTURE_NEAREST_LINEAR: number;
  28443. /** mag = nearest and min = nearest and mip = none */
  28444. static readonly TEXTURE_NEAREST_NEAREST: number;
  28445. /** mag = linear and min = nearest and mip = nearest */
  28446. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28447. /** mag = linear and min = nearest and mip = linear */
  28448. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28449. /** mag = linear and min = linear and mip = none */
  28450. static readonly TEXTURE_LINEAR_LINEAR: number;
  28451. /** mag = linear and min = nearest and mip = none */
  28452. static readonly TEXTURE_LINEAR_NEAREST: number;
  28453. /** Explicit coordinates mode */
  28454. static readonly TEXTURE_EXPLICIT_MODE: number;
  28455. /** Spherical coordinates mode */
  28456. static readonly TEXTURE_SPHERICAL_MODE: number;
  28457. /** Planar coordinates mode */
  28458. static readonly TEXTURE_PLANAR_MODE: number;
  28459. /** Cubic coordinates mode */
  28460. static readonly TEXTURE_CUBIC_MODE: number;
  28461. /** Projection coordinates mode */
  28462. static readonly TEXTURE_PROJECTION_MODE: number;
  28463. /** Skybox coordinates mode */
  28464. static readonly TEXTURE_SKYBOX_MODE: number;
  28465. /** Inverse Cubic coordinates mode */
  28466. static readonly TEXTURE_INVCUBIC_MODE: number;
  28467. /** Equirectangular coordinates mode */
  28468. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28469. /** Equirectangular Fixed coordinates mode */
  28470. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28471. /** Equirectangular Fixed Mirrored coordinates mode */
  28472. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28473. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28474. static readonly SCALEMODE_FLOOR: number;
  28475. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28476. static readonly SCALEMODE_NEAREST: number;
  28477. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28478. static readonly SCALEMODE_CEILING: number;
  28479. /**
  28480. * Returns the current npm package of the sdk
  28481. */
  28482. static readonly NpmPackage: string;
  28483. /**
  28484. * Returns the current version of the framework
  28485. */
  28486. static readonly Version: string;
  28487. /**
  28488. * Returns a string describing the current engine
  28489. */
  28490. readonly description: string;
  28491. /**
  28492. * Gets or sets the epsilon value used by collision engine
  28493. */
  28494. static CollisionsEpsilon: number;
  28495. /**
  28496. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28497. */
  28498. static ShadersRepository: string;
  28499. /**
  28500. * Method called to create the default loading screen.
  28501. * This can be overriden in your own app.
  28502. * @param canvas The rendering canvas element
  28503. * @returns The loading screen
  28504. */
  28505. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28506. /**
  28507. * Method called to create the default rescale post process on each engine.
  28508. */
  28509. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28510. /** @hidden */
  28511. _shaderProcessor: IShaderProcessor;
  28512. /**
  28513. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28514. */
  28515. forcePOTTextures: boolean;
  28516. /**
  28517. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28518. */
  28519. isFullscreen: boolean;
  28520. /**
  28521. * Gets a boolean indicating if the pointer is currently locked
  28522. */
  28523. isPointerLock: boolean;
  28524. /**
  28525. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28526. */
  28527. cullBackFaces: boolean;
  28528. /**
  28529. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28530. */
  28531. renderEvenInBackground: boolean;
  28532. /**
  28533. * Gets or sets a boolean indicating that cache can be kept between frames
  28534. */
  28535. preventCacheWipeBetweenFrames: boolean;
  28536. /**
  28537. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28538. **/
  28539. enableOfflineSupport: boolean;
  28540. /**
  28541. * 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)
  28542. **/
  28543. disableManifestCheck: boolean;
  28544. /**
  28545. * Gets the list of created scenes
  28546. */
  28547. scenes: Scene[];
  28548. /**
  28549. * Event raised when a new scene is created
  28550. */
  28551. onNewSceneAddedObservable: Observable<Scene>;
  28552. /**
  28553. * Gets the list of created postprocesses
  28554. */
  28555. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28556. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28557. validateShaderPrograms: boolean;
  28558. /**
  28559. * Observable event triggered each time the rendering canvas is resized
  28560. */
  28561. onResizeObservable: Observable<Engine>;
  28562. /**
  28563. * Observable event triggered each time the canvas loses focus
  28564. */
  28565. onCanvasBlurObservable: Observable<Engine>;
  28566. /**
  28567. * Observable event triggered each time the canvas gains focus
  28568. */
  28569. onCanvasFocusObservable: Observable<Engine>;
  28570. /**
  28571. * Observable event triggered each time the canvas receives pointerout event
  28572. */
  28573. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28574. /**
  28575. * Observable event triggered before each texture is initialized
  28576. */
  28577. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28578. /**
  28579. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28580. */
  28581. disableUniformBuffers: boolean;
  28582. /** @hidden */
  28583. _uniformBuffers: UniformBuffer[];
  28584. /**
  28585. * Gets a boolean indicating that the engine supports uniform buffers
  28586. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28587. */
  28588. readonly supportsUniformBuffers: boolean;
  28589. /**
  28590. * Observable raised when the engine begins a new frame
  28591. */
  28592. onBeginFrameObservable: Observable<Engine>;
  28593. /**
  28594. * If set, will be used to request the next animation frame for the render loop
  28595. */
  28596. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28597. /**
  28598. * Observable raised when the engine ends the current frame
  28599. */
  28600. onEndFrameObservable: Observable<Engine>;
  28601. /**
  28602. * Observable raised when the engine is about to compile a shader
  28603. */
  28604. onBeforeShaderCompilationObservable: Observable<Engine>;
  28605. /**
  28606. * Observable raised when the engine has jsut compiled a shader
  28607. */
  28608. onAfterShaderCompilationObservable: Observable<Engine>;
  28609. /** @hidden */
  28610. _gl: WebGLRenderingContext;
  28611. private _renderingCanvas;
  28612. private _windowIsBackground;
  28613. private _webGLVersion;
  28614. protected _highPrecisionShadersAllowed: boolean;
  28615. /** @hidden */
  28616. readonly _shouldUseHighPrecisionShader: boolean;
  28617. /**
  28618. * Gets a boolean indicating that only power of 2 textures are supported
  28619. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28620. */
  28621. readonly needPOTTextures: boolean;
  28622. /** @hidden */
  28623. _badOS: boolean;
  28624. /** @hidden */
  28625. _badDesktopOS: boolean;
  28626. /**
  28627. * Gets the audio engine
  28628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28629. * @ignorenaming
  28630. */
  28631. static audioEngine: IAudioEngine;
  28632. /**
  28633. * Default AudioEngine factory responsible of creating the Audio Engine.
  28634. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28635. */
  28636. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28637. /**
  28638. * Default offline support factory responsible of creating a tool used to store data locally.
  28639. * By default, this will create a Database object if the workload has been embedded.
  28640. */
  28641. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28642. private _onFocus;
  28643. private _onBlur;
  28644. private _onCanvasPointerOut;
  28645. private _onCanvasBlur;
  28646. private _onCanvasFocus;
  28647. private _onFullscreenChange;
  28648. private _onPointerLockChange;
  28649. private _hardwareScalingLevel;
  28650. /** @hidden */
  28651. _caps: EngineCapabilities;
  28652. private _pointerLockRequested;
  28653. private _isStencilEnable;
  28654. private _colorWrite;
  28655. private _loadingScreen;
  28656. /** @hidden */
  28657. _drawCalls: PerfCounter;
  28658. private _glVersion;
  28659. private _glRenderer;
  28660. private _glVendor;
  28661. private _videoTextureSupported;
  28662. private _renderingQueueLaunched;
  28663. private _activeRenderLoops;
  28664. private _deterministicLockstep;
  28665. private _lockstepMaxSteps;
  28666. /**
  28667. * Observable signaled when a context lost event is raised
  28668. */
  28669. onContextLostObservable: Observable<Engine>;
  28670. /**
  28671. * Observable signaled when a context restored event is raised
  28672. */
  28673. onContextRestoredObservable: Observable<Engine>;
  28674. private _onContextLost;
  28675. private _onContextRestored;
  28676. private _contextWasLost;
  28677. /** @hidden */
  28678. _doNotHandleContextLost: boolean;
  28679. /**
  28680. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28681. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28682. */
  28683. doNotHandleContextLost: boolean;
  28684. private _performanceMonitor;
  28685. private _fps;
  28686. private _deltaTime;
  28687. /**
  28688. * Turn this value on if you want to pause FPS computation when in background
  28689. */
  28690. disablePerformanceMonitorInBackground: boolean;
  28691. /**
  28692. * Gets the performance monitor attached to this engine
  28693. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28694. */
  28695. readonly performanceMonitor: PerformanceMonitor;
  28696. /**
  28697. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28698. */
  28699. disableVertexArrayObjects: boolean;
  28700. /** @hidden */
  28701. protected _depthCullingState: _DepthCullingState;
  28702. /** @hidden */
  28703. protected _stencilState: _StencilState;
  28704. /** @hidden */
  28705. protected _alphaState: _AlphaState;
  28706. /** @hidden */
  28707. protected _alphaMode: number;
  28708. /** @hidden */
  28709. _internalTexturesCache: InternalTexture[];
  28710. /** @hidden */
  28711. protected _activeChannel: number;
  28712. private _currentTextureChannel;
  28713. /** @hidden */
  28714. protected _boundTexturesCache: {
  28715. [key: string]: Nullable<InternalTexture>;
  28716. };
  28717. /** @hidden */
  28718. protected _currentEffect: Nullable<Effect>;
  28719. /** @hidden */
  28720. protected _currentProgram: Nullable<WebGLProgram>;
  28721. private _compiledEffects;
  28722. private _vertexAttribArraysEnabled;
  28723. /** @hidden */
  28724. protected _cachedViewport: Nullable<Viewport>;
  28725. private _cachedVertexArrayObject;
  28726. /** @hidden */
  28727. protected _cachedVertexBuffers: any;
  28728. /** @hidden */
  28729. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28730. /** @hidden */
  28731. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28732. /** @hidden */
  28733. _currentRenderTarget: Nullable<InternalTexture>;
  28734. private _uintIndicesCurrentlySet;
  28735. private _currentBoundBuffer;
  28736. /** @hidden */
  28737. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28738. private _currentBufferPointers;
  28739. private _currentInstanceLocations;
  28740. private _currentInstanceBuffers;
  28741. private _textureUnits;
  28742. /** @hidden */
  28743. _workingCanvas: Nullable<HTMLCanvasElement>;
  28744. /** @hidden */
  28745. _workingContext: Nullable<CanvasRenderingContext2D>;
  28746. private _rescalePostProcess;
  28747. private _dummyFramebuffer;
  28748. private _externalData;
  28749. /** @hidden */
  28750. _bindedRenderFunction: any;
  28751. private _vaoRecordInProgress;
  28752. private _mustWipeVertexAttributes;
  28753. private _emptyTexture;
  28754. private _emptyCubeTexture;
  28755. private _emptyTexture3D;
  28756. /** @hidden */
  28757. _frameHandler: number;
  28758. private _nextFreeTextureSlots;
  28759. private _maxSimultaneousTextures;
  28760. private _activeRequests;
  28761. private _texturesSupported;
  28762. /** @hidden */
  28763. _textureFormatInUse: Nullable<string>;
  28764. /**
  28765. * Gets the list of texture formats supported
  28766. */
  28767. readonly texturesSupported: Array<string>;
  28768. /**
  28769. * Gets the list of texture formats in use
  28770. */
  28771. readonly textureFormatInUse: Nullable<string>;
  28772. /**
  28773. * Gets the current viewport
  28774. */
  28775. readonly currentViewport: Nullable<Viewport>;
  28776. /**
  28777. * Gets the default empty texture
  28778. */
  28779. readonly emptyTexture: InternalTexture;
  28780. /**
  28781. * Gets the default empty 3D texture
  28782. */
  28783. readonly emptyTexture3D: InternalTexture;
  28784. /**
  28785. * Gets the default empty cube texture
  28786. */
  28787. readonly emptyCubeTexture: InternalTexture;
  28788. /**
  28789. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28790. */
  28791. readonly premultipliedAlpha: boolean;
  28792. /**
  28793. * Creates a new engine
  28794. * @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
  28795. * @param antialias defines enable antialiasing (default: false)
  28796. * @param options defines further options to be sent to the getContext() function
  28797. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28798. */
  28799. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28800. /**
  28801. * Initializes a webVR display and starts listening to display change events
  28802. * The onVRDisplayChangedObservable will be notified upon these changes
  28803. * @returns The onVRDisplayChangedObservable
  28804. */
  28805. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28806. /** @hidden */
  28807. _prepareVRComponent(): void;
  28808. /** @hidden */
  28809. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28810. /** @hidden */
  28811. _submitVRFrame(): void;
  28812. /**
  28813. * Call this function to leave webVR mode
  28814. * Will do nothing if webVR is not supported or if there is no webVR device
  28815. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28816. */
  28817. disableVR(): void;
  28818. /**
  28819. * Gets a boolean indicating that the system is in VR mode and is presenting
  28820. * @returns true if VR mode is engaged
  28821. */
  28822. isVRPresenting(): boolean;
  28823. /** @hidden */
  28824. _requestVRFrame(): void;
  28825. private _disableTouchAction;
  28826. private _rebuildInternalTextures;
  28827. private _rebuildEffects;
  28828. /**
  28829. * Gets a boolean indicating if all created effects are ready
  28830. * @returns true if all effects are ready
  28831. */
  28832. areAllEffectsReady(): boolean;
  28833. private _rebuildBuffers;
  28834. private _initGLContext;
  28835. /**
  28836. * Gets version of the current webGL context
  28837. */
  28838. readonly webGLVersion: number;
  28839. /**
  28840. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28841. */
  28842. readonly isStencilEnable: boolean;
  28843. /** @hidden */
  28844. _prepareWorkingCanvas(): void;
  28845. /**
  28846. * Reset the texture cache to empty state
  28847. */
  28848. resetTextureCache(): void;
  28849. /**
  28850. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28851. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28852. * @returns true if engine is in deterministic lock step mode
  28853. */
  28854. isDeterministicLockStep(): boolean;
  28855. /**
  28856. * Gets the max steps when engine is running in deterministic lock step
  28857. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28858. * @returns the max steps
  28859. */
  28860. getLockstepMaxSteps(): number;
  28861. /**
  28862. * Gets an object containing information about the current webGL context
  28863. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28864. */
  28865. getGlInfo(): {
  28866. vendor: string;
  28867. renderer: string;
  28868. version: string;
  28869. };
  28870. /**
  28871. * Gets current aspect ratio
  28872. * @param camera defines the camera to use to get the aspect ratio
  28873. * @param useScreen defines if screen size must be used (or the current render target if any)
  28874. * @returns a number defining the aspect ratio
  28875. */
  28876. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28877. /**
  28878. * Gets current screen aspect ratio
  28879. * @returns a number defining the aspect ratio
  28880. */
  28881. getScreenAspectRatio(): number;
  28882. /**
  28883. * Gets the current render width
  28884. * @param useScreen defines if screen size must be used (or the current render target if any)
  28885. * @returns a number defining the current render width
  28886. */
  28887. getRenderWidth(useScreen?: boolean): number;
  28888. /**
  28889. * Gets the current render height
  28890. * @param useScreen defines if screen size must be used (or the current render target if any)
  28891. * @returns a number defining the current render height
  28892. */
  28893. getRenderHeight(useScreen?: boolean): number;
  28894. /**
  28895. * Gets the HTML canvas attached with the current webGL context
  28896. * @returns a HTML canvas
  28897. */
  28898. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28899. /**
  28900. * Gets the client rect of the HTML canvas attached with the current webGL context
  28901. * @returns a client rectanglee
  28902. */
  28903. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28904. /**
  28905. * Defines the hardware scaling level.
  28906. * By default the hardware scaling level is computed from the window device ratio.
  28907. * 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.
  28908. * @param level defines the level to use
  28909. */
  28910. setHardwareScalingLevel(level: number): void;
  28911. /**
  28912. * Gets the current hardware scaling level.
  28913. * By default the hardware scaling level is computed from the window device ratio.
  28914. * 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.
  28915. * @returns a number indicating the current hardware scaling level
  28916. */
  28917. getHardwareScalingLevel(): number;
  28918. /**
  28919. * Gets the list of loaded textures
  28920. * @returns an array containing all loaded textures
  28921. */
  28922. getLoadedTexturesCache(): InternalTexture[];
  28923. /**
  28924. * Gets the object containing all engine capabilities
  28925. * @returns the EngineCapabilities object
  28926. */
  28927. getCaps(): EngineCapabilities;
  28928. /**
  28929. * Gets the current depth function
  28930. * @returns a number defining the depth function
  28931. */
  28932. getDepthFunction(): Nullable<number>;
  28933. /**
  28934. * Sets the current depth function
  28935. * @param depthFunc defines the function to use
  28936. */
  28937. setDepthFunction(depthFunc: number): void;
  28938. /**
  28939. * Sets the current depth function to GREATER
  28940. */
  28941. setDepthFunctionToGreater(): void;
  28942. /**
  28943. * Sets the current depth function to GEQUAL
  28944. */
  28945. setDepthFunctionToGreaterOrEqual(): void;
  28946. /**
  28947. * Sets the current depth function to LESS
  28948. */
  28949. setDepthFunctionToLess(): void;
  28950. private _cachedStencilBuffer;
  28951. private _cachedStencilFunction;
  28952. private _cachedStencilMask;
  28953. private _cachedStencilOperationPass;
  28954. private _cachedStencilOperationFail;
  28955. private _cachedStencilOperationDepthFail;
  28956. private _cachedStencilReference;
  28957. /**
  28958. * Caches the the state of the stencil buffer
  28959. */
  28960. cacheStencilState(): void;
  28961. /**
  28962. * Restores the state of the stencil buffer
  28963. */
  28964. restoreStencilState(): void;
  28965. /**
  28966. * Sets the current depth function to LEQUAL
  28967. */
  28968. setDepthFunctionToLessOrEqual(): void;
  28969. /**
  28970. * Gets a boolean indicating if stencil buffer is enabled
  28971. * @returns the current stencil buffer state
  28972. */
  28973. getStencilBuffer(): boolean;
  28974. /**
  28975. * Enable or disable the stencil buffer
  28976. * @param enable defines if the stencil buffer must be enabled or disabled
  28977. */
  28978. setStencilBuffer(enable: boolean): void;
  28979. /**
  28980. * Gets the current stencil mask
  28981. * @returns a number defining the new stencil mask to use
  28982. */
  28983. getStencilMask(): number;
  28984. /**
  28985. * Sets the current stencil mask
  28986. * @param mask defines the new stencil mask to use
  28987. */
  28988. setStencilMask(mask: number): void;
  28989. /**
  28990. * Gets the current stencil function
  28991. * @returns a number defining the stencil function to use
  28992. */
  28993. getStencilFunction(): number;
  28994. /**
  28995. * Gets the current stencil reference value
  28996. * @returns a number defining the stencil reference value to use
  28997. */
  28998. getStencilFunctionReference(): number;
  28999. /**
  29000. * Gets the current stencil mask
  29001. * @returns a number defining the stencil mask to use
  29002. */
  29003. getStencilFunctionMask(): number;
  29004. /**
  29005. * Sets the current stencil function
  29006. * @param stencilFunc defines the new stencil function to use
  29007. */
  29008. setStencilFunction(stencilFunc: number): void;
  29009. /**
  29010. * Sets the current stencil reference
  29011. * @param reference defines the new stencil reference to use
  29012. */
  29013. setStencilFunctionReference(reference: number): void;
  29014. /**
  29015. * Sets the current stencil mask
  29016. * @param mask defines the new stencil mask to use
  29017. */
  29018. setStencilFunctionMask(mask: number): void;
  29019. /**
  29020. * Gets the current stencil operation when stencil fails
  29021. * @returns a number defining stencil operation to use when stencil fails
  29022. */
  29023. getStencilOperationFail(): number;
  29024. /**
  29025. * Gets the current stencil operation when depth fails
  29026. * @returns a number defining stencil operation to use when depth fails
  29027. */
  29028. getStencilOperationDepthFail(): number;
  29029. /**
  29030. * Gets the current stencil operation when stencil passes
  29031. * @returns a number defining stencil operation to use when stencil passes
  29032. */
  29033. getStencilOperationPass(): number;
  29034. /**
  29035. * Sets the stencil operation to use when stencil fails
  29036. * @param operation defines the stencil operation to use when stencil fails
  29037. */
  29038. setStencilOperationFail(operation: number): void;
  29039. /**
  29040. * Sets the stencil operation to use when depth fails
  29041. * @param operation defines the stencil operation to use when depth fails
  29042. */
  29043. setStencilOperationDepthFail(operation: number): void;
  29044. /**
  29045. * Sets the stencil operation to use when stencil passes
  29046. * @param operation defines the stencil operation to use when stencil passes
  29047. */
  29048. setStencilOperationPass(operation: number): void;
  29049. /**
  29050. * Sets a boolean indicating if the dithering state is enabled or disabled
  29051. * @param value defines the dithering state
  29052. */
  29053. setDitheringState(value: boolean): void;
  29054. /**
  29055. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29056. * @param value defines the rasterizer state
  29057. */
  29058. setRasterizerState(value: boolean): void;
  29059. /**
  29060. * stop executing a render loop function and remove it from the execution array
  29061. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29062. */
  29063. stopRenderLoop(renderFunction?: () => void): void;
  29064. /** @hidden */
  29065. _renderLoop(): void;
  29066. /**
  29067. * Register and execute a render loop. The engine can have more than one render function
  29068. * @param renderFunction defines the function to continuously execute
  29069. */
  29070. runRenderLoop(renderFunction: () => void): void;
  29071. /**
  29072. * Toggle full screen mode
  29073. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29074. */
  29075. switchFullscreen(requestPointerLock: boolean): void;
  29076. /**
  29077. * Enters full screen mode
  29078. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29079. */
  29080. enterFullscreen(requestPointerLock: boolean): void;
  29081. /**
  29082. * Exits full screen mode
  29083. */
  29084. exitFullscreen(): void;
  29085. /**
  29086. * Enters Pointerlock mode
  29087. */
  29088. enterPointerlock(): void;
  29089. /**
  29090. * Exits Pointerlock mode
  29091. */
  29092. exitPointerlock(): void;
  29093. /**
  29094. * Clear the current render buffer or the current render target (if any is set up)
  29095. * @param color defines the color to use
  29096. * @param backBuffer defines if the back buffer must be cleared
  29097. * @param depth defines if the depth buffer must be cleared
  29098. * @param stencil defines if the stencil buffer must be cleared
  29099. */
  29100. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29101. /**
  29102. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29103. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29104. * @param y defines the y-coordinate of the corner of the clear rectangle
  29105. * @param width defines the width of the clear rectangle
  29106. * @param height defines the height of the clear rectangle
  29107. * @param clearColor defines the clear color
  29108. */
  29109. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  29110. /**
  29111. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29112. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29113. * @param y defines the y-coordinate of the corner of the clear rectangle
  29114. * @param width defines the width of the clear rectangle
  29115. * @param height defines the height of the clear rectangle
  29116. */
  29117. enableScissor(x: number, y: number, width: number, height: number): void;
  29118. /**
  29119. * Disable previously set scissor test rectangle
  29120. */
  29121. disableScissor(): void;
  29122. private _viewportCached;
  29123. /** @hidden */
  29124. _viewport(x: number, y: number, width: number, height: number): void;
  29125. /**
  29126. * Set the WebGL's viewport
  29127. * @param viewport defines the viewport element to be used
  29128. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29129. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29130. */
  29131. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29132. /**
  29133. * Directly set the WebGL Viewport
  29134. * @param x defines the x coordinate of the viewport (in screen space)
  29135. * @param y defines the y coordinate of the viewport (in screen space)
  29136. * @param width defines the width of the viewport (in screen space)
  29137. * @param height defines the height of the viewport (in screen space)
  29138. * @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
  29139. */
  29140. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29141. /**
  29142. * Begin a new frame
  29143. */
  29144. beginFrame(): void;
  29145. /**
  29146. * Enf the current frame
  29147. */
  29148. endFrame(): void;
  29149. /**
  29150. * Resize the view according to the canvas' size
  29151. */
  29152. resize(): void;
  29153. /**
  29154. * Force a specific size of the canvas
  29155. * @param width defines the new canvas' width
  29156. * @param height defines the new canvas' height
  29157. */
  29158. setSize(width: number, height: number): void;
  29159. /**
  29160. * Binds the frame buffer to the specified texture.
  29161. * @param texture The texture to render to or null for the default canvas
  29162. * @param faceIndex The face of the texture to render to in case of cube texture
  29163. * @param requiredWidth The width of the target to render to
  29164. * @param requiredHeight The height of the target to render to
  29165. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29166. * @param depthStencilTexture The depth stencil texture to use to render
  29167. * @param lodLevel defines le lod level to bind to the frame buffer
  29168. */
  29169. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29170. /** @hidden */
  29171. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29172. /**
  29173. * Unbind the current render target texture from the webGL context
  29174. * @param texture defines the render target texture to unbind
  29175. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29176. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29177. */
  29178. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29179. /**
  29180. * Force the mipmap generation for the given render target texture
  29181. * @param texture defines the render target texture to use
  29182. */
  29183. generateMipMapsForCubemap(texture: InternalTexture): void;
  29184. /**
  29185. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29186. */
  29187. flushFramebuffer(): void;
  29188. /**
  29189. * Unbind the current render target and bind the default framebuffer
  29190. */
  29191. restoreDefaultFramebuffer(): void;
  29192. /**
  29193. * Create an uniform buffer
  29194. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29195. * @param elements defines the content of the uniform buffer
  29196. * @returns the webGL uniform buffer
  29197. */
  29198. createUniformBuffer(elements: FloatArray): DataBuffer;
  29199. /**
  29200. * Create a dynamic uniform buffer
  29201. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29202. * @param elements defines the content of the uniform buffer
  29203. * @returns the webGL uniform buffer
  29204. */
  29205. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29206. /**
  29207. * Update an existing uniform buffer
  29208. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29209. * @param uniformBuffer defines the target uniform buffer
  29210. * @param elements defines the content to update
  29211. * @param offset defines the offset in the uniform buffer where update should start
  29212. * @param count defines the size of the data to update
  29213. */
  29214. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29215. private _resetVertexBufferBinding;
  29216. /**
  29217. * Creates a vertex buffer
  29218. * @param data the data for the vertex buffer
  29219. * @returns the new WebGL static buffer
  29220. */
  29221. createVertexBuffer(data: DataArray): DataBuffer;
  29222. /**
  29223. * Creates a dynamic vertex buffer
  29224. * @param data the data for the dynamic vertex buffer
  29225. * @returns the new WebGL dynamic buffer
  29226. */
  29227. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29228. /**
  29229. * Update a dynamic index buffer
  29230. * @param indexBuffer defines the target index buffer
  29231. * @param indices defines the data to update
  29232. * @param offset defines the offset in the target index buffer where update should start
  29233. */
  29234. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29235. /**
  29236. * Updates a dynamic vertex buffer.
  29237. * @param vertexBuffer the vertex buffer to update
  29238. * @param data the data used to update the vertex buffer
  29239. * @param byteOffset the byte offset of the data
  29240. * @param byteLength the byte length of the data
  29241. */
  29242. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29243. private _resetIndexBufferBinding;
  29244. /**
  29245. * Creates a new index buffer
  29246. * @param indices defines the content of the index buffer
  29247. * @param updatable defines if the index buffer must be updatable
  29248. * @returns a new webGL buffer
  29249. */
  29250. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29251. /**
  29252. * Bind a webGL buffer to the webGL context
  29253. * @param buffer defines the buffer to bind
  29254. */
  29255. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29256. /**
  29257. * Bind an uniform buffer to the current webGL context
  29258. * @param buffer defines the buffer to bind
  29259. */
  29260. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29261. /**
  29262. * Bind a buffer to the current webGL context at a given location
  29263. * @param buffer defines the buffer to bind
  29264. * @param location defines the index where to bind the buffer
  29265. */
  29266. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29267. /**
  29268. * Bind a specific block at a given index in a specific shader program
  29269. * @param pipelineContext defines the pipeline context to use
  29270. * @param blockName defines the block name
  29271. * @param index defines the index where to bind the block
  29272. */
  29273. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29274. private bindIndexBuffer;
  29275. private bindBuffer;
  29276. /**
  29277. * update the bound buffer with the given data
  29278. * @param data defines the data to update
  29279. */
  29280. updateArrayBuffer(data: Float32Array): void;
  29281. private _vertexAttribPointer;
  29282. private _bindIndexBufferWithCache;
  29283. private _bindVertexBuffersAttributes;
  29284. /**
  29285. * Records a vertex array object
  29286. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29287. * @param vertexBuffers defines the list of vertex buffers to store
  29288. * @param indexBuffer defines the index buffer to store
  29289. * @param effect defines the effect to store
  29290. * @returns the new vertex array object
  29291. */
  29292. recordVertexArrayObject(vertexBuffers: {
  29293. [key: string]: VertexBuffer;
  29294. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29295. /**
  29296. * Bind a specific vertex array object
  29297. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29298. * @param vertexArrayObject defines the vertex array object to bind
  29299. * @param indexBuffer defines the index buffer to bind
  29300. */
  29301. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29302. /**
  29303. * Bind webGl buffers directly to the webGL context
  29304. * @param vertexBuffer defines the vertex buffer to bind
  29305. * @param indexBuffer defines the index buffer to bind
  29306. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29307. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29308. * @param effect defines the effect associated with the vertex buffer
  29309. */
  29310. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29311. private _unbindVertexArrayObject;
  29312. /**
  29313. * Bind a list of vertex buffers to the webGL context
  29314. * @param vertexBuffers defines the list of vertex buffers to bind
  29315. * @param indexBuffer defines the index buffer to bind
  29316. * @param effect defines the effect associated with the vertex buffers
  29317. */
  29318. bindBuffers(vertexBuffers: {
  29319. [key: string]: Nullable<VertexBuffer>;
  29320. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29321. /**
  29322. * Unbind all instance attributes
  29323. */
  29324. unbindInstanceAttributes(): void;
  29325. /**
  29326. * Release and free the memory of a vertex array object
  29327. * @param vao defines the vertex array object to delete
  29328. */
  29329. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29330. /** @hidden */
  29331. _releaseBuffer(buffer: DataBuffer): boolean;
  29332. /**
  29333. * Creates a webGL buffer to use with instanciation
  29334. * @param capacity defines the size of the buffer
  29335. * @returns the webGL buffer
  29336. */
  29337. createInstancesBuffer(capacity: number): DataBuffer;
  29338. /**
  29339. * Delete a webGL buffer used with instanciation
  29340. * @param buffer defines the webGL buffer to delete
  29341. */
  29342. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29343. /**
  29344. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29345. * @param instancesBuffer defines the webGL buffer to update and bind
  29346. * @param data defines the data to store in the buffer
  29347. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29348. */
  29349. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29350. /**
  29351. * Apply all cached states (depth, culling, stencil and alpha)
  29352. */
  29353. applyStates(): void;
  29354. /**
  29355. * Send a draw order
  29356. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29357. * @param indexStart defines the starting index
  29358. * @param indexCount defines the number of index to draw
  29359. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29360. */
  29361. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29362. /**
  29363. * Draw a list of points
  29364. * @param verticesStart defines the index of first vertex to draw
  29365. * @param verticesCount defines the count of vertices to draw
  29366. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29367. */
  29368. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29369. /**
  29370. * Draw a list of unindexed primitives
  29371. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29372. * @param verticesStart defines the index of first vertex to draw
  29373. * @param verticesCount defines the count of vertices to draw
  29374. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29375. */
  29376. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29377. /**
  29378. * Draw a list of indexed primitives
  29379. * @param fillMode defines the primitive to use
  29380. * @param indexStart defines the starting index
  29381. * @param indexCount defines the number of index to draw
  29382. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29383. */
  29384. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29385. /**
  29386. * Draw a list of unindexed primitives
  29387. * @param fillMode defines the primitive to use
  29388. * @param verticesStart defines the index of first vertex to draw
  29389. * @param verticesCount defines the count of vertices to draw
  29390. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29391. */
  29392. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29393. private _drawMode;
  29394. /** @hidden */
  29395. _releaseEffect(effect: Effect): void;
  29396. /** @hidden */
  29397. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29398. /**
  29399. * Create a new effect (used to store vertex/fragment shaders)
  29400. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29401. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29402. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29403. * @param samplers defines an array of string used to represent textures
  29404. * @param defines defines the string containing the defines to use to compile the shaders
  29405. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29406. * @param onCompiled defines a function to call when the effect creation is successful
  29407. * @param onError defines a function to call when the effect creation has failed
  29408. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29409. * @returns the new Effect
  29410. */
  29411. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29412. private _compileShader;
  29413. private _compileRawShader;
  29414. /**
  29415. * Directly creates a webGL program
  29416. * @param pipelineContext defines the pipeline context to attach to
  29417. * @param vertexCode defines the vertex shader code to use
  29418. * @param fragmentCode defines the fragment shader code to use
  29419. * @param context defines the webGL context to use (if not set, the current one will be used)
  29420. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29421. * @returns the new webGL program
  29422. */
  29423. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29424. /**
  29425. * Creates a webGL program
  29426. * @param pipelineContext defines the pipeline context to attach to
  29427. * @param vertexCode defines the vertex shader code to use
  29428. * @param fragmentCode defines the fragment shader code to use
  29429. * @param defines defines the string containing the defines to use to compile the shaders
  29430. * @param context defines the webGL context to use (if not set, the current one will be used)
  29431. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29432. * @returns the new webGL program
  29433. */
  29434. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29435. /**
  29436. * Creates a new pipeline context
  29437. * @returns the new pipeline
  29438. */
  29439. createPipelineContext(): WebGLPipelineContext;
  29440. private _createShaderProgram;
  29441. private _finalizePipelineContext;
  29442. /** @hidden */
  29443. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29444. /** @hidden */
  29445. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29446. /** @hidden */
  29447. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29448. /**
  29449. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29450. * @param pipelineContext defines the pipeline context to use
  29451. * @param uniformsNames defines the list of uniform names
  29452. * @returns an array of webGL uniform locations
  29453. */
  29454. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29455. /**
  29456. * Gets the lsit of active attributes for a given webGL program
  29457. * @param pipelineContext defines the pipeline context to use
  29458. * @param attributesNames defines the list of attribute names to get
  29459. * @returns an array of indices indicating the offset of each attribute
  29460. */
  29461. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29462. /**
  29463. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29464. * @param effect defines the effect to activate
  29465. */
  29466. enableEffect(effect: Nullable<Effect>): void;
  29467. /**
  29468. * Set the value of an uniform to an array of int32
  29469. * @param uniform defines the webGL uniform location where to store the value
  29470. * @param array defines the array of int32 to store
  29471. */
  29472. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29473. /**
  29474. * Set the value of an uniform to an array of int32 (stored as vec2)
  29475. * @param uniform defines the webGL uniform location where to store the value
  29476. * @param array defines the array of int32 to store
  29477. */
  29478. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29479. /**
  29480. * Set the value of an uniform to an array of int32 (stored as vec3)
  29481. * @param uniform defines the webGL uniform location where to store the value
  29482. * @param array defines the array of int32 to store
  29483. */
  29484. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29485. /**
  29486. * Set the value of an uniform to an array of int32 (stored as vec4)
  29487. * @param uniform defines the webGL uniform location where to store the value
  29488. * @param array defines the array of int32 to store
  29489. */
  29490. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29491. /**
  29492. * Set the value of an uniform to an array of float32
  29493. * @param uniform defines the webGL uniform location where to store the value
  29494. * @param array defines the array of float32 to store
  29495. */
  29496. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29497. /**
  29498. * Set the value of an uniform to an array of float32 (stored as vec2)
  29499. * @param uniform defines the webGL uniform location where to store the value
  29500. * @param array defines the array of float32 to store
  29501. */
  29502. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29503. /**
  29504. * Set the value of an uniform to an array of float32 (stored as vec3)
  29505. * @param uniform defines the webGL uniform location where to store the value
  29506. * @param array defines the array of float32 to store
  29507. */
  29508. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29509. /**
  29510. * Set the value of an uniform to an array of float32 (stored as vec4)
  29511. * @param uniform defines the webGL uniform location where to store the value
  29512. * @param array defines the array of float32 to store
  29513. */
  29514. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29515. /**
  29516. * Set the value of an uniform to an array of number
  29517. * @param uniform defines the webGL uniform location where to store the value
  29518. * @param array defines the array of number to store
  29519. */
  29520. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29521. /**
  29522. * Set the value of an uniform to an array of number (stored as vec2)
  29523. * @param uniform defines the webGL uniform location where to store the value
  29524. * @param array defines the array of number to store
  29525. */
  29526. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29527. /**
  29528. * Set the value of an uniform to an array of number (stored as vec3)
  29529. * @param uniform defines the webGL uniform location where to store the value
  29530. * @param array defines the array of number to store
  29531. */
  29532. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29533. /**
  29534. * Set the value of an uniform to an array of number (stored as vec4)
  29535. * @param uniform defines the webGL uniform location where to store the value
  29536. * @param array defines the array of number to store
  29537. */
  29538. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29539. /**
  29540. * Set the value of an uniform to an array of float32 (stored as matrices)
  29541. * @param uniform defines the webGL uniform location where to store the value
  29542. * @param matrices defines the array of float32 to store
  29543. */
  29544. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29545. /**
  29546. * Set the value of an uniform to a matrix
  29547. * @param uniform defines the webGL uniform location where to store the value
  29548. * @param matrix defines the matrix to store
  29549. */
  29550. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29551. /**
  29552. * Set the value of an uniform to a matrix (3x3)
  29553. * @param uniform defines the webGL uniform location where to store the value
  29554. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29555. */
  29556. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29557. /**
  29558. * Set the value of an uniform to a matrix (2x2)
  29559. * @param uniform defines the webGL uniform location where to store the value
  29560. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29561. */
  29562. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29563. /**
  29564. * Set the value of an uniform to a number (int)
  29565. * @param uniform defines the webGL uniform location where to store the value
  29566. * @param value defines the int number to store
  29567. */
  29568. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29569. /**
  29570. * Set the value of an uniform to a number (float)
  29571. * @param uniform defines the webGL uniform location where to store the value
  29572. * @param value defines the float number to store
  29573. */
  29574. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29575. /**
  29576. * Set the value of an uniform to a vec2
  29577. * @param uniform defines the webGL uniform location where to store the value
  29578. * @param x defines the 1st component of the value
  29579. * @param y defines the 2nd component of the value
  29580. */
  29581. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29582. /**
  29583. * Set the value of an uniform to a vec3
  29584. * @param uniform defines the webGL uniform location where to store the value
  29585. * @param x defines the 1st component of the value
  29586. * @param y defines the 2nd component of the value
  29587. * @param z defines the 3rd component of the value
  29588. */
  29589. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29590. /**
  29591. * Set the value of an uniform to a boolean
  29592. * @param uniform defines the webGL uniform location where to store the value
  29593. * @param bool defines the boolean to store
  29594. */
  29595. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29596. /**
  29597. * Set the value of an uniform to a vec4
  29598. * @param uniform defines the webGL uniform location where to store the value
  29599. * @param x defines the 1st component of the value
  29600. * @param y defines the 2nd component of the value
  29601. * @param z defines the 3rd component of the value
  29602. * @param w defines the 4th component of the value
  29603. */
  29604. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29605. /**
  29606. * Set the value of an uniform to a Color3
  29607. * @param uniform defines the webGL uniform location where to store the value
  29608. * @param color3 defines the color to store
  29609. */
  29610. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29611. /**
  29612. * Set the value of an uniform to a Color3 and an alpha value
  29613. * @param uniform defines the webGL uniform location where to store the value
  29614. * @param color3 defines the color to store
  29615. * @param alpha defines the alpha component to store
  29616. */
  29617. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29618. /**
  29619. * Sets a Color4 on a uniform variable
  29620. * @param uniform defines the uniform location
  29621. * @param color4 defines the value to be set
  29622. */
  29623. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29624. /**
  29625. * Set various states to the webGL context
  29626. * @param culling defines backface culling state
  29627. * @param zOffset defines the value to apply to zOffset (0 by default)
  29628. * @param force defines if states must be applied even if cache is up to date
  29629. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29630. */
  29631. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29632. /**
  29633. * Set the z offset to apply to current rendering
  29634. * @param value defines the offset to apply
  29635. */
  29636. setZOffset(value: number): void;
  29637. /**
  29638. * Gets the current value of the zOffset
  29639. * @returns the current zOffset state
  29640. */
  29641. getZOffset(): number;
  29642. /**
  29643. * Enable or disable depth buffering
  29644. * @param enable defines the state to set
  29645. */
  29646. setDepthBuffer(enable: boolean): void;
  29647. /**
  29648. * Gets a boolean indicating if depth writing is enabled
  29649. * @returns the current depth writing state
  29650. */
  29651. getDepthWrite(): boolean;
  29652. /**
  29653. * Enable or disable depth writing
  29654. * @param enable defines the state to set
  29655. */
  29656. setDepthWrite(enable: boolean): void;
  29657. /**
  29658. * Enable or disable color writing
  29659. * @param enable defines the state to set
  29660. */
  29661. setColorWrite(enable: boolean): void;
  29662. /**
  29663. * Gets a boolean indicating if color writing is enabled
  29664. * @returns the current color writing state
  29665. */
  29666. getColorWrite(): boolean;
  29667. /**
  29668. * Sets alpha constants used by some alpha blending modes
  29669. * @param r defines the red component
  29670. * @param g defines the green component
  29671. * @param b defines the blue component
  29672. * @param a defines the alpha component
  29673. */
  29674. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29675. /**
  29676. * Sets the current alpha mode
  29677. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29678. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29679. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29680. */
  29681. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29682. /**
  29683. * Gets the current alpha mode
  29684. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29685. * @returns the current alpha mode
  29686. */
  29687. getAlphaMode(): number;
  29688. /**
  29689. * Clears the list of texture accessible through engine.
  29690. * This can help preventing texture load conflict due to name collision.
  29691. */
  29692. clearInternalTexturesCache(): void;
  29693. /**
  29694. * Force the entire cache to be cleared
  29695. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29696. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29697. */
  29698. wipeCaches(bruteForce?: boolean): void;
  29699. /**
  29700. * Set the compressed texture format to use, based on the formats you have, and the formats
  29701. * supported by the hardware / browser.
  29702. *
  29703. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29704. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29705. * to API arguments needed to compressed textures. This puts the burden on the container
  29706. * generator to house the arcane code for determining these for current & future formats.
  29707. *
  29708. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29709. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29710. *
  29711. * Note: The result of this call is not taken into account when a texture is base64.
  29712. *
  29713. * @param formatsAvailable defines the list of those format families you have created
  29714. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29715. *
  29716. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29717. * @returns The extension selected.
  29718. */
  29719. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29720. /** @hidden */
  29721. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29722. min: number;
  29723. mag: number;
  29724. };
  29725. /** @hidden */
  29726. _createTexture(): WebGLTexture;
  29727. /**
  29728. * Usually called from Texture.ts.
  29729. * Passed information to create a WebGLTexture
  29730. * @param urlArg defines a value which contains one of the following:
  29731. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29732. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29733. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29734. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29735. * @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)
  29736. * @param scene needed for loading to the correct scene
  29737. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29738. * @param onLoad optional callback to be called upon successful completion
  29739. * @param onError optional callback to be called upon failure
  29740. * @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
  29741. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29742. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29743. * @param forcedExtension defines the extension to use to pick the right loader
  29744. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29745. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29746. */
  29747. 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;
  29748. /**
  29749. * @hidden
  29750. * Rescales a texture
  29751. * @param source input texutre
  29752. * @param destination destination texture
  29753. * @param scene scene to use to render the resize
  29754. * @param internalFormat format to use when resizing
  29755. * @param onComplete callback to be called when resize has completed
  29756. */
  29757. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29758. private _unpackFlipYCached;
  29759. /**
  29760. * In case you are sharing the context with other applications, it might
  29761. * be interested to not cache the unpack flip y state to ensure a consistent
  29762. * value would be set.
  29763. */
  29764. enableUnpackFlipYCached: boolean;
  29765. /** @hidden */
  29766. _unpackFlipY(value: boolean): void;
  29767. /** @hidden */
  29768. _getUnpackAlignement(): number;
  29769. /**
  29770. * Creates a dynamic texture
  29771. * @param width defines the width of the texture
  29772. * @param height defines the height of the texture
  29773. * @param generateMipMaps defines if the engine should generate the mip levels
  29774. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29775. * @returns the dynamic texture inside an InternalTexture
  29776. */
  29777. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29778. /**
  29779. * Update the sampling mode of a given texture
  29780. * @param samplingMode defines the required sampling mode
  29781. * @param texture defines the texture to update
  29782. */
  29783. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29784. /**
  29785. * Update the content of a dynamic texture
  29786. * @param texture defines the texture to update
  29787. * @param canvas defines the canvas containing the source
  29788. * @param invertY defines if data must be stored with Y axis inverted
  29789. * @param premulAlpha defines if alpha is stored as premultiplied
  29790. * @param format defines the format of the data
  29791. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29792. */
  29793. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29794. /**
  29795. * Update a video texture
  29796. * @param texture defines the texture to update
  29797. * @param video defines the video element to use
  29798. * @param invertY defines if data must be stored with Y axis inverted
  29799. */
  29800. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29801. /**
  29802. * Updates a depth texture Comparison Mode and Function.
  29803. * If the comparison Function is equal to 0, the mode will be set to none.
  29804. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29805. * @param texture The texture to set the comparison function for
  29806. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29807. */
  29808. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29809. /** @hidden */
  29810. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29811. width: number;
  29812. height: number;
  29813. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29814. /**
  29815. * Creates a depth stencil texture.
  29816. * This is only available in WebGL 2 or with the depth texture extension available.
  29817. * @param size The size of face edge in the texture.
  29818. * @param options The options defining the texture.
  29819. * @returns The texture
  29820. */
  29821. createDepthStencilTexture(size: number | {
  29822. width: number;
  29823. height: number;
  29824. }, options: DepthTextureCreationOptions): InternalTexture;
  29825. /**
  29826. * Creates a depth stencil texture.
  29827. * This is only available in WebGL 2 or with the depth texture extension available.
  29828. * @param size The size of face edge in the texture.
  29829. * @param options The options defining the texture.
  29830. * @returns The texture
  29831. */
  29832. private _createDepthStencilTexture;
  29833. /**
  29834. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29835. * @param renderTarget The render target to set the frame buffer for
  29836. */
  29837. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29838. /**
  29839. * Creates a new render target texture
  29840. * @param size defines the size of the texture
  29841. * @param options defines the options used to create the texture
  29842. * @returns a new render target texture stored in an InternalTexture
  29843. */
  29844. createRenderTargetTexture(size: number | {
  29845. width: number;
  29846. height: number;
  29847. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29848. /** @hidden */
  29849. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29850. /**
  29851. * Updates the sample count of a render target texture
  29852. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29853. * @param texture defines the texture to update
  29854. * @param samples defines the sample count to set
  29855. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29856. */
  29857. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29858. /** @hidden */
  29859. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29860. /** @hidden */
  29861. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29862. /** @hidden */
  29863. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29864. /** @hidden */
  29865. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29866. /**
  29867. * @hidden
  29868. */
  29869. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29870. private _prepareWebGLTextureContinuation;
  29871. private _prepareWebGLTexture;
  29872. /** @hidden */
  29873. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29874. /** @hidden */
  29875. _releaseFramebufferObjects(texture: InternalTexture): void;
  29876. /** @hidden */
  29877. _releaseTexture(texture: InternalTexture): void;
  29878. private setProgram;
  29879. private _boundUniforms;
  29880. /**
  29881. * Binds an effect to the webGL context
  29882. * @param effect defines the effect to bind
  29883. */
  29884. bindSamplers(effect: Effect): void;
  29885. private _activateCurrentTexture;
  29886. /** @hidden */
  29887. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29888. /** @hidden */
  29889. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29890. /**
  29891. * Sets a texture to the webGL context from a postprocess
  29892. * @param channel defines the channel to use
  29893. * @param postProcess defines the source postprocess
  29894. */
  29895. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29896. /**
  29897. * Binds the output of the passed in post process to the texture channel specified
  29898. * @param channel The channel the texture should be bound to
  29899. * @param postProcess The post process which's output should be bound
  29900. */
  29901. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29902. /**
  29903. * Unbind all textures from the webGL context
  29904. */
  29905. unbindAllTextures(): void;
  29906. /**
  29907. * Sets a texture to the according uniform.
  29908. * @param channel The texture channel
  29909. * @param uniform The uniform to set
  29910. * @param texture The texture to apply
  29911. */
  29912. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29913. /**
  29914. * Sets a depth stencil texture from a render target to the according uniform.
  29915. * @param channel The texture channel
  29916. * @param uniform The uniform to set
  29917. * @param texture The render target texture containing the depth stencil texture to apply
  29918. */
  29919. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29920. private _bindSamplerUniformToChannel;
  29921. private _getTextureWrapMode;
  29922. private _setTexture;
  29923. /**
  29924. * Sets an array of texture to the webGL context
  29925. * @param channel defines the channel where the texture array must be set
  29926. * @param uniform defines the associated uniform location
  29927. * @param textures defines the array of textures to bind
  29928. */
  29929. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29930. /** @hidden */
  29931. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29932. private _setTextureParameterFloat;
  29933. private _setTextureParameterInteger;
  29934. /**
  29935. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29936. * @param x defines the x coordinate of the rectangle where pixels must be read
  29937. * @param y defines the y coordinate of the rectangle where pixels must be read
  29938. * @param width defines the width of the rectangle where pixels must be read
  29939. * @param height defines the height of the rectangle where pixels must be read
  29940. * @returns a Uint8Array containing RGBA colors
  29941. */
  29942. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29943. /**
  29944. * Add an externaly attached data from its key.
  29945. * This method call will fail and return false, if such key already exists.
  29946. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29947. * @param key the unique key that identifies the data
  29948. * @param data the data object to associate to the key for this Engine instance
  29949. * @return true if no such key were already present and the data was added successfully, false otherwise
  29950. */
  29951. addExternalData<T>(key: string, data: T): boolean;
  29952. /**
  29953. * Get an externaly attached data from its key
  29954. * @param key the unique key that identifies the data
  29955. * @return the associated data, if present (can be null), or undefined if not present
  29956. */
  29957. getExternalData<T>(key: string): T;
  29958. /**
  29959. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29960. * @param key the unique key that identifies the data
  29961. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29962. * @return the associated data, can be null if the factory returned null.
  29963. */
  29964. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29965. /**
  29966. * Remove an externaly attached data from the Engine instance
  29967. * @param key the unique key that identifies the data
  29968. * @return true if the data was successfully removed, false if it doesn't exist
  29969. */
  29970. removeExternalData(key: string): boolean;
  29971. /**
  29972. * Unbind all vertex attributes from the webGL context
  29973. */
  29974. unbindAllAttributes(): void;
  29975. /**
  29976. * 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
  29977. */
  29978. releaseEffects(): void;
  29979. /**
  29980. * Dispose and release all associated resources
  29981. */
  29982. dispose(): void;
  29983. /**
  29984. * Display the loading screen
  29985. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29986. */
  29987. displayLoadingUI(): void;
  29988. /**
  29989. * Hide the loading screen
  29990. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29991. */
  29992. hideLoadingUI(): void;
  29993. /**
  29994. * Gets the current loading screen object
  29995. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29996. */
  29997. /**
  29998. * Sets the current loading screen object
  29999. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30000. */
  30001. loadingScreen: ILoadingScreen;
  30002. /**
  30003. * Sets the current loading screen text
  30004. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30005. */
  30006. loadingUIText: string;
  30007. /**
  30008. * Sets the current loading screen background color
  30009. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30010. */
  30011. loadingUIBackgroundColor: string;
  30012. /**
  30013. * Attach a new callback raised when context lost event is fired
  30014. * @param callback defines the callback to call
  30015. */
  30016. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30017. /**
  30018. * Attach a new callback raised when context restored event is fired
  30019. * @param callback defines the callback to call
  30020. */
  30021. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30022. /**
  30023. * Gets the source code of the vertex shader associated with a specific webGL program
  30024. * @param program defines the program to use
  30025. * @returns a string containing the source code of the vertex shader associated with the program
  30026. */
  30027. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30028. /**
  30029. * Gets the source code of the fragment shader associated with a specific webGL program
  30030. * @param program defines the program to use
  30031. * @returns a string containing the source code of the fragment shader associated with the program
  30032. */
  30033. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30034. /**
  30035. * Get the current error code of the webGL context
  30036. * @returns the error code
  30037. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30038. */
  30039. getError(): number;
  30040. /**
  30041. * Gets the current framerate
  30042. * @returns a number representing the framerate
  30043. */
  30044. getFps(): number;
  30045. /**
  30046. * Gets the time spent between current and previous frame
  30047. * @returns a number representing the delta time in ms
  30048. */
  30049. getDeltaTime(): number;
  30050. private _measureFps;
  30051. /** @hidden */
  30052. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30053. private _canRenderToFloatFramebuffer;
  30054. private _canRenderToHalfFloatFramebuffer;
  30055. private _canRenderToFramebuffer;
  30056. /** @hidden */
  30057. _getWebGLTextureType(type: number): number;
  30058. /** @hidden */
  30059. _getInternalFormat(format: number): number;
  30060. /** @hidden */
  30061. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30062. /** @hidden */
  30063. _getRGBAMultiSampleBufferFormat(type: number): number;
  30064. /** @hidden */
  30065. _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;
  30066. /** @hidden */
  30067. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30068. /**
  30069. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30070. * @returns true if the engine can be created
  30071. * @ignorenaming
  30072. */
  30073. static isSupported(): boolean;
  30074. }
  30075. }
  30076. declare module "babylonjs/Materials/effect" {
  30077. import { Observable } from "babylonjs/Misc/observable";
  30078. import { Nullable } from "babylonjs/types";
  30079. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  30080. import { IDisposable } from "babylonjs/scene";
  30081. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30082. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30083. import { Engine } from "babylonjs/Engines/engine";
  30084. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30085. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30086. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30087. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30089. /**
  30090. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  30091. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  30092. */
  30093. export class EffectFallbacks {
  30094. private _defines;
  30095. private _currentRank;
  30096. private _maxRank;
  30097. private _mesh;
  30098. /**
  30099. * Removes the fallback from the bound mesh.
  30100. */
  30101. unBindMesh(): void;
  30102. /**
  30103. * Adds a fallback on the specified property.
  30104. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30105. * @param define The name of the define in the shader
  30106. */
  30107. addFallback(rank: number, define: string): void;
  30108. /**
  30109. * Sets the mesh to use CPU skinning when needing to fallback.
  30110. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30111. * @param mesh The mesh to use the fallbacks.
  30112. */
  30113. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30114. /**
  30115. * Checks to see if more fallbacks are still availible.
  30116. */
  30117. readonly isMoreFallbacks: boolean;
  30118. /**
  30119. * Removes the defines that should be removed when falling back.
  30120. * @param currentDefines defines the current define statements for the shader.
  30121. * @param effect defines the current effect we try to compile
  30122. * @returns The resulting defines with defines of the current rank removed.
  30123. */
  30124. reduce(currentDefines: string, effect: Effect): string;
  30125. }
  30126. /**
  30127. * Options to be used when creating an effect.
  30128. */
  30129. export class EffectCreationOptions {
  30130. /**
  30131. * Atrributes that will be used in the shader.
  30132. */
  30133. attributes: string[];
  30134. /**
  30135. * Uniform varible names that will be set in the shader.
  30136. */
  30137. uniformsNames: string[];
  30138. /**
  30139. * Uniform buffer varible names that will be set in the shader.
  30140. */
  30141. uniformBuffersNames: string[];
  30142. /**
  30143. * Sampler texture variable names that will be set in the shader.
  30144. */
  30145. samplers: string[];
  30146. /**
  30147. * Define statements that will be set in the shader.
  30148. */
  30149. defines: any;
  30150. /**
  30151. * Possible fallbacks for this effect to improve performance when needed.
  30152. */
  30153. fallbacks: Nullable<EffectFallbacks>;
  30154. /**
  30155. * Callback that will be called when the shader is compiled.
  30156. */
  30157. onCompiled: Nullable<(effect: Effect) => void>;
  30158. /**
  30159. * Callback that will be called if an error occurs during shader compilation.
  30160. */
  30161. onError: Nullable<(effect: Effect, errors: string) => void>;
  30162. /**
  30163. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30164. */
  30165. indexParameters: any;
  30166. /**
  30167. * Max number of lights that can be used in the shader.
  30168. */
  30169. maxSimultaneousLights: number;
  30170. /**
  30171. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30172. */
  30173. transformFeedbackVaryings: Nullable<string[]>;
  30174. }
  30175. /**
  30176. * Effect containing vertex and fragment shader that can be executed on an object.
  30177. */
  30178. export class Effect implements IDisposable {
  30179. /**
  30180. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30181. */
  30182. static ShadersRepository: string;
  30183. /**
  30184. * Name of the effect.
  30185. */
  30186. name: any;
  30187. /**
  30188. * String container all the define statements that should be set on the shader.
  30189. */
  30190. defines: string;
  30191. /**
  30192. * Callback that will be called when the shader is compiled.
  30193. */
  30194. onCompiled: Nullable<(effect: Effect) => void>;
  30195. /**
  30196. * Callback that will be called if an error occurs during shader compilation.
  30197. */
  30198. onError: Nullable<(effect: Effect, errors: string) => void>;
  30199. /**
  30200. * Callback that will be called when effect is bound.
  30201. */
  30202. onBind: Nullable<(effect: Effect) => void>;
  30203. /**
  30204. * Unique ID of the effect.
  30205. */
  30206. uniqueId: number;
  30207. /**
  30208. * Observable that will be called when the shader is compiled.
  30209. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30210. */
  30211. onCompileObservable: Observable<Effect>;
  30212. /**
  30213. * Observable that will be called if an error occurs during shader compilation.
  30214. */
  30215. onErrorObservable: Observable<Effect>;
  30216. /** @hidden */
  30217. _onBindObservable: Nullable<Observable<Effect>>;
  30218. /**
  30219. * Observable that will be called when effect is bound.
  30220. */
  30221. readonly onBindObservable: Observable<Effect>;
  30222. /** @hidden */
  30223. _bonesComputationForcedToCPU: boolean;
  30224. private static _uniqueIdSeed;
  30225. private _engine;
  30226. private _uniformBuffersNames;
  30227. private _uniformsNames;
  30228. private _samplerList;
  30229. private _samplers;
  30230. private _isReady;
  30231. private _compilationError;
  30232. private _attributesNames;
  30233. private _attributes;
  30234. private _uniforms;
  30235. /**
  30236. * Key for the effect.
  30237. * @hidden
  30238. */
  30239. _key: string;
  30240. private _indexParameters;
  30241. private _fallbacks;
  30242. private _vertexSourceCode;
  30243. private _fragmentSourceCode;
  30244. private _vertexSourceCodeOverride;
  30245. private _fragmentSourceCodeOverride;
  30246. private _transformFeedbackVaryings;
  30247. /**
  30248. * Compiled shader to webGL program.
  30249. * @hidden
  30250. */
  30251. _pipelineContext: Nullable<IPipelineContext>;
  30252. private _valueCache;
  30253. private static _baseCache;
  30254. /**
  30255. * Instantiates an effect.
  30256. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30257. * @param baseName Name of the effect.
  30258. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30259. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30260. * @param samplers List of sampler variables that will be passed to the shader.
  30261. * @param engine Engine to be used to render the effect
  30262. * @param defines Define statements to be added to the shader.
  30263. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30264. * @param onCompiled Callback that will be called when the shader is compiled.
  30265. * @param onError Callback that will be called if an error occurs during shader compilation.
  30266. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30267. */
  30268. 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);
  30269. private _useFinalCode;
  30270. /**
  30271. * Unique key for this effect
  30272. */
  30273. readonly key: string;
  30274. /**
  30275. * If the effect has been compiled and prepared.
  30276. * @returns if the effect is compiled and prepared.
  30277. */
  30278. isReady(): boolean;
  30279. /**
  30280. * The engine the effect was initialized with.
  30281. * @returns the engine.
  30282. */
  30283. getEngine(): Engine;
  30284. /**
  30285. * The pipeline context for this effect
  30286. * @returns the associated pipeline context
  30287. */
  30288. getPipelineContext(): Nullable<IPipelineContext>;
  30289. /**
  30290. * The set of names of attribute variables for the shader.
  30291. * @returns An array of attribute names.
  30292. */
  30293. getAttributesNames(): string[];
  30294. /**
  30295. * Returns the attribute at the given index.
  30296. * @param index The index of the attribute.
  30297. * @returns The location of the attribute.
  30298. */
  30299. getAttributeLocation(index: number): number;
  30300. /**
  30301. * Returns the attribute based on the name of the variable.
  30302. * @param name of the attribute to look up.
  30303. * @returns the attribute location.
  30304. */
  30305. getAttributeLocationByName(name: string): number;
  30306. /**
  30307. * The number of attributes.
  30308. * @returns the numnber of attributes.
  30309. */
  30310. getAttributesCount(): number;
  30311. /**
  30312. * Gets the index of a uniform variable.
  30313. * @param uniformName of the uniform to look up.
  30314. * @returns the index.
  30315. */
  30316. getUniformIndex(uniformName: string): number;
  30317. /**
  30318. * Returns the attribute based on the name of the variable.
  30319. * @param uniformName of the uniform to look up.
  30320. * @returns the location of the uniform.
  30321. */
  30322. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30323. /**
  30324. * Returns an array of sampler variable names
  30325. * @returns The array of sampler variable neames.
  30326. */
  30327. getSamplers(): string[];
  30328. /**
  30329. * The error from the last compilation.
  30330. * @returns the error string.
  30331. */
  30332. getCompilationError(): string;
  30333. /**
  30334. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30335. * @param func The callback to be used.
  30336. */
  30337. executeWhenCompiled(func: (effect: Effect) => void): void;
  30338. private _checkIsReady;
  30339. /** @hidden */
  30340. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30341. /** @hidden */
  30342. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30343. /** @hidden */
  30344. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30345. /**
  30346. * Recompiles the webGL program
  30347. * @param vertexSourceCode The source code for the vertex shader.
  30348. * @param fragmentSourceCode The source code for the fragment shader.
  30349. * @param onCompiled Callback called when completed.
  30350. * @param onError Callback called on error.
  30351. * @hidden
  30352. */
  30353. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30354. /**
  30355. * Prepares the effect
  30356. * @hidden
  30357. */
  30358. _prepareEffect(): void;
  30359. /**
  30360. * Checks if the effect is supported. (Must be called after compilation)
  30361. */
  30362. readonly isSupported: boolean;
  30363. /**
  30364. * Binds a texture to the engine to be used as output of the shader.
  30365. * @param channel Name of the output variable.
  30366. * @param texture Texture to bind.
  30367. * @hidden
  30368. */
  30369. _bindTexture(channel: string, texture: InternalTexture): void;
  30370. /**
  30371. * Sets a texture on the engine to be used in the shader.
  30372. * @param channel Name of the sampler variable.
  30373. * @param texture Texture to set.
  30374. */
  30375. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30376. /**
  30377. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30378. * @param channel Name of the sampler variable.
  30379. * @param texture Texture to set.
  30380. */
  30381. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30382. /**
  30383. * Sets an array of textures on the engine to be used in the shader.
  30384. * @param channel Name of the variable.
  30385. * @param textures Textures to set.
  30386. */
  30387. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30388. /**
  30389. * 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)
  30390. * @param channel Name of the sampler variable.
  30391. * @param postProcess Post process to get the input texture from.
  30392. */
  30393. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30394. /**
  30395. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30396. * 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)
  30397. * @param channel Name of the sampler variable.
  30398. * @param postProcess Post process to get the output texture from.
  30399. */
  30400. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30401. /** @hidden */
  30402. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30403. /** @hidden */
  30404. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30405. /** @hidden */
  30406. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30407. /** @hidden */
  30408. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30409. /**
  30410. * Binds a buffer to a uniform.
  30411. * @param buffer Buffer to bind.
  30412. * @param name Name of the uniform variable to bind to.
  30413. */
  30414. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30415. /**
  30416. * Binds block to a uniform.
  30417. * @param blockName Name of the block to bind.
  30418. * @param index Index to bind.
  30419. */
  30420. bindUniformBlock(blockName: string, index: number): void;
  30421. /**
  30422. * Sets an interger value on a uniform variable.
  30423. * @param uniformName Name of the variable.
  30424. * @param value Value to be set.
  30425. * @returns this effect.
  30426. */
  30427. setInt(uniformName: string, value: number): Effect;
  30428. /**
  30429. * Sets an int array on a uniform variable.
  30430. * @param uniformName Name of the variable.
  30431. * @param array array to be set.
  30432. * @returns this effect.
  30433. */
  30434. setIntArray(uniformName: string, array: Int32Array): Effect;
  30435. /**
  30436. * 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)
  30437. * @param uniformName Name of the variable.
  30438. * @param array array to be set.
  30439. * @returns this effect.
  30440. */
  30441. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30442. /**
  30443. * 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)
  30444. * @param uniformName Name of the variable.
  30445. * @param array array to be set.
  30446. * @returns this effect.
  30447. */
  30448. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30449. /**
  30450. * 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)
  30451. * @param uniformName Name of the variable.
  30452. * @param array array to be set.
  30453. * @returns this effect.
  30454. */
  30455. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30456. /**
  30457. * Sets an float array on a uniform variable.
  30458. * @param uniformName Name of the variable.
  30459. * @param array array to be set.
  30460. * @returns this effect.
  30461. */
  30462. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30463. /**
  30464. * 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)
  30465. * @param uniformName Name of the variable.
  30466. * @param array array to be set.
  30467. * @returns this effect.
  30468. */
  30469. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30470. /**
  30471. * 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)
  30472. * @param uniformName Name of the variable.
  30473. * @param array array to be set.
  30474. * @returns this effect.
  30475. */
  30476. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30477. /**
  30478. * 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)
  30479. * @param uniformName Name of the variable.
  30480. * @param array array to be set.
  30481. * @returns this effect.
  30482. */
  30483. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30484. /**
  30485. * Sets an array on a uniform variable.
  30486. * @param uniformName Name of the variable.
  30487. * @param array array to be set.
  30488. * @returns this effect.
  30489. */
  30490. setArray(uniformName: string, array: number[]): Effect;
  30491. /**
  30492. * 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)
  30493. * @param uniformName Name of the variable.
  30494. * @param array array to be set.
  30495. * @returns this effect.
  30496. */
  30497. setArray2(uniformName: string, array: number[]): Effect;
  30498. /**
  30499. * 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)
  30500. * @param uniformName Name of the variable.
  30501. * @param array array to be set.
  30502. * @returns this effect.
  30503. */
  30504. setArray3(uniformName: string, array: number[]): Effect;
  30505. /**
  30506. * 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)
  30507. * @param uniformName Name of the variable.
  30508. * @param array array to be set.
  30509. * @returns this effect.
  30510. */
  30511. setArray4(uniformName: string, array: number[]): Effect;
  30512. /**
  30513. * Sets matrices on a uniform variable.
  30514. * @param uniformName Name of the variable.
  30515. * @param matrices matrices to be set.
  30516. * @returns this effect.
  30517. */
  30518. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30519. /**
  30520. * Sets matrix on a uniform variable.
  30521. * @param uniformName Name of the variable.
  30522. * @param matrix matrix to be set.
  30523. * @returns this effect.
  30524. */
  30525. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30526. /**
  30527. * 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)
  30528. * @param uniformName Name of the variable.
  30529. * @param matrix matrix to be set.
  30530. * @returns this effect.
  30531. */
  30532. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30533. /**
  30534. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30535. * @param uniformName Name of the variable.
  30536. * @param matrix matrix to be set.
  30537. * @returns this effect.
  30538. */
  30539. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30540. /**
  30541. * Sets a float on a uniform variable.
  30542. * @param uniformName Name of the variable.
  30543. * @param value value to be set.
  30544. * @returns this effect.
  30545. */
  30546. setFloat(uniformName: string, value: number): Effect;
  30547. /**
  30548. * Sets a boolean on a uniform variable.
  30549. * @param uniformName Name of the variable.
  30550. * @param bool value to be set.
  30551. * @returns this effect.
  30552. */
  30553. setBool(uniformName: string, bool: boolean): Effect;
  30554. /**
  30555. * Sets a Vector2 on a uniform variable.
  30556. * @param uniformName Name of the variable.
  30557. * @param vector2 vector2 to be set.
  30558. * @returns this effect.
  30559. */
  30560. setVector2(uniformName: string, vector2: Vector2): Effect;
  30561. /**
  30562. * Sets a float2 on a uniform variable.
  30563. * @param uniformName Name of the variable.
  30564. * @param x First float in float2.
  30565. * @param y Second float in float2.
  30566. * @returns this effect.
  30567. */
  30568. setFloat2(uniformName: string, x: number, y: number): Effect;
  30569. /**
  30570. * Sets a Vector3 on a uniform variable.
  30571. * @param uniformName Name of the variable.
  30572. * @param vector3 Value to be set.
  30573. * @returns this effect.
  30574. */
  30575. setVector3(uniformName: string, vector3: Vector3): Effect;
  30576. /**
  30577. * Sets a float3 on a uniform variable.
  30578. * @param uniformName Name of the variable.
  30579. * @param x First float in float3.
  30580. * @param y Second float in float3.
  30581. * @param z Third float in float3.
  30582. * @returns this effect.
  30583. */
  30584. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30585. /**
  30586. * Sets a Vector4 on a uniform variable.
  30587. * @param uniformName Name of the variable.
  30588. * @param vector4 Value to be set.
  30589. * @returns this effect.
  30590. */
  30591. setVector4(uniformName: string, vector4: Vector4): Effect;
  30592. /**
  30593. * Sets a float4 on a uniform variable.
  30594. * @param uniformName Name of the variable.
  30595. * @param x First float in float4.
  30596. * @param y Second float in float4.
  30597. * @param z Third float in float4.
  30598. * @param w Fourth float in float4.
  30599. * @returns this effect.
  30600. */
  30601. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30602. /**
  30603. * Sets a Color3 on a uniform variable.
  30604. * @param uniformName Name of the variable.
  30605. * @param color3 Value to be set.
  30606. * @returns this effect.
  30607. */
  30608. setColor3(uniformName: string, color3: Color3): Effect;
  30609. /**
  30610. * Sets a Color4 on a uniform variable.
  30611. * @param uniformName Name of the variable.
  30612. * @param color3 Value to be set.
  30613. * @param alpha Alpha value to be set.
  30614. * @returns this effect.
  30615. */
  30616. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30617. /**
  30618. * Sets a Color4 on a uniform variable
  30619. * @param uniformName defines the name of the variable
  30620. * @param color4 defines the value to be set
  30621. * @returns this effect.
  30622. */
  30623. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30624. /** Release all associated resources */
  30625. dispose(): void;
  30626. /**
  30627. * This function will add a new shader to the shader store
  30628. * @param name the name of the shader
  30629. * @param pixelShader optional pixel shader content
  30630. * @param vertexShader optional vertex shader content
  30631. */
  30632. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30633. /**
  30634. * Store of each shader (The can be looked up using effect.key)
  30635. */
  30636. static ShadersStore: {
  30637. [key: string]: string;
  30638. };
  30639. /**
  30640. * Store of each included file for a shader (The can be looked up using effect.key)
  30641. */
  30642. static IncludesShadersStore: {
  30643. [key: string]: string;
  30644. };
  30645. /**
  30646. * Resets the cache of effects.
  30647. */
  30648. static ResetCache(): void;
  30649. }
  30650. }
  30651. declare module "babylonjs/Materials/colorCurves" {
  30652. import { Effect } from "babylonjs/Materials/effect";
  30653. /**
  30654. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30655. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30656. * 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;
  30657. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30658. */
  30659. export class ColorCurves {
  30660. private _dirty;
  30661. private _tempColor;
  30662. private _globalCurve;
  30663. private _highlightsCurve;
  30664. private _midtonesCurve;
  30665. private _shadowsCurve;
  30666. private _positiveCurve;
  30667. private _negativeCurve;
  30668. private _globalHue;
  30669. private _globalDensity;
  30670. private _globalSaturation;
  30671. private _globalExposure;
  30672. /**
  30673. * Gets the global Hue value.
  30674. * 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).
  30675. */
  30676. /**
  30677. * Sets the global Hue value.
  30678. * 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).
  30679. */
  30680. globalHue: number;
  30681. /**
  30682. * Gets the global Density value.
  30683. * 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.
  30684. * Values less than zero provide a filter of opposite hue.
  30685. */
  30686. /**
  30687. * Sets the global Density value.
  30688. * 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.
  30689. * Values less than zero provide a filter of opposite hue.
  30690. */
  30691. globalDensity: number;
  30692. /**
  30693. * Gets the global Saturation value.
  30694. * 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.
  30695. */
  30696. /**
  30697. * Sets the global Saturation value.
  30698. * 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.
  30699. */
  30700. globalSaturation: number;
  30701. /**
  30702. * Gets the global Exposure value.
  30703. * 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.
  30704. */
  30705. /**
  30706. * Sets the global Exposure value.
  30707. * 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.
  30708. */
  30709. globalExposure: number;
  30710. private _highlightsHue;
  30711. private _highlightsDensity;
  30712. private _highlightsSaturation;
  30713. private _highlightsExposure;
  30714. /**
  30715. * Gets the highlights Hue value.
  30716. * 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).
  30717. */
  30718. /**
  30719. * Sets the highlights Hue value.
  30720. * 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).
  30721. */
  30722. highlightsHue: number;
  30723. /**
  30724. * Gets the highlights Density value.
  30725. * 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.
  30726. * Values less than zero provide a filter of opposite hue.
  30727. */
  30728. /**
  30729. * Sets the highlights Density value.
  30730. * 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.
  30731. * Values less than zero provide a filter of opposite hue.
  30732. */
  30733. highlightsDensity: number;
  30734. /**
  30735. * Gets the highlights Saturation value.
  30736. * 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.
  30737. */
  30738. /**
  30739. * Sets the highlights Saturation value.
  30740. * 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.
  30741. */
  30742. highlightsSaturation: number;
  30743. /**
  30744. * Gets the highlights Exposure value.
  30745. * 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.
  30746. */
  30747. /**
  30748. * Sets the highlights Exposure value.
  30749. * 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.
  30750. */
  30751. highlightsExposure: number;
  30752. private _midtonesHue;
  30753. private _midtonesDensity;
  30754. private _midtonesSaturation;
  30755. private _midtonesExposure;
  30756. /**
  30757. * Gets the midtones Hue value.
  30758. * 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).
  30759. */
  30760. /**
  30761. * Sets the midtones Hue value.
  30762. * 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).
  30763. */
  30764. midtonesHue: number;
  30765. /**
  30766. * Gets the midtones Density value.
  30767. * 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.
  30768. * Values less than zero provide a filter of opposite hue.
  30769. */
  30770. /**
  30771. * Sets the midtones Density value.
  30772. * 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.
  30773. * Values less than zero provide a filter of opposite hue.
  30774. */
  30775. midtonesDensity: number;
  30776. /**
  30777. * Gets the midtones Saturation value.
  30778. * 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.
  30779. */
  30780. /**
  30781. * Sets the midtones Saturation value.
  30782. * 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.
  30783. */
  30784. midtonesSaturation: number;
  30785. /**
  30786. * Gets the midtones Exposure value.
  30787. * 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.
  30788. */
  30789. /**
  30790. * Sets the midtones Exposure value.
  30791. * 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.
  30792. */
  30793. midtonesExposure: number;
  30794. private _shadowsHue;
  30795. private _shadowsDensity;
  30796. private _shadowsSaturation;
  30797. private _shadowsExposure;
  30798. /**
  30799. * Gets the shadows Hue value.
  30800. * 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).
  30801. */
  30802. /**
  30803. * Sets the shadows Hue value.
  30804. * 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).
  30805. */
  30806. shadowsHue: number;
  30807. /**
  30808. * Gets the shadows Density value.
  30809. * 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.
  30810. * Values less than zero provide a filter of opposite hue.
  30811. */
  30812. /**
  30813. * Sets the shadows Density value.
  30814. * 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.
  30815. * Values less than zero provide a filter of opposite hue.
  30816. */
  30817. shadowsDensity: number;
  30818. /**
  30819. * Gets the shadows Saturation value.
  30820. * 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.
  30821. */
  30822. /**
  30823. * Sets the shadows Saturation value.
  30824. * 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.
  30825. */
  30826. shadowsSaturation: number;
  30827. /**
  30828. * Gets the shadows Exposure value.
  30829. * 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.
  30830. */
  30831. /**
  30832. * Sets the shadows Exposure value.
  30833. * 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.
  30834. */
  30835. shadowsExposure: number;
  30836. /**
  30837. * Returns the class name
  30838. * @returns The class name
  30839. */
  30840. getClassName(): string;
  30841. /**
  30842. * Binds the color curves to the shader.
  30843. * @param colorCurves The color curve to bind
  30844. * @param effect The effect to bind to
  30845. * @param positiveUniform The positive uniform shader parameter
  30846. * @param neutralUniform The neutral uniform shader parameter
  30847. * @param negativeUniform The negative uniform shader parameter
  30848. */
  30849. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30850. /**
  30851. * Prepare the list of uniforms associated with the ColorCurves effects.
  30852. * @param uniformsList The list of uniforms used in the effect
  30853. */
  30854. static PrepareUniforms(uniformsList: string[]): void;
  30855. /**
  30856. * Returns color grading data based on a hue, density, saturation and exposure value.
  30857. * @param filterHue The hue of the color filter.
  30858. * @param filterDensity The density of the color filter.
  30859. * @param saturation The saturation.
  30860. * @param exposure The exposure.
  30861. * @param result The result data container.
  30862. */
  30863. private getColorGradingDataToRef;
  30864. /**
  30865. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30866. * @param value The input slider value in range [-100,100].
  30867. * @returns Adjusted value.
  30868. */
  30869. private static applyColorGradingSliderNonlinear;
  30870. /**
  30871. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30872. * @param hue The hue (H) input.
  30873. * @param saturation The saturation (S) input.
  30874. * @param brightness The brightness (B) input.
  30875. * @result An RGBA color represented as Vector4.
  30876. */
  30877. private static fromHSBToRef;
  30878. /**
  30879. * Returns a value clamped between min and max
  30880. * @param value The value to clamp
  30881. * @param min The minimum of value
  30882. * @param max The maximum of value
  30883. * @returns The clamped value.
  30884. */
  30885. private static clamp;
  30886. /**
  30887. * Clones the current color curve instance.
  30888. * @return The cloned curves
  30889. */
  30890. clone(): ColorCurves;
  30891. /**
  30892. * Serializes the current color curve instance to a json representation.
  30893. * @return a JSON representation
  30894. */
  30895. serialize(): any;
  30896. /**
  30897. * Parses the color curve from a json representation.
  30898. * @param source the JSON source to parse
  30899. * @return The parsed curves
  30900. */
  30901. static Parse(source: any): ColorCurves;
  30902. }
  30903. }
  30904. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30905. import { Observable } from "babylonjs/Misc/observable";
  30906. import { Nullable } from "babylonjs/types";
  30907. import { Color4 } from "babylonjs/Maths/math";
  30908. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30909. import { Effect } from "babylonjs/Materials/effect";
  30910. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30911. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30912. /**
  30913. * Interface to follow in your material defines to integrate easily the
  30914. * Image proccessing functions.
  30915. * @hidden
  30916. */
  30917. export interface IImageProcessingConfigurationDefines {
  30918. IMAGEPROCESSING: boolean;
  30919. VIGNETTE: boolean;
  30920. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30921. VIGNETTEBLENDMODEOPAQUE: boolean;
  30922. TONEMAPPING: boolean;
  30923. TONEMAPPING_ACES: boolean;
  30924. CONTRAST: boolean;
  30925. EXPOSURE: boolean;
  30926. COLORCURVES: boolean;
  30927. COLORGRADING: boolean;
  30928. COLORGRADING3D: boolean;
  30929. SAMPLER3DGREENDEPTH: boolean;
  30930. SAMPLER3DBGRMAP: boolean;
  30931. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30932. }
  30933. /**
  30934. * @hidden
  30935. */
  30936. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30937. IMAGEPROCESSING: boolean;
  30938. VIGNETTE: boolean;
  30939. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30940. VIGNETTEBLENDMODEOPAQUE: boolean;
  30941. TONEMAPPING: boolean;
  30942. TONEMAPPING_ACES: boolean;
  30943. CONTRAST: boolean;
  30944. COLORCURVES: boolean;
  30945. COLORGRADING: boolean;
  30946. COLORGRADING3D: boolean;
  30947. SAMPLER3DGREENDEPTH: boolean;
  30948. SAMPLER3DBGRMAP: boolean;
  30949. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30950. EXPOSURE: boolean;
  30951. constructor();
  30952. }
  30953. /**
  30954. * This groups together the common properties used for image processing either in direct forward pass
  30955. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30956. * or not.
  30957. */
  30958. export class ImageProcessingConfiguration {
  30959. /**
  30960. * Default tone mapping applied in BabylonJS.
  30961. */
  30962. static readonly TONEMAPPING_STANDARD: number;
  30963. /**
  30964. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30965. * to other engines rendering to increase portability.
  30966. */
  30967. static readonly TONEMAPPING_ACES: number;
  30968. /**
  30969. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30970. */
  30971. colorCurves: Nullable<ColorCurves>;
  30972. private _colorCurvesEnabled;
  30973. /**
  30974. * Gets wether the color curves effect is enabled.
  30975. */
  30976. /**
  30977. * Sets wether the color curves effect is enabled.
  30978. */
  30979. colorCurvesEnabled: boolean;
  30980. private _colorGradingTexture;
  30981. /**
  30982. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30983. */
  30984. /**
  30985. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30986. */
  30987. colorGradingTexture: Nullable<BaseTexture>;
  30988. private _colorGradingEnabled;
  30989. /**
  30990. * Gets wether the color grading effect is enabled.
  30991. */
  30992. /**
  30993. * Sets wether the color grading effect is enabled.
  30994. */
  30995. colorGradingEnabled: boolean;
  30996. private _colorGradingWithGreenDepth;
  30997. /**
  30998. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30999. */
  31000. /**
  31001. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  31002. */
  31003. colorGradingWithGreenDepth: boolean;
  31004. private _colorGradingBGR;
  31005. /**
  31006. * Gets wether the color grading texture contains BGR values.
  31007. */
  31008. /**
  31009. * Sets wether the color grading texture contains BGR values.
  31010. */
  31011. colorGradingBGR: boolean;
  31012. /** @hidden */
  31013. _exposure: number;
  31014. /**
  31015. * Gets the Exposure used in the effect.
  31016. */
  31017. /**
  31018. * Sets the Exposure used in the effect.
  31019. */
  31020. exposure: number;
  31021. private _toneMappingEnabled;
  31022. /**
  31023. * Gets wether the tone mapping effect is enabled.
  31024. */
  31025. /**
  31026. * Sets wether the tone mapping effect is enabled.
  31027. */
  31028. toneMappingEnabled: boolean;
  31029. private _toneMappingType;
  31030. /**
  31031. * Gets the type of tone mapping effect.
  31032. */
  31033. /**
  31034. * Sets the type of tone mapping effect used in BabylonJS.
  31035. */
  31036. toneMappingType: number;
  31037. protected _contrast: number;
  31038. /**
  31039. * Gets the contrast used in the effect.
  31040. */
  31041. /**
  31042. * Sets the contrast used in the effect.
  31043. */
  31044. contrast: number;
  31045. /**
  31046. * Vignette stretch size.
  31047. */
  31048. vignetteStretch: number;
  31049. /**
  31050. * Vignette centre X Offset.
  31051. */
  31052. vignetteCentreX: number;
  31053. /**
  31054. * Vignette centre Y Offset.
  31055. */
  31056. vignetteCentreY: number;
  31057. /**
  31058. * Vignette weight or intensity of the vignette effect.
  31059. */
  31060. vignetteWeight: number;
  31061. /**
  31062. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  31063. * if vignetteEnabled is set to true.
  31064. */
  31065. vignetteColor: Color4;
  31066. /**
  31067. * Camera field of view used by the Vignette effect.
  31068. */
  31069. vignetteCameraFov: number;
  31070. private _vignetteBlendMode;
  31071. /**
  31072. * Gets the vignette blend mode allowing different kind of effect.
  31073. */
  31074. /**
  31075. * Sets the vignette blend mode allowing different kind of effect.
  31076. */
  31077. vignetteBlendMode: number;
  31078. private _vignetteEnabled;
  31079. /**
  31080. * Gets wether the vignette effect is enabled.
  31081. */
  31082. /**
  31083. * Sets wether the vignette effect is enabled.
  31084. */
  31085. vignetteEnabled: boolean;
  31086. private _applyByPostProcess;
  31087. /**
  31088. * Gets wether the image processing is applied through a post process or not.
  31089. */
  31090. /**
  31091. * Sets wether the image processing is applied through a post process or not.
  31092. */
  31093. applyByPostProcess: boolean;
  31094. private _isEnabled;
  31095. /**
  31096. * Gets wether the image processing is enabled or not.
  31097. */
  31098. /**
  31099. * Sets wether the image processing is enabled or not.
  31100. */
  31101. isEnabled: boolean;
  31102. /**
  31103. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  31104. */
  31105. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  31106. /**
  31107. * Method called each time the image processing information changes requires to recompile the effect.
  31108. */
  31109. protected _updateParameters(): void;
  31110. /**
  31111. * Gets the current class name.
  31112. * @return "ImageProcessingConfiguration"
  31113. */
  31114. getClassName(): string;
  31115. /**
  31116. * Prepare the list of uniforms associated with the Image Processing effects.
  31117. * @param uniforms The list of uniforms used in the effect
  31118. * @param defines the list of defines currently in use
  31119. */
  31120. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31121. /**
  31122. * Prepare the list of samplers associated with the Image Processing effects.
  31123. * @param samplersList The list of uniforms used in the effect
  31124. * @param defines the list of defines currently in use
  31125. */
  31126. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31127. /**
  31128. * Prepare the list of defines associated to the shader.
  31129. * @param defines the list of defines to complete
  31130. * @param forPostProcess Define if we are currently in post process mode or not
  31131. */
  31132. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31133. /**
  31134. * Returns true if all the image processing information are ready.
  31135. * @returns True if ready, otherwise, false
  31136. */
  31137. isReady(): boolean;
  31138. /**
  31139. * Binds the image processing to the shader.
  31140. * @param effect The effect to bind to
  31141. * @param aspectRatio Define the current aspect ratio of the effect
  31142. */
  31143. bind(effect: Effect, aspectRatio?: number): void;
  31144. /**
  31145. * Clones the current image processing instance.
  31146. * @return The cloned image processing
  31147. */
  31148. clone(): ImageProcessingConfiguration;
  31149. /**
  31150. * Serializes the current image processing instance to a json representation.
  31151. * @return a JSON representation
  31152. */
  31153. serialize(): any;
  31154. /**
  31155. * Parses the image processing from a json representation.
  31156. * @param source the JSON source to parse
  31157. * @return The parsed image processing
  31158. */
  31159. static Parse(source: any): ImageProcessingConfiguration;
  31160. private static _VIGNETTEMODE_MULTIPLY;
  31161. private static _VIGNETTEMODE_OPAQUE;
  31162. /**
  31163. * Used to apply the vignette as a mix with the pixel color.
  31164. */
  31165. static readonly VIGNETTEMODE_MULTIPLY: number;
  31166. /**
  31167. * Used to apply the vignette as a replacement of the pixel color.
  31168. */
  31169. static readonly VIGNETTEMODE_OPAQUE: number;
  31170. }
  31171. }
  31172. declare module "babylonjs/Materials/fresnelParameters" {
  31173. import { Color3 } from "babylonjs/Maths/math";
  31174. /**
  31175. * This represents all the required information to add a fresnel effect on a material:
  31176. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31177. */
  31178. export class FresnelParameters {
  31179. private _isEnabled;
  31180. /**
  31181. * Define if the fresnel effect is enable or not.
  31182. */
  31183. isEnabled: boolean;
  31184. /**
  31185. * Define the color used on edges (grazing angle)
  31186. */
  31187. leftColor: Color3;
  31188. /**
  31189. * Define the color used on center
  31190. */
  31191. rightColor: Color3;
  31192. /**
  31193. * Define bias applied to computed fresnel term
  31194. */
  31195. bias: number;
  31196. /**
  31197. * Defined the power exponent applied to fresnel term
  31198. */
  31199. power: number;
  31200. /**
  31201. * Clones the current fresnel and its valuues
  31202. * @returns a clone fresnel configuration
  31203. */
  31204. clone(): FresnelParameters;
  31205. /**
  31206. * Serializes the current fresnel parameters to a JSON representation.
  31207. * @return the JSON serialization
  31208. */
  31209. serialize(): any;
  31210. /**
  31211. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31212. * @param parsedFresnelParameters Define the JSON representation
  31213. * @returns the parsed parameters
  31214. */
  31215. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31216. }
  31217. }
  31218. declare module "babylonjs/Misc/decorators" {
  31219. import { Nullable } from "babylonjs/types";
  31220. import { Scene } from "babylonjs/scene";
  31221. import { IAnimatable } from "babylonjs/Misc/tools";
  31222. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31223. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31224. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31225. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31226. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31227. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31228. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31229. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31230. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31231. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31232. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31233. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31234. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31235. /**
  31236. * Decorator used to define property that can be serialized as reference to a camera
  31237. * @param sourceName defines the name of the property to decorate
  31238. */
  31239. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31240. /**
  31241. * Class used to help serialization objects
  31242. */
  31243. export class SerializationHelper {
  31244. /** @hidden */
  31245. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31246. /** @hidden */
  31247. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31248. /** @hidden */
  31249. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31250. /** @hidden */
  31251. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31252. /**
  31253. * Appends the serialized animations from the source animations
  31254. * @param source Source containing the animations
  31255. * @param destination Target to store the animations
  31256. */
  31257. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31258. /**
  31259. * Static function used to serialized a specific entity
  31260. * @param entity defines the entity to serialize
  31261. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31262. * @returns a JSON compatible object representing the serialization of the entity
  31263. */
  31264. static Serialize<T>(entity: T, serializationObject?: any): any;
  31265. /**
  31266. * Creates a new entity from a serialization data object
  31267. * @param creationFunction defines a function used to instanciated the new entity
  31268. * @param source defines the source serialization data
  31269. * @param scene defines the hosting scene
  31270. * @param rootUrl defines the root url for resources
  31271. * @returns a new entity
  31272. */
  31273. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31274. /**
  31275. * Clones an object
  31276. * @param creationFunction defines the function used to instanciate the new object
  31277. * @param source defines the source object
  31278. * @returns the cloned object
  31279. */
  31280. static Clone<T>(creationFunction: () => T, source: T): T;
  31281. /**
  31282. * Instanciates a new object based on a source one (some data will be shared between both object)
  31283. * @param creationFunction defines the function used to instanciate the new object
  31284. * @param source defines the source object
  31285. * @returns the new object
  31286. */
  31287. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31288. }
  31289. }
  31290. declare module "babylonjs/Cameras/camera" {
  31291. import { SmartArray } from "babylonjs/Misc/smartArray";
  31292. import { Observable } from "babylonjs/Misc/observable";
  31293. import { Nullable } from "babylonjs/types";
  31294. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31295. import { Scene } from "babylonjs/scene";
  31296. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31297. import { Node } from "babylonjs/node";
  31298. import { Mesh } from "babylonjs/Meshes/mesh";
  31299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31300. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31301. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31302. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31303. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31304. import { Ray } from "babylonjs/Culling/ray";
  31305. /**
  31306. * This is the base class of all the camera used in the application.
  31307. * @see http://doc.babylonjs.com/features/cameras
  31308. */
  31309. export class Camera extends Node {
  31310. /** @hidden */
  31311. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31312. /**
  31313. * This is the default projection mode used by the cameras.
  31314. * It helps recreating a feeling of perspective and better appreciate depth.
  31315. * This is the best way to simulate real life cameras.
  31316. */
  31317. static readonly PERSPECTIVE_CAMERA: number;
  31318. /**
  31319. * This helps creating camera with an orthographic mode.
  31320. * 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.
  31321. */
  31322. static readonly ORTHOGRAPHIC_CAMERA: number;
  31323. /**
  31324. * This is the default FOV mode for perspective cameras.
  31325. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31326. */
  31327. static readonly FOVMODE_VERTICAL_FIXED: number;
  31328. /**
  31329. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31330. */
  31331. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31332. /**
  31333. * This specifies ther is no need for a camera rig.
  31334. * Basically only one eye is rendered corresponding to the camera.
  31335. */
  31336. static readonly RIG_MODE_NONE: number;
  31337. /**
  31338. * Simulates a camera Rig with one blue eye and one red eye.
  31339. * This can be use with 3d blue and red glasses.
  31340. */
  31341. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31342. /**
  31343. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31344. */
  31345. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31346. /**
  31347. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31348. */
  31349. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31350. /**
  31351. * Defines that both eyes of the camera will be rendered over under each other.
  31352. */
  31353. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31354. /**
  31355. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31356. */
  31357. static readonly RIG_MODE_VR: number;
  31358. /**
  31359. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31360. */
  31361. static readonly RIG_MODE_WEBVR: number;
  31362. /**
  31363. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31364. */
  31365. static readonly RIG_MODE_CUSTOM: number;
  31366. /**
  31367. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31368. */
  31369. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31370. /**
  31371. * Define the input manager associated with the camera.
  31372. */
  31373. inputs: CameraInputsManager<Camera>;
  31374. /** @hidden */
  31375. _position: Vector3;
  31376. /**
  31377. * Define the current local position of the camera in the scene
  31378. */
  31379. position: Vector3;
  31380. /**
  31381. * The vector the camera should consider as up.
  31382. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31383. */
  31384. upVector: Vector3;
  31385. /**
  31386. * Define the current limit on the left side for an orthographic camera
  31387. * In scene unit
  31388. */
  31389. orthoLeft: Nullable<number>;
  31390. /**
  31391. * Define the current limit on the right side for an orthographic camera
  31392. * In scene unit
  31393. */
  31394. orthoRight: Nullable<number>;
  31395. /**
  31396. * Define the current limit on the bottom side for an orthographic camera
  31397. * In scene unit
  31398. */
  31399. orthoBottom: Nullable<number>;
  31400. /**
  31401. * Define the current limit on the top side for an orthographic camera
  31402. * In scene unit
  31403. */
  31404. orthoTop: Nullable<number>;
  31405. /**
  31406. * Field Of View is set in Radians. (default is 0.8)
  31407. */
  31408. fov: number;
  31409. /**
  31410. * Define the minimum distance the camera can see from.
  31411. * This is important to note that the depth buffer are not infinite and the closer it starts
  31412. * the more your scene might encounter depth fighting issue.
  31413. */
  31414. minZ: number;
  31415. /**
  31416. * Define the maximum distance the camera can see to.
  31417. * This is important to note that the depth buffer are not infinite and the further it end
  31418. * the more your scene might encounter depth fighting issue.
  31419. */
  31420. maxZ: number;
  31421. /**
  31422. * Define the default inertia of the camera.
  31423. * This helps giving a smooth feeling to the camera movement.
  31424. */
  31425. inertia: number;
  31426. /**
  31427. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  31428. */
  31429. mode: number;
  31430. /**
  31431. * Define wether the camera is intermediate.
  31432. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31433. */
  31434. isIntermediate: boolean;
  31435. /**
  31436. * Define the viewport of the camera.
  31437. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31438. */
  31439. viewport: Viewport;
  31440. /**
  31441. * Restricts the camera to viewing objects with the same layerMask.
  31442. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31443. */
  31444. layerMask: number;
  31445. /**
  31446. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31447. */
  31448. fovMode: number;
  31449. /**
  31450. * Rig mode of the camera.
  31451. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31452. * This is normally controlled byt the camera themselves as internal use.
  31453. */
  31454. cameraRigMode: number;
  31455. /**
  31456. * Defines the distance between both "eyes" in case of a RIG
  31457. */
  31458. interaxialDistance: number;
  31459. /**
  31460. * Defines if stereoscopic rendering is done side by side or over under.
  31461. */
  31462. isStereoscopicSideBySide: boolean;
  31463. /**
  31464. * 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
  31465. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31466. * else in the scene.
  31467. */
  31468. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31469. /**
  31470. * When set, the camera will render to this render target instead of the default canvas
  31471. */
  31472. outputRenderTarget: Nullable<RenderTargetTexture>;
  31473. /**
  31474. * Observable triggered when the camera view matrix has changed.
  31475. */
  31476. onViewMatrixChangedObservable: Observable<Camera>;
  31477. /**
  31478. * Observable triggered when the camera Projection matrix has changed.
  31479. */
  31480. onProjectionMatrixChangedObservable: Observable<Camera>;
  31481. /**
  31482. * Observable triggered when the inputs have been processed.
  31483. */
  31484. onAfterCheckInputsObservable: Observable<Camera>;
  31485. /**
  31486. * Observable triggered when reset has been called and applied to the camera.
  31487. */
  31488. onRestoreStateObservable: Observable<Camera>;
  31489. /** @hidden */
  31490. _cameraRigParams: any;
  31491. /** @hidden */
  31492. _rigCameras: Camera[];
  31493. /** @hidden */
  31494. _rigPostProcess: Nullable<PostProcess>;
  31495. protected _webvrViewMatrix: Matrix;
  31496. /** @hidden */
  31497. _skipRendering: boolean;
  31498. /** @hidden */
  31499. _projectionMatrix: Matrix;
  31500. /** @hidden */
  31501. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31502. /** @hidden */
  31503. _activeMeshes: SmartArray<AbstractMesh>;
  31504. protected _globalPosition: Vector3;
  31505. /** @hidden */
  31506. _computedViewMatrix: Matrix;
  31507. private _doNotComputeProjectionMatrix;
  31508. private _transformMatrix;
  31509. private _frustumPlanes;
  31510. private _refreshFrustumPlanes;
  31511. private _storedFov;
  31512. private _stateStored;
  31513. /**
  31514. * Instantiates a new camera object.
  31515. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31516. * @see http://doc.babylonjs.com/features/cameras
  31517. * @param name Defines the name of the camera in the scene
  31518. * @param position Defines the position of the camera
  31519. * @param scene Defines the scene the camera belongs too
  31520. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31521. */
  31522. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31523. /**
  31524. * Store current camera state (fov, position, etc..)
  31525. * @returns the camera
  31526. */
  31527. storeState(): Camera;
  31528. /**
  31529. * Restores the camera state values if it has been stored. You must call storeState() first
  31530. */
  31531. protected _restoreStateValues(): boolean;
  31532. /**
  31533. * Restored camera state. You must call storeState() first.
  31534. * @returns true if restored and false otherwise
  31535. */
  31536. restoreState(): boolean;
  31537. /**
  31538. * Gets the class name of the camera.
  31539. * @returns the class name
  31540. */
  31541. getClassName(): string;
  31542. /** @hidden */
  31543. readonly _isCamera: boolean;
  31544. /**
  31545. * Gets a string representation of the camera useful for debug purpose.
  31546. * @param fullDetails Defines that a more verboe level of logging is required
  31547. * @returns the string representation
  31548. */
  31549. toString(fullDetails?: boolean): string;
  31550. /**
  31551. * Gets the current world space position of the camera.
  31552. */
  31553. readonly globalPosition: Vector3;
  31554. /**
  31555. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31556. * @returns the active meshe list
  31557. */
  31558. getActiveMeshes(): SmartArray<AbstractMesh>;
  31559. /**
  31560. * Check wether a mesh is part of the current active mesh list of the camera
  31561. * @param mesh Defines the mesh to check
  31562. * @returns true if active, false otherwise
  31563. */
  31564. isActiveMesh(mesh: Mesh): boolean;
  31565. /**
  31566. * Is this camera ready to be used/rendered
  31567. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31568. * @return true if the camera is ready
  31569. */
  31570. isReady(completeCheck?: boolean): boolean;
  31571. /** @hidden */
  31572. _initCache(): void;
  31573. /** @hidden */
  31574. _updateCache(ignoreParentClass?: boolean): void;
  31575. /** @hidden */
  31576. _isSynchronized(): boolean;
  31577. /** @hidden */
  31578. _isSynchronizedViewMatrix(): boolean;
  31579. /** @hidden */
  31580. _isSynchronizedProjectionMatrix(): boolean;
  31581. /**
  31582. * Attach the input controls to a specific dom element to get the input from.
  31583. * @param element Defines the element the controls should be listened from
  31584. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31585. */
  31586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31587. /**
  31588. * Detach the current controls from the specified dom element.
  31589. * @param element Defines the element to stop listening the inputs from
  31590. */
  31591. detachControl(element: HTMLElement): void;
  31592. /**
  31593. * Update the camera state according to the different inputs gathered during the frame.
  31594. */
  31595. update(): void;
  31596. /** @hidden */
  31597. _checkInputs(): void;
  31598. /** @hidden */
  31599. readonly rigCameras: Camera[];
  31600. /**
  31601. * Gets the post process used by the rig cameras
  31602. */
  31603. readonly rigPostProcess: Nullable<PostProcess>;
  31604. /**
  31605. * Internal, gets the first post proces.
  31606. * @returns the first post process to be run on this camera.
  31607. */
  31608. _getFirstPostProcess(): Nullable<PostProcess>;
  31609. private _cascadePostProcessesToRigCams;
  31610. /**
  31611. * Attach a post process to the camera.
  31612. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31613. * @param postProcess The post process to attach to the camera
  31614. * @param insertAt The position of the post process in case several of them are in use in the scene
  31615. * @returns the position the post process has been inserted at
  31616. */
  31617. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31618. /**
  31619. * Detach a post process to the camera.
  31620. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31621. * @param postProcess The post process to detach from the camera
  31622. */
  31623. detachPostProcess(postProcess: PostProcess): void;
  31624. /**
  31625. * Gets the current world matrix of the camera
  31626. */
  31627. getWorldMatrix(): Matrix;
  31628. /** @hidden */
  31629. _getViewMatrix(): Matrix;
  31630. /**
  31631. * Gets the current view matrix of the camera.
  31632. * @param force forces the camera to recompute the matrix without looking at the cached state
  31633. * @returns the view matrix
  31634. */
  31635. getViewMatrix(force?: boolean): Matrix;
  31636. /**
  31637. * Freeze the projection matrix.
  31638. * It will prevent the cache check of the camera projection compute and can speed up perf
  31639. * if no parameter of the camera are meant to change
  31640. * @param projection Defines manually a projection if necessary
  31641. */
  31642. freezeProjectionMatrix(projection?: Matrix): void;
  31643. /**
  31644. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31645. */
  31646. unfreezeProjectionMatrix(): void;
  31647. /**
  31648. * Gets the current projection matrix of the camera.
  31649. * @param force forces the camera to recompute the matrix without looking at the cached state
  31650. * @returns the projection matrix
  31651. */
  31652. getProjectionMatrix(force?: boolean): Matrix;
  31653. /**
  31654. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31655. * @returns a Matrix
  31656. */
  31657. getTransformationMatrix(): Matrix;
  31658. private _updateFrustumPlanes;
  31659. /**
  31660. * Checks if a cullable object (mesh...) is in the camera frustum
  31661. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31662. * @param target The object to check
  31663. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31664. * @returns true if the object is in frustum otherwise false
  31665. */
  31666. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31667. /**
  31668. * Checks if a cullable object (mesh...) is in the camera frustum
  31669. * Unlike isInFrustum this cheks the full bounding box
  31670. * @param target The object to check
  31671. * @returns true if the object is in frustum otherwise false
  31672. */
  31673. isCompletelyInFrustum(target: ICullable): boolean;
  31674. /**
  31675. * Gets a ray in the forward direction from the camera.
  31676. * @param length Defines the length of the ray to create
  31677. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31678. * @param origin Defines the start point of the ray which defaults to the camera position
  31679. * @returns the forward ray
  31680. */
  31681. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31682. /**
  31683. * Releases resources associated with this node.
  31684. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31685. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31686. */
  31687. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31688. /** @hidden */
  31689. _isLeftCamera: boolean;
  31690. /**
  31691. * Gets the left camera of a rig setup in case of Rigged Camera
  31692. */
  31693. readonly isLeftCamera: boolean;
  31694. /** @hidden */
  31695. _isRightCamera: boolean;
  31696. /**
  31697. * Gets the right camera of a rig setup in case of Rigged Camera
  31698. */
  31699. readonly isRightCamera: boolean;
  31700. /**
  31701. * Gets the left camera of a rig setup in case of Rigged Camera
  31702. */
  31703. readonly leftCamera: Nullable<FreeCamera>;
  31704. /**
  31705. * Gets the right camera of a rig setup in case of Rigged Camera
  31706. */
  31707. readonly rightCamera: Nullable<FreeCamera>;
  31708. /**
  31709. * Gets the left camera target of a rig setup in case of Rigged Camera
  31710. * @returns the target position
  31711. */
  31712. getLeftTarget(): Nullable<Vector3>;
  31713. /**
  31714. * Gets the right camera target of a rig setup in case of Rigged Camera
  31715. * @returns the target position
  31716. */
  31717. getRightTarget(): Nullable<Vector3>;
  31718. /**
  31719. * @hidden
  31720. */
  31721. setCameraRigMode(mode: number, rigParams: any): void;
  31722. /** @hidden */
  31723. static _setStereoscopicRigMode(camera: Camera): void;
  31724. /** @hidden */
  31725. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31726. /** @hidden */
  31727. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31728. /** @hidden */
  31729. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31730. /** @hidden */
  31731. _getVRProjectionMatrix(): Matrix;
  31732. protected _updateCameraRotationMatrix(): void;
  31733. protected _updateWebVRCameraRotationMatrix(): void;
  31734. /**
  31735. * This function MUST be overwritten by the different WebVR cameras available.
  31736. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31737. * @hidden
  31738. */
  31739. _getWebVRProjectionMatrix(): Matrix;
  31740. /**
  31741. * This function MUST be overwritten by the different WebVR cameras available.
  31742. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31743. * @hidden
  31744. */
  31745. _getWebVRViewMatrix(): Matrix;
  31746. /** @hidden */
  31747. setCameraRigParameter(name: string, value: any): void;
  31748. /**
  31749. * needs to be overridden by children so sub has required properties to be copied
  31750. * @hidden
  31751. */
  31752. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31753. /**
  31754. * May need to be overridden by children
  31755. * @hidden
  31756. */
  31757. _updateRigCameras(): void;
  31758. /** @hidden */
  31759. _setupInputs(): void;
  31760. /**
  31761. * Serialiaze the camera setup to a json represention
  31762. * @returns the JSON representation
  31763. */
  31764. serialize(): any;
  31765. /**
  31766. * Clones the current camera.
  31767. * @param name The cloned camera name
  31768. * @returns the cloned camera
  31769. */
  31770. clone(name: string): Camera;
  31771. /**
  31772. * Gets the direction of the camera relative to a given local axis.
  31773. * @param localAxis Defines the reference axis to provide a relative direction.
  31774. * @return the direction
  31775. */
  31776. getDirection(localAxis: Vector3): Vector3;
  31777. /**
  31778. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31779. * @param localAxis Defines the reference axis to provide a relative direction.
  31780. * @param result Defines the vector to store the result in
  31781. */
  31782. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31783. /**
  31784. * Gets a camera constructor for a given camera type
  31785. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31786. * @param name The name of the camera the result will be able to instantiate
  31787. * @param scene The scene the result will construct the camera in
  31788. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31789. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31790. * @returns a factory method to construc the camera
  31791. */
  31792. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31793. /**
  31794. * Compute the world matrix of the camera.
  31795. * @returns the camera workd matrix
  31796. */
  31797. computeWorldMatrix(): Matrix;
  31798. /**
  31799. * Parse a JSON and creates the camera from the parsed information
  31800. * @param parsedCamera The JSON to parse
  31801. * @param scene The scene to instantiate the camera in
  31802. * @returns the newly constructed camera
  31803. */
  31804. static Parse(parsedCamera: any, scene: Scene): Camera;
  31805. }
  31806. }
  31807. declare module "babylonjs/Misc/tools" {
  31808. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31809. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31810. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31811. import { Observable } from "babylonjs/Misc/observable";
  31812. import { DomManagement } from "babylonjs/Misc/domManagement";
  31813. import { WebRequest } from "babylonjs/Misc/webRequest";
  31814. import { Camera } from "babylonjs/Cameras/camera";
  31815. import { Engine } from "babylonjs/Engines/engine";
  31816. import { Animation } from "babylonjs/Animations/animation";
  31817. /**
  31818. * Interface for any object that can request an animation frame
  31819. */
  31820. export interface ICustomAnimationFrameRequester {
  31821. /**
  31822. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31823. */
  31824. renderFunction?: Function;
  31825. /**
  31826. * Called to request the next frame to render to
  31827. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31828. */
  31829. requestAnimationFrame: Function;
  31830. /**
  31831. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31832. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31833. */
  31834. requestID?: number;
  31835. }
  31836. /**
  31837. * Interface containing an array of animations
  31838. */
  31839. export interface IAnimatable {
  31840. /**
  31841. * Array of animations
  31842. */
  31843. animations: Nullable<Array<Animation>>;
  31844. }
  31845. /** Interface used by value gradients (color, factor, ...) */
  31846. export interface IValueGradient {
  31847. /**
  31848. * Gets or sets the gradient value (between 0 and 1)
  31849. */
  31850. gradient: number;
  31851. }
  31852. /** Class used to store color4 gradient */
  31853. export class ColorGradient implements IValueGradient {
  31854. /**
  31855. * Gets or sets the gradient value (between 0 and 1)
  31856. */
  31857. gradient: number;
  31858. /**
  31859. * Gets or sets first associated color
  31860. */
  31861. color1: Color4;
  31862. /**
  31863. * Gets or sets second associated color
  31864. */
  31865. color2?: Color4;
  31866. /**
  31867. * Will get a color picked randomly between color1 and color2.
  31868. * If color2 is undefined then color1 will be used
  31869. * @param result defines the target Color4 to store the result in
  31870. */
  31871. getColorToRef(result: Color4): void;
  31872. }
  31873. /** Class used to store color 3 gradient */
  31874. export class Color3Gradient implements IValueGradient {
  31875. /**
  31876. * Gets or sets the gradient value (between 0 and 1)
  31877. */
  31878. gradient: number;
  31879. /**
  31880. * Gets or sets the associated color
  31881. */
  31882. color: Color3;
  31883. }
  31884. /** Class used to store factor gradient */
  31885. export class FactorGradient implements IValueGradient {
  31886. /**
  31887. * Gets or sets the gradient value (between 0 and 1)
  31888. */
  31889. gradient: number;
  31890. /**
  31891. * Gets or sets first associated factor
  31892. */
  31893. factor1: number;
  31894. /**
  31895. * Gets or sets second associated factor
  31896. */
  31897. factor2?: number;
  31898. /**
  31899. * Will get a number picked randomly between factor1 and factor2.
  31900. * If factor2 is undefined then factor1 will be used
  31901. * @returns the picked number
  31902. */
  31903. getFactor(): number;
  31904. }
  31905. /**
  31906. * @ignore
  31907. * Application error to support additional information when loading a file
  31908. */
  31909. export class LoadFileError extends Error {
  31910. /** defines the optional web request */
  31911. request?: WebRequest | undefined;
  31912. private static _setPrototypeOf;
  31913. /**
  31914. * Creates a new LoadFileError
  31915. * @param message defines the message of the error
  31916. * @param request defines the optional web request
  31917. */
  31918. constructor(message: string,
  31919. /** defines the optional web request */
  31920. request?: WebRequest | undefined);
  31921. }
  31922. /**
  31923. * Class used to define a retry strategy when error happens while loading assets
  31924. */
  31925. export class RetryStrategy {
  31926. /**
  31927. * Function used to defines an exponential back off strategy
  31928. * @param maxRetries defines the maximum number of retries (3 by default)
  31929. * @param baseInterval defines the interval between retries
  31930. * @returns the strategy function to use
  31931. */
  31932. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31933. }
  31934. /**
  31935. * File request interface
  31936. */
  31937. export interface IFileRequest {
  31938. /**
  31939. * Raised when the request is complete (success or error).
  31940. */
  31941. onCompleteObservable: Observable<IFileRequest>;
  31942. /**
  31943. * Aborts the request for a file.
  31944. */
  31945. abort: () => void;
  31946. }
  31947. /**
  31948. * Class containing a set of static utilities functions
  31949. */
  31950. export class Tools {
  31951. /**
  31952. * Gets or sets the base URL to use to load assets
  31953. */
  31954. static BaseUrl: string;
  31955. /**
  31956. * Enable/Disable Custom HTTP Request Headers globally.
  31957. * default = false
  31958. * @see CustomRequestHeaders
  31959. */
  31960. static UseCustomRequestHeaders: boolean;
  31961. /**
  31962. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31963. * i.e. when loading files, where the server/service expects an Authorization header
  31964. */
  31965. static CustomRequestHeaders: {
  31966. [key: string]: string;
  31967. };
  31968. /**
  31969. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31970. */
  31971. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31972. /**
  31973. * Default behaviour for cors in the application.
  31974. * It can be a string if the expected behavior is identical in the entire app.
  31975. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31976. */
  31977. static CorsBehavior: string | ((url: string | string[]) => string);
  31978. /**
  31979. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31980. * @ignorenaming
  31981. */
  31982. static UseFallbackTexture: boolean;
  31983. /**
  31984. * Use this object to register external classes like custom textures or material
  31985. * to allow the laoders to instantiate them
  31986. */
  31987. static RegisteredExternalClasses: {
  31988. [key: string]: Object;
  31989. };
  31990. /**
  31991. * Texture content used if a texture cannot loaded
  31992. * @ignorenaming
  31993. */
  31994. static fallbackTexture: string;
  31995. /**
  31996. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31997. * @param u defines the coordinate on X axis
  31998. * @param v defines the coordinate on Y axis
  31999. * @param width defines the width of the source data
  32000. * @param height defines the height of the source data
  32001. * @param pixels defines the source byte array
  32002. * @param color defines the output color
  32003. */
  32004. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  32005. /**
  32006. * Interpolates between a and b via alpha
  32007. * @param a The lower value (returned when alpha = 0)
  32008. * @param b The upper value (returned when alpha = 1)
  32009. * @param alpha The interpolation-factor
  32010. * @return The mixed value
  32011. */
  32012. static Mix(a: number, b: number, alpha: number): number;
  32013. /**
  32014. * Tries to instantiate a new object from a given class name
  32015. * @param className defines the class name to instantiate
  32016. * @returns the new object or null if the system was not able to do the instantiation
  32017. */
  32018. static Instantiate(className: string): any;
  32019. /**
  32020. * Provides a slice function that will work even on IE
  32021. * @param data defines the array to slice
  32022. * @param start defines the start of the data (optional)
  32023. * @param end defines the end of the data (optional)
  32024. * @returns the new sliced array
  32025. */
  32026. static Slice<T>(data: T, start?: number, end?: number): T;
  32027. /**
  32028. * Polyfill for setImmediate
  32029. * @param action defines the action to execute after the current execution block
  32030. */
  32031. static SetImmediate(action: () => void): void;
  32032. /**
  32033. * Function indicating if a number is an exponent of 2
  32034. * @param value defines the value to test
  32035. * @returns true if the value is an exponent of 2
  32036. */
  32037. static IsExponentOfTwo(value: number): boolean;
  32038. private static _tmpFloatArray;
  32039. /**
  32040. * Returns the nearest 32-bit single precision float representation of a Number
  32041. * @param value A Number. If the parameter is of a different type, it will get converted
  32042. * to a number or to NaN if it cannot be converted
  32043. * @returns number
  32044. */
  32045. static FloatRound(value: number): number;
  32046. /**
  32047. * Find the next highest power of two.
  32048. * @param x Number to start search from.
  32049. * @return Next highest power of two.
  32050. */
  32051. static CeilingPOT(x: number): number;
  32052. /**
  32053. * Find the next lowest power of two.
  32054. * @param x Number to start search from.
  32055. * @return Next lowest power of two.
  32056. */
  32057. static FloorPOT(x: number): number;
  32058. /**
  32059. * Find the nearest power of two.
  32060. * @param x Number to start search from.
  32061. * @return Next nearest power of two.
  32062. */
  32063. static NearestPOT(x: number): number;
  32064. /**
  32065. * Get the closest exponent of two
  32066. * @param value defines the value to approximate
  32067. * @param max defines the maximum value to return
  32068. * @param mode defines how to define the closest value
  32069. * @returns closest exponent of two of the given value
  32070. */
  32071. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32072. /**
  32073. * Extracts the filename from a path
  32074. * @param path defines the path to use
  32075. * @returns the filename
  32076. */
  32077. static GetFilename(path: string): string;
  32078. /**
  32079. * Extracts the "folder" part of a path (everything before the filename).
  32080. * @param uri The URI to extract the info from
  32081. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32082. * @returns The "folder" part of the path
  32083. */
  32084. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32085. /**
  32086. * Extracts text content from a DOM element hierarchy
  32087. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32088. */
  32089. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32090. /**
  32091. * Convert an angle in radians to degrees
  32092. * @param angle defines the angle to convert
  32093. * @returns the angle in degrees
  32094. */
  32095. static ToDegrees(angle: number): number;
  32096. /**
  32097. * Convert an angle in degrees to radians
  32098. * @param angle defines the angle to convert
  32099. * @returns the angle in radians
  32100. */
  32101. static ToRadians(angle: number): number;
  32102. /**
  32103. * Encode a buffer to a base64 string
  32104. * @param buffer defines the buffer to encode
  32105. * @returns the encoded string
  32106. */
  32107. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32108. /**
  32109. * Extracts minimum and maximum values from a list of indexed positions
  32110. * @param positions defines the positions to use
  32111. * @param indices defines the indices to the positions
  32112. * @param indexStart defines the start index
  32113. * @param indexCount defines the end index
  32114. * @param bias defines bias value to add to the result
  32115. * @return minimum and maximum values
  32116. */
  32117. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32118. minimum: Vector3;
  32119. maximum: Vector3;
  32120. };
  32121. /**
  32122. * Extracts minimum and maximum values from a list of positions
  32123. * @param positions defines the positions to use
  32124. * @param start defines the start index in the positions array
  32125. * @param count defines the number of positions to handle
  32126. * @param bias defines bias value to add to the result
  32127. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32128. * @return minimum and maximum values
  32129. */
  32130. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32131. minimum: Vector3;
  32132. maximum: Vector3;
  32133. };
  32134. /**
  32135. * Returns an array if obj is not an array
  32136. * @param obj defines the object to evaluate as an array
  32137. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32138. * @returns either obj directly if obj is an array or a new array containing obj
  32139. */
  32140. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32141. /**
  32142. * Gets the pointer prefix to use
  32143. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32144. */
  32145. static GetPointerPrefix(): string;
  32146. /**
  32147. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32148. * @param func - the function to be called
  32149. * @param requester - the object that will request the next frame. Falls back to window.
  32150. * @returns frame number
  32151. */
  32152. static QueueNewFrame(func: () => void, requester?: any): number;
  32153. /**
  32154. * Ask the browser to promote the current element to fullscreen rendering mode
  32155. * @param element defines the DOM element to promote
  32156. */
  32157. static RequestFullscreen(element: HTMLElement): void;
  32158. /**
  32159. * Asks the browser to exit fullscreen mode
  32160. */
  32161. static ExitFullscreen(): void;
  32162. /**
  32163. * Ask the browser to promote the current element to pointerlock mode
  32164. * @param element defines the DOM element to promote
  32165. */
  32166. static RequestPointerlock(element: HTMLElement): void;
  32167. /**
  32168. * Asks the browser to exit pointerlock mode
  32169. */
  32170. static ExitPointerlock(): void;
  32171. /**
  32172. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32173. * @param url define the url we are trying
  32174. * @param element define the dom element where to configure the cors policy
  32175. */
  32176. static SetCorsBehavior(url: string | string[], element: {
  32177. crossOrigin: string | null;
  32178. }): void;
  32179. /**
  32180. * Removes unwanted characters from an url
  32181. * @param url defines the url to clean
  32182. * @returns the cleaned url
  32183. */
  32184. static CleanUrl(url: string): string;
  32185. /**
  32186. * Gets or sets a function used to pre-process url before using them to load assets
  32187. */
  32188. static PreprocessUrl: (url: string) => string;
  32189. /**
  32190. * Loads an image as an HTMLImageElement.
  32191. * @param input url string, ArrayBuffer, or Blob to load
  32192. * @param onLoad callback called when the image successfully loads
  32193. * @param onError callback called when the image fails to load
  32194. * @param offlineProvider offline provider for caching
  32195. * @returns the HTMLImageElement of the loaded image
  32196. */
  32197. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32198. /**
  32199. * Loads a file
  32200. * @param url url string, ArrayBuffer, or Blob to load
  32201. * @param onSuccess callback called when the file successfully loads
  32202. * @param onProgress callback called while file is loading (if the server supports this mode)
  32203. * @param offlineProvider defines the offline provider for caching
  32204. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32205. * @param onError callback called when the file fails to load
  32206. * @returns a file request object
  32207. */
  32208. 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;
  32209. /**
  32210. * Loads a file from a url
  32211. * @param url the file url to load
  32212. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32213. */
  32214. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32215. /**
  32216. * Load a script (identified by an url). When the url returns, the
  32217. * content of this file is added into a new script element, attached to the DOM (body element)
  32218. * @param scriptUrl defines the url of the script to laod
  32219. * @param onSuccess defines the callback called when the script is loaded
  32220. * @param onError defines the callback to call if an error occurs
  32221. * @param scriptId defines the id of the script element
  32222. */
  32223. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32224. /**
  32225. * Load an asynchronous script (identified by an url). When the url returns, the
  32226. * content of this file is added into a new script element, attached to the DOM (body element)
  32227. * @param scriptUrl defines the url of the script to laod
  32228. * @param scriptId defines the id of the script element
  32229. * @returns a promise request object
  32230. */
  32231. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32232. /**
  32233. * Loads a file from a blob
  32234. * @param fileToLoad defines the blob to use
  32235. * @param callback defines the callback to call when data is loaded
  32236. * @param progressCallback defines the callback to call during loading process
  32237. * @returns a file request object
  32238. */
  32239. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32240. /**
  32241. * Loads a file
  32242. * @param fileToLoad defines the file to load
  32243. * @param callback defines the callback to call when data is loaded
  32244. * @param progressCallBack defines the callback to call during loading process
  32245. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32246. * @returns a file request object
  32247. */
  32248. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32249. /**
  32250. * Creates a data url from a given string content
  32251. * @param content defines the content to convert
  32252. * @returns the new data url link
  32253. */
  32254. static FileAsURL(content: string): string;
  32255. /**
  32256. * Format the given number to a specific decimal format
  32257. * @param value defines the number to format
  32258. * @param decimals defines the number of decimals to use
  32259. * @returns the formatted string
  32260. */
  32261. static Format(value: number, decimals?: number): string;
  32262. /**
  32263. * Checks if a given vector is inside a specific range
  32264. * @param v defines the vector to test
  32265. * @param min defines the minimum range
  32266. * @param max defines the maximum range
  32267. */
  32268. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32269. /**
  32270. * Tries to copy an object by duplicating every property
  32271. * @param source defines the source object
  32272. * @param destination defines the target object
  32273. * @param doNotCopyList defines a list of properties to avoid
  32274. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32275. */
  32276. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32277. /**
  32278. * Gets a boolean indicating if the given object has no own property
  32279. * @param obj defines the object to test
  32280. * @returns true if object has no own property
  32281. */
  32282. static IsEmpty(obj: any): boolean;
  32283. /**
  32284. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32285. * @param str Source string
  32286. * @param suffix Suffix to search for in the source string
  32287. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32288. */
  32289. static EndsWith(str: string, suffix: string): boolean;
  32290. /**
  32291. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  32292. * @param str Source string
  32293. * @param suffix Suffix to search for in the source string
  32294. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32295. */
  32296. static StartsWith(str: string, suffix: string): boolean;
  32297. /**
  32298. * Function used to register events at window level
  32299. * @param events defines the events to register
  32300. */
  32301. static RegisterTopRootEvents(events: {
  32302. name: string;
  32303. handler: Nullable<(e: FocusEvent) => any>;
  32304. }[]): void;
  32305. /**
  32306. * Function used to unregister events from window level
  32307. * @param events defines the events to unregister
  32308. */
  32309. static UnregisterTopRootEvents(events: {
  32310. name: string;
  32311. handler: Nullable<(e: FocusEvent) => any>;
  32312. }[]): void;
  32313. /**
  32314. * @ignore
  32315. */
  32316. static _ScreenshotCanvas: HTMLCanvasElement;
  32317. /**
  32318. * Dumps the current bound framebuffer
  32319. * @param width defines the rendering width
  32320. * @param height defines the rendering height
  32321. * @param engine defines the hosting engine
  32322. * @param successCallback defines the callback triggered once the data are available
  32323. * @param mimeType defines the mime type of the result
  32324. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32325. */
  32326. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32327. /**
  32328. * Converts the canvas data to blob.
  32329. * This acts as a polyfill for browsers not supporting the to blob function.
  32330. * @param canvas Defines the canvas to extract the data from
  32331. * @param successCallback Defines the callback triggered once the data are available
  32332. * @param mimeType Defines the mime type of the result
  32333. */
  32334. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32335. /**
  32336. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32337. * @param successCallback defines the callback triggered once the data are available
  32338. * @param mimeType defines the mime type of the result
  32339. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32340. */
  32341. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32342. /**
  32343. * Downloads a blob in the browser
  32344. * @param blob defines the blob to download
  32345. * @param fileName defines the name of the downloaded file
  32346. */
  32347. static Download(blob: Blob, fileName: string): void;
  32348. /**
  32349. * Captures a screenshot of the current rendering
  32350. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32351. * @param engine defines the rendering engine
  32352. * @param camera defines the source camera
  32353. * @param size This parameter can be set to a single number or to an object with the
  32354. * following (optional) properties: precision, width, height. If a single number is passed,
  32355. * it will be used for both width and height. If an object is passed, the screenshot size
  32356. * will be derived from the parameters. The precision property is a multiplier allowing
  32357. * rendering at a higher or lower resolution
  32358. * @param successCallback defines the callback receives a single parameter which contains the
  32359. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32360. * src parameter of an <img> to display it
  32361. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32362. * Check your browser for supported MIME types
  32363. */
  32364. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32365. /**
  32366. * Generates an image screenshot from the specified camera.
  32367. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32368. * @param engine The engine to use for rendering
  32369. * @param camera The camera to use for rendering
  32370. * @param size This parameter can be set to a single number or to an object with the
  32371. * following (optional) properties: precision, width, height. If a single number is passed,
  32372. * it will be used for both width and height. If an object is passed, the screenshot size
  32373. * will be derived from the parameters. The precision property is a multiplier allowing
  32374. * rendering at a higher or lower resolution
  32375. * @param successCallback The callback receives a single parameter which contains the
  32376. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32377. * src parameter of an <img> to display it
  32378. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32379. * Check your browser for supported MIME types
  32380. * @param samples Texture samples (default: 1)
  32381. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32382. * @param fileName A name for for the downloaded file.
  32383. */
  32384. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32385. /**
  32386. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32387. * Be aware Math.random() could cause collisions, but:
  32388. * "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"
  32389. * @returns a pseudo random id
  32390. */
  32391. static RandomId(): string;
  32392. /**
  32393. * Test if the given uri is a base64 string
  32394. * @param uri The uri to test
  32395. * @return True if the uri is a base64 string or false otherwise
  32396. */
  32397. static IsBase64(uri: string): boolean;
  32398. /**
  32399. * Decode the given base64 uri.
  32400. * @param uri The uri to decode
  32401. * @return The decoded base64 data.
  32402. */
  32403. static DecodeBase64(uri: string): ArrayBuffer;
  32404. /**
  32405. * Gets the absolute url.
  32406. * @param url the input url
  32407. * @return the absolute url
  32408. */
  32409. static GetAbsoluteUrl(url: string): string;
  32410. /**
  32411. * No log
  32412. */
  32413. static readonly NoneLogLevel: number;
  32414. /**
  32415. * Only message logs
  32416. */
  32417. static readonly MessageLogLevel: number;
  32418. /**
  32419. * Only warning logs
  32420. */
  32421. static readonly WarningLogLevel: number;
  32422. /**
  32423. * Only error logs
  32424. */
  32425. static readonly ErrorLogLevel: number;
  32426. /**
  32427. * All logs
  32428. */
  32429. static readonly AllLogLevel: number;
  32430. /**
  32431. * Gets a value indicating the number of loading errors
  32432. * @ignorenaming
  32433. */
  32434. static readonly errorsCount: number;
  32435. /**
  32436. * Callback called when a new log is added
  32437. */
  32438. static OnNewCacheEntry: (entry: string) => void;
  32439. /**
  32440. * Log a message to the console
  32441. * @param message defines the message to log
  32442. */
  32443. static Log(message: string): void;
  32444. /**
  32445. * Write a warning message to the console
  32446. * @param message defines the message to log
  32447. */
  32448. static Warn(message: string): void;
  32449. /**
  32450. * Write an error message to the console
  32451. * @param message defines the message to log
  32452. */
  32453. static Error(message: string): void;
  32454. /**
  32455. * Gets current log cache (list of logs)
  32456. */
  32457. static readonly LogCache: string;
  32458. /**
  32459. * Clears the log cache
  32460. */
  32461. static ClearLogCache(): void;
  32462. /**
  32463. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32464. */
  32465. static LogLevels: number;
  32466. /**
  32467. * Checks if the loaded document was accessed via `file:`-Protocol.
  32468. * @returns boolean
  32469. */
  32470. static IsFileURL(): boolean;
  32471. /**
  32472. * Checks if the window object exists
  32473. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32474. */
  32475. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32476. /**
  32477. * No performance log
  32478. */
  32479. static readonly PerformanceNoneLogLevel: number;
  32480. /**
  32481. * Use user marks to log performance
  32482. */
  32483. static readonly PerformanceUserMarkLogLevel: number;
  32484. /**
  32485. * Log performance to the console
  32486. */
  32487. static readonly PerformanceConsoleLogLevel: number;
  32488. private static _performance;
  32489. /**
  32490. * Sets the current performance log level
  32491. */
  32492. static PerformanceLogLevel: number;
  32493. private static _StartPerformanceCounterDisabled;
  32494. private static _EndPerformanceCounterDisabled;
  32495. private static _StartUserMark;
  32496. private static _EndUserMark;
  32497. private static _StartPerformanceConsole;
  32498. private static _EndPerformanceConsole;
  32499. /**
  32500. * Starts a performance counter
  32501. */
  32502. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32503. /**
  32504. * Ends a specific performance coutner
  32505. */
  32506. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32507. /**
  32508. * Gets either window.performance.now() if supported or Date.now() else
  32509. */
  32510. static readonly Now: number;
  32511. /**
  32512. * This method will return the name of the class used to create the instance of the given object.
  32513. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32514. * @param object the object to get the class name from
  32515. * @param isType defines if the object is actually a type
  32516. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32517. */
  32518. static GetClassName(object: any, isType?: boolean): string;
  32519. /**
  32520. * Gets the first element of an array satisfying a given predicate
  32521. * @param array defines the array to browse
  32522. * @param predicate defines the predicate to use
  32523. * @returns null if not found or the element
  32524. */
  32525. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32526. /**
  32527. * This method will return the name of the full name of the class, including its owning module (if any).
  32528. * 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).
  32529. * @param object the object to get the class name from
  32530. * @param isType defines if the object is actually a type
  32531. * @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.
  32532. * @ignorenaming
  32533. */
  32534. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32535. /**
  32536. * Returns a promise that resolves after the given amount of time.
  32537. * @param delay Number of milliseconds to delay
  32538. * @returns Promise that resolves after the given amount of time
  32539. */
  32540. static DelayAsync(delay: number): Promise<void>;
  32541. /**
  32542. * Gets the current gradient from an array of IValueGradient
  32543. * @param ratio defines the current ratio to get
  32544. * @param gradients defines the array of IValueGradient
  32545. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32546. */
  32547. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32548. }
  32549. /**
  32550. * This class is used to track a performance counter which is number based.
  32551. * The user has access to many properties which give statistics of different nature.
  32552. *
  32553. * The implementer can track two kinds of Performance Counter: time and count.
  32554. * 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.
  32555. * 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.
  32556. */
  32557. export class PerfCounter {
  32558. /**
  32559. * Gets or sets a global boolean to turn on and off all the counters
  32560. */
  32561. static Enabled: boolean;
  32562. /**
  32563. * Returns the smallest value ever
  32564. */
  32565. readonly min: number;
  32566. /**
  32567. * Returns the biggest value ever
  32568. */
  32569. readonly max: number;
  32570. /**
  32571. * Returns the average value since the performance counter is running
  32572. */
  32573. readonly average: number;
  32574. /**
  32575. * Returns the average value of the last second the counter was monitored
  32576. */
  32577. readonly lastSecAverage: number;
  32578. /**
  32579. * Returns the current value
  32580. */
  32581. readonly current: number;
  32582. /**
  32583. * Gets the accumulated total
  32584. */
  32585. readonly total: number;
  32586. /**
  32587. * Gets the total value count
  32588. */
  32589. readonly count: number;
  32590. /**
  32591. * Creates a new counter
  32592. */
  32593. constructor();
  32594. /**
  32595. * Call this method to start monitoring a new frame.
  32596. * 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.
  32597. */
  32598. fetchNewFrame(): void;
  32599. /**
  32600. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32601. * @param newCount the count value to add to the monitored count
  32602. * @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.
  32603. */
  32604. addCount(newCount: number, fetchResult: boolean): void;
  32605. /**
  32606. * Start monitoring this performance counter
  32607. */
  32608. beginMonitoring(): void;
  32609. /**
  32610. * Compute the time lapsed since the previous beginMonitoring() call.
  32611. * @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
  32612. */
  32613. endMonitoring(newFrame?: boolean): void;
  32614. private _fetchResult;
  32615. private _startMonitoringTime;
  32616. private _min;
  32617. private _max;
  32618. private _average;
  32619. private _current;
  32620. private _totalValueCount;
  32621. private _totalAccumulated;
  32622. private _lastSecAverage;
  32623. private _lastSecAccumulated;
  32624. private _lastSecTime;
  32625. private _lastSecValueCount;
  32626. }
  32627. /**
  32628. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32629. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32630. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32631. * @param name The name of the class, case should be preserved
  32632. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32633. */
  32634. export function className(name: string, module?: string): (target: Object) => void;
  32635. /**
  32636. * An implementation of a loop for asynchronous functions.
  32637. */
  32638. export class AsyncLoop {
  32639. /**
  32640. * Defines the number of iterations for the loop
  32641. */
  32642. iterations: number;
  32643. /**
  32644. * Defines the current index of the loop.
  32645. */
  32646. index: number;
  32647. private _done;
  32648. private _fn;
  32649. private _successCallback;
  32650. /**
  32651. * Constructor.
  32652. * @param iterations the number of iterations.
  32653. * @param func the function to run each iteration
  32654. * @param successCallback the callback that will be called upon succesful execution
  32655. * @param offset starting offset.
  32656. */
  32657. constructor(
  32658. /**
  32659. * Defines the number of iterations for the loop
  32660. */
  32661. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32662. /**
  32663. * Execute the next iteration. Must be called after the last iteration was finished.
  32664. */
  32665. executeNext(): void;
  32666. /**
  32667. * Break the loop and run the success callback.
  32668. */
  32669. breakLoop(): void;
  32670. /**
  32671. * Create and run an async loop.
  32672. * @param iterations the number of iterations.
  32673. * @param fn the function to run each iteration
  32674. * @param successCallback the callback that will be called upon succesful execution
  32675. * @param offset starting offset.
  32676. * @returns the created async loop object
  32677. */
  32678. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32679. /**
  32680. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32681. * @param iterations total number of iterations
  32682. * @param syncedIterations number of synchronous iterations in each async iteration.
  32683. * @param fn the function to call each iteration.
  32684. * @param callback a success call back that will be called when iterating stops.
  32685. * @param breakFunction a break condition (optional)
  32686. * @param timeout timeout settings for the setTimeout function. default - 0.
  32687. * @returns the created async loop object
  32688. */
  32689. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32690. }
  32691. }
  32692. declare module "babylonjs/Collisions/collisionCoordinator" {
  32693. import { Nullable } from "babylonjs/types";
  32694. import { Scene } from "babylonjs/scene";
  32695. import { Vector3 } from "babylonjs/Maths/math";
  32696. import { Collider } from "babylonjs/Collisions/collider";
  32697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32698. /** @hidden */
  32699. export interface ICollisionCoordinator {
  32700. createCollider(): Collider;
  32701. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32702. init(scene: Scene): void;
  32703. }
  32704. /** @hidden */
  32705. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32706. private _scene;
  32707. private _scaledPosition;
  32708. private _scaledVelocity;
  32709. private _finalPosition;
  32710. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32711. createCollider(): Collider;
  32712. init(scene: Scene): void;
  32713. private _collideWithWorld;
  32714. }
  32715. }
  32716. declare module "babylonjs/Inputs/scene.inputManager" {
  32717. import { Nullable } from "babylonjs/types";
  32718. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32719. import { Vector2 } from "babylonjs/Maths/math";
  32720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32721. import { Scene } from "babylonjs/scene";
  32722. /**
  32723. * Class used to manage all inputs for the scene.
  32724. */
  32725. export class InputManager {
  32726. /** The distance in pixel that you have to move to prevent some events */
  32727. static DragMovementThreshold: number;
  32728. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32729. static LongPressDelay: number;
  32730. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32731. static DoubleClickDelay: number;
  32732. /** If you need to check double click without raising a single click at first click, enable this flag */
  32733. static ExclusiveDoubleClickMode: boolean;
  32734. private _wheelEventName;
  32735. private _onPointerMove;
  32736. private _onPointerDown;
  32737. private _onPointerUp;
  32738. private _initClickEvent;
  32739. private _initActionManager;
  32740. private _delayedSimpleClick;
  32741. private _delayedSimpleClickTimeout;
  32742. private _previousDelayedSimpleClickTimeout;
  32743. private _meshPickProceed;
  32744. private _previousButtonPressed;
  32745. private _currentPickResult;
  32746. private _previousPickResult;
  32747. private _totalPointersPressed;
  32748. private _doubleClickOccured;
  32749. private _pointerOverMesh;
  32750. private _pickedDownMesh;
  32751. private _pickedUpMesh;
  32752. private _pointerX;
  32753. private _pointerY;
  32754. private _unTranslatedPointerX;
  32755. private _unTranslatedPointerY;
  32756. private _startingPointerPosition;
  32757. private _previousStartingPointerPosition;
  32758. private _startingPointerTime;
  32759. private _previousStartingPointerTime;
  32760. private _pointerCaptures;
  32761. private _onKeyDown;
  32762. private _onKeyUp;
  32763. private _onCanvasFocusObserver;
  32764. private _onCanvasBlurObserver;
  32765. private _scene;
  32766. /**
  32767. * Creates a new InputManager
  32768. * @param scene defines the hosting scene
  32769. */
  32770. constructor(scene: Scene);
  32771. /**
  32772. * Gets the mesh that is currently under the pointer
  32773. */
  32774. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32775. /**
  32776. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32777. */
  32778. readonly unTranslatedPointer: Vector2;
  32779. /**
  32780. * Gets or sets the current on-screen X position of the pointer
  32781. */
  32782. pointerX: number;
  32783. /**
  32784. * Gets or sets the current on-screen Y position of the pointer
  32785. */
  32786. pointerY: number;
  32787. private _updatePointerPosition;
  32788. private _processPointerMove;
  32789. private _setRayOnPointerInfo;
  32790. private _checkPrePointerObservable;
  32791. /**
  32792. * Use this method to simulate a pointer move on a mesh
  32793. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32794. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32795. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32796. */
  32797. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32798. /**
  32799. * Use this method to simulate a pointer down on a mesh
  32800. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32801. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32802. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32803. */
  32804. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32805. private _processPointerDown;
  32806. /** @hidden */
  32807. _isPointerSwiping(): boolean;
  32808. /**
  32809. * Use this method to simulate a pointer up on a mesh
  32810. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32811. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32812. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32813. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32814. */
  32815. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32816. private _processPointerUp;
  32817. /**
  32818. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32819. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32820. * @returns true if the pointer was captured
  32821. */
  32822. isPointerCaptured(pointerId?: number): boolean;
  32823. /**
  32824. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32825. * @param attachUp defines if you want to attach events to pointerup
  32826. * @param attachDown defines if you want to attach events to pointerdown
  32827. * @param attachMove defines if you want to attach events to pointermove
  32828. */
  32829. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32830. /**
  32831. * Detaches all event handlers
  32832. */
  32833. detachControl(): void;
  32834. /**
  32835. * Force the value of meshUnderPointer
  32836. * @param mesh defines the mesh to use
  32837. */
  32838. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32839. /**
  32840. * Gets the mesh under the pointer
  32841. * @returns a Mesh or null if no mesh is under the pointer
  32842. */
  32843. getPointerOverMesh(): Nullable<AbstractMesh>;
  32844. }
  32845. }
  32846. declare module "babylonjs/Animations/animationGroup" {
  32847. import { Animatable } from "babylonjs/Animations/animatable";
  32848. import { Animation } from "babylonjs/Animations/animation";
  32849. import { Scene, IDisposable } from "babylonjs/scene";
  32850. import { Observable } from "babylonjs/Misc/observable";
  32851. import { Nullable } from "babylonjs/types";
  32852. import "babylonjs/Animations/animatable";
  32853. /**
  32854. * This class defines the direct association between an animation and a target
  32855. */
  32856. export class TargetedAnimation {
  32857. /**
  32858. * Animation to perform
  32859. */
  32860. animation: Animation;
  32861. /**
  32862. * Target to animate
  32863. */
  32864. target: any;
  32865. /**
  32866. * Serialize the object
  32867. * @returns the JSON object representing the current entity
  32868. */
  32869. serialize(): any;
  32870. }
  32871. /**
  32872. * Use this class to create coordinated animations on multiple targets
  32873. */
  32874. export class AnimationGroup implements IDisposable {
  32875. /** The name of the animation group */
  32876. name: string;
  32877. private _scene;
  32878. private _targetedAnimations;
  32879. private _animatables;
  32880. private _from;
  32881. private _to;
  32882. private _isStarted;
  32883. private _isPaused;
  32884. private _speedRatio;
  32885. private _loopAnimation;
  32886. /**
  32887. * Gets or sets the unique id of the node
  32888. */
  32889. uniqueId: number;
  32890. /**
  32891. * This observable will notify when one animation have ended
  32892. */
  32893. onAnimationEndObservable: Observable<TargetedAnimation>;
  32894. /**
  32895. * Observer raised when one animation loops
  32896. */
  32897. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32898. /**
  32899. * This observable will notify when all animations have ended.
  32900. */
  32901. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32902. /**
  32903. * This observable will notify when all animations have paused.
  32904. */
  32905. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32906. /**
  32907. * This observable will notify when all animations are playing.
  32908. */
  32909. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32910. /**
  32911. * Gets the first frame
  32912. */
  32913. readonly from: number;
  32914. /**
  32915. * Gets the last frame
  32916. */
  32917. readonly to: number;
  32918. /**
  32919. * Define if the animations are started
  32920. */
  32921. readonly isStarted: boolean;
  32922. /**
  32923. * Gets a value indicating that the current group is playing
  32924. */
  32925. readonly isPlaying: boolean;
  32926. /**
  32927. * Gets or sets the speed ratio to use for all animations
  32928. */
  32929. /**
  32930. * Gets or sets the speed ratio to use for all animations
  32931. */
  32932. speedRatio: number;
  32933. /**
  32934. * Gets or sets if all animations should loop or not
  32935. */
  32936. loopAnimation: boolean;
  32937. /**
  32938. * Gets the targeted animations for this animation group
  32939. */
  32940. readonly targetedAnimations: Array<TargetedAnimation>;
  32941. /**
  32942. * returning the list of animatables controlled by this animation group.
  32943. */
  32944. readonly animatables: Array<Animatable>;
  32945. /**
  32946. * Instantiates a new Animation Group.
  32947. * This helps managing several animations at once.
  32948. * @see http://doc.babylonjs.com/how_to/group
  32949. * @param name Defines the name of the group
  32950. * @param scene Defines the scene the group belongs to
  32951. */
  32952. constructor(
  32953. /** The name of the animation group */
  32954. name: string, scene?: Nullable<Scene>);
  32955. /**
  32956. * Add an animation (with its target) in the group
  32957. * @param animation defines the animation we want to add
  32958. * @param target defines the target of the animation
  32959. * @returns the TargetedAnimation object
  32960. */
  32961. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32962. /**
  32963. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32964. * It can add constant keys at begin or end
  32965. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32966. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32967. * @returns the animation group
  32968. */
  32969. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32970. /**
  32971. * Start all animations on given targets
  32972. * @param loop defines if animations must loop
  32973. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32974. * @param from defines the from key (optional)
  32975. * @param to defines the to key (optional)
  32976. * @returns the current animation group
  32977. */
  32978. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32979. /**
  32980. * Pause all animations
  32981. * @returns the animation group
  32982. */
  32983. pause(): AnimationGroup;
  32984. /**
  32985. * Play all animations to initial state
  32986. * This function will start() the animations if they were not started or will restart() them if they were paused
  32987. * @param loop defines if animations must loop
  32988. * @returns the animation group
  32989. */
  32990. play(loop?: boolean): AnimationGroup;
  32991. /**
  32992. * Reset all animations to initial state
  32993. * @returns the animation group
  32994. */
  32995. reset(): AnimationGroup;
  32996. /**
  32997. * Restart animations from key 0
  32998. * @returns the animation group
  32999. */
  33000. restart(): AnimationGroup;
  33001. /**
  33002. * Stop all animations
  33003. * @returns the animation group
  33004. */
  33005. stop(): AnimationGroup;
  33006. /**
  33007. * Set animation weight for all animatables
  33008. * @param weight defines the weight to use
  33009. * @return the animationGroup
  33010. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33011. */
  33012. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33013. /**
  33014. * Synchronize and normalize all animatables with a source animatable
  33015. * @param root defines the root animatable to synchronize with
  33016. * @return the animationGroup
  33017. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33018. */
  33019. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33020. /**
  33021. * Goes to a specific frame in this animation group
  33022. * @param frame the frame number to go to
  33023. * @return the animationGroup
  33024. */
  33025. goToFrame(frame: number): AnimationGroup;
  33026. /**
  33027. * Dispose all associated resources
  33028. */
  33029. dispose(): void;
  33030. private _checkAnimationGroupEnded;
  33031. /**
  33032. * Clone the current animation group and returns a copy
  33033. * @param newName defines the name of the new group
  33034. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33035. * @returns the new aniamtion group
  33036. */
  33037. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33038. /**
  33039. * Serializes the animationGroup to an object
  33040. * @returns Serialized object
  33041. */
  33042. serialize(): any;
  33043. /**
  33044. * Returns a new AnimationGroup object parsed from the source provided.
  33045. * @param parsedAnimationGroup defines the source
  33046. * @param scene defines the scene that will receive the animationGroup
  33047. * @returns a new AnimationGroup
  33048. */
  33049. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33050. /**
  33051. * Returns the string "AnimationGroup"
  33052. * @returns "AnimationGroup"
  33053. */
  33054. getClassName(): string;
  33055. /**
  33056. * Creates a detailled string about the object
  33057. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33058. * @returns a string representing the object
  33059. */
  33060. toString(fullDetails?: boolean): string;
  33061. }
  33062. }
  33063. declare module "babylonjs/scene" {
  33064. import { Nullable } from "babylonjs/types";
  33065. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  33066. import { Observable } from "babylonjs/Misc/observable";
  33067. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33068. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  33069. import { Geometry } from "babylonjs/Meshes/geometry";
  33070. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33071. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33073. import { Mesh } from "babylonjs/Meshes/mesh";
  33074. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33075. import { Bone } from "babylonjs/Bones/bone";
  33076. import { Skeleton } from "babylonjs/Bones/skeleton";
  33077. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33078. import { Camera } from "babylonjs/Cameras/camera";
  33079. import { AbstractScene } from "babylonjs/abstractScene";
  33080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33081. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33082. import { Material } from "babylonjs/Materials/material";
  33083. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33084. import { Effect } from "babylonjs/Materials/effect";
  33085. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33086. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33087. import { Light } from "babylonjs/Lights/light";
  33088. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33089. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33090. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33091. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33092. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33093. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33094. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33095. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33096. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33097. import { Engine } from "babylonjs/Engines/engine";
  33098. import { Node } from "babylonjs/node";
  33099. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33100. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33101. import { WebRequest } from "babylonjs/Misc/webRequest";
  33102. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33103. import { Ray } from "babylonjs/Culling/ray";
  33104. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33105. import { Animation } from "babylonjs/Animations/animation";
  33106. import { Animatable } from "babylonjs/Animations/animatable";
  33107. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33108. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33109. import { Collider } from "babylonjs/Collisions/collider";
  33110. /**
  33111. * Define an interface for all classes that will hold resources
  33112. */
  33113. export interface IDisposable {
  33114. /**
  33115. * Releases all held resources
  33116. */
  33117. dispose(): void;
  33118. }
  33119. /** Interface defining initialization parameters for Scene class */
  33120. export interface SceneOptions {
  33121. /**
  33122. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33123. * It will improve performance when the number of geometries becomes important.
  33124. */
  33125. useGeometryUniqueIdsMap?: boolean;
  33126. /**
  33127. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33128. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33129. */
  33130. useMaterialMeshMap?: boolean;
  33131. /**
  33132. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33133. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33134. */
  33135. useClonedMeshhMap?: boolean;
  33136. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33137. virtual?: boolean;
  33138. }
  33139. /**
  33140. * Represents a scene to be rendered by the engine.
  33141. * @see http://doc.babylonjs.com/features/scene
  33142. */
  33143. export class Scene extends AbstractScene implements IAnimatable {
  33144. private static _uniqueIdCounter;
  33145. /** The fog is deactivated */
  33146. static readonly FOGMODE_NONE: number;
  33147. /** The fog density is following an exponential function */
  33148. static readonly FOGMODE_EXP: number;
  33149. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33150. static readonly FOGMODE_EXP2: number;
  33151. /** The fog density is following a linear function. */
  33152. static readonly FOGMODE_LINEAR: number;
  33153. /**
  33154. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33155. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33156. */
  33157. static MinDeltaTime: number;
  33158. /**
  33159. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33160. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33161. */
  33162. static MaxDeltaTime: number;
  33163. /**
  33164. * Factory used to create the default material.
  33165. * @param name The name of the material to create
  33166. * @param scene The scene to create the material for
  33167. * @returns The default material
  33168. */
  33169. static DefaultMaterialFactory(scene: Scene): Material;
  33170. /**
  33171. * Factory used to create the a collision coordinator.
  33172. * @returns The collision coordinator
  33173. */
  33174. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33175. /** @hidden */
  33176. _inputManager: InputManager;
  33177. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33178. cameraToUseForPointers: Nullable<Camera>;
  33179. /** @hidden */
  33180. readonly _isScene: boolean;
  33181. /**
  33182. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33183. */
  33184. autoClear: boolean;
  33185. /**
  33186. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33187. */
  33188. autoClearDepthAndStencil: boolean;
  33189. /**
  33190. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33191. */
  33192. clearColor: Color4;
  33193. /**
  33194. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33195. */
  33196. ambientColor: Color3;
  33197. /**
  33198. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33199. * It should only be one of the following (if not the default embedded one):
  33200. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33201. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33202. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33203. * The material properties need to be setup according to the type of texture in use.
  33204. */
  33205. environmentBRDFTexture: BaseTexture;
  33206. /** @hidden */
  33207. protected _environmentTexture: Nullable<BaseTexture>;
  33208. /**
  33209. * Texture used in all pbr material as the reflection texture.
  33210. * As in the majority of the scene they are the same (exception for multi room and so on),
  33211. * this is easier to reference from here than from all the materials.
  33212. */
  33213. /**
  33214. * Texture used in all pbr material as the reflection texture.
  33215. * As in the majority of the scene they are the same (exception for multi room and so on),
  33216. * this is easier to set here than in all the materials.
  33217. */
  33218. environmentTexture: Nullable<BaseTexture>;
  33219. /** @hidden */
  33220. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33221. /**
  33222. * Default image processing configuration used either in the rendering
  33223. * Forward main pass or through the imageProcessingPostProcess if present.
  33224. * As in the majority of the scene they are the same (exception for multi camera),
  33225. * this is easier to reference from here than from all the materials and post process.
  33226. *
  33227. * No setter as we it is a shared configuration, you can set the values instead.
  33228. */
  33229. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33230. private _forceWireframe;
  33231. /**
  33232. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33233. */
  33234. forceWireframe: boolean;
  33235. private _forcePointsCloud;
  33236. /**
  33237. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33238. */
  33239. forcePointsCloud: boolean;
  33240. /**
  33241. * Gets or sets the active clipplane 1
  33242. */
  33243. clipPlane: Nullable<Plane>;
  33244. /**
  33245. * Gets or sets the active clipplane 2
  33246. */
  33247. clipPlane2: Nullable<Plane>;
  33248. /**
  33249. * Gets or sets the active clipplane 3
  33250. */
  33251. clipPlane3: Nullable<Plane>;
  33252. /**
  33253. * Gets or sets the active clipplane 4
  33254. */
  33255. clipPlane4: Nullable<Plane>;
  33256. /**
  33257. * Gets or sets a boolean indicating if animations are enabled
  33258. */
  33259. animationsEnabled: boolean;
  33260. private _animationPropertiesOverride;
  33261. /**
  33262. * Gets or sets the animation properties override
  33263. */
  33264. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33265. /**
  33266. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33267. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33268. */
  33269. useConstantAnimationDeltaTime: boolean;
  33270. /**
  33271. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33272. * Please note that it requires to run a ray cast through the scene on every frame
  33273. */
  33274. constantlyUpdateMeshUnderPointer: boolean;
  33275. /**
  33276. * Defines the HTML cursor to use when hovering over interactive elements
  33277. */
  33278. hoverCursor: string;
  33279. /**
  33280. * Defines the HTML default cursor to use (empty by default)
  33281. */
  33282. defaultCursor: string;
  33283. /**
  33284. * This is used to call preventDefault() on pointer down
  33285. * in order to block unwanted artifacts like system double clicks
  33286. */
  33287. preventDefaultOnPointerDown: boolean;
  33288. /**
  33289. * This is used to call preventDefault() on pointer up
  33290. * in order to block unwanted artifacts like system double clicks
  33291. */
  33292. preventDefaultOnPointerUp: boolean;
  33293. /**
  33294. * Gets or sets user defined metadata
  33295. */
  33296. metadata: any;
  33297. /**
  33298. * For internal use only. Please do not use.
  33299. */
  33300. reservedDataStore: any;
  33301. /**
  33302. * Gets the name of the plugin used to load this scene (null by default)
  33303. */
  33304. loadingPluginName: string;
  33305. /**
  33306. * Use this array to add regular expressions used to disable offline support for specific urls
  33307. */
  33308. disableOfflineSupportExceptionRules: RegExp[];
  33309. /**
  33310. * An event triggered when the scene is disposed.
  33311. */
  33312. onDisposeObservable: Observable<Scene>;
  33313. private _onDisposeObserver;
  33314. /** Sets a function to be executed when this scene is disposed. */
  33315. onDispose: () => void;
  33316. /**
  33317. * An event triggered before rendering the scene (right after animations and physics)
  33318. */
  33319. onBeforeRenderObservable: Observable<Scene>;
  33320. private _onBeforeRenderObserver;
  33321. /** Sets a function to be executed before rendering this scene */
  33322. beforeRender: Nullable<() => void>;
  33323. /**
  33324. * An event triggered after rendering the scene
  33325. */
  33326. onAfterRenderObservable: Observable<Scene>;
  33327. /**
  33328. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33329. */
  33330. onAfterRenderCameraObservable: Observable<Camera>;
  33331. private _onAfterRenderObserver;
  33332. /** Sets a function to be executed after rendering this scene */
  33333. afterRender: Nullable<() => void>;
  33334. /**
  33335. * An event triggered before animating the scene
  33336. */
  33337. onBeforeAnimationsObservable: Observable<Scene>;
  33338. /**
  33339. * An event triggered after animations processing
  33340. */
  33341. onAfterAnimationsObservable: Observable<Scene>;
  33342. /**
  33343. * An event triggered before draw calls are ready to be sent
  33344. */
  33345. onBeforeDrawPhaseObservable: Observable<Scene>;
  33346. /**
  33347. * An event triggered after draw calls have been sent
  33348. */
  33349. onAfterDrawPhaseObservable: Observable<Scene>;
  33350. /**
  33351. * An event triggered when the scene is ready
  33352. */
  33353. onReadyObservable: Observable<Scene>;
  33354. /**
  33355. * An event triggered before rendering a camera
  33356. */
  33357. onBeforeCameraRenderObservable: Observable<Camera>;
  33358. private _onBeforeCameraRenderObserver;
  33359. /** Sets a function to be executed before rendering a camera*/
  33360. beforeCameraRender: () => void;
  33361. /**
  33362. * An event triggered after rendering a camera
  33363. */
  33364. onAfterCameraRenderObservable: Observable<Camera>;
  33365. private _onAfterCameraRenderObserver;
  33366. /** Sets a function to be executed after rendering a camera*/
  33367. afterCameraRender: () => void;
  33368. /**
  33369. * An event triggered when active meshes evaluation is about to start
  33370. */
  33371. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33372. /**
  33373. * An event triggered when active meshes evaluation is done
  33374. */
  33375. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33376. /**
  33377. * An event triggered when particles rendering is about to start
  33378. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33379. */
  33380. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33381. /**
  33382. * An event triggered when particles rendering is done
  33383. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33384. */
  33385. onAfterParticlesRenderingObservable: Observable<Scene>;
  33386. /**
  33387. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33388. */
  33389. onDataLoadedObservable: Observable<Scene>;
  33390. /**
  33391. * An event triggered when a camera is created
  33392. */
  33393. onNewCameraAddedObservable: Observable<Camera>;
  33394. /**
  33395. * An event triggered when a camera is removed
  33396. */
  33397. onCameraRemovedObservable: Observable<Camera>;
  33398. /**
  33399. * An event triggered when a light is created
  33400. */
  33401. onNewLightAddedObservable: Observable<Light>;
  33402. /**
  33403. * An event triggered when a light is removed
  33404. */
  33405. onLightRemovedObservable: Observable<Light>;
  33406. /**
  33407. * An event triggered when a geometry is created
  33408. */
  33409. onNewGeometryAddedObservable: Observable<Geometry>;
  33410. /**
  33411. * An event triggered when a geometry is removed
  33412. */
  33413. onGeometryRemovedObservable: Observable<Geometry>;
  33414. /**
  33415. * An event triggered when a transform node is created
  33416. */
  33417. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33418. /**
  33419. * An event triggered when a transform node is removed
  33420. */
  33421. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33422. /**
  33423. * An event triggered when a mesh is created
  33424. */
  33425. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33426. /**
  33427. * An event triggered when a mesh is removed
  33428. */
  33429. onMeshRemovedObservable: Observable<AbstractMesh>;
  33430. /**
  33431. * An event triggered when a skeleton is created
  33432. */
  33433. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33434. /**
  33435. * An event triggered when a skeleton is removed
  33436. */
  33437. onSkeletonRemovedObservable: Observable<Skeleton>;
  33438. /**
  33439. * An event triggered when a material is created
  33440. */
  33441. onNewMaterialAddedObservable: Observable<Material>;
  33442. /**
  33443. * An event triggered when a material is removed
  33444. */
  33445. onMaterialRemovedObservable: Observable<Material>;
  33446. /**
  33447. * An event triggered when a texture is created
  33448. */
  33449. onNewTextureAddedObservable: Observable<BaseTexture>;
  33450. /**
  33451. * An event triggered when a texture is removed
  33452. */
  33453. onTextureRemovedObservable: Observable<BaseTexture>;
  33454. /**
  33455. * An event triggered when render targets are about to be rendered
  33456. * Can happen multiple times per frame.
  33457. */
  33458. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33459. /**
  33460. * An event triggered when render targets were rendered.
  33461. * Can happen multiple times per frame.
  33462. */
  33463. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33464. /**
  33465. * An event triggered before calculating deterministic simulation step
  33466. */
  33467. onBeforeStepObservable: Observable<Scene>;
  33468. /**
  33469. * An event triggered after calculating deterministic simulation step
  33470. */
  33471. onAfterStepObservable: Observable<Scene>;
  33472. /**
  33473. * An event triggered when the activeCamera property is updated
  33474. */
  33475. onActiveCameraChanged: Observable<Scene>;
  33476. /**
  33477. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33478. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33479. * 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)
  33480. */
  33481. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33482. /**
  33483. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33484. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33485. * 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)
  33486. */
  33487. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33488. /**
  33489. * This Observable will when a mesh has been imported into the scene.
  33490. */
  33491. onMeshImportedObservable: Observable<AbstractMesh>;
  33492. /**
  33493. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33494. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33495. */
  33496. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33497. /** @hidden */
  33498. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33499. /**
  33500. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33501. */
  33502. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33503. /**
  33504. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33505. */
  33506. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33507. /**
  33508. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33509. */
  33510. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33511. /** Callback called when a pointer move is detected */
  33512. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33513. /** Callback called when a pointer down is detected */
  33514. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33515. /** Callback called when a pointer up is detected */
  33516. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33517. /** Callback called when a pointer pick is detected */
  33518. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33519. /**
  33520. * 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).
  33521. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33522. */
  33523. onPrePointerObservable: Observable<PointerInfoPre>;
  33524. /**
  33525. * Observable event triggered each time an input event is received from the rendering canvas
  33526. */
  33527. onPointerObservable: Observable<PointerInfo>;
  33528. /**
  33529. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33530. */
  33531. readonly unTranslatedPointer: Vector2;
  33532. /**
  33533. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33534. */
  33535. static DragMovementThreshold: number;
  33536. /**
  33537. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33538. */
  33539. static LongPressDelay: number;
  33540. /**
  33541. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33542. */
  33543. static DoubleClickDelay: number;
  33544. /** If you need to check double click without raising a single click at first click, enable this flag */
  33545. static ExclusiveDoubleClickMode: boolean;
  33546. /** @hidden */
  33547. _mirroredCameraPosition: Nullable<Vector3>;
  33548. /**
  33549. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33550. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33551. */
  33552. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33553. /**
  33554. * Observable event triggered each time an keyboard event is received from the hosting window
  33555. */
  33556. onKeyboardObservable: Observable<KeyboardInfo>;
  33557. private _useRightHandedSystem;
  33558. /**
  33559. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33560. */
  33561. useRightHandedSystem: boolean;
  33562. private _timeAccumulator;
  33563. private _currentStepId;
  33564. private _currentInternalStep;
  33565. /**
  33566. * Sets the step Id used by deterministic lock step
  33567. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33568. * @param newStepId defines the step Id
  33569. */
  33570. setStepId(newStepId: number): void;
  33571. /**
  33572. * Gets the step Id used by deterministic lock step
  33573. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33574. * @returns the step Id
  33575. */
  33576. getStepId(): number;
  33577. /**
  33578. * Gets the internal step used by deterministic lock step
  33579. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33580. * @returns the internal step
  33581. */
  33582. getInternalStep(): number;
  33583. private _fogEnabled;
  33584. /**
  33585. * Gets or sets a boolean indicating if fog is enabled on this scene
  33586. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33587. * (Default is true)
  33588. */
  33589. fogEnabled: boolean;
  33590. private _fogMode;
  33591. /**
  33592. * Gets or sets the fog mode to use
  33593. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33594. * | mode | value |
  33595. * | --- | --- |
  33596. * | FOGMODE_NONE | 0 |
  33597. * | FOGMODE_EXP | 1 |
  33598. * | FOGMODE_EXP2 | 2 |
  33599. * | FOGMODE_LINEAR | 3 |
  33600. */
  33601. fogMode: number;
  33602. /**
  33603. * Gets or sets the fog color to use
  33604. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33605. * (Default is Color3(0.2, 0.2, 0.3))
  33606. */
  33607. fogColor: Color3;
  33608. /**
  33609. * Gets or sets the fog density to use
  33610. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33611. * (Default is 0.1)
  33612. */
  33613. fogDensity: number;
  33614. /**
  33615. * Gets or sets the fog start distance to use
  33616. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33617. * (Default is 0)
  33618. */
  33619. fogStart: number;
  33620. /**
  33621. * Gets or sets the fog end distance to use
  33622. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33623. * (Default is 1000)
  33624. */
  33625. fogEnd: number;
  33626. private _shadowsEnabled;
  33627. /**
  33628. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33629. */
  33630. shadowsEnabled: boolean;
  33631. private _lightsEnabled;
  33632. /**
  33633. * Gets or sets a boolean indicating if lights are enabled on this scene
  33634. */
  33635. lightsEnabled: boolean;
  33636. /** All of the active cameras added to this scene. */
  33637. activeCameras: Camera[];
  33638. /** @hidden */
  33639. _activeCamera: Nullable<Camera>;
  33640. /** Gets or sets the current active camera */
  33641. activeCamera: Nullable<Camera>;
  33642. private _defaultMaterial;
  33643. /** The default material used on meshes when no material is affected */
  33644. /** The default material used on meshes when no material is affected */
  33645. defaultMaterial: Material;
  33646. private _texturesEnabled;
  33647. /**
  33648. * Gets or sets a boolean indicating if textures are enabled on this scene
  33649. */
  33650. texturesEnabled: boolean;
  33651. /**
  33652. * Gets or sets a boolean indicating if particles are enabled on this scene
  33653. */
  33654. particlesEnabled: boolean;
  33655. /**
  33656. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33657. */
  33658. spritesEnabled: boolean;
  33659. private _skeletonsEnabled;
  33660. /**
  33661. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33662. */
  33663. skeletonsEnabled: boolean;
  33664. /**
  33665. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33666. */
  33667. lensFlaresEnabled: boolean;
  33668. /**
  33669. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33670. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33671. */
  33672. collisionsEnabled: boolean;
  33673. private _collisionCoordinator;
  33674. /** @hidden */
  33675. readonly collisionCoordinator: ICollisionCoordinator;
  33676. /**
  33677. * Defines the gravity applied to this scene (used only for collisions)
  33678. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33679. */
  33680. gravity: Vector3;
  33681. /**
  33682. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33683. */
  33684. postProcessesEnabled: boolean;
  33685. /**
  33686. * The list of postprocesses added to the scene
  33687. */
  33688. postProcesses: PostProcess[];
  33689. /**
  33690. * Gets the current postprocess manager
  33691. */
  33692. postProcessManager: PostProcessManager;
  33693. /**
  33694. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33695. */
  33696. renderTargetsEnabled: boolean;
  33697. /**
  33698. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33699. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33700. */
  33701. dumpNextRenderTargets: boolean;
  33702. /**
  33703. * The list of user defined render targets added to the scene
  33704. */
  33705. customRenderTargets: RenderTargetTexture[];
  33706. /**
  33707. * Defines if texture loading must be delayed
  33708. * If true, textures will only be loaded when they need to be rendered
  33709. */
  33710. useDelayedTextureLoading: boolean;
  33711. /**
  33712. * Gets the list of meshes imported to the scene through SceneLoader
  33713. */
  33714. importedMeshesFiles: String[];
  33715. /**
  33716. * Gets or sets a boolean indicating if probes are enabled on this scene
  33717. */
  33718. probesEnabled: boolean;
  33719. /**
  33720. * Gets or sets the current offline provider to use to store scene data
  33721. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33722. */
  33723. offlineProvider: IOfflineProvider;
  33724. /**
  33725. * Gets or sets the action manager associated with the scene
  33726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33727. */
  33728. actionManager: AbstractActionManager;
  33729. private _meshesForIntersections;
  33730. /**
  33731. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33732. */
  33733. proceduralTexturesEnabled: boolean;
  33734. private _engine;
  33735. private _totalVertices;
  33736. /** @hidden */
  33737. _activeIndices: PerfCounter;
  33738. /** @hidden */
  33739. _activeParticles: PerfCounter;
  33740. /** @hidden */
  33741. _activeBones: PerfCounter;
  33742. private _animationRatio;
  33743. /** @hidden */
  33744. _animationTimeLast: number;
  33745. /** @hidden */
  33746. _animationTime: number;
  33747. /**
  33748. * Gets or sets a general scale for animation speed
  33749. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33750. */
  33751. animationTimeScale: number;
  33752. /** @hidden */
  33753. _cachedMaterial: Nullable<Material>;
  33754. /** @hidden */
  33755. _cachedEffect: Nullable<Effect>;
  33756. /** @hidden */
  33757. _cachedVisibility: Nullable<number>;
  33758. private _renderId;
  33759. private _frameId;
  33760. private _executeWhenReadyTimeoutId;
  33761. private _intermediateRendering;
  33762. private _viewUpdateFlag;
  33763. private _projectionUpdateFlag;
  33764. /** @hidden */
  33765. _toBeDisposed: Nullable<IDisposable>[];
  33766. private _activeRequests;
  33767. /** @hidden */
  33768. _pendingData: any[];
  33769. private _isDisposed;
  33770. /**
  33771. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33772. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33773. */
  33774. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33775. private _activeMeshes;
  33776. private _processedMaterials;
  33777. private _renderTargets;
  33778. /** @hidden */
  33779. _activeParticleSystems: SmartArray<IParticleSystem>;
  33780. private _activeSkeletons;
  33781. private _softwareSkinnedMeshes;
  33782. private _renderingManager;
  33783. /** @hidden */
  33784. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33785. private _transformMatrix;
  33786. private _sceneUbo;
  33787. /** @hidden */
  33788. _viewMatrix: Matrix;
  33789. private _projectionMatrix;
  33790. /** @hidden */
  33791. _forcedViewPosition: Nullable<Vector3>;
  33792. /** @hidden */
  33793. _frustumPlanes: Plane[];
  33794. /**
  33795. * Gets the list of frustum planes (built from the active camera)
  33796. */
  33797. readonly frustumPlanes: Plane[];
  33798. /**
  33799. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33800. * This is useful if there are more lights that the maximum simulteanous authorized
  33801. */
  33802. requireLightSorting: boolean;
  33803. /** @hidden */
  33804. readonly useMaterialMeshMap: boolean;
  33805. /** @hidden */
  33806. readonly useClonedMeshhMap: boolean;
  33807. private _externalData;
  33808. private _uid;
  33809. /**
  33810. * @hidden
  33811. * Backing store of defined scene components.
  33812. */
  33813. _components: ISceneComponent[];
  33814. /**
  33815. * @hidden
  33816. * Backing store of defined scene components.
  33817. */
  33818. _serializableComponents: ISceneSerializableComponent[];
  33819. /**
  33820. * List of components to register on the next registration step.
  33821. */
  33822. private _transientComponents;
  33823. /**
  33824. * Registers the transient components if needed.
  33825. */
  33826. private _registerTransientComponents;
  33827. /**
  33828. * @hidden
  33829. * Add a component to the scene.
  33830. * Note that the ccomponent could be registered on th next frame if this is called after
  33831. * the register component stage.
  33832. * @param component Defines the component to add to the scene
  33833. */
  33834. _addComponent(component: ISceneComponent): void;
  33835. /**
  33836. * @hidden
  33837. * Gets a component from the scene.
  33838. * @param name defines the name of the component to retrieve
  33839. * @returns the component or null if not present
  33840. */
  33841. _getComponent(name: string): Nullable<ISceneComponent>;
  33842. /**
  33843. * @hidden
  33844. * Defines the actions happening before camera updates.
  33845. */
  33846. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33847. /**
  33848. * @hidden
  33849. * Defines the actions happening before clear the canvas.
  33850. */
  33851. _beforeClearStage: Stage<SimpleStageAction>;
  33852. /**
  33853. * @hidden
  33854. * Defines the actions when collecting render targets for the frame.
  33855. */
  33856. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33857. /**
  33858. * @hidden
  33859. * Defines the actions happening for one camera in the frame.
  33860. */
  33861. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33862. /**
  33863. * @hidden
  33864. * Defines the actions happening during the per mesh ready checks.
  33865. */
  33866. _isReadyForMeshStage: Stage<MeshStageAction>;
  33867. /**
  33868. * @hidden
  33869. * Defines the actions happening before evaluate active mesh checks.
  33870. */
  33871. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33872. /**
  33873. * @hidden
  33874. * Defines the actions happening during the evaluate sub mesh checks.
  33875. */
  33876. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33877. /**
  33878. * @hidden
  33879. * Defines the actions happening during the active mesh stage.
  33880. */
  33881. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33882. /**
  33883. * @hidden
  33884. * Defines the actions happening during the per camera render target step.
  33885. */
  33886. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33887. /**
  33888. * @hidden
  33889. * Defines the actions happening just before the active camera is drawing.
  33890. */
  33891. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33892. /**
  33893. * @hidden
  33894. * Defines the actions happening just before a render target is drawing.
  33895. */
  33896. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33897. /**
  33898. * @hidden
  33899. * Defines the actions happening just before a rendering group is drawing.
  33900. */
  33901. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33902. /**
  33903. * @hidden
  33904. * Defines the actions happening just before a mesh is drawing.
  33905. */
  33906. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33907. /**
  33908. * @hidden
  33909. * Defines the actions happening just after a mesh has been drawn.
  33910. */
  33911. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33912. /**
  33913. * @hidden
  33914. * Defines the actions happening just after a rendering group has been drawn.
  33915. */
  33916. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33917. /**
  33918. * @hidden
  33919. * Defines the actions happening just after the active camera has been drawn.
  33920. */
  33921. _afterCameraDrawStage: Stage<CameraStageAction>;
  33922. /**
  33923. * @hidden
  33924. * Defines the actions happening just after a render target has been drawn.
  33925. */
  33926. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33927. /**
  33928. * @hidden
  33929. * Defines the actions happening just after rendering all cameras and computing intersections.
  33930. */
  33931. _afterRenderStage: Stage<SimpleStageAction>;
  33932. /**
  33933. * @hidden
  33934. * Defines the actions happening when a pointer move event happens.
  33935. */
  33936. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33937. /**
  33938. * @hidden
  33939. * Defines the actions happening when a pointer down event happens.
  33940. */
  33941. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33942. /**
  33943. * @hidden
  33944. * Defines the actions happening when a pointer up event happens.
  33945. */
  33946. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33947. /**
  33948. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33949. */
  33950. private geometriesByUniqueId;
  33951. /**
  33952. * Creates a new Scene
  33953. * @param engine defines the engine to use to render this scene
  33954. * @param options defines the scene options
  33955. */
  33956. constructor(engine: Engine, options?: SceneOptions);
  33957. /**
  33958. * Gets a string idenfifying the name of the class
  33959. * @returns "Scene" string
  33960. */
  33961. getClassName(): string;
  33962. private _defaultMeshCandidates;
  33963. /**
  33964. * @hidden
  33965. */
  33966. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33967. private _defaultSubMeshCandidates;
  33968. /**
  33969. * @hidden
  33970. */
  33971. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33972. /**
  33973. * Sets the default candidate providers for the scene.
  33974. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33975. * and getCollidingSubMeshCandidates to their default function
  33976. */
  33977. setDefaultCandidateProviders(): void;
  33978. /**
  33979. * Gets the mesh that is currently under the pointer
  33980. */
  33981. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33982. /**
  33983. * Gets or sets the current on-screen X position of the pointer
  33984. */
  33985. pointerX: number;
  33986. /**
  33987. * Gets or sets the current on-screen Y position of the pointer
  33988. */
  33989. pointerY: number;
  33990. /**
  33991. * Gets the cached material (ie. the latest rendered one)
  33992. * @returns the cached material
  33993. */
  33994. getCachedMaterial(): Nullable<Material>;
  33995. /**
  33996. * Gets the cached effect (ie. the latest rendered one)
  33997. * @returns the cached effect
  33998. */
  33999. getCachedEffect(): Nullable<Effect>;
  34000. /**
  34001. * Gets the cached visibility state (ie. the latest rendered one)
  34002. * @returns the cached visibility state
  34003. */
  34004. getCachedVisibility(): Nullable<number>;
  34005. /**
  34006. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34007. * @param material defines the current material
  34008. * @param effect defines the current effect
  34009. * @param visibility defines the current visibility state
  34010. * @returns true if one parameter is not cached
  34011. */
  34012. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34013. /**
  34014. * Gets the engine associated with the scene
  34015. * @returns an Engine
  34016. */
  34017. getEngine(): Engine;
  34018. /**
  34019. * Gets the total number of vertices rendered per frame
  34020. * @returns the total number of vertices rendered per frame
  34021. */
  34022. getTotalVertices(): number;
  34023. /**
  34024. * Gets the performance counter for total vertices
  34025. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34026. */
  34027. readonly totalVerticesPerfCounter: PerfCounter;
  34028. /**
  34029. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34030. * @returns the total number of active indices rendered per frame
  34031. */
  34032. getActiveIndices(): number;
  34033. /**
  34034. * Gets the performance counter for active indices
  34035. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34036. */
  34037. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34038. /**
  34039. * Gets the total number of active particles rendered per frame
  34040. * @returns the total number of active particles rendered per frame
  34041. */
  34042. getActiveParticles(): number;
  34043. /**
  34044. * Gets the performance counter for active particles
  34045. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34046. */
  34047. readonly activeParticlesPerfCounter: PerfCounter;
  34048. /**
  34049. * Gets the total number of active bones rendered per frame
  34050. * @returns the total number of active bones rendered per frame
  34051. */
  34052. getActiveBones(): number;
  34053. /**
  34054. * Gets the performance counter for active bones
  34055. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34056. */
  34057. readonly activeBonesPerfCounter: PerfCounter;
  34058. /**
  34059. * Gets the array of active meshes
  34060. * @returns an array of AbstractMesh
  34061. */
  34062. getActiveMeshes(): SmartArray<AbstractMesh>;
  34063. /**
  34064. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34065. * @returns a number
  34066. */
  34067. getAnimationRatio(): number;
  34068. /**
  34069. * Gets an unique Id for the current render phase
  34070. * @returns a number
  34071. */
  34072. getRenderId(): number;
  34073. /**
  34074. * Gets an unique Id for the current frame
  34075. * @returns a number
  34076. */
  34077. getFrameId(): number;
  34078. /** Call this function if you want to manually increment the render Id*/
  34079. incrementRenderId(): void;
  34080. private _createUbo;
  34081. /**
  34082. * Use this method to simulate a pointer move on a mesh
  34083. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34084. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34085. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34086. * @returns the current scene
  34087. */
  34088. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34089. /**
  34090. * Use this method to simulate a pointer down on a mesh
  34091. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34092. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34093. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34094. * @returns the current scene
  34095. */
  34096. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34097. /**
  34098. * Use this method to simulate a pointer up on a mesh
  34099. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34100. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34101. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34102. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34103. * @returns the current scene
  34104. */
  34105. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34106. /**
  34107. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34108. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34109. * @returns true if the pointer was captured
  34110. */
  34111. isPointerCaptured(pointerId?: number): boolean;
  34112. /**
  34113. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34114. * @param attachUp defines if you want to attach events to pointerup
  34115. * @param attachDown defines if you want to attach events to pointerdown
  34116. * @param attachMove defines if you want to attach events to pointermove
  34117. */
  34118. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34119. /** Detaches all event handlers*/
  34120. detachControl(): void;
  34121. /**
  34122. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34123. * Delay loaded resources are not taking in account
  34124. * @return true if all required resources are ready
  34125. */
  34126. isReady(): boolean;
  34127. /** Resets all cached information relative to material (including effect and visibility) */
  34128. resetCachedMaterial(): void;
  34129. /**
  34130. * Registers a function to be called before every frame render
  34131. * @param func defines the function to register
  34132. */
  34133. registerBeforeRender(func: () => void): void;
  34134. /**
  34135. * Unregisters a function called before every frame render
  34136. * @param func defines the function to unregister
  34137. */
  34138. unregisterBeforeRender(func: () => void): void;
  34139. /**
  34140. * Registers a function to be called after every frame render
  34141. * @param func defines the function to register
  34142. */
  34143. registerAfterRender(func: () => void): void;
  34144. /**
  34145. * Unregisters a function called after every frame render
  34146. * @param func defines the function to unregister
  34147. */
  34148. unregisterAfterRender(func: () => void): void;
  34149. private _executeOnceBeforeRender;
  34150. /**
  34151. * The provided function will run before render once and will be disposed afterwards.
  34152. * A timeout delay can be provided so that the function will be executed in N ms.
  34153. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34154. * @param func The function to be executed.
  34155. * @param timeout optional delay in ms
  34156. */
  34157. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34158. /** @hidden */
  34159. _addPendingData(data: any): void;
  34160. /** @hidden */
  34161. _removePendingData(data: any): void;
  34162. /**
  34163. * Returns the number of items waiting to be loaded
  34164. * @returns the number of items waiting to be loaded
  34165. */
  34166. getWaitingItemsCount(): number;
  34167. /**
  34168. * Returns a boolean indicating if the scene is still loading data
  34169. */
  34170. readonly isLoading: boolean;
  34171. /**
  34172. * Registers a function to be executed when the scene is ready
  34173. * @param {Function} func - the function to be executed
  34174. */
  34175. executeWhenReady(func: () => void): void;
  34176. /**
  34177. * Returns a promise that resolves when the scene is ready
  34178. * @returns A promise that resolves when the scene is ready
  34179. */
  34180. whenReadyAsync(): Promise<void>;
  34181. /** @hidden */
  34182. _checkIsReady(): void;
  34183. /**
  34184. * Gets all animatable attached to the scene
  34185. */
  34186. readonly animatables: Animatable[];
  34187. /**
  34188. * Resets the last animation time frame.
  34189. * Useful to override when animations start running when loading a scene for the first time.
  34190. */
  34191. resetLastAnimationTimeFrame(): void;
  34192. /**
  34193. * Gets the current view matrix
  34194. * @returns a Matrix
  34195. */
  34196. getViewMatrix(): Matrix;
  34197. /**
  34198. * Gets the current projection matrix
  34199. * @returns a Matrix
  34200. */
  34201. getProjectionMatrix(): Matrix;
  34202. /**
  34203. * Gets the current transform matrix
  34204. * @returns a Matrix made of View * Projection
  34205. */
  34206. getTransformMatrix(): Matrix;
  34207. /**
  34208. * Sets the current transform matrix
  34209. * @param viewL defines the View matrix to use
  34210. * @param projectionL defines the Projection matrix to use
  34211. * @param viewR defines the right View matrix to use (if provided)
  34212. * @param projectionR defines the right Projection matrix to use (if provided)
  34213. */
  34214. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34215. /**
  34216. * Gets the uniform buffer used to store scene data
  34217. * @returns a UniformBuffer
  34218. */
  34219. getSceneUniformBuffer(): UniformBuffer;
  34220. /**
  34221. * Gets an unique (relatively to the current scene) Id
  34222. * @returns an unique number for the scene
  34223. */
  34224. getUniqueId(): number;
  34225. /**
  34226. * Add a mesh to the list of scene's meshes
  34227. * @param newMesh defines the mesh to add
  34228. * @param recursive if all child meshes should also be added to the scene
  34229. */
  34230. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34231. /**
  34232. * Remove a mesh for the list of scene's meshes
  34233. * @param toRemove defines the mesh to remove
  34234. * @param recursive if all child meshes should also be removed from the scene
  34235. * @returns the index where the mesh was in the mesh list
  34236. */
  34237. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34238. /**
  34239. * Add a transform node to the list of scene's transform nodes
  34240. * @param newTransformNode defines the transform node to add
  34241. */
  34242. addTransformNode(newTransformNode: TransformNode): void;
  34243. /**
  34244. * Remove a transform node for the list of scene's transform nodes
  34245. * @param toRemove defines the transform node to remove
  34246. * @returns the index where the transform node was in the transform node list
  34247. */
  34248. removeTransformNode(toRemove: TransformNode): number;
  34249. /**
  34250. * Remove a skeleton for the list of scene's skeletons
  34251. * @param toRemove defines the skeleton to remove
  34252. * @returns the index where the skeleton was in the skeleton list
  34253. */
  34254. removeSkeleton(toRemove: Skeleton): number;
  34255. /**
  34256. * Remove a morph target for the list of scene's morph targets
  34257. * @param toRemove defines the morph target to remove
  34258. * @returns the index where the morph target was in the morph target list
  34259. */
  34260. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34261. /**
  34262. * Remove a light for the list of scene's lights
  34263. * @param toRemove defines the light to remove
  34264. * @returns the index where the light was in the light list
  34265. */
  34266. removeLight(toRemove: Light): number;
  34267. /**
  34268. * Remove a camera for the list of scene's cameras
  34269. * @param toRemove defines the camera to remove
  34270. * @returns the index where the camera was in the camera list
  34271. */
  34272. removeCamera(toRemove: Camera): number;
  34273. /**
  34274. * Remove a particle system for the list of scene's particle systems
  34275. * @param toRemove defines the particle system to remove
  34276. * @returns the index where the particle system was in the particle system list
  34277. */
  34278. removeParticleSystem(toRemove: IParticleSystem): number;
  34279. /**
  34280. * Remove a animation for the list of scene's animations
  34281. * @param toRemove defines the animation to remove
  34282. * @returns the index where the animation was in the animation list
  34283. */
  34284. removeAnimation(toRemove: Animation): number;
  34285. /**
  34286. * Will stop the animation of the given target
  34287. * @param target - the target
  34288. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34289. * @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)
  34290. */
  34291. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34292. /**
  34293. * Removes the given animation group from this scene.
  34294. * @param toRemove The animation group to remove
  34295. * @returns The index of the removed animation group
  34296. */
  34297. removeAnimationGroup(toRemove: AnimationGroup): number;
  34298. /**
  34299. * Removes the given multi-material from this scene.
  34300. * @param toRemove The multi-material to remove
  34301. * @returns The index of the removed multi-material
  34302. */
  34303. removeMultiMaterial(toRemove: MultiMaterial): number;
  34304. /**
  34305. * Removes the given material from this scene.
  34306. * @param toRemove The material to remove
  34307. * @returns The index of the removed material
  34308. */
  34309. removeMaterial(toRemove: Material): number;
  34310. /**
  34311. * Removes the given action manager from this scene.
  34312. * @param toRemove The action manager to remove
  34313. * @returns The index of the removed action manager
  34314. */
  34315. removeActionManager(toRemove: AbstractActionManager): number;
  34316. /**
  34317. * Removes the given texture from this scene.
  34318. * @param toRemove The texture to remove
  34319. * @returns The index of the removed texture
  34320. */
  34321. removeTexture(toRemove: BaseTexture): number;
  34322. /**
  34323. * Adds the given light to this scene
  34324. * @param newLight The light to add
  34325. */
  34326. addLight(newLight: Light): void;
  34327. /**
  34328. * Sorts the list list based on light priorities
  34329. */
  34330. sortLightsByPriority(): void;
  34331. /**
  34332. * Adds the given camera to this scene
  34333. * @param newCamera The camera to add
  34334. */
  34335. addCamera(newCamera: Camera): void;
  34336. /**
  34337. * Adds the given skeleton to this scene
  34338. * @param newSkeleton The skeleton to add
  34339. */
  34340. addSkeleton(newSkeleton: Skeleton): void;
  34341. /**
  34342. * Adds the given particle system to this scene
  34343. * @param newParticleSystem The particle system to add
  34344. */
  34345. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34346. /**
  34347. * Adds the given animation to this scene
  34348. * @param newAnimation The animation to add
  34349. */
  34350. addAnimation(newAnimation: Animation): void;
  34351. /**
  34352. * Adds the given animation group to this scene.
  34353. * @param newAnimationGroup The animation group to add
  34354. */
  34355. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34356. /**
  34357. * Adds the given multi-material to this scene
  34358. * @param newMultiMaterial The multi-material to add
  34359. */
  34360. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34361. /**
  34362. * Adds the given material to this scene
  34363. * @param newMaterial The material to add
  34364. */
  34365. addMaterial(newMaterial: Material): void;
  34366. /**
  34367. * Adds the given morph target to this scene
  34368. * @param newMorphTargetManager The morph target to add
  34369. */
  34370. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34371. /**
  34372. * Adds the given geometry to this scene
  34373. * @param newGeometry The geometry to add
  34374. */
  34375. addGeometry(newGeometry: Geometry): void;
  34376. /**
  34377. * Adds the given action manager to this scene
  34378. * @param newActionManager The action manager to add
  34379. */
  34380. addActionManager(newActionManager: AbstractActionManager): void;
  34381. /**
  34382. * Adds the given texture to this scene.
  34383. * @param newTexture The texture to add
  34384. */
  34385. addTexture(newTexture: BaseTexture): void;
  34386. /**
  34387. * Switch active camera
  34388. * @param newCamera defines the new active camera
  34389. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34390. */
  34391. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34392. /**
  34393. * sets the active camera of the scene using its ID
  34394. * @param id defines the camera's ID
  34395. * @return the new active camera or null if none found.
  34396. */
  34397. setActiveCameraByID(id: string): Nullable<Camera>;
  34398. /**
  34399. * sets the active camera of the scene using its name
  34400. * @param name defines the camera's name
  34401. * @returns the new active camera or null if none found.
  34402. */
  34403. setActiveCameraByName(name: string): Nullable<Camera>;
  34404. /**
  34405. * get an animation group using its name
  34406. * @param name defines the material's name
  34407. * @return the animation group or null if none found.
  34408. */
  34409. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34410. /**
  34411. * Get a material using its unique id
  34412. * @param uniqueId defines the material's unique id
  34413. * @return the material or null if none found.
  34414. */
  34415. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34416. /**
  34417. * get a material using its id
  34418. * @param id defines the material's ID
  34419. * @return the material or null if none found.
  34420. */
  34421. getMaterialByID(id: string): Nullable<Material>;
  34422. /**
  34423. * Gets a material using its name
  34424. * @param name defines the material's name
  34425. * @return the material or null if none found.
  34426. */
  34427. getMaterialByName(name: string): Nullable<Material>;
  34428. /**
  34429. * Gets a camera using its id
  34430. * @param id defines the id to look for
  34431. * @returns the camera or null if not found
  34432. */
  34433. getCameraByID(id: string): Nullable<Camera>;
  34434. /**
  34435. * Gets a camera using its unique id
  34436. * @param uniqueId defines the unique id to look for
  34437. * @returns the camera or null if not found
  34438. */
  34439. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34440. /**
  34441. * Gets a camera using its name
  34442. * @param name defines the camera's name
  34443. * @return the camera or null if none found.
  34444. */
  34445. getCameraByName(name: string): Nullable<Camera>;
  34446. /**
  34447. * Gets a bone using its id
  34448. * @param id defines the bone's id
  34449. * @return the bone or null if not found
  34450. */
  34451. getBoneByID(id: string): Nullable<Bone>;
  34452. /**
  34453. * Gets a bone using its id
  34454. * @param name defines the bone's name
  34455. * @return the bone or null if not found
  34456. */
  34457. getBoneByName(name: string): Nullable<Bone>;
  34458. /**
  34459. * Gets a light node using its name
  34460. * @param name defines the the light's name
  34461. * @return the light or null if none found.
  34462. */
  34463. getLightByName(name: string): Nullable<Light>;
  34464. /**
  34465. * Gets a light node using its id
  34466. * @param id defines the light's id
  34467. * @return the light or null if none found.
  34468. */
  34469. getLightByID(id: string): Nullable<Light>;
  34470. /**
  34471. * Gets a light node using its scene-generated unique ID
  34472. * @param uniqueId defines the light's unique id
  34473. * @return the light or null if none found.
  34474. */
  34475. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34476. /**
  34477. * Gets a particle system by id
  34478. * @param id defines the particle system id
  34479. * @return the corresponding system or null if none found
  34480. */
  34481. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34482. /**
  34483. * Gets a geometry using its ID
  34484. * @param id defines the geometry's id
  34485. * @return the geometry or null if none found.
  34486. */
  34487. getGeometryByID(id: string): Nullable<Geometry>;
  34488. private _getGeometryByUniqueID;
  34489. /**
  34490. * Add a new geometry to this scene
  34491. * @param geometry defines the geometry to be added to the scene.
  34492. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34493. * @return a boolean defining if the geometry was added or not
  34494. */
  34495. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34496. /**
  34497. * Removes an existing geometry
  34498. * @param geometry defines the geometry to be removed from the scene
  34499. * @return a boolean defining if the geometry was removed or not
  34500. */
  34501. removeGeometry(geometry: Geometry): boolean;
  34502. /**
  34503. * Gets the list of geometries attached to the scene
  34504. * @returns an array of Geometry
  34505. */
  34506. getGeometries(): Geometry[];
  34507. /**
  34508. * Gets the first added mesh found of a given ID
  34509. * @param id defines the id to search for
  34510. * @return the mesh found or null if not found at all
  34511. */
  34512. getMeshByID(id: string): Nullable<AbstractMesh>;
  34513. /**
  34514. * Gets a list of meshes using their id
  34515. * @param id defines the id to search for
  34516. * @returns a list of meshes
  34517. */
  34518. getMeshesByID(id: string): Array<AbstractMesh>;
  34519. /**
  34520. * Gets the first added transform node found of a given ID
  34521. * @param id defines the id to search for
  34522. * @return the found transform node or null if not found at all.
  34523. */
  34524. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34525. /**
  34526. * Gets a transform node with its auto-generated unique id
  34527. * @param uniqueId efines the unique id to search for
  34528. * @return the found transform node or null if not found at all.
  34529. */
  34530. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34531. /**
  34532. * Gets a list of transform nodes using their id
  34533. * @param id defines the id to search for
  34534. * @returns a list of transform nodes
  34535. */
  34536. getTransformNodesByID(id: string): Array<TransformNode>;
  34537. /**
  34538. * Gets a mesh with its auto-generated unique id
  34539. * @param uniqueId defines the unique id to search for
  34540. * @return the found mesh or null if not found at all.
  34541. */
  34542. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34543. /**
  34544. * Gets a the last added mesh using a given id
  34545. * @param id defines the id to search for
  34546. * @return the found mesh or null if not found at all.
  34547. */
  34548. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34549. /**
  34550. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34551. * @param id defines the id to search for
  34552. * @return the found node or null if not found at all
  34553. */
  34554. getLastEntryByID(id: string): Nullable<Node>;
  34555. /**
  34556. * Gets a node (Mesh, Camera, Light) using a given id
  34557. * @param id defines the id to search for
  34558. * @return the found node or null if not found at all
  34559. */
  34560. getNodeByID(id: string): Nullable<Node>;
  34561. /**
  34562. * Gets a node (Mesh, Camera, Light) using a given name
  34563. * @param name defines the name to search for
  34564. * @return the found node or null if not found at all.
  34565. */
  34566. getNodeByName(name: string): Nullable<Node>;
  34567. /**
  34568. * Gets a mesh using a given name
  34569. * @param name defines the name to search for
  34570. * @return the found mesh or null if not found at all.
  34571. */
  34572. getMeshByName(name: string): Nullable<AbstractMesh>;
  34573. /**
  34574. * Gets a transform node using a given name
  34575. * @param name defines the name to search for
  34576. * @return the found transform node or null if not found at all.
  34577. */
  34578. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34579. /**
  34580. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34581. * @param id defines the id to search for
  34582. * @return the found skeleton or null if not found at all.
  34583. */
  34584. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34585. /**
  34586. * Gets a skeleton using a given auto generated unique id
  34587. * @param uniqueId defines the unique id to search for
  34588. * @return the found skeleton or null if not found at all.
  34589. */
  34590. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34591. /**
  34592. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34593. * @param id defines the id to search for
  34594. * @return the found skeleton or null if not found at all.
  34595. */
  34596. getSkeletonById(id: string): Nullable<Skeleton>;
  34597. /**
  34598. * Gets a skeleton using a given name
  34599. * @param name defines the name to search for
  34600. * @return the found skeleton or null if not found at all.
  34601. */
  34602. getSkeletonByName(name: string): Nullable<Skeleton>;
  34603. /**
  34604. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34605. * @param id defines the id to search for
  34606. * @return the found morph target manager or null if not found at all.
  34607. */
  34608. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34609. /**
  34610. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34611. * @param id defines the id to search for
  34612. * @return the found morph target or null if not found at all.
  34613. */
  34614. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34615. /**
  34616. * Gets a boolean indicating if the given mesh is active
  34617. * @param mesh defines the mesh to look for
  34618. * @returns true if the mesh is in the active list
  34619. */
  34620. isActiveMesh(mesh: AbstractMesh): boolean;
  34621. /**
  34622. * Return a unique id as a string which can serve as an identifier for the scene
  34623. */
  34624. readonly uid: string;
  34625. /**
  34626. * Add an externaly attached data from its key.
  34627. * This method call will fail and return false, if such key already exists.
  34628. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34629. * @param key the unique key that identifies the data
  34630. * @param data the data object to associate to the key for this Engine instance
  34631. * @return true if no such key were already present and the data was added successfully, false otherwise
  34632. */
  34633. addExternalData<T>(key: string, data: T): boolean;
  34634. /**
  34635. * Get an externaly attached data from its key
  34636. * @param key the unique key that identifies the data
  34637. * @return the associated data, if present (can be null), or undefined if not present
  34638. */
  34639. getExternalData<T>(key: string): Nullable<T>;
  34640. /**
  34641. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34642. * @param key the unique key that identifies the data
  34643. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34644. * @return the associated data, can be null if the factory returned null.
  34645. */
  34646. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34647. /**
  34648. * Remove an externaly attached data from the Engine instance
  34649. * @param key the unique key that identifies the data
  34650. * @return true if the data was successfully removed, false if it doesn't exist
  34651. */
  34652. removeExternalData(key: string): boolean;
  34653. private _evaluateSubMesh;
  34654. /**
  34655. * Clear the processed materials smart array preventing retention point in material dispose.
  34656. */
  34657. freeProcessedMaterials(): void;
  34658. private _preventFreeActiveMeshesAndRenderingGroups;
  34659. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34660. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34661. * when disposing several meshes in a row or a hierarchy of meshes.
  34662. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34663. */
  34664. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34665. /**
  34666. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34667. */
  34668. freeActiveMeshes(): void;
  34669. /**
  34670. * Clear the info related to rendering groups preventing retention points during dispose.
  34671. */
  34672. freeRenderingGroups(): void;
  34673. /** @hidden */
  34674. _isInIntermediateRendering(): boolean;
  34675. /**
  34676. * Lambda returning the list of potentially active meshes.
  34677. */
  34678. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34679. /**
  34680. * Lambda returning the list of potentially active sub meshes.
  34681. */
  34682. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34683. /**
  34684. * Lambda returning the list of potentially intersecting sub meshes.
  34685. */
  34686. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34687. /**
  34688. * Lambda returning the list of potentially colliding sub meshes.
  34689. */
  34690. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34691. private _activeMeshesFrozen;
  34692. /**
  34693. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34694. * @returns the current scene
  34695. */
  34696. freezeActiveMeshes(): Scene;
  34697. /**
  34698. * Use this function to restart evaluating active meshes on every frame
  34699. * @returns the current scene
  34700. */
  34701. unfreezeActiveMeshes(): Scene;
  34702. private _evaluateActiveMeshes;
  34703. private _activeMesh;
  34704. /**
  34705. * Update the transform matrix to update from the current active camera
  34706. * @param force defines a boolean used to force the update even if cache is up to date
  34707. */
  34708. updateTransformMatrix(force?: boolean): void;
  34709. private _bindFrameBuffer;
  34710. /** @hidden */
  34711. _allowPostProcessClearColor: boolean;
  34712. /** @hidden */
  34713. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34714. private _processSubCameras;
  34715. private _checkIntersections;
  34716. /** @hidden */
  34717. _advancePhysicsEngineStep(step: number): void;
  34718. /**
  34719. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34720. */
  34721. getDeterministicFrameTime: () => number;
  34722. /** @hidden */
  34723. _animate(): void;
  34724. /** Execute all animations (for a frame) */
  34725. animate(): void;
  34726. /**
  34727. * Render the scene
  34728. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34729. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34730. */
  34731. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34732. /**
  34733. * Freeze all materials
  34734. * A frozen material will not be updatable but should be faster to render
  34735. */
  34736. freezeMaterials(): void;
  34737. /**
  34738. * Unfreeze all materials
  34739. * A frozen material will not be updatable but should be faster to render
  34740. */
  34741. unfreezeMaterials(): void;
  34742. /**
  34743. * Releases all held ressources
  34744. */
  34745. dispose(): void;
  34746. /**
  34747. * Gets if the scene is already disposed
  34748. */
  34749. readonly isDisposed: boolean;
  34750. /**
  34751. * Call this function to reduce memory footprint of the scene.
  34752. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34753. */
  34754. clearCachedVertexData(): void;
  34755. /**
  34756. * This function will remove the local cached buffer data from texture.
  34757. * It will save memory but will prevent the texture from being rebuilt
  34758. */
  34759. cleanCachedTextureBuffer(): void;
  34760. /**
  34761. * Get the world extend vectors with an optional filter
  34762. *
  34763. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34764. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34765. */
  34766. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34767. min: Vector3;
  34768. max: Vector3;
  34769. };
  34770. /**
  34771. * Creates a ray that can be used to pick in the scene
  34772. * @param x defines the x coordinate of the origin (on-screen)
  34773. * @param y defines the y coordinate of the origin (on-screen)
  34774. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34775. * @param camera defines the camera to use for the picking
  34776. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34777. * @returns a Ray
  34778. */
  34779. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34780. /**
  34781. * Creates a ray that can be used to pick in the scene
  34782. * @param x defines the x coordinate of the origin (on-screen)
  34783. * @param y defines the y coordinate of the origin (on-screen)
  34784. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34785. * @param result defines the ray where to store the picking ray
  34786. * @param camera defines the camera to use for the picking
  34787. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34788. * @returns the current scene
  34789. */
  34790. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34791. /**
  34792. * Creates a ray that can be used to pick in the scene
  34793. * @param x defines the x coordinate of the origin (on-screen)
  34794. * @param y defines the y coordinate of the origin (on-screen)
  34795. * @param camera defines the camera to use for the picking
  34796. * @returns a Ray
  34797. */
  34798. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34799. /**
  34800. * Creates a ray that can be used to pick in the scene
  34801. * @param x defines the x coordinate of the origin (on-screen)
  34802. * @param y defines the y coordinate of the origin (on-screen)
  34803. * @param result defines the ray where to store the picking ray
  34804. * @param camera defines the camera to use for the picking
  34805. * @returns the current scene
  34806. */
  34807. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34808. /** Launch a ray to try to pick a mesh in the scene
  34809. * @param x position on screen
  34810. * @param y position on screen
  34811. * @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
  34812. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34813. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34814. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34815. * @returns a PickingInfo
  34816. */
  34817. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34818. /** Use the given ray to pick a mesh in the scene
  34819. * @param ray The ray to use to pick meshes
  34820. * @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
  34821. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34822. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34823. * @returns a PickingInfo
  34824. */
  34825. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34826. /**
  34827. * Launch a ray to try to pick a mesh in the scene
  34828. * @param x X position on screen
  34829. * @param y Y position on screen
  34830. * @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
  34831. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34832. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34833. * @returns an array of PickingInfo
  34834. */
  34835. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34836. /**
  34837. * Launch a ray to try to pick a mesh in the scene
  34838. * @param ray Ray to use
  34839. * @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
  34840. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34841. * @returns an array of PickingInfo
  34842. */
  34843. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34844. /**
  34845. * Force the value of meshUnderPointer
  34846. * @param mesh defines the mesh to use
  34847. */
  34848. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34849. /**
  34850. * Gets the mesh under the pointer
  34851. * @returns a Mesh or null if no mesh is under the pointer
  34852. */
  34853. getPointerOverMesh(): Nullable<AbstractMesh>;
  34854. /** @hidden */
  34855. _rebuildGeometries(): void;
  34856. /** @hidden */
  34857. _rebuildTextures(): void;
  34858. private _getByTags;
  34859. /**
  34860. * Get a list of meshes by tags
  34861. * @param tagsQuery defines the tags query to use
  34862. * @param forEach defines a predicate used to filter results
  34863. * @returns an array of Mesh
  34864. */
  34865. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34866. /**
  34867. * Get a list of cameras by tags
  34868. * @param tagsQuery defines the tags query to use
  34869. * @param forEach defines a predicate used to filter results
  34870. * @returns an array of Camera
  34871. */
  34872. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34873. /**
  34874. * Get a list of lights by tags
  34875. * @param tagsQuery defines the tags query to use
  34876. * @param forEach defines a predicate used to filter results
  34877. * @returns an array of Light
  34878. */
  34879. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34880. /**
  34881. * Get a list of materials by tags
  34882. * @param tagsQuery defines the tags query to use
  34883. * @param forEach defines a predicate used to filter results
  34884. * @returns an array of Material
  34885. */
  34886. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34887. /**
  34888. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34889. * This allowed control for front to back rendering or reversly depending of the special needs.
  34890. *
  34891. * @param renderingGroupId The rendering group id corresponding to its index
  34892. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34893. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34894. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34895. */
  34896. 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;
  34897. /**
  34898. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34899. *
  34900. * @param renderingGroupId The rendering group id corresponding to its index
  34901. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34902. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34903. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34904. */
  34905. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34906. /**
  34907. * Gets the current auto clear configuration for one rendering group of the rendering
  34908. * manager.
  34909. * @param index the rendering group index to get the information for
  34910. * @returns The auto clear setup for the requested rendering group
  34911. */
  34912. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34913. private _blockMaterialDirtyMechanism;
  34914. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34915. blockMaterialDirtyMechanism: boolean;
  34916. /**
  34917. * Will flag all materials as dirty to trigger new shader compilation
  34918. * @param flag defines the flag used to specify which material part must be marked as dirty
  34919. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34920. */
  34921. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34922. /** @hidden */
  34923. _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;
  34924. /** @hidden */
  34925. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34926. }
  34927. }
  34928. declare module "babylonjs/assetContainer" {
  34929. import { AbstractScene } from "babylonjs/abstractScene";
  34930. import { Scene } from "babylonjs/scene";
  34931. import { Mesh } from "babylonjs/Meshes/mesh";
  34932. /**
  34933. * Set of assets to keep when moving a scene into an asset container.
  34934. */
  34935. export class KeepAssets extends AbstractScene {
  34936. }
  34937. /**
  34938. * Container with a set of assets that can be added or removed from a scene.
  34939. */
  34940. export class AssetContainer extends AbstractScene {
  34941. /**
  34942. * The scene the AssetContainer belongs to.
  34943. */
  34944. scene: Scene;
  34945. /**
  34946. * Instantiates an AssetContainer.
  34947. * @param scene The scene the AssetContainer belongs to.
  34948. */
  34949. constructor(scene: Scene);
  34950. /**
  34951. * Adds all the assets from the container to the scene.
  34952. */
  34953. addAllToScene(): void;
  34954. /**
  34955. * Removes all the assets in the container from the scene
  34956. */
  34957. removeAllFromScene(): void;
  34958. /**
  34959. * Disposes all the assets in the container
  34960. */
  34961. dispose(): void;
  34962. private _moveAssets;
  34963. /**
  34964. * Removes all the assets contained in the scene and adds them to the container.
  34965. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34966. */
  34967. moveAllFromScene(keepAssets?: KeepAssets): void;
  34968. /**
  34969. * 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.
  34970. * @returns the root mesh
  34971. */
  34972. createRootMesh(): Mesh;
  34973. }
  34974. }
  34975. declare module "babylonjs/abstractScene" {
  34976. import { Scene } from "babylonjs/scene";
  34977. import { Nullable } from "babylonjs/types";
  34978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34979. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34980. import { Geometry } from "babylonjs/Meshes/geometry";
  34981. import { Skeleton } from "babylonjs/Bones/skeleton";
  34982. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34983. import { AssetContainer } from "babylonjs/assetContainer";
  34984. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34985. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34986. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34987. import { Material } from "babylonjs/Materials/material";
  34988. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34989. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34990. import { Camera } from "babylonjs/Cameras/camera";
  34991. import { Light } from "babylonjs/Lights/light";
  34992. import { Node } from "babylonjs/node";
  34993. import { Animation } from "babylonjs/Animations/animation";
  34994. /**
  34995. * Defines how the parser contract is defined.
  34996. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34997. */
  34998. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34999. /**
  35000. * Defines how the individual parser contract is defined.
  35001. * These parser can parse an individual asset
  35002. */
  35003. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35004. /**
  35005. * Base class of the scene acting as a container for the different elements composing a scene.
  35006. * This class is dynamically extended by the different components of the scene increasing
  35007. * flexibility and reducing coupling
  35008. */
  35009. export abstract class AbstractScene {
  35010. /**
  35011. * Stores the list of available parsers in the application.
  35012. */
  35013. private static _BabylonFileParsers;
  35014. /**
  35015. * Stores the list of available individual parsers in the application.
  35016. */
  35017. private static _IndividualBabylonFileParsers;
  35018. /**
  35019. * Adds a parser in the list of available ones
  35020. * @param name Defines the name of the parser
  35021. * @param parser Defines the parser to add
  35022. */
  35023. static AddParser(name: string, parser: BabylonFileParser): void;
  35024. /**
  35025. * Gets a general parser from the list of avaialble ones
  35026. * @param name Defines the name of the parser
  35027. * @returns the requested parser or null
  35028. */
  35029. static GetParser(name: string): Nullable<BabylonFileParser>;
  35030. /**
  35031. * Adds n individual parser in the list of available ones
  35032. * @param name Defines the name of the parser
  35033. * @param parser Defines the parser to add
  35034. */
  35035. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35036. /**
  35037. * Gets an individual parser from the list of avaialble ones
  35038. * @param name Defines the name of the parser
  35039. * @returns the requested parser or null
  35040. */
  35041. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35042. /**
  35043. * Parser json data and populate both a scene and its associated container object
  35044. * @param jsonData Defines the data to parse
  35045. * @param scene Defines the scene to parse the data for
  35046. * @param container Defines the container attached to the parsing sequence
  35047. * @param rootUrl Defines the root url of the data
  35048. */
  35049. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35050. /**
  35051. * Gets the list of root nodes (ie. nodes with no parent)
  35052. */
  35053. rootNodes: Node[];
  35054. /** All of the cameras added to this scene
  35055. * @see http://doc.babylonjs.com/babylon101/cameras
  35056. */
  35057. cameras: Camera[];
  35058. /**
  35059. * All of the lights added to this scene
  35060. * @see http://doc.babylonjs.com/babylon101/lights
  35061. */
  35062. lights: Light[];
  35063. /**
  35064. * All of the (abstract) meshes added to this scene
  35065. */
  35066. meshes: AbstractMesh[];
  35067. /**
  35068. * The list of skeletons added to the scene
  35069. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35070. */
  35071. skeletons: Skeleton[];
  35072. /**
  35073. * All of the particle systems added to this scene
  35074. * @see http://doc.babylonjs.com/babylon101/particles
  35075. */
  35076. particleSystems: IParticleSystem[];
  35077. /**
  35078. * Gets a list of Animations associated with the scene
  35079. */
  35080. animations: Animation[];
  35081. /**
  35082. * All of the animation groups added to this scene
  35083. * @see http://doc.babylonjs.com/how_to/group
  35084. */
  35085. animationGroups: AnimationGroup[];
  35086. /**
  35087. * All of the multi-materials added to this scene
  35088. * @see http://doc.babylonjs.com/how_to/multi_materials
  35089. */
  35090. multiMaterials: MultiMaterial[];
  35091. /**
  35092. * All of the materials added to this scene
  35093. * In the context of a Scene, it is not supposed to be modified manually.
  35094. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35095. * Note also that the order of the Material wihin the array is not significant and might change.
  35096. * @see http://doc.babylonjs.com/babylon101/materials
  35097. */
  35098. materials: Material[];
  35099. /**
  35100. * The list of morph target managers added to the scene
  35101. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35102. */
  35103. morphTargetManagers: MorphTargetManager[];
  35104. /**
  35105. * The list of geometries used in the scene.
  35106. */
  35107. geometries: Geometry[];
  35108. /**
  35109. * All of the tranform nodes added to this scene
  35110. * In the context of a Scene, it is not supposed to be modified manually.
  35111. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35112. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35113. * @see http://doc.babylonjs.com/how_to/transformnode
  35114. */
  35115. transformNodes: TransformNode[];
  35116. /**
  35117. * ActionManagers available on the scene.
  35118. */
  35119. actionManagers: AbstractActionManager[];
  35120. /**
  35121. * Textures to keep.
  35122. */
  35123. textures: BaseTexture[];
  35124. /**
  35125. * Environment texture for the scene
  35126. */
  35127. environmentTexture: Nullable<BaseTexture>;
  35128. }
  35129. }
  35130. declare module "babylonjs/Audio/sound" {
  35131. import { Observable } from "babylonjs/Misc/observable";
  35132. import { Vector3 } from "babylonjs/Maths/math";
  35133. import { Nullable } from "babylonjs/types";
  35134. import { Scene } from "babylonjs/scene";
  35135. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35136. /**
  35137. * Interface used to define options for Sound class
  35138. */
  35139. export interface ISoundOptions {
  35140. /**
  35141. * Does the sound autoplay once loaded.
  35142. */
  35143. autoplay?: boolean;
  35144. /**
  35145. * Does the sound loop after it finishes playing once.
  35146. */
  35147. loop?: boolean;
  35148. /**
  35149. * Sound's volume
  35150. */
  35151. volume?: number;
  35152. /**
  35153. * Is it a spatial sound?
  35154. */
  35155. spatialSound?: boolean;
  35156. /**
  35157. * Maximum distance to hear that sound
  35158. */
  35159. maxDistance?: number;
  35160. /**
  35161. * Uses user defined attenuation function
  35162. */
  35163. useCustomAttenuation?: boolean;
  35164. /**
  35165. * Define the roll off factor of spatial sounds.
  35166. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35167. */
  35168. rolloffFactor?: number;
  35169. /**
  35170. * Define the reference distance the sound should be heard perfectly.
  35171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35172. */
  35173. refDistance?: number;
  35174. /**
  35175. * Define the distance attenuation model the sound will follow.
  35176. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35177. */
  35178. distanceModel?: string;
  35179. /**
  35180. * Defines the playback speed (1 by default)
  35181. */
  35182. playbackRate?: number;
  35183. /**
  35184. * Defines if the sound is from a streaming source
  35185. */
  35186. streaming?: boolean;
  35187. /**
  35188. * Defines an optional length (in seconds) inside the sound file
  35189. */
  35190. length?: number;
  35191. /**
  35192. * Defines an optional offset (in seconds) inside the sound file
  35193. */
  35194. offset?: number;
  35195. }
  35196. /**
  35197. * Defines a sound that can be played in the application.
  35198. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35199. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35200. */
  35201. export class Sound {
  35202. /**
  35203. * The name of the sound in the scene.
  35204. */
  35205. name: string;
  35206. /**
  35207. * Does the sound autoplay once loaded.
  35208. */
  35209. autoplay: boolean;
  35210. /**
  35211. * Does the sound loop after it finishes playing once.
  35212. */
  35213. loop: boolean;
  35214. /**
  35215. * Does the sound use a custom attenuation curve to simulate the falloff
  35216. * happening when the source gets further away from the camera.
  35217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35218. */
  35219. useCustomAttenuation: boolean;
  35220. /**
  35221. * The sound track id this sound belongs to.
  35222. */
  35223. soundTrackId: number;
  35224. /**
  35225. * Is this sound currently played.
  35226. */
  35227. isPlaying: boolean;
  35228. /**
  35229. * Is this sound currently paused.
  35230. */
  35231. isPaused: boolean;
  35232. /**
  35233. * Does this sound enables spatial sound.
  35234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35235. */
  35236. spatialSound: boolean;
  35237. /**
  35238. * Define the reference distance the sound should be heard perfectly.
  35239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35240. */
  35241. refDistance: number;
  35242. /**
  35243. * Define the roll off factor of spatial sounds.
  35244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35245. */
  35246. rolloffFactor: number;
  35247. /**
  35248. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35250. */
  35251. maxDistance: number;
  35252. /**
  35253. * Define the distance attenuation model the sound will follow.
  35254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35255. */
  35256. distanceModel: string;
  35257. /**
  35258. * @hidden
  35259. * Back Compat
  35260. **/
  35261. onended: () => any;
  35262. /**
  35263. * Observable event when the current playing sound finishes.
  35264. */
  35265. onEndedObservable: Observable<Sound>;
  35266. private _panningModel;
  35267. private _playbackRate;
  35268. private _streaming;
  35269. private _startTime;
  35270. private _startOffset;
  35271. private _position;
  35272. /** @hidden */
  35273. _positionInEmitterSpace: boolean;
  35274. private _localDirection;
  35275. private _volume;
  35276. private _isReadyToPlay;
  35277. private _isDirectional;
  35278. private _readyToPlayCallback;
  35279. private _audioBuffer;
  35280. private _soundSource;
  35281. private _streamingSource;
  35282. private _soundPanner;
  35283. private _soundGain;
  35284. private _inputAudioNode;
  35285. private _outputAudioNode;
  35286. private _coneInnerAngle;
  35287. private _coneOuterAngle;
  35288. private _coneOuterGain;
  35289. private _scene;
  35290. private _connectedTransformNode;
  35291. private _customAttenuationFunction;
  35292. private _registerFunc;
  35293. private _isOutputConnected;
  35294. private _htmlAudioElement;
  35295. private _urlType;
  35296. private _length?;
  35297. private _offset?;
  35298. /** @hidden */
  35299. static _SceneComponentInitialization: (scene: Scene) => void;
  35300. /**
  35301. * Create a sound and attach it to a scene
  35302. * @param name Name of your sound
  35303. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35304. * @param scene defines the scene the sound belongs to
  35305. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35306. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35307. */
  35308. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35309. /**
  35310. * Release the sound and its associated resources
  35311. */
  35312. dispose(): void;
  35313. /**
  35314. * Gets if the sounds is ready to be played or not.
  35315. * @returns true if ready, otherwise false
  35316. */
  35317. isReady(): boolean;
  35318. private _soundLoaded;
  35319. /**
  35320. * Sets the data of the sound from an audiobuffer
  35321. * @param audioBuffer The audioBuffer containing the data
  35322. */
  35323. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35324. /**
  35325. * Updates the current sounds options such as maxdistance, loop...
  35326. * @param options A JSON object containing values named as the object properties
  35327. */
  35328. updateOptions(options: ISoundOptions): void;
  35329. private _createSpatialParameters;
  35330. private _updateSpatialParameters;
  35331. /**
  35332. * Switch the panning model to HRTF:
  35333. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35334. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35335. */
  35336. switchPanningModelToHRTF(): void;
  35337. /**
  35338. * Switch the panning model to Equal Power:
  35339. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35341. */
  35342. switchPanningModelToEqualPower(): void;
  35343. private _switchPanningModel;
  35344. /**
  35345. * Connect this sound to a sound track audio node like gain...
  35346. * @param soundTrackAudioNode the sound track audio node to connect to
  35347. */
  35348. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35349. /**
  35350. * Transform this sound into a directional source
  35351. * @param coneInnerAngle Size of the inner cone in degree
  35352. * @param coneOuterAngle Size of the outer cone in degree
  35353. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35354. */
  35355. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35356. /**
  35357. * Gets or sets the inner angle for the directional cone.
  35358. */
  35359. /**
  35360. * Gets or sets the inner angle for the directional cone.
  35361. */
  35362. directionalConeInnerAngle: number;
  35363. /**
  35364. * Gets or sets the outer angle for the directional cone.
  35365. */
  35366. /**
  35367. * Gets or sets the outer angle for the directional cone.
  35368. */
  35369. directionalConeOuterAngle: number;
  35370. /**
  35371. * Sets the position of the emitter if spatial sound is enabled
  35372. * @param newPosition Defines the new posisiton
  35373. */
  35374. setPosition(newPosition: Vector3): void;
  35375. /**
  35376. * Sets the local direction of the emitter if spatial sound is enabled
  35377. * @param newLocalDirection Defines the new local direction
  35378. */
  35379. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35380. private _updateDirection;
  35381. /** @hidden */
  35382. updateDistanceFromListener(): void;
  35383. /**
  35384. * Sets a new custom attenuation function for the sound.
  35385. * @param callback Defines the function used for the attenuation
  35386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35387. */
  35388. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35389. /**
  35390. * Play the sound
  35391. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35392. * @param offset (optional) Start the sound at a specific time in seconds
  35393. * @param length (optional) Sound duration (in seconds)
  35394. */
  35395. play(time?: number, offset?: number, length?: number): void;
  35396. private _onended;
  35397. /**
  35398. * Stop the sound
  35399. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35400. */
  35401. stop(time?: number): void;
  35402. /**
  35403. * Put the sound in pause
  35404. */
  35405. pause(): void;
  35406. /**
  35407. * Sets a dedicated volume for this sounds
  35408. * @param newVolume Define the new volume of the sound
  35409. * @param time Define time for gradual change to new volume
  35410. */
  35411. setVolume(newVolume: number, time?: number): void;
  35412. /**
  35413. * Set the sound play back rate
  35414. * @param newPlaybackRate Define the playback rate the sound should be played at
  35415. */
  35416. setPlaybackRate(newPlaybackRate: number): void;
  35417. /**
  35418. * Gets the volume of the sound.
  35419. * @returns the volume of the sound
  35420. */
  35421. getVolume(): number;
  35422. /**
  35423. * Attach the sound to a dedicated mesh
  35424. * @param transformNode The transform node to connect the sound with
  35425. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35426. */
  35427. attachToMesh(transformNode: TransformNode): void;
  35428. /**
  35429. * Detach the sound from the previously attached mesh
  35430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35431. */
  35432. detachFromMesh(): void;
  35433. private _onRegisterAfterWorldMatrixUpdate;
  35434. /**
  35435. * Clone the current sound in the scene.
  35436. * @returns the new sound clone
  35437. */
  35438. clone(): Nullable<Sound>;
  35439. /**
  35440. * Gets the current underlying audio buffer containing the data
  35441. * @returns the audio buffer
  35442. */
  35443. getAudioBuffer(): Nullable<AudioBuffer>;
  35444. /**
  35445. * Serializes the Sound in a JSON representation
  35446. * @returns the JSON representation of the sound
  35447. */
  35448. serialize(): any;
  35449. /**
  35450. * Parse a JSON representation of a sound to innstantiate in a given scene
  35451. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35452. * @param scene Define the scene the new parsed sound should be created in
  35453. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35454. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35455. * @returns the newly parsed sound
  35456. */
  35457. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35458. }
  35459. }
  35460. declare module "babylonjs/Actions/directAudioActions" {
  35461. import { Action } from "babylonjs/Actions/action";
  35462. import { Condition } from "babylonjs/Actions/condition";
  35463. import { Sound } from "babylonjs/Audio/sound";
  35464. /**
  35465. * This defines an action helpful to play a defined sound on a triggered action.
  35466. */
  35467. export class PlaySoundAction extends Action {
  35468. private _sound;
  35469. /**
  35470. * Instantiate the action
  35471. * @param triggerOptions defines the trigger options
  35472. * @param sound defines the sound to play
  35473. * @param condition defines the trigger related conditions
  35474. */
  35475. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35476. /** @hidden */
  35477. _prepare(): void;
  35478. /**
  35479. * Execute the action and play the sound.
  35480. */
  35481. execute(): void;
  35482. /**
  35483. * Serializes the actions and its related information.
  35484. * @param parent defines the object to serialize in
  35485. * @returns the serialized object
  35486. */
  35487. serialize(parent: any): any;
  35488. }
  35489. /**
  35490. * This defines an action helpful to stop a defined sound on a triggered action.
  35491. */
  35492. export class StopSoundAction extends Action {
  35493. private _sound;
  35494. /**
  35495. * Instantiate the action
  35496. * @param triggerOptions defines the trigger options
  35497. * @param sound defines the sound to stop
  35498. * @param condition defines the trigger related conditions
  35499. */
  35500. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35501. /** @hidden */
  35502. _prepare(): void;
  35503. /**
  35504. * Execute the action and stop the sound.
  35505. */
  35506. execute(): void;
  35507. /**
  35508. * Serializes the actions and its related information.
  35509. * @param parent defines the object to serialize in
  35510. * @returns the serialized object
  35511. */
  35512. serialize(parent: any): any;
  35513. }
  35514. }
  35515. declare module "babylonjs/Actions/interpolateValueAction" {
  35516. import { Action } from "babylonjs/Actions/action";
  35517. import { Condition } from "babylonjs/Actions/condition";
  35518. import { Observable } from "babylonjs/Misc/observable";
  35519. /**
  35520. * This defines an action responsible to change the value of a property
  35521. * by interpolating between its current value and the newly set one once triggered.
  35522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35523. */
  35524. export class InterpolateValueAction extends Action {
  35525. /**
  35526. * Defines the path of the property where the value should be interpolated
  35527. */
  35528. propertyPath: string;
  35529. /**
  35530. * Defines the target value at the end of the interpolation.
  35531. */
  35532. value: any;
  35533. /**
  35534. * Defines the time it will take for the property to interpolate to the value.
  35535. */
  35536. duration: number;
  35537. /**
  35538. * Defines if the other scene animations should be stopped when the action has been triggered
  35539. */
  35540. stopOtherAnimations?: boolean;
  35541. /**
  35542. * Defines a callback raised once the interpolation animation has been done.
  35543. */
  35544. onInterpolationDone?: () => void;
  35545. /**
  35546. * Observable triggered once the interpolation animation has been done.
  35547. */
  35548. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35549. private _target;
  35550. private _effectiveTarget;
  35551. private _property;
  35552. /**
  35553. * Instantiate the action
  35554. * @param triggerOptions defines the trigger options
  35555. * @param target defines the object containing the value to interpolate
  35556. * @param propertyPath defines the path to the property in the target object
  35557. * @param value defines the target value at the end of the interpolation
  35558. * @param duration deines the time it will take for the property to interpolate to the value.
  35559. * @param condition defines the trigger related conditions
  35560. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35561. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35562. */
  35563. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35564. /** @hidden */
  35565. _prepare(): void;
  35566. /**
  35567. * Execute the action starts the value interpolation.
  35568. */
  35569. execute(): void;
  35570. /**
  35571. * Serializes the actions and its related information.
  35572. * @param parent defines the object to serialize in
  35573. * @returns the serialized object
  35574. */
  35575. serialize(parent: any): any;
  35576. }
  35577. }
  35578. declare module "babylonjs/Actions/index" {
  35579. export * from "babylonjs/Actions/action";
  35580. export * from "babylonjs/Actions/actionEvent";
  35581. export * from "babylonjs/Actions/actionManager";
  35582. export * from "babylonjs/Actions/condition";
  35583. export * from "babylonjs/Actions/directActions";
  35584. export * from "babylonjs/Actions/directAudioActions";
  35585. export * from "babylonjs/Actions/interpolateValueAction";
  35586. }
  35587. declare module "babylonjs/Animations/index" {
  35588. export * from "babylonjs/Animations/animatable";
  35589. export * from "babylonjs/Animations/animation";
  35590. export * from "babylonjs/Animations/animationGroup";
  35591. export * from "babylonjs/Animations/animationPropertiesOverride";
  35592. export * from "babylonjs/Animations/easing";
  35593. export * from "babylonjs/Animations/runtimeAnimation";
  35594. export * from "babylonjs/Animations/animationEvent";
  35595. export * from "babylonjs/Animations/animationGroup";
  35596. export * from "babylonjs/Animations/animationKey";
  35597. export * from "babylonjs/Animations/animationRange";
  35598. }
  35599. declare module "babylonjs/Audio/soundTrack" {
  35600. import { Sound } from "babylonjs/Audio/sound";
  35601. import { Analyser } from "babylonjs/Audio/analyser";
  35602. import { Scene } from "babylonjs/scene";
  35603. /**
  35604. * Options allowed during the creation of a sound track.
  35605. */
  35606. export interface ISoundTrackOptions {
  35607. /**
  35608. * The volume the sound track should take during creation
  35609. */
  35610. volume?: number;
  35611. /**
  35612. * Define if the sound track is the main sound track of the scene
  35613. */
  35614. mainTrack?: boolean;
  35615. }
  35616. /**
  35617. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35618. * It will be also used in a future release to apply effects on a specific track.
  35619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35620. */
  35621. export class SoundTrack {
  35622. /**
  35623. * The unique identifier of the sound track in the scene.
  35624. */
  35625. id: number;
  35626. /**
  35627. * The list of sounds included in the sound track.
  35628. */
  35629. soundCollection: Array<Sound>;
  35630. private _outputAudioNode;
  35631. private _scene;
  35632. private _isMainTrack;
  35633. private _connectedAnalyser;
  35634. private _options;
  35635. private _isInitialized;
  35636. /**
  35637. * Creates a new sound track.
  35638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35639. * @param scene Define the scene the sound track belongs to
  35640. * @param options
  35641. */
  35642. constructor(scene: Scene, options?: ISoundTrackOptions);
  35643. private _initializeSoundTrackAudioGraph;
  35644. /**
  35645. * Release the sound track and its associated resources
  35646. */
  35647. dispose(): void;
  35648. /**
  35649. * Adds a sound to this sound track
  35650. * @param sound define the cound to add
  35651. * @ignoreNaming
  35652. */
  35653. AddSound(sound: Sound): void;
  35654. /**
  35655. * Removes a sound to this sound track
  35656. * @param sound define the cound to remove
  35657. * @ignoreNaming
  35658. */
  35659. RemoveSound(sound: Sound): void;
  35660. /**
  35661. * Set a global volume for the full sound track.
  35662. * @param newVolume Define the new volume of the sound track
  35663. */
  35664. setVolume(newVolume: number): void;
  35665. /**
  35666. * Switch the panning model to HRTF:
  35667. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35669. */
  35670. switchPanningModelToHRTF(): void;
  35671. /**
  35672. * Switch the panning model to Equal Power:
  35673. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35674. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35675. */
  35676. switchPanningModelToEqualPower(): void;
  35677. /**
  35678. * Connect the sound track to an audio analyser allowing some amazing
  35679. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35681. * @param analyser The analyser to connect to the engine
  35682. */
  35683. connectToAnalyser(analyser: Analyser): void;
  35684. }
  35685. }
  35686. declare module "babylonjs/Audio/audioSceneComponent" {
  35687. import { Sound } from "babylonjs/Audio/sound";
  35688. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35689. import { Nullable } from "babylonjs/types";
  35690. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35691. import { Scene } from "babylonjs/scene";
  35692. import { AbstractScene } from "babylonjs/abstractScene";
  35693. module "babylonjs/abstractScene" {
  35694. interface AbstractScene {
  35695. /**
  35696. * The list of sounds used in the scene.
  35697. */
  35698. sounds: Nullable<Array<Sound>>;
  35699. }
  35700. }
  35701. module "babylonjs/scene" {
  35702. interface Scene {
  35703. /**
  35704. * @hidden
  35705. * Backing field
  35706. */
  35707. _mainSoundTrack: SoundTrack;
  35708. /**
  35709. * The main sound track played by the scene.
  35710. * It cotains your primary collection of sounds.
  35711. */
  35712. mainSoundTrack: SoundTrack;
  35713. /**
  35714. * The list of sound tracks added to the scene
  35715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35716. */
  35717. soundTracks: Nullable<Array<SoundTrack>>;
  35718. /**
  35719. * Gets a sound using a given name
  35720. * @param name defines the name to search for
  35721. * @return the found sound or null if not found at all.
  35722. */
  35723. getSoundByName(name: string): Nullable<Sound>;
  35724. /**
  35725. * Gets or sets if audio support is enabled
  35726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35727. */
  35728. audioEnabled: boolean;
  35729. /**
  35730. * Gets or sets if audio will be output to headphones
  35731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35732. */
  35733. headphone: boolean;
  35734. }
  35735. }
  35736. /**
  35737. * Defines the sound scene component responsible to manage any sounds
  35738. * in a given scene.
  35739. */
  35740. export class AudioSceneComponent implements ISceneSerializableComponent {
  35741. /**
  35742. * The component name helpfull to identify the component in the list of scene components.
  35743. */
  35744. readonly name: string;
  35745. /**
  35746. * The scene the component belongs to.
  35747. */
  35748. scene: Scene;
  35749. private _audioEnabled;
  35750. /**
  35751. * Gets whether audio is enabled or not.
  35752. * Please use related enable/disable method to switch state.
  35753. */
  35754. readonly audioEnabled: boolean;
  35755. private _headphone;
  35756. /**
  35757. * Gets whether audio is outputing to headphone or not.
  35758. * Please use the according Switch methods to change output.
  35759. */
  35760. readonly headphone: boolean;
  35761. /**
  35762. * Creates a new instance of the component for the given scene
  35763. * @param scene Defines the scene to register the component in
  35764. */
  35765. constructor(scene: Scene);
  35766. /**
  35767. * Registers the component in a given scene
  35768. */
  35769. register(): void;
  35770. /**
  35771. * Rebuilds the elements related to this component in case of
  35772. * context lost for instance.
  35773. */
  35774. rebuild(): void;
  35775. /**
  35776. * Serializes the component data to the specified json object
  35777. * @param serializationObject The object to serialize to
  35778. */
  35779. serialize(serializationObject: any): void;
  35780. /**
  35781. * Adds all the elements from the container to the scene
  35782. * @param container the container holding the elements
  35783. */
  35784. addFromContainer(container: AbstractScene): void;
  35785. /**
  35786. * Removes all the elements in the container from the scene
  35787. * @param container contains the elements to remove
  35788. * @param dispose if the removed element should be disposed (default: false)
  35789. */
  35790. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35791. /**
  35792. * Disposes the component and the associated ressources.
  35793. */
  35794. dispose(): void;
  35795. /**
  35796. * Disables audio in the associated scene.
  35797. */
  35798. disableAudio(): void;
  35799. /**
  35800. * Enables audio in the associated scene.
  35801. */
  35802. enableAudio(): void;
  35803. /**
  35804. * Switch audio to headphone output.
  35805. */
  35806. switchAudioModeForHeadphones(): void;
  35807. /**
  35808. * Switch audio to normal speakers.
  35809. */
  35810. switchAudioModeForNormalSpeakers(): void;
  35811. private _afterRender;
  35812. }
  35813. }
  35814. declare module "babylonjs/Audio/weightedsound" {
  35815. import { Sound } from "babylonjs/Audio/sound";
  35816. /**
  35817. * Wraps one or more Sound objects and selects one with random weight for playback.
  35818. */
  35819. export class WeightedSound {
  35820. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35821. loop: boolean;
  35822. private _coneInnerAngle;
  35823. private _coneOuterAngle;
  35824. private _volume;
  35825. /** A Sound is currently playing. */
  35826. isPlaying: boolean;
  35827. /** A Sound is currently paused. */
  35828. isPaused: boolean;
  35829. private _sounds;
  35830. private _weights;
  35831. private _currentIndex?;
  35832. /**
  35833. * Creates a new WeightedSound from the list of sounds given.
  35834. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35835. * @param sounds Array of Sounds that will be selected from.
  35836. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35837. */
  35838. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35839. /**
  35840. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35841. */
  35842. /**
  35843. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35844. */
  35845. directionalConeInnerAngle: number;
  35846. /**
  35847. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35848. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35849. */
  35850. /**
  35851. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35852. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35853. */
  35854. directionalConeOuterAngle: number;
  35855. /**
  35856. * Playback volume.
  35857. */
  35858. /**
  35859. * Playback volume.
  35860. */
  35861. volume: number;
  35862. private _onended;
  35863. /**
  35864. * Suspend playback
  35865. */
  35866. pause(): void;
  35867. /**
  35868. * Stop playback
  35869. */
  35870. stop(): void;
  35871. /**
  35872. * Start playback.
  35873. * @param startOffset Position the clip head at a specific time in seconds.
  35874. */
  35875. play(startOffset?: number): void;
  35876. }
  35877. }
  35878. declare module "babylonjs/Audio/index" {
  35879. export * from "babylonjs/Audio/analyser";
  35880. export * from "babylonjs/Audio/audioEngine";
  35881. export * from "babylonjs/Audio/audioSceneComponent";
  35882. export * from "babylonjs/Audio/sound";
  35883. export * from "babylonjs/Audio/soundTrack";
  35884. export * from "babylonjs/Audio/weightedsound";
  35885. }
  35886. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35887. import { Behavior } from "babylonjs/Behaviors/behavior";
  35888. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35889. import { BackEase } from "babylonjs/Animations/easing";
  35890. /**
  35891. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35892. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35893. */
  35894. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35895. /**
  35896. * Gets the name of the behavior.
  35897. */
  35898. readonly name: string;
  35899. /**
  35900. * The easing function used by animations
  35901. */
  35902. static EasingFunction: BackEase;
  35903. /**
  35904. * The easing mode used by animations
  35905. */
  35906. static EasingMode: number;
  35907. /**
  35908. * The duration of the animation, in milliseconds
  35909. */
  35910. transitionDuration: number;
  35911. /**
  35912. * Length of the distance animated by the transition when lower radius is reached
  35913. */
  35914. lowerRadiusTransitionRange: number;
  35915. /**
  35916. * Length of the distance animated by the transition when upper radius is reached
  35917. */
  35918. upperRadiusTransitionRange: number;
  35919. private _autoTransitionRange;
  35920. /**
  35921. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35922. */
  35923. /**
  35924. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35925. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35926. */
  35927. autoTransitionRange: boolean;
  35928. private _attachedCamera;
  35929. private _onAfterCheckInputsObserver;
  35930. private _onMeshTargetChangedObserver;
  35931. /**
  35932. * Initializes the behavior.
  35933. */
  35934. init(): void;
  35935. /**
  35936. * Attaches the behavior to its arc rotate camera.
  35937. * @param camera Defines the camera to attach the behavior to
  35938. */
  35939. attach(camera: ArcRotateCamera): void;
  35940. /**
  35941. * Detaches the behavior from its current arc rotate camera.
  35942. */
  35943. detach(): void;
  35944. private _radiusIsAnimating;
  35945. private _radiusBounceTransition;
  35946. private _animatables;
  35947. private _cachedWheelPrecision;
  35948. /**
  35949. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35950. * @param radiusLimit The limit to check against.
  35951. * @return Bool to indicate if at limit.
  35952. */
  35953. private _isRadiusAtLimit;
  35954. /**
  35955. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35956. * @param radiusDelta The delta by which to animate to. Can be negative.
  35957. */
  35958. private _applyBoundRadiusAnimation;
  35959. /**
  35960. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35961. */
  35962. protected _clearAnimationLocks(): void;
  35963. /**
  35964. * Stops and removes all animations that have been applied to the camera
  35965. */
  35966. stopAllAnimations(): void;
  35967. }
  35968. }
  35969. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35970. import { Behavior } from "babylonjs/Behaviors/behavior";
  35971. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35972. import { ExponentialEase } from "babylonjs/Animations/easing";
  35973. import { Nullable } from "babylonjs/types";
  35974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35975. import { Vector3 } from "babylonjs/Maths/math";
  35976. /**
  35977. * 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.
  35978. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35979. */
  35980. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35981. /**
  35982. * Gets the name of the behavior.
  35983. */
  35984. readonly name: string;
  35985. private _mode;
  35986. private _radiusScale;
  35987. private _positionScale;
  35988. private _defaultElevation;
  35989. private _elevationReturnTime;
  35990. private _elevationReturnWaitTime;
  35991. private _zoomStopsAnimation;
  35992. private _framingTime;
  35993. /**
  35994. * The easing function used by animations
  35995. */
  35996. static EasingFunction: ExponentialEase;
  35997. /**
  35998. * The easing mode used by animations
  35999. */
  36000. static EasingMode: number;
  36001. /**
  36002. * Sets the current mode used by the behavior
  36003. */
  36004. /**
  36005. * Gets current mode used by the behavior.
  36006. */
  36007. mode: number;
  36008. /**
  36009. * Sets the scale applied to the radius (1 by default)
  36010. */
  36011. /**
  36012. * Gets the scale applied to the radius
  36013. */
  36014. radiusScale: number;
  36015. /**
  36016. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36017. */
  36018. /**
  36019. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36020. */
  36021. positionScale: number;
  36022. /**
  36023. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36024. * behaviour is triggered, in radians.
  36025. */
  36026. /**
  36027. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36028. * behaviour is triggered, in radians.
  36029. */
  36030. defaultElevation: number;
  36031. /**
  36032. * Sets the time (in milliseconds) taken to return to the default beta position.
  36033. * Negative value indicates camera should not return to default.
  36034. */
  36035. /**
  36036. * Gets the time (in milliseconds) taken to return to the default beta position.
  36037. * Negative value indicates camera should not return to default.
  36038. */
  36039. elevationReturnTime: number;
  36040. /**
  36041. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36042. */
  36043. /**
  36044. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36045. */
  36046. elevationReturnWaitTime: number;
  36047. /**
  36048. * Sets the flag that indicates if user zooming should stop animation.
  36049. */
  36050. /**
  36051. * Gets the flag that indicates if user zooming should stop animation.
  36052. */
  36053. zoomStopsAnimation: boolean;
  36054. /**
  36055. * Sets the transition time when framing the mesh, in milliseconds
  36056. */
  36057. /**
  36058. * Gets the transition time when framing the mesh, in milliseconds
  36059. */
  36060. framingTime: number;
  36061. /**
  36062. * Define if the behavior should automatically change the configured
  36063. * camera limits and sensibilities.
  36064. */
  36065. autoCorrectCameraLimitsAndSensibility: boolean;
  36066. private _onPrePointerObservableObserver;
  36067. private _onAfterCheckInputsObserver;
  36068. private _onMeshTargetChangedObserver;
  36069. private _attachedCamera;
  36070. private _isPointerDown;
  36071. private _lastInteractionTime;
  36072. /**
  36073. * Initializes the behavior.
  36074. */
  36075. init(): void;
  36076. /**
  36077. * Attaches the behavior to its arc rotate camera.
  36078. * @param camera Defines the camera to attach the behavior to
  36079. */
  36080. attach(camera: ArcRotateCamera): void;
  36081. /**
  36082. * Detaches the behavior from its current arc rotate camera.
  36083. */
  36084. detach(): void;
  36085. private _animatables;
  36086. private _betaIsAnimating;
  36087. private _betaTransition;
  36088. private _radiusTransition;
  36089. private _vectorTransition;
  36090. /**
  36091. * Targets the given mesh and updates zoom level accordingly.
  36092. * @param mesh The mesh to target.
  36093. * @param radius Optional. If a cached radius position already exists, overrides default.
  36094. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36095. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36096. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36097. */
  36098. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36099. /**
  36100. * Targets the given mesh with its children and updates zoom level accordingly.
  36101. * @param mesh The mesh to target.
  36102. * @param radius Optional. If a cached radius position already exists, overrides default.
  36103. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36104. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36105. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36106. */
  36107. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36108. /**
  36109. * Targets the given meshes with their children and updates zoom level accordingly.
  36110. * @param meshes The mesh to target.
  36111. * @param radius Optional. If a cached radius position already exists, overrides default.
  36112. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36113. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36114. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36115. */
  36116. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36117. /**
  36118. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36119. * @param minimumWorld Determines the smaller position of the bounding box extend
  36120. * @param maximumWorld Determines the bigger position of the bounding box extend
  36121. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36122. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36123. */
  36124. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36125. /**
  36126. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36127. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36128. * frustum width.
  36129. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36130. * to fully enclose the mesh in the viewing frustum.
  36131. */
  36132. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36133. /**
  36134. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36135. * is automatically returned to its default position (expected to be above ground plane).
  36136. */
  36137. private _maintainCameraAboveGround;
  36138. /**
  36139. * Returns the frustum slope based on the canvas ratio and camera FOV
  36140. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36141. */
  36142. private _getFrustumSlope;
  36143. /**
  36144. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36145. */
  36146. private _clearAnimationLocks;
  36147. /**
  36148. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36149. */
  36150. private _applyUserInteraction;
  36151. /**
  36152. * Stops and removes all animations that have been applied to the camera
  36153. */
  36154. stopAllAnimations(): void;
  36155. /**
  36156. * Gets a value indicating if the user is moving the camera
  36157. */
  36158. readonly isUserIsMoving: boolean;
  36159. /**
  36160. * The camera can move all the way towards the mesh.
  36161. */
  36162. static IgnoreBoundsSizeMode: number;
  36163. /**
  36164. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36165. */
  36166. static FitFrustumSidesMode: number;
  36167. }
  36168. }
  36169. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36170. import { Nullable } from "babylonjs/types";
  36171. import { Camera } from "babylonjs/Cameras/camera";
  36172. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36173. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36174. /**
  36175. * Base class for Camera Pointer Inputs.
  36176. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36177. * for example usage.
  36178. */
  36179. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36180. /**
  36181. * Defines the camera the input is attached to.
  36182. */
  36183. abstract camera: Camera;
  36184. /**
  36185. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36186. */
  36187. protected _altKey: boolean;
  36188. protected _ctrlKey: boolean;
  36189. protected _metaKey: boolean;
  36190. protected _shiftKey: boolean;
  36191. /**
  36192. * Which mouse buttons were pressed at time of last mouse event.
  36193. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36194. */
  36195. protected _buttonsPressed: number;
  36196. /**
  36197. * Defines the buttons associated with the input to handle camera move.
  36198. */
  36199. buttons: number[];
  36200. /**
  36201. * Attach the input controls to a specific dom element to get the input from.
  36202. * @param element Defines the element the controls should be listened from
  36203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36204. */
  36205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36206. /**
  36207. * Detach the current controls from the specified dom element.
  36208. * @param element Defines the element to stop listening the inputs from
  36209. */
  36210. detachControl(element: Nullable<HTMLElement>): void;
  36211. /**
  36212. * Gets the class name of the current input.
  36213. * @returns the class name
  36214. */
  36215. getClassName(): string;
  36216. /**
  36217. * Get the friendly name associated with the input class.
  36218. * @returns the input friendly name
  36219. */
  36220. getSimpleName(): string;
  36221. /**
  36222. * Called on pointer POINTERDOUBLETAP event.
  36223. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36224. */
  36225. protected onDoubleTap(type: string): void;
  36226. /**
  36227. * Called on pointer POINTERMOVE event if only a single touch is active.
  36228. * Override this method to provide functionality.
  36229. */
  36230. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36231. /**
  36232. * Called on pointer POINTERMOVE event if multiple touches are active.
  36233. * Override this method to provide functionality.
  36234. */
  36235. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36236. /**
  36237. * Called on JS contextmenu event.
  36238. * Override this method to provide functionality.
  36239. */
  36240. protected onContextMenu(evt: PointerEvent): void;
  36241. /**
  36242. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36243. * press.
  36244. * Override this method to provide functionality.
  36245. */
  36246. protected onButtonDown(evt: PointerEvent): void;
  36247. /**
  36248. * Called each time a new POINTERUP event occurs. Ie, for each button
  36249. * release.
  36250. * Override this method to provide functionality.
  36251. */
  36252. protected onButtonUp(evt: PointerEvent): void;
  36253. /**
  36254. * Called when window becomes inactive.
  36255. * Override this method to provide functionality.
  36256. */
  36257. protected onLostFocus(): void;
  36258. private _pointerInput;
  36259. private _observer;
  36260. private _onLostFocus;
  36261. private pointA;
  36262. private pointB;
  36263. }
  36264. }
  36265. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36266. import { Nullable } from "babylonjs/types";
  36267. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36268. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36269. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36270. /**
  36271. * Manage the pointers inputs to control an arc rotate camera.
  36272. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36273. */
  36274. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36275. /**
  36276. * Defines the camera the input is attached to.
  36277. */
  36278. camera: ArcRotateCamera;
  36279. /**
  36280. * Gets the class name of the current input.
  36281. * @returns the class name
  36282. */
  36283. getClassName(): string;
  36284. /**
  36285. * Defines the buttons associated with the input to handle camera move.
  36286. */
  36287. buttons: number[];
  36288. /**
  36289. * Defines the pointer angular sensibility along the X axis or how fast is
  36290. * the camera rotating.
  36291. */
  36292. angularSensibilityX: number;
  36293. /**
  36294. * Defines the pointer angular sensibility along the Y axis or how fast is
  36295. * the camera rotating.
  36296. */
  36297. angularSensibilityY: number;
  36298. /**
  36299. * Defines the pointer pinch precision or how fast is the camera zooming.
  36300. */
  36301. pinchPrecision: number;
  36302. /**
  36303. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36304. * from 0.
  36305. * It defines the percentage of current camera.radius to use as delta when
  36306. * pinch zoom is used.
  36307. */
  36308. pinchDeltaPercentage: number;
  36309. /**
  36310. * Defines the pointer panning sensibility or how fast is the camera moving.
  36311. */
  36312. panningSensibility: number;
  36313. /**
  36314. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36315. */
  36316. multiTouchPanning: boolean;
  36317. /**
  36318. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36319. * zoom (pinch) through multitouch.
  36320. */
  36321. multiTouchPanAndZoom: boolean;
  36322. /**
  36323. * Revers pinch action direction.
  36324. */
  36325. pinchInwards: boolean;
  36326. private _isPanClick;
  36327. private _twoFingerActivityCount;
  36328. private _isPinching;
  36329. /**
  36330. * Called on pointer POINTERMOVE event if only a single touch is active.
  36331. */
  36332. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36333. /**
  36334. * Called on pointer POINTERDOUBLETAP event.
  36335. */
  36336. protected onDoubleTap(type: string): void;
  36337. /**
  36338. * Called on pointer POINTERMOVE event if multiple touches are active.
  36339. */
  36340. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36341. /**
  36342. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36343. * press.
  36344. */
  36345. protected onButtonDown(evt: PointerEvent): void;
  36346. /**
  36347. * Called each time a new POINTERUP event occurs. Ie, for each button
  36348. * release.
  36349. */
  36350. protected onButtonUp(evt: PointerEvent): void;
  36351. /**
  36352. * Called when window becomes inactive.
  36353. */
  36354. protected onLostFocus(): void;
  36355. }
  36356. }
  36357. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36358. import { Nullable } from "babylonjs/types";
  36359. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36360. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36361. /**
  36362. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36364. */
  36365. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36366. /**
  36367. * Defines the camera the input is attached to.
  36368. */
  36369. camera: ArcRotateCamera;
  36370. /**
  36371. * Defines the list of key codes associated with the up action (increase alpha)
  36372. */
  36373. keysUp: number[];
  36374. /**
  36375. * Defines the list of key codes associated with the down action (decrease alpha)
  36376. */
  36377. keysDown: number[];
  36378. /**
  36379. * Defines the list of key codes associated with the left action (increase beta)
  36380. */
  36381. keysLeft: number[];
  36382. /**
  36383. * Defines the list of key codes associated with the right action (decrease beta)
  36384. */
  36385. keysRight: number[];
  36386. /**
  36387. * Defines the list of key codes associated with the reset action.
  36388. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36389. */
  36390. keysReset: number[];
  36391. /**
  36392. * Defines the panning sensibility of the inputs.
  36393. * (How fast is the camera paning)
  36394. */
  36395. panningSensibility: number;
  36396. /**
  36397. * Defines the zooming sensibility of the inputs.
  36398. * (How fast is the camera zooming)
  36399. */
  36400. zoomingSensibility: number;
  36401. /**
  36402. * Defines wether maintaining the alt key down switch the movement mode from
  36403. * orientation to zoom.
  36404. */
  36405. useAltToZoom: boolean;
  36406. /**
  36407. * Rotation speed of the camera
  36408. */
  36409. angularSpeed: number;
  36410. private _keys;
  36411. private _ctrlPressed;
  36412. private _altPressed;
  36413. private _onCanvasBlurObserver;
  36414. private _onKeyboardObserver;
  36415. private _engine;
  36416. private _scene;
  36417. /**
  36418. * Attach the input controls to a specific dom element to get the input from.
  36419. * @param element Defines the element the controls should be listened from
  36420. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36421. */
  36422. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36423. /**
  36424. * Detach the current controls from the specified dom element.
  36425. * @param element Defines the element to stop listening the inputs from
  36426. */
  36427. detachControl(element: Nullable<HTMLElement>): void;
  36428. /**
  36429. * Update the current camera state depending on the inputs that have been used this frame.
  36430. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36431. */
  36432. checkInputs(): void;
  36433. /**
  36434. * Gets the class name of the current intput.
  36435. * @returns the class name
  36436. */
  36437. getClassName(): string;
  36438. /**
  36439. * Get the friendly name associated with the input class.
  36440. * @returns the input friendly name
  36441. */
  36442. getSimpleName(): string;
  36443. }
  36444. }
  36445. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36446. import { Nullable } from "babylonjs/types";
  36447. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36448. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36449. /**
  36450. * Manage the mouse wheel inputs to control an arc rotate camera.
  36451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36452. */
  36453. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36454. /**
  36455. * Defines the camera the input is attached to.
  36456. */
  36457. camera: ArcRotateCamera;
  36458. /**
  36459. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36460. */
  36461. wheelPrecision: number;
  36462. /**
  36463. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36464. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36465. */
  36466. wheelDeltaPercentage: number;
  36467. private _wheel;
  36468. private _observer;
  36469. private computeDeltaFromMouseWheelLegacyEvent;
  36470. /**
  36471. * Attach the input controls to a specific dom element to get the input from.
  36472. * @param element Defines the element the controls should be listened from
  36473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36474. */
  36475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36476. /**
  36477. * Detach the current controls from the specified dom element.
  36478. * @param element Defines the element to stop listening the inputs from
  36479. */
  36480. detachControl(element: Nullable<HTMLElement>): void;
  36481. /**
  36482. * Gets the class name of the current intput.
  36483. * @returns the class name
  36484. */
  36485. getClassName(): string;
  36486. /**
  36487. * Get the friendly name associated with the input class.
  36488. * @returns the input friendly name
  36489. */
  36490. getSimpleName(): string;
  36491. }
  36492. }
  36493. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36494. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36495. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36496. /**
  36497. * Default Inputs manager for the ArcRotateCamera.
  36498. * It groups all the default supported inputs for ease of use.
  36499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36500. */
  36501. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36502. /**
  36503. * Instantiates a new ArcRotateCameraInputsManager.
  36504. * @param camera Defines the camera the inputs belong to
  36505. */
  36506. constructor(camera: ArcRotateCamera);
  36507. /**
  36508. * Add mouse wheel input support to the input manager.
  36509. * @returns the current input manager
  36510. */
  36511. addMouseWheel(): ArcRotateCameraInputsManager;
  36512. /**
  36513. * Add pointers input support to the input manager.
  36514. * @returns the current input manager
  36515. */
  36516. addPointers(): ArcRotateCameraInputsManager;
  36517. /**
  36518. * Add keyboard input support to the input manager.
  36519. * @returns the current input manager
  36520. */
  36521. addKeyboard(): ArcRotateCameraInputsManager;
  36522. }
  36523. }
  36524. declare module "babylonjs/Cameras/arcRotateCamera" {
  36525. import { Observable } from "babylonjs/Misc/observable";
  36526. import { Nullable } from "babylonjs/types";
  36527. import { Scene } from "babylonjs/scene";
  36528. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36530. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36531. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36532. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36533. import { Camera } from "babylonjs/Cameras/camera";
  36534. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36535. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36536. import { Collider } from "babylonjs/Collisions/collider";
  36537. /**
  36538. * This represents an orbital type of camera.
  36539. *
  36540. * 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.
  36541. * 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.
  36542. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36543. */
  36544. export class ArcRotateCamera extends TargetCamera {
  36545. /**
  36546. * Defines the rotation angle of the camera along the longitudinal axis.
  36547. */
  36548. alpha: number;
  36549. /**
  36550. * Defines the rotation angle of the camera along the latitudinal axis.
  36551. */
  36552. beta: number;
  36553. /**
  36554. * Defines the radius of the camera from it s target point.
  36555. */
  36556. radius: number;
  36557. protected _target: Vector3;
  36558. protected _targetHost: Nullable<AbstractMesh>;
  36559. /**
  36560. * Defines the target point of the camera.
  36561. * The camera looks towards it form the radius distance.
  36562. */
  36563. target: Vector3;
  36564. /**
  36565. * Define the current local position of the camera in the scene
  36566. */
  36567. position: Vector3;
  36568. protected _upVector: Vector3;
  36569. protected _upToYMatrix: Matrix;
  36570. protected _YToUpMatrix: Matrix;
  36571. /**
  36572. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36573. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36574. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36575. */
  36576. upVector: Vector3;
  36577. /**
  36578. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36579. */
  36580. setMatUp(): void;
  36581. /**
  36582. * Current inertia value on the longitudinal axis.
  36583. * The bigger this number the longer it will take for the camera to stop.
  36584. */
  36585. inertialAlphaOffset: number;
  36586. /**
  36587. * Current inertia value on the latitudinal axis.
  36588. * The bigger this number the longer it will take for the camera to stop.
  36589. */
  36590. inertialBetaOffset: number;
  36591. /**
  36592. * Current inertia value on the radius axis.
  36593. * The bigger this number the longer it will take for the camera to stop.
  36594. */
  36595. inertialRadiusOffset: number;
  36596. /**
  36597. * Minimum allowed angle on the longitudinal axis.
  36598. * This can help limiting how the Camera is able to move in the scene.
  36599. */
  36600. lowerAlphaLimit: Nullable<number>;
  36601. /**
  36602. * Maximum allowed angle on the longitudinal axis.
  36603. * This can help limiting how the Camera is able to move in the scene.
  36604. */
  36605. upperAlphaLimit: Nullable<number>;
  36606. /**
  36607. * Minimum allowed angle on the latitudinal axis.
  36608. * This can help limiting how the Camera is able to move in the scene.
  36609. */
  36610. lowerBetaLimit: number;
  36611. /**
  36612. * Maximum allowed angle on the latitudinal axis.
  36613. * This can help limiting how the Camera is able to move in the scene.
  36614. */
  36615. upperBetaLimit: number;
  36616. /**
  36617. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36618. * This can help limiting how the Camera is able to move in the scene.
  36619. */
  36620. lowerRadiusLimit: Nullable<number>;
  36621. /**
  36622. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36623. * This can help limiting how the Camera is able to move in the scene.
  36624. */
  36625. upperRadiusLimit: Nullable<number>;
  36626. /**
  36627. * Defines the current inertia value used during panning of the camera along the X axis.
  36628. */
  36629. inertialPanningX: number;
  36630. /**
  36631. * Defines the current inertia value used during panning of the camera along the Y axis.
  36632. */
  36633. inertialPanningY: number;
  36634. /**
  36635. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36636. * Basically if your fingers moves away from more than this distance you will be considered
  36637. * in pinch mode.
  36638. */
  36639. pinchToPanMaxDistance: number;
  36640. /**
  36641. * Defines the maximum distance the camera can pan.
  36642. * This could help keeping the cammera always in your scene.
  36643. */
  36644. panningDistanceLimit: Nullable<number>;
  36645. /**
  36646. * Defines the target of the camera before paning.
  36647. */
  36648. panningOriginTarget: Vector3;
  36649. /**
  36650. * Defines the value of the inertia used during panning.
  36651. * 0 would mean stop inertia and one would mean no decelleration at all.
  36652. */
  36653. panningInertia: number;
  36654. /**
  36655. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36656. */
  36657. angularSensibilityX: number;
  36658. /**
  36659. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36660. */
  36661. angularSensibilityY: number;
  36662. /**
  36663. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36664. */
  36665. pinchPrecision: number;
  36666. /**
  36667. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36668. * It will be used instead of pinchDeltaPrecision if different from 0.
  36669. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36670. */
  36671. pinchDeltaPercentage: number;
  36672. /**
  36673. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36674. */
  36675. panningSensibility: number;
  36676. /**
  36677. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36678. */
  36679. keysUp: number[];
  36680. /**
  36681. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36682. */
  36683. keysDown: number[];
  36684. /**
  36685. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36686. */
  36687. keysLeft: number[];
  36688. /**
  36689. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36690. */
  36691. keysRight: number[];
  36692. /**
  36693. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36694. */
  36695. wheelPrecision: number;
  36696. /**
  36697. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36698. * It will be used instead of pinchDeltaPrecision if different from 0.
  36699. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36700. */
  36701. wheelDeltaPercentage: number;
  36702. /**
  36703. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36704. */
  36705. zoomOnFactor: number;
  36706. /**
  36707. * Defines a screen offset for the camera position.
  36708. */
  36709. targetScreenOffset: Vector2;
  36710. /**
  36711. * Allows the camera to be completely reversed.
  36712. * If false the camera can not arrive upside down.
  36713. */
  36714. allowUpsideDown: boolean;
  36715. /**
  36716. * Define if double tap/click is used to restore the previously saved state of the camera.
  36717. */
  36718. useInputToRestoreState: boolean;
  36719. /** @hidden */
  36720. _viewMatrix: Matrix;
  36721. /** @hidden */
  36722. _useCtrlForPanning: boolean;
  36723. /** @hidden */
  36724. _panningMouseButton: number;
  36725. /**
  36726. * Defines the input associated to the camera.
  36727. */
  36728. inputs: ArcRotateCameraInputsManager;
  36729. /** @hidden */
  36730. _reset: () => void;
  36731. /**
  36732. * Defines the allowed panning axis.
  36733. */
  36734. panningAxis: Vector3;
  36735. protected _localDirection: Vector3;
  36736. protected _transformedDirection: Vector3;
  36737. private _bouncingBehavior;
  36738. /**
  36739. * Gets the bouncing behavior of the camera if it has been enabled.
  36740. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36741. */
  36742. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36743. /**
  36744. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36745. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36746. */
  36747. useBouncingBehavior: boolean;
  36748. private _framingBehavior;
  36749. /**
  36750. * Gets the framing behavior of the camera if it has been enabled.
  36751. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36752. */
  36753. readonly framingBehavior: Nullable<FramingBehavior>;
  36754. /**
  36755. * Defines if the framing behavior of the camera is enabled on the camera.
  36756. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36757. */
  36758. useFramingBehavior: boolean;
  36759. private _autoRotationBehavior;
  36760. /**
  36761. * Gets the auto rotation behavior of the camera if it has been enabled.
  36762. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36763. */
  36764. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36765. /**
  36766. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36767. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36768. */
  36769. useAutoRotationBehavior: boolean;
  36770. /**
  36771. * Observable triggered when the mesh target has been changed on the camera.
  36772. */
  36773. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36774. /**
  36775. * Event raised when the camera is colliding with a mesh.
  36776. */
  36777. onCollide: (collidedMesh: AbstractMesh) => void;
  36778. /**
  36779. * Defines whether the camera should check collision with the objects oh the scene.
  36780. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36781. */
  36782. checkCollisions: boolean;
  36783. /**
  36784. * Defines the collision radius of the camera.
  36785. * This simulates a sphere around the camera.
  36786. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36787. */
  36788. collisionRadius: Vector3;
  36789. protected _collider: Collider;
  36790. protected _previousPosition: Vector3;
  36791. protected _collisionVelocity: Vector3;
  36792. protected _newPosition: Vector3;
  36793. protected _previousAlpha: number;
  36794. protected _previousBeta: number;
  36795. protected _previousRadius: number;
  36796. protected _collisionTriggered: boolean;
  36797. protected _targetBoundingCenter: Nullable<Vector3>;
  36798. private _computationVector;
  36799. /**
  36800. * Instantiates a new ArcRotateCamera in a given scene
  36801. * @param name Defines the name of the camera
  36802. * @param alpha Defines the camera rotation along the logitudinal axis
  36803. * @param beta Defines the camera rotation along the latitudinal axis
  36804. * @param radius Defines the camera distance from its target
  36805. * @param target Defines the camera target
  36806. * @param scene Defines the scene the camera belongs to
  36807. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36808. */
  36809. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36810. /** @hidden */
  36811. _initCache(): void;
  36812. /** @hidden */
  36813. _updateCache(ignoreParentClass?: boolean): void;
  36814. protected _getTargetPosition(): Vector3;
  36815. private _storedAlpha;
  36816. private _storedBeta;
  36817. private _storedRadius;
  36818. private _storedTarget;
  36819. /**
  36820. * Stores the current state of the camera (alpha, beta, radius and target)
  36821. * @returns the camera itself
  36822. */
  36823. storeState(): Camera;
  36824. /**
  36825. * @hidden
  36826. * Restored camera state. You must call storeState() first
  36827. */
  36828. _restoreStateValues(): boolean;
  36829. /** @hidden */
  36830. _isSynchronizedViewMatrix(): boolean;
  36831. /**
  36832. * Attached controls to the current camera.
  36833. * @param element Defines the element the controls should be listened from
  36834. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36835. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36836. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36837. */
  36838. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36839. /**
  36840. * Detach the current controls from the camera.
  36841. * The camera will stop reacting to inputs.
  36842. * @param element Defines the element to stop listening the inputs from
  36843. */
  36844. detachControl(element: HTMLElement): void;
  36845. /** @hidden */
  36846. _checkInputs(): void;
  36847. protected _checkLimits(): void;
  36848. /**
  36849. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36850. */
  36851. rebuildAnglesAndRadius(): void;
  36852. /**
  36853. * Use a position to define the current camera related information like aplha, beta and radius
  36854. * @param position Defines the position to set the camera at
  36855. */
  36856. setPosition(position: Vector3): void;
  36857. /**
  36858. * Defines the target the camera should look at.
  36859. * This will automatically adapt alpha beta and radius to fit within the new target.
  36860. * @param target Defines the new target as a Vector or a mesh
  36861. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36862. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36863. */
  36864. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36865. /** @hidden */
  36866. _getViewMatrix(): Matrix;
  36867. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36868. /**
  36869. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36870. * @param meshes Defines the mesh to zoom on
  36871. * @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)
  36872. */
  36873. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36874. /**
  36875. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36876. * The target will be changed but the radius
  36877. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36878. * @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)
  36879. */
  36880. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36881. min: Vector3;
  36882. max: Vector3;
  36883. distance: number;
  36884. }, doNotUpdateMaxZ?: boolean): void;
  36885. /**
  36886. * @override
  36887. * Override Camera.createRigCamera
  36888. */
  36889. createRigCamera(name: string, cameraIndex: number): Camera;
  36890. /**
  36891. * @hidden
  36892. * @override
  36893. * Override Camera._updateRigCameras
  36894. */
  36895. _updateRigCameras(): void;
  36896. /**
  36897. * Destroy the camera and release the current resources hold by it.
  36898. */
  36899. dispose(): void;
  36900. /**
  36901. * Gets the current object class name.
  36902. * @return the class name
  36903. */
  36904. getClassName(): string;
  36905. }
  36906. }
  36907. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36908. import { Behavior } from "babylonjs/Behaviors/behavior";
  36909. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36910. /**
  36911. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36912. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36913. */
  36914. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36915. /**
  36916. * Gets the name of the behavior.
  36917. */
  36918. readonly name: string;
  36919. private _zoomStopsAnimation;
  36920. private _idleRotationSpeed;
  36921. private _idleRotationWaitTime;
  36922. private _idleRotationSpinupTime;
  36923. /**
  36924. * Sets the flag that indicates if user zooming should stop animation.
  36925. */
  36926. /**
  36927. * Gets the flag that indicates if user zooming should stop animation.
  36928. */
  36929. zoomStopsAnimation: boolean;
  36930. /**
  36931. * Sets the default speed at which the camera rotates around the model.
  36932. */
  36933. /**
  36934. * Gets the default speed at which the camera rotates around the model.
  36935. */
  36936. idleRotationSpeed: number;
  36937. /**
  36938. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36939. */
  36940. /**
  36941. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36942. */
  36943. idleRotationWaitTime: number;
  36944. /**
  36945. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36946. */
  36947. /**
  36948. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36949. */
  36950. idleRotationSpinupTime: number;
  36951. /**
  36952. * Gets a value indicating if the camera is currently rotating because of this behavior
  36953. */
  36954. readonly rotationInProgress: boolean;
  36955. private _onPrePointerObservableObserver;
  36956. private _onAfterCheckInputsObserver;
  36957. private _attachedCamera;
  36958. private _isPointerDown;
  36959. private _lastFrameTime;
  36960. private _lastInteractionTime;
  36961. private _cameraRotationSpeed;
  36962. /**
  36963. * Initializes the behavior.
  36964. */
  36965. init(): void;
  36966. /**
  36967. * Attaches the behavior to its arc rotate camera.
  36968. * @param camera Defines the camera to attach the behavior to
  36969. */
  36970. attach(camera: ArcRotateCamera): void;
  36971. /**
  36972. * Detaches the behavior from its current arc rotate camera.
  36973. */
  36974. detach(): void;
  36975. /**
  36976. * Returns true if user is scrolling.
  36977. * @return true if user is scrolling.
  36978. */
  36979. private _userIsZooming;
  36980. private _lastFrameRadius;
  36981. private _shouldAnimationStopForInteraction;
  36982. /**
  36983. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36984. */
  36985. private _applyUserInteraction;
  36986. private _userIsMoving;
  36987. }
  36988. }
  36989. declare module "babylonjs/Behaviors/Cameras/index" {
  36990. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36991. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36992. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36993. }
  36994. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36995. import { Mesh } from "babylonjs/Meshes/mesh";
  36996. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36997. import { Behavior } from "babylonjs/Behaviors/behavior";
  36998. /**
  36999. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37000. */
  37001. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37002. private ui;
  37003. /**
  37004. * The name of the behavior
  37005. */
  37006. name: string;
  37007. /**
  37008. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37009. */
  37010. distanceAwayFromFace: number;
  37011. /**
  37012. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37013. */
  37014. distanceAwayFromBottomOfFace: number;
  37015. private _faceVectors;
  37016. private _target;
  37017. private _scene;
  37018. private _onRenderObserver;
  37019. private _tmpMatrix;
  37020. private _tmpVector;
  37021. /**
  37022. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37023. * @param ui The transform node that should be attched to the mesh
  37024. */
  37025. constructor(ui: TransformNode);
  37026. /**
  37027. * Initializes the behavior
  37028. */
  37029. init(): void;
  37030. private _closestFace;
  37031. private _zeroVector;
  37032. private _lookAtTmpMatrix;
  37033. private _lookAtToRef;
  37034. /**
  37035. * Attaches the AttachToBoxBehavior to the passed in mesh
  37036. * @param target The mesh that the specified node will be attached to
  37037. */
  37038. attach(target: Mesh): void;
  37039. /**
  37040. * Detaches the behavior from the mesh
  37041. */
  37042. detach(): void;
  37043. }
  37044. }
  37045. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37046. import { Behavior } from "babylonjs/Behaviors/behavior";
  37047. import { Mesh } from "babylonjs/Meshes/mesh";
  37048. /**
  37049. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37050. */
  37051. export class FadeInOutBehavior implements Behavior<Mesh> {
  37052. /**
  37053. * Time in milliseconds to delay before fading in (Default: 0)
  37054. */
  37055. delay: number;
  37056. /**
  37057. * Time in milliseconds for the mesh to fade in (Default: 300)
  37058. */
  37059. fadeInTime: number;
  37060. private _millisecondsPerFrame;
  37061. private _hovered;
  37062. private _hoverValue;
  37063. private _ownerNode;
  37064. /**
  37065. * Instatiates the FadeInOutBehavior
  37066. */
  37067. constructor();
  37068. /**
  37069. * The name of the behavior
  37070. */
  37071. readonly name: string;
  37072. /**
  37073. * Initializes the behavior
  37074. */
  37075. init(): void;
  37076. /**
  37077. * Attaches the fade behavior on the passed in mesh
  37078. * @param ownerNode The mesh that will be faded in/out once attached
  37079. */
  37080. attach(ownerNode: Mesh): void;
  37081. /**
  37082. * Detaches the behavior from the mesh
  37083. */
  37084. detach(): void;
  37085. /**
  37086. * Triggers the mesh to begin fading in or out
  37087. * @param value if the object should fade in or out (true to fade in)
  37088. */
  37089. fadeIn(value: boolean): void;
  37090. private _update;
  37091. private _setAllVisibility;
  37092. }
  37093. }
  37094. declare module "babylonjs/Misc/pivotTools" {
  37095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37096. /**
  37097. * Class containing a set of static utilities functions for managing Pivots
  37098. * @hidden
  37099. */
  37100. export class PivotTools {
  37101. private static _PivotCached;
  37102. private static _OldPivotPoint;
  37103. private static _PivotTranslation;
  37104. private static _PivotTmpVector;
  37105. /** @hidden */
  37106. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37107. /** @hidden */
  37108. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37109. }
  37110. }
  37111. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37112. import { Scene } from "babylonjs/scene";
  37113. import { Vector4, Plane } from "babylonjs/Maths/math";
  37114. import { Mesh } from "babylonjs/Meshes/mesh";
  37115. import { Nullable } from "babylonjs/types";
  37116. /**
  37117. * Class containing static functions to help procedurally build meshes
  37118. */
  37119. export class PlaneBuilder {
  37120. /**
  37121. * Creates a plane mesh
  37122. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37123. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37124. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37128. * @param name defines the name of the mesh
  37129. * @param options defines the options used to create the mesh
  37130. * @param scene defines the hosting scene
  37131. * @returns the plane mesh
  37132. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37133. */
  37134. static CreatePlane(name: string, options: {
  37135. size?: number;
  37136. width?: number;
  37137. height?: number;
  37138. sideOrientation?: number;
  37139. frontUVs?: Vector4;
  37140. backUVs?: Vector4;
  37141. updatable?: boolean;
  37142. sourcePlane?: Plane;
  37143. }, scene?: Nullable<Scene>): Mesh;
  37144. }
  37145. }
  37146. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37147. import { Behavior } from "babylonjs/Behaviors/behavior";
  37148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37149. import { Observable } from "babylonjs/Misc/observable";
  37150. import { Vector3 } from "babylonjs/Maths/math";
  37151. import { Ray } from "babylonjs/Culling/ray";
  37152. import "babylonjs/Meshes/Builders/planeBuilder";
  37153. /**
  37154. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37155. */
  37156. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37157. private static _AnyMouseID;
  37158. /**
  37159. * Abstract mesh the behavior is set on
  37160. */
  37161. attachedNode: AbstractMesh;
  37162. private _dragPlane;
  37163. private _scene;
  37164. private _pointerObserver;
  37165. private _beforeRenderObserver;
  37166. private static _planeScene;
  37167. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37168. /**
  37169. * 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)
  37170. */
  37171. maxDragAngle: number;
  37172. /**
  37173. * @hidden
  37174. */
  37175. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37176. /**
  37177. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37178. */
  37179. currentDraggingPointerID: number;
  37180. /**
  37181. * The last position where the pointer hit the drag plane in world space
  37182. */
  37183. lastDragPosition: Vector3;
  37184. /**
  37185. * If the behavior is currently in a dragging state
  37186. */
  37187. dragging: boolean;
  37188. /**
  37189. * 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)
  37190. */
  37191. dragDeltaRatio: number;
  37192. /**
  37193. * If the drag plane orientation should be updated during the dragging (Default: true)
  37194. */
  37195. updateDragPlane: boolean;
  37196. private _debugMode;
  37197. private _moving;
  37198. /**
  37199. * Fires each time the attached mesh is dragged with the pointer
  37200. * * delta between last drag position and current drag position in world space
  37201. * * dragDistance along the drag axis
  37202. * * dragPlaneNormal normal of the current drag plane used during the drag
  37203. * * dragPlanePoint in world space where the drag intersects the drag plane
  37204. */
  37205. onDragObservable: Observable<{
  37206. delta: Vector3;
  37207. dragPlanePoint: Vector3;
  37208. dragPlaneNormal: Vector3;
  37209. dragDistance: number;
  37210. pointerId: number;
  37211. }>;
  37212. /**
  37213. * Fires each time a drag begins (eg. mouse down on mesh)
  37214. */
  37215. onDragStartObservable: Observable<{
  37216. dragPlanePoint: Vector3;
  37217. pointerId: number;
  37218. }>;
  37219. /**
  37220. * Fires each time a drag ends (eg. mouse release after drag)
  37221. */
  37222. onDragEndObservable: Observable<{
  37223. dragPlanePoint: Vector3;
  37224. pointerId: number;
  37225. }>;
  37226. /**
  37227. * If the attached mesh should be moved when dragged
  37228. */
  37229. moveAttached: boolean;
  37230. /**
  37231. * If the drag behavior will react to drag events (Default: true)
  37232. */
  37233. enabled: boolean;
  37234. /**
  37235. * If camera controls should be detached during the drag
  37236. */
  37237. detachCameraControls: boolean;
  37238. /**
  37239. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37240. */
  37241. useObjectOrienationForDragging: boolean;
  37242. private _options;
  37243. /**
  37244. * Creates a pointer drag behavior that can be attached to a mesh
  37245. * @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)
  37246. */
  37247. constructor(options?: {
  37248. dragAxis?: Vector3;
  37249. dragPlaneNormal?: Vector3;
  37250. });
  37251. /**
  37252. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37253. */
  37254. validateDrag: (targetPosition: Vector3) => boolean;
  37255. /**
  37256. * The name of the behavior
  37257. */
  37258. readonly name: string;
  37259. /**
  37260. * Initializes the behavior
  37261. */
  37262. init(): void;
  37263. private _tmpVector;
  37264. private _alternatePickedPoint;
  37265. private _worldDragAxis;
  37266. private _targetPosition;
  37267. private _attachedElement;
  37268. /**
  37269. * Attaches the drag behavior the passed in mesh
  37270. * @param ownerNode The mesh that will be dragged around once attached
  37271. */
  37272. attach(ownerNode: AbstractMesh): void;
  37273. /**
  37274. * Force relase the drag action by code.
  37275. */
  37276. releaseDrag(): void;
  37277. private _startDragRay;
  37278. private _lastPointerRay;
  37279. /**
  37280. * Simulates the start of a pointer drag event on the behavior
  37281. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37282. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37283. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37284. */
  37285. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37286. private _startDrag;
  37287. private _dragDelta;
  37288. private _moveDrag;
  37289. private _pickWithRayOnDragPlane;
  37290. private _pointA;
  37291. private _pointB;
  37292. private _pointC;
  37293. private _lineA;
  37294. private _lineB;
  37295. private _localAxis;
  37296. private _lookAt;
  37297. private _updateDragPlanePosition;
  37298. /**
  37299. * Detaches the behavior from the mesh
  37300. */
  37301. detach(): void;
  37302. }
  37303. }
  37304. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37305. import { Mesh } from "babylonjs/Meshes/mesh";
  37306. import { Behavior } from "babylonjs/Behaviors/behavior";
  37307. /**
  37308. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37309. */
  37310. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37311. private _dragBehaviorA;
  37312. private _dragBehaviorB;
  37313. private _startDistance;
  37314. private _initialScale;
  37315. private _targetScale;
  37316. private _ownerNode;
  37317. private _sceneRenderObserver;
  37318. /**
  37319. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37320. */
  37321. constructor();
  37322. /**
  37323. * The name of the behavior
  37324. */
  37325. readonly name: string;
  37326. /**
  37327. * Initializes the behavior
  37328. */
  37329. init(): void;
  37330. private _getCurrentDistance;
  37331. /**
  37332. * Attaches the scale behavior the passed in mesh
  37333. * @param ownerNode The mesh that will be scaled around once attached
  37334. */
  37335. attach(ownerNode: Mesh): void;
  37336. /**
  37337. * Detaches the behavior from the mesh
  37338. */
  37339. detach(): void;
  37340. }
  37341. }
  37342. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37343. import { Behavior } from "babylonjs/Behaviors/behavior";
  37344. import { Mesh } from "babylonjs/Meshes/mesh";
  37345. import { Observable } from "babylonjs/Misc/observable";
  37346. /**
  37347. * 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
  37348. */
  37349. export class SixDofDragBehavior implements Behavior<Mesh> {
  37350. private static _virtualScene;
  37351. private _ownerNode;
  37352. private _sceneRenderObserver;
  37353. private _scene;
  37354. private _targetPosition;
  37355. private _virtualOriginMesh;
  37356. private _virtualDragMesh;
  37357. private _pointerObserver;
  37358. private _moving;
  37359. private _startingOrientation;
  37360. /**
  37361. * 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)
  37362. */
  37363. private zDragFactor;
  37364. /**
  37365. * If the object should rotate to face the drag origin
  37366. */
  37367. rotateDraggedObject: boolean;
  37368. /**
  37369. * If the behavior is currently in a dragging state
  37370. */
  37371. dragging: boolean;
  37372. /**
  37373. * 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)
  37374. */
  37375. dragDeltaRatio: number;
  37376. /**
  37377. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37378. */
  37379. currentDraggingPointerID: number;
  37380. /**
  37381. * If camera controls should be detached during the drag
  37382. */
  37383. detachCameraControls: boolean;
  37384. /**
  37385. * Fires each time a drag starts
  37386. */
  37387. onDragStartObservable: Observable<{}>;
  37388. /**
  37389. * Fires each time a drag ends (eg. mouse release after drag)
  37390. */
  37391. onDragEndObservable: Observable<{}>;
  37392. /**
  37393. * 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
  37394. */
  37395. constructor();
  37396. /**
  37397. * The name of the behavior
  37398. */
  37399. readonly name: string;
  37400. /**
  37401. * Initializes the behavior
  37402. */
  37403. init(): void;
  37404. /**
  37405. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37406. */
  37407. private readonly _pointerCamera;
  37408. /**
  37409. * Attaches the scale behavior the passed in mesh
  37410. * @param ownerNode The mesh that will be scaled around once attached
  37411. */
  37412. attach(ownerNode: Mesh): void;
  37413. /**
  37414. * Detaches the behavior from the mesh
  37415. */
  37416. detach(): void;
  37417. }
  37418. }
  37419. declare module "babylonjs/Behaviors/Meshes/index" {
  37420. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37421. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37422. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37423. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37424. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37425. }
  37426. declare module "babylonjs/Behaviors/index" {
  37427. export * from "babylonjs/Behaviors/behavior";
  37428. export * from "babylonjs/Behaviors/Cameras/index";
  37429. export * from "babylonjs/Behaviors/Meshes/index";
  37430. }
  37431. declare module "babylonjs/Bones/boneIKController" {
  37432. import { Bone } from "babylonjs/Bones/bone";
  37433. import { Vector3 } from "babylonjs/Maths/math";
  37434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37435. import { Nullable } from "babylonjs/types";
  37436. /**
  37437. * Class used to apply inverse kinematics to bones
  37438. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37439. */
  37440. export class BoneIKController {
  37441. private static _tmpVecs;
  37442. private static _tmpQuat;
  37443. private static _tmpMats;
  37444. /**
  37445. * Gets or sets the target mesh
  37446. */
  37447. targetMesh: AbstractMesh;
  37448. /** Gets or sets the mesh used as pole */
  37449. poleTargetMesh: AbstractMesh;
  37450. /**
  37451. * Gets or sets the bone used as pole
  37452. */
  37453. poleTargetBone: Nullable<Bone>;
  37454. /**
  37455. * Gets or sets the target position
  37456. */
  37457. targetPosition: Vector3;
  37458. /**
  37459. * Gets or sets the pole target position
  37460. */
  37461. poleTargetPosition: Vector3;
  37462. /**
  37463. * Gets or sets the pole target local offset
  37464. */
  37465. poleTargetLocalOffset: Vector3;
  37466. /**
  37467. * Gets or sets the pole angle
  37468. */
  37469. poleAngle: number;
  37470. /**
  37471. * Gets or sets the mesh associated with the controller
  37472. */
  37473. mesh: AbstractMesh;
  37474. /**
  37475. * 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)
  37476. */
  37477. slerpAmount: number;
  37478. private _bone1Quat;
  37479. private _bone1Mat;
  37480. private _bone2Ang;
  37481. private _bone1;
  37482. private _bone2;
  37483. private _bone1Length;
  37484. private _bone2Length;
  37485. private _maxAngle;
  37486. private _maxReach;
  37487. private _rightHandedSystem;
  37488. private _bendAxis;
  37489. private _slerping;
  37490. private _adjustRoll;
  37491. /**
  37492. * Gets or sets maximum allowed angle
  37493. */
  37494. maxAngle: number;
  37495. /**
  37496. * Creates a new BoneIKController
  37497. * @param mesh defines the mesh to control
  37498. * @param bone defines the bone to control
  37499. * @param options defines options to set up the controller
  37500. */
  37501. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37502. targetMesh?: AbstractMesh;
  37503. poleTargetMesh?: AbstractMesh;
  37504. poleTargetBone?: Bone;
  37505. poleTargetLocalOffset?: Vector3;
  37506. poleAngle?: number;
  37507. bendAxis?: Vector3;
  37508. maxAngle?: number;
  37509. slerpAmount?: number;
  37510. });
  37511. private _setMaxAngle;
  37512. /**
  37513. * Force the controller to update the bones
  37514. */
  37515. update(): void;
  37516. }
  37517. }
  37518. declare module "babylonjs/Bones/boneLookController" {
  37519. import { Vector3, Space } from "babylonjs/Maths/math";
  37520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37521. import { Bone } from "babylonjs/Bones/bone";
  37522. /**
  37523. * Class used to make a bone look toward a point in space
  37524. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37525. */
  37526. export class BoneLookController {
  37527. private static _tmpVecs;
  37528. private static _tmpQuat;
  37529. private static _tmpMats;
  37530. /**
  37531. * The target Vector3 that the bone will look at
  37532. */
  37533. target: Vector3;
  37534. /**
  37535. * The mesh that the bone is attached to
  37536. */
  37537. mesh: AbstractMesh;
  37538. /**
  37539. * The bone that will be looking to the target
  37540. */
  37541. bone: Bone;
  37542. /**
  37543. * The up axis of the coordinate system that is used when the bone is rotated
  37544. */
  37545. upAxis: Vector3;
  37546. /**
  37547. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37548. */
  37549. upAxisSpace: Space;
  37550. /**
  37551. * Used to make an adjustment to the yaw of the bone
  37552. */
  37553. adjustYaw: number;
  37554. /**
  37555. * Used to make an adjustment to the pitch of the bone
  37556. */
  37557. adjustPitch: number;
  37558. /**
  37559. * Used to make an adjustment to the roll of the bone
  37560. */
  37561. adjustRoll: number;
  37562. /**
  37563. * 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)
  37564. */
  37565. slerpAmount: number;
  37566. private _minYaw;
  37567. private _maxYaw;
  37568. private _minPitch;
  37569. private _maxPitch;
  37570. private _minYawSin;
  37571. private _minYawCos;
  37572. private _maxYawSin;
  37573. private _maxYawCos;
  37574. private _midYawConstraint;
  37575. private _minPitchTan;
  37576. private _maxPitchTan;
  37577. private _boneQuat;
  37578. private _slerping;
  37579. private _transformYawPitch;
  37580. private _transformYawPitchInv;
  37581. private _firstFrameSkipped;
  37582. private _yawRange;
  37583. private _fowardAxis;
  37584. /**
  37585. * Gets or sets the minimum yaw angle that the bone can look to
  37586. */
  37587. minYaw: number;
  37588. /**
  37589. * Gets or sets the maximum yaw angle that the bone can look to
  37590. */
  37591. maxYaw: number;
  37592. /**
  37593. * Gets or sets the minimum pitch angle that the bone can look to
  37594. */
  37595. minPitch: number;
  37596. /**
  37597. * Gets or sets the maximum pitch angle that the bone can look to
  37598. */
  37599. maxPitch: number;
  37600. /**
  37601. * Create a BoneLookController
  37602. * @param mesh the mesh that the bone belongs to
  37603. * @param bone the bone that will be looking to the target
  37604. * @param target the target Vector3 to look at
  37605. * @param options optional settings:
  37606. * * maxYaw: the maximum angle the bone will yaw to
  37607. * * minYaw: the minimum angle the bone will yaw to
  37608. * * maxPitch: the maximum angle the bone will pitch to
  37609. * * minPitch: the minimum angle the bone will yaw to
  37610. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37611. * * upAxis: the up axis of the coordinate system
  37612. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37613. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37614. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37615. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37616. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37617. * * adjustRoll: used to make an adjustment to the roll of the bone
  37618. **/
  37619. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37620. maxYaw?: number;
  37621. minYaw?: number;
  37622. maxPitch?: number;
  37623. minPitch?: number;
  37624. slerpAmount?: number;
  37625. upAxis?: Vector3;
  37626. upAxisSpace?: Space;
  37627. yawAxis?: Vector3;
  37628. pitchAxis?: Vector3;
  37629. adjustYaw?: number;
  37630. adjustPitch?: number;
  37631. adjustRoll?: number;
  37632. });
  37633. /**
  37634. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37635. */
  37636. update(): void;
  37637. private _getAngleDiff;
  37638. private _getAngleBetween;
  37639. private _isAngleBetween;
  37640. }
  37641. }
  37642. declare module "babylonjs/Bones/index" {
  37643. export * from "babylonjs/Bones/bone";
  37644. export * from "babylonjs/Bones/boneIKController";
  37645. export * from "babylonjs/Bones/boneLookController";
  37646. export * from "babylonjs/Bones/skeleton";
  37647. }
  37648. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37649. import { Nullable } from "babylonjs/types";
  37650. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37651. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37652. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37653. /**
  37654. * Manage the gamepad inputs to control an arc rotate camera.
  37655. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37656. */
  37657. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37658. /**
  37659. * Defines the camera the input is attached to.
  37660. */
  37661. camera: ArcRotateCamera;
  37662. /**
  37663. * Defines the gamepad the input is gathering event from.
  37664. */
  37665. gamepad: Nullable<Gamepad>;
  37666. /**
  37667. * Defines the gamepad rotation sensiblity.
  37668. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37669. */
  37670. gamepadRotationSensibility: number;
  37671. /**
  37672. * Defines the gamepad move sensiblity.
  37673. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37674. */
  37675. gamepadMoveSensibility: number;
  37676. private _onGamepadConnectedObserver;
  37677. private _onGamepadDisconnectedObserver;
  37678. /**
  37679. * Attach the input controls to a specific dom element to get the input from.
  37680. * @param element Defines the element the controls should be listened from
  37681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37682. */
  37683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37684. /**
  37685. * Detach the current controls from the specified dom element.
  37686. * @param element Defines the element to stop listening the inputs from
  37687. */
  37688. detachControl(element: Nullable<HTMLElement>): void;
  37689. /**
  37690. * Update the current camera state depending on the inputs that have been used this frame.
  37691. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37692. */
  37693. checkInputs(): void;
  37694. /**
  37695. * Gets the class name of the current intput.
  37696. * @returns the class name
  37697. */
  37698. getClassName(): string;
  37699. /**
  37700. * Get the friendly name associated with the input class.
  37701. * @returns the input friendly name
  37702. */
  37703. getSimpleName(): string;
  37704. }
  37705. }
  37706. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37707. import { Nullable } from "babylonjs/types";
  37708. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37709. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37710. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37711. interface ArcRotateCameraInputsManager {
  37712. /**
  37713. * Add orientation input support to the input manager.
  37714. * @returns the current input manager
  37715. */
  37716. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37717. }
  37718. }
  37719. /**
  37720. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37721. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37722. */
  37723. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37724. /**
  37725. * Defines the camera the input is attached to.
  37726. */
  37727. camera: ArcRotateCamera;
  37728. /**
  37729. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37730. */
  37731. alphaCorrection: number;
  37732. /**
  37733. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37734. */
  37735. gammaCorrection: number;
  37736. private _alpha;
  37737. private _gamma;
  37738. private _dirty;
  37739. private _deviceOrientationHandler;
  37740. /**
  37741. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37742. */
  37743. constructor();
  37744. /**
  37745. * Attach the input controls to a specific dom element to get the input from.
  37746. * @param element Defines the element the controls should be listened from
  37747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37748. */
  37749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37750. /** @hidden */
  37751. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37752. /**
  37753. * Update the current camera state depending on the inputs that have been used this frame.
  37754. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37755. */
  37756. checkInputs(): void;
  37757. /**
  37758. * Detach the current controls from the specified dom element.
  37759. * @param element Defines the element to stop listening the inputs from
  37760. */
  37761. detachControl(element: Nullable<HTMLElement>): void;
  37762. /**
  37763. * Gets the class name of the current intput.
  37764. * @returns the class name
  37765. */
  37766. getClassName(): string;
  37767. /**
  37768. * Get the friendly name associated with the input class.
  37769. * @returns the input friendly name
  37770. */
  37771. getSimpleName(): string;
  37772. }
  37773. }
  37774. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37775. import { Nullable } from "babylonjs/types";
  37776. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37777. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37778. /**
  37779. * Listen to mouse events to control the camera.
  37780. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37781. */
  37782. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37783. /**
  37784. * Defines the camera the input is attached to.
  37785. */
  37786. camera: FlyCamera;
  37787. /**
  37788. * Defines if touch is enabled. (Default is true.)
  37789. */
  37790. touchEnabled: boolean;
  37791. /**
  37792. * Defines the buttons associated with the input to handle camera rotation.
  37793. */
  37794. buttons: number[];
  37795. /**
  37796. * Assign buttons for Yaw control.
  37797. */
  37798. buttonsYaw: number[];
  37799. /**
  37800. * Assign buttons for Pitch control.
  37801. */
  37802. buttonsPitch: number[];
  37803. /**
  37804. * Assign buttons for Roll control.
  37805. */
  37806. buttonsRoll: number[];
  37807. /**
  37808. * Detect if any button is being pressed while mouse is moved.
  37809. * -1 = Mouse locked.
  37810. * 0 = Left button.
  37811. * 1 = Middle Button.
  37812. * 2 = Right Button.
  37813. */
  37814. activeButton: number;
  37815. /**
  37816. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37817. * Higher values reduce its sensitivity.
  37818. */
  37819. angularSensibility: number;
  37820. private _mousemoveCallback;
  37821. private _observer;
  37822. private _rollObserver;
  37823. private previousPosition;
  37824. private noPreventDefault;
  37825. private element;
  37826. /**
  37827. * Listen to mouse events to control the camera.
  37828. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37830. */
  37831. constructor(touchEnabled?: boolean);
  37832. /**
  37833. * Attach the mouse control to the HTML DOM element.
  37834. * @param element Defines the element that listens to the input events.
  37835. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37836. */
  37837. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37838. /**
  37839. * Detach the current controls from the specified dom element.
  37840. * @param element Defines the element to stop listening the inputs from
  37841. */
  37842. detachControl(element: Nullable<HTMLElement>): void;
  37843. /**
  37844. * Gets the class name of the current input.
  37845. * @returns the class name.
  37846. */
  37847. getClassName(): string;
  37848. /**
  37849. * Get the friendly name associated with the input class.
  37850. * @returns the input's friendly name.
  37851. */
  37852. getSimpleName(): string;
  37853. private _pointerInput;
  37854. private _onMouseMove;
  37855. /**
  37856. * Rotate camera by mouse offset.
  37857. */
  37858. private rotateCamera;
  37859. }
  37860. }
  37861. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37862. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37863. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37864. /**
  37865. * Default Inputs manager for the FlyCamera.
  37866. * It groups all the default supported inputs for ease of use.
  37867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37868. */
  37869. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37870. /**
  37871. * Instantiates a new FlyCameraInputsManager.
  37872. * @param camera Defines the camera the inputs belong to.
  37873. */
  37874. constructor(camera: FlyCamera);
  37875. /**
  37876. * Add keyboard input support to the input manager.
  37877. * @returns the new FlyCameraKeyboardMoveInput().
  37878. */
  37879. addKeyboard(): FlyCameraInputsManager;
  37880. /**
  37881. * Add mouse input support to the input manager.
  37882. * @param touchEnabled Enable touch screen support.
  37883. * @returns the new FlyCameraMouseInput().
  37884. */
  37885. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37886. }
  37887. }
  37888. declare module "babylonjs/Cameras/flyCamera" {
  37889. import { Scene } from "babylonjs/scene";
  37890. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37892. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37893. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37894. /**
  37895. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37896. * such as in a 3D Space Shooter or a Flight Simulator.
  37897. */
  37898. export class FlyCamera extends TargetCamera {
  37899. /**
  37900. * Define the collision ellipsoid of the camera.
  37901. * This is helpful for simulating a camera body, like a player's body.
  37902. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37903. */
  37904. ellipsoid: Vector3;
  37905. /**
  37906. * Define an offset for the position of the ellipsoid around the camera.
  37907. * This can be helpful if the camera is attached away from the player's body center,
  37908. * such as at its head.
  37909. */
  37910. ellipsoidOffset: Vector3;
  37911. /**
  37912. * Enable or disable collisions of the camera with the rest of the scene objects.
  37913. */
  37914. checkCollisions: boolean;
  37915. /**
  37916. * Enable or disable gravity on the camera.
  37917. */
  37918. applyGravity: boolean;
  37919. /**
  37920. * Define the current direction the camera is moving to.
  37921. */
  37922. cameraDirection: Vector3;
  37923. /**
  37924. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37925. * This overrides and empties cameraRotation.
  37926. */
  37927. rotationQuaternion: Quaternion;
  37928. /**
  37929. * Track Roll to maintain the wanted Rolling when looking around.
  37930. */
  37931. _trackRoll: number;
  37932. /**
  37933. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37934. */
  37935. rollCorrect: number;
  37936. /**
  37937. * Mimic a banked turn, Rolling the camera when Yawing.
  37938. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37939. */
  37940. bankedTurn: boolean;
  37941. /**
  37942. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37943. */
  37944. bankedTurnLimit: number;
  37945. /**
  37946. * Value of 0 disables the banked Roll.
  37947. * Value of 1 is equal to the Yaw angle in radians.
  37948. */
  37949. bankedTurnMultiplier: number;
  37950. /**
  37951. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37952. */
  37953. inputs: FlyCameraInputsManager;
  37954. /**
  37955. * Gets the input sensibility for mouse input.
  37956. * Higher values reduce sensitivity.
  37957. */
  37958. /**
  37959. * Sets the input sensibility for a mouse input.
  37960. * Higher values reduce sensitivity.
  37961. */
  37962. angularSensibility: number;
  37963. /**
  37964. * Get the keys for camera movement forward.
  37965. */
  37966. /**
  37967. * Set the keys for camera movement forward.
  37968. */
  37969. keysForward: number[];
  37970. /**
  37971. * Get the keys for camera movement backward.
  37972. */
  37973. keysBackward: number[];
  37974. /**
  37975. * Get the keys for camera movement up.
  37976. */
  37977. /**
  37978. * Set the keys for camera movement up.
  37979. */
  37980. keysUp: number[];
  37981. /**
  37982. * Get the keys for camera movement down.
  37983. */
  37984. /**
  37985. * Set the keys for camera movement down.
  37986. */
  37987. keysDown: number[];
  37988. /**
  37989. * Get the keys for camera movement left.
  37990. */
  37991. /**
  37992. * Set the keys for camera movement left.
  37993. */
  37994. keysLeft: number[];
  37995. /**
  37996. * Set the keys for camera movement right.
  37997. */
  37998. /**
  37999. * Set the keys for camera movement right.
  38000. */
  38001. keysRight: number[];
  38002. /**
  38003. * Event raised when the camera collides with a mesh in the scene.
  38004. */
  38005. onCollide: (collidedMesh: AbstractMesh) => void;
  38006. private _collider;
  38007. private _needMoveForGravity;
  38008. private _oldPosition;
  38009. private _diffPosition;
  38010. private _newPosition;
  38011. /** @hidden */
  38012. _localDirection: Vector3;
  38013. /** @hidden */
  38014. _transformedDirection: Vector3;
  38015. /**
  38016. * Instantiates a FlyCamera.
  38017. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38018. * such as in a 3D Space Shooter or a Flight Simulator.
  38019. * @param name Define the name of the camera in the scene.
  38020. * @param position Define the starting position of the camera in the scene.
  38021. * @param scene Define the scene the camera belongs to.
  38022. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38023. */
  38024. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38025. /**
  38026. * Attach a control to the HTML DOM element.
  38027. * @param element Defines the element that listens to the input events.
  38028. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38029. */
  38030. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38031. /**
  38032. * Detach a control from the HTML DOM element.
  38033. * The camera will stop reacting to that input.
  38034. * @param element Defines the element that listens to the input events.
  38035. */
  38036. detachControl(element: HTMLElement): void;
  38037. private _collisionMask;
  38038. /**
  38039. * Get the mask that the camera ignores in collision events.
  38040. */
  38041. /**
  38042. * Set the mask that the camera ignores in collision events.
  38043. */
  38044. collisionMask: number;
  38045. /** @hidden */
  38046. _collideWithWorld(displacement: Vector3): void;
  38047. /** @hidden */
  38048. private _onCollisionPositionChange;
  38049. /** @hidden */
  38050. _checkInputs(): void;
  38051. /** @hidden */
  38052. _decideIfNeedsToMove(): boolean;
  38053. /** @hidden */
  38054. _updatePosition(): void;
  38055. /**
  38056. * Restore the Roll to its target value at the rate specified.
  38057. * @param rate - Higher means slower restoring.
  38058. * @hidden
  38059. */
  38060. restoreRoll(rate: number): void;
  38061. /**
  38062. * Destroy the camera and release the current resources held by it.
  38063. */
  38064. dispose(): void;
  38065. /**
  38066. * Get the current object class name.
  38067. * @returns the class name.
  38068. */
  38069. getClassName(): string;
  38070. }
  38071. }
  38072. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38073. import { Nullable } from "babylonjs/types";
  38074. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38075. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38076. /**
  38077. * Listen to keyboard events to control the camera.
  38078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38079. */
  38080. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38081. /**
  38082. * Defines the camera the input is attached to.
  38083. */
  38084. camera: FlyCamera;
  38085. /**
  38086. * The list of keyboard keys used to control the forward move of the camera.
  38087. */
  38088. keysForward: number[];
  38089. /**
  38090. * The list of keyboard keys used to control the backward move of the camera.
  38091. */
  38092. keysBackward: number[];
  38093. /**
  38094. * The list of keyboard keys used to control the forward move of the camera.
  38095. */
  38096. keysUp: number[];
  38097. /**
  38098. * The list of keyboard keys used to control the backward move of the camera.
  38099. */
  38100. keysDown: number[];
  38101. /**
  38102. * The list of keyboard keys used to control the right strafe move of the camera.
  38103. */
  38104. keysRight: number[];
  38105. /**
  38106. * The list of keyboard keys used to control the left strafe move of the camera.
  38107. */
  38108. keysLeft: number[];
  38109. private _keys;
  38110. private _onCanvasBlurObserver;
  38111. private _onKeyboardObserver;
  38112. private _engine;
  38113. private _scene;
  38114. /**
  38115. * Attach the input controls to a specific dom element to get the input from.
  38116. * @param element Defines the element the controls should be listened from
  38117. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38118. */
  38119. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38120. /**
  38121. * Detach the current controls from the specified dom element.
  38122. * @param element Defines the element to stop listening the inputs from
  38123. */
  38124. detachControl(element: Nullable<HTMLElement>): void;
  38125. /**
  38126. * Gets the class name of the current intput.
  38127. * @returns the class name
  38128. */
  38129. getClassName(): string;
  38130. /** @hidden */
  38131. _onLostFocus(e: FocusEvent): void;
  38132. /**
  38133. * Get the friendly name associated with the input class.
  38134. * @returns the input friendly name
  38135. */
  38136. getSimpleName(): string;
  38137. /**
  38138. * Update the current camera state depending on the inputs that have been used this frame.
  38139. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38140. */
  38141. checkInputs(): void;
  38142. }
  38143. }
  38144. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38145. import { Nullable } from "babylonjs/types";
  38146. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38147. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38148. /**
  38149. * Manage the mouse wheel inputs to control a follow camera.
  38150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38151. */
  38152. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38153. /**
  38154. * Defines the camera the input is attached to.
  38155. */
  38156. camera: FollowCamera;
  38157. /**
  38158. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38159. */
  38160. axisControlRadius: boolean;
  38161. /**
  38162. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38163. */
  38164. axisControlHeight: boolean;
  38165. /**
  38166. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38167. */
  38168. axisControlRotation: boolean;
  38169. /**
  38170. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38171. * relation to mouseWheel events.
  38172. */
  38173. wheelPrecision: number;
  38174. /**
  38175. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38176. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38177. */
  38178. wheelDeltaPercentage: number;
  38179. private _wheel;
  38180. private _observer;
  38181. /**
  38182. * Attach the input controls to a specific dom element to get the input from.
  38183. * @param element Defines the element the controls should be listened from
  38184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38185. */
  38186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38187. /**
  38188. * Detach the current controls from the specified dom element.
  38189. * @param element Defines the element to stop listening the inputs from
  38190. */
  38191. detachControl(element: Nullable<HTMLElement>): void;
  38192. /**
  38193. * Gets the class name of the current intput.
  38194. * @returns the class name
  38195. */
  38196. getClassName(): string;
  38197. /**
  38198. * Get the friendly name associated with the input class.
  38199. * @returns the input friendly name
  38200. */
  38201. getSimpleName(): string;
  38202. }
  38203. }
  38204. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38205. import { Nullable } from "babylonjs/types";
  38206. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38207. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38208. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38209. /**
  38210. * Manage the pointers inputs to control an follow camera.
  38211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38212. */
  38213. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38214. /**
  38215. * Defines the camera the input is attached to.
  38216. */
  38217. camera: FollowCamera;
  38218. /**
  38219. * Gets the class name of the current input.
  38220. * @returns the class name
  38221. */
  38222. getClassName(): string;
  38223. /**
  38224. * Defines the pointer angular sensibility along the X axis or how fast is
  38225. * the camera rotating.
  38226. * A negative number will reverse the axis direction.
  38227. */
  38228. angularSensibilityX: number;
  38229. /**
  38230. * Defines the pointer angular sensibility along the Y axis or how fast is
  38231. * the camera rotating.
  38232. * A negative number will reverse the axis direction.
  38233. */
  38234. angularSensibilityY: number;
  38235. /**
  38236. * Defines the pointer pinch precision or how fast is the camera zooming.
  38237. * A negative number will reverse the axis direction.
  38238. */
  38239. pinchPrecision: number;
  38240. /**
  38241. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38242. * from 0.
  38243. * It defines the percentage of current camera.radius to use as delta when
  38244. * pinch zoom is used.
  38245. */
  38246. pinchDeltaPercentage: number;
  38247. /**
  38248. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38249. */
  38250. axisXControlRadius: boolean;
  38251. /**
  38252. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38253. */
  38254. axisXControlHeight: boolean;
  38255. /**
  38256. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38257. */
  38258. axisXControlRotation: boolean;
  38259. /**
  38260. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38261. */
  38262. axisYControlRadius: boolean;
  38263. /**
  38264. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38265. */
  38266. axisYControlHeight: boolean;
  38267. /**
  38268. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38269. */
  38270. axisYControlRotation: boolean;
  38271. /**
  38272. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38273. */
  38274. axisPinchControlRadius: boolean;
  38275. /**
  38276. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38277. */
  38278. axisPinchControlHeight: boolean;
  38279. /**
  38280. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38281. */
  38282. axisPinchControlRotation: boolean;
  38283. /**
  38284. * Log error messages if basic misconfiguration has occurred.
  38285. */
  38286. warningEnable: boolean;
  38287. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38288. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38289. private _warningCounter;
  38290. private _warning;
  38291. }
  38292. }
  38293. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38294. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38295. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38296. /**
  38297. * Default Inputs manager for the FollowCamera.
  38298. * It groups all the default supported inputs for ease of use.
  38299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38300. */
  38301. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38302. /**
  38303. * Instantiates a new FollowCameraInputsManager.
  38304. * @param camera Defines the camera the inputs belong to
  38305. */
  38306. constructor(camera: FollowCamera);
  38307. /**
  38308. * Add keyboard input support to the input manager.
  38309. * @returns the current input manager
  38310. */
  38311. addKeyboard(): FollowCameraInputsManager;
  38312. /**
  38313. * Add mouse wheel input support to the input manager.
  38314. * @returns the current input manager
  38315. */
  38316. addMouseWheel(): FollowCameraInputsManager;
  38317. /**
  38318. * Add pointers input support to the input manager.
  38319. * @returns the current input manager
  38320. */
  38321. addPointers(): FollowCameraInputsManager;
  38322. /**
  38323. * Add orientation input support to the input manager.
  38324. * @returns the current input manager
  38325. */
  38326. addVRDeviceOrientation(): FollowCameraInputsManager;
  38327. }
  38328. }
  38329. declare module "babylonjs/Cameras/followCamera" {
  38330. import { Nullable } from "babylonjs/types";
  38331. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38332. import { Scene } from "babylonjs/scene";
  38333. import { Vector3 } from "babylonjs/Maths/math";
  38334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38335. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38336. /**
  38337. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38338. * an arc rotate version arcFollowCamera are available.
  38339. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38340. */
  38341. export class FollowCamera extends TargetCamera {
  38342. /**
  38343. * Distance the follow camera should follow an object at
  38344. */
  38345. radius: number;
  38346. /**
  38347. * Minimum allowed distance of the camera to the axis of rotation
  38348. * (The camera can not get closer).
  38349. * This can help limiting how the Camera is able to move in the scene.
  38350. */
  38351. lowerRadiusLimit: Nullable<number>;
  38352. /**
  38353. * Maximum allowed distance of the camera to the axis of rotation
  38354. * (The camera can not get further).
  38355. * This can help limiting how the Camera is able to move in the scene.
  38356. */
  38357. upperRadiusLimit: Nullable<number>;
  38358. /**
  38359. * Define a rotation offset between the camera and the object it follows
  38360. */
  38361. rotationOffset: number;
  38362. /**
  38363. * Minimum allowed angle to camera position relative to target object.
  38364. * This can help limiting how the Camera is able to move in the scene.
  38365. */
  38366. lowerRotationOffsetLimit: Nullable<number>;
  38367. /**
  38368. * Maximum allowed angle to camera position relative to target object.
  38369. * This can help limiting how the Camera is able to move in the scene.
  38370. */
  38371. upperRotationOffsetLimit: Nullable<number>;
  38372. /**
  38373. * Define a height offset between the camera and the object it follows.
  38374. * It can help following an object from the top (like a car chaing a plane)
  38375. */
  38376. heightOffset: number;
  38377. /**
  38378. * Minimum allowed height of camera position relative to target object.
  38379. * This can help limiting how the Camera is able to move in the scene.
  38380. */
  38381. lowerHeightOffsetLimit: Nullable<number>;
  38382. /**
  38383. * Maximum allowed height of camera position relative to target object.
  38384. * This can help limiting how the Camera is able to move in the scene.
  38385. */
  38386. upperHeightOffsetLimit: Nullable<number>;
  38387. /**
  38388. * Define how fast the camera can accelerate to follow it s target.
  38389. */
  38390. cameraAcceleration: number;
  38391. /**
  38392. * Define the speed limit of the camera following an object.
  38393. */
  38394. maxCameraSpeed: number;
  38395. /**
  38396. * Define the target of the camera.
  38397. */
  38398. lockedTarget: Nullable<AbstractMesh>;
  38399. /**
  38400. * Defines the input associated with the camera.
  38401. */
  38402. inputs: FollowCameraInputsManager;
  38403. /**
  38404. * Instantiates the follow camera.
  38405. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38406. * @param name Define the name of the camera in the scene
  38407. * @param position Define the position of the camera
  38408. * @param scene Define the scene the camera belong to
  38409. * @param lockedTarget Define the target of the camera
  38410. */
  38411. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38412. private _follow;
  38413. /**
  38414. * Attached controls to the current camera.
  38415. * @param element Defines the element the controls should be listened from
  38416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38417. */
  38418. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38419. /**
  38420. * Detach the current controls from the camera.
  38421. * The camera will stop reacting to inputs.
  38422. * @param element Defines the element to stop listening the inputs from
  38423. */
  38424. detachControl(element: HTMLElement): void;
  38425. /** @hidden */
  38426. _checkInputs(): void;
  38427. private _checkLimits;
  38428. /**
  38429. * Gets the camera class name.
  38430. * @returns the class name
  38431. */
  38432. getClassName(): string;
  38433. }
  38434. /**
  38435. * Arc Rotate version of the follow camera.
  38436. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38437. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38438. */
  38439. export class ArcFollowCamera extends TargetCamera {
  38440. /** The longitudinal angle of the camera */
  38441. alpha: number;
  38442. /** The latitudinal angle of the camera */
  38443. beta: number;
  38444. /** The radius of the camera from its target */
  38445. radius: number;
  38446. /** Define the camera target (the messh it should follow) */
  38447. target: Nullable<AbstractMesh>;
  38448. private _cartesianCoordinates;
  38449. /**
  38450. * Instantiates a new ArcFollowCamera
  38451. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38452. * @param name Define the name of the camera
  38453. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38454. * @param beta Define the rotation angle of the camera around the elevation axis
  38455. * @param radius Define the radius of the camera from its target point
  38456. * @param target Define the target of the camera
  38457. * @param scene Define the scene the camera belongs to
  38458. */
  38459. constructor(name: string,
  38460. /** The longitudinal angle of the camera */
  38461. alpha: number,
  38462. /** The latitudinal angle of the camera */
  38463. beta: number,
  38464. /** The radius of the camera from its target */
  38465. radius: number,
  38466. /** Define the camera target (the messh it should follow) */
  38467. target: Nullable<AbstractMesh>, scene: Scene);
  38468. private _follow;
  38469. /** @hidden */
  38470. _checkInputs(): void;
  38471. /**
  38472. * Returns the class name of the object.
  38473. * It is mostly used internally for serialization purposes.
  38474. */
  38475. getClassName(): string;
  38476. }
  38477. }
  38478. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38479. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38480. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38481. import { Nullable } from "babylonjs/types";
  38482. /**
  38483. * Manage the keyboard inputs to control the movement of a follow camera.
  38484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38485. */
  38486. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38487. /**
  38488. * Defines the camera the input is attached to.
  38489. */
  38490. camera: FollowCamera;
  38491. /**
  38492. * Defines the list of key codes associated with the up action (increase heightOffset)
  38493. */
  38494. keysHeightOffsetIncr: number[];
  38495. /**
  38496. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38497. */
  38498. keysHeightOffsetDecr: number[];
  38499. /**
  38500. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38501. */
  38502. keysHeightOffsetModifierAlt: boolean;
  38503. /**
  38504. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38505. */
  38506. keysHeightOffsetModifierCtrl: boolean;
  38507. /**
  38508. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38509. */
  38510. keysHeightOffsetModifierShift: boolean;
  38511. /**
  38512. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38513. */
  38514. keysRotationOffsetIncr: number[];
  38515. /**
  38516. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38517. */
  38518. keysRotationOffsetDecr: number[];
  38519. /**
  38520. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38521. */
  38522. keysRotationOffsetModifierAlt: boolean;
  38523. /**
  38524. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38525. */
  38526. keysRotationOffsetModifierCtrl: boolean;
  38527. /**
  38528. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38529. */
  38530. keysRotationOffsetModifierShift: boolean;
  38531. /**
  38532. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38533. */
  38534. keysRadiusIncr: number[];
  38535. /**
  38536. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38537. */
  38538. keysRadiusDecr: number[];
  38539. /**
  38540. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38541. */
  38542. keysRadiusModifierAlt: boolean;
  38543. /**
  38544. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38545. */
  38546. keysRadiusModifierCtrl: boolean;
  38547. /**
  38548. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38549. */
  38550. keysRadiusModifierShift: boolean;
  38551. /**
  38552. * Defines the rate of change of heightOffset.
  38553. */
  38554. heightSensibility: number;
  38555. /**
  38556. * Defines the rate of change of rotationOffset.
  38557. */
  38558. rotationSensibility: number;
  38559. /**
  38560. * Defines the rate of change of radius.
  38561. */
  38562. radiusSensibility: number;
  38563. private _keys;
  38564. private _ctrlPressed;
  38565. private _altPressed;
  38566. private _shiftPressed;
  38567. private _onCanvasBlurObserver;
  38568. private _onKeyboardObserver;
  38569. private _engine;
  38570. private _scene;
  38571. /**
  38572. * Attach the input controls to a specific dom element to get the input from.
  38573. * @param element Defines the element the controls should be listened from
  38574. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38575. */
  38576. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38577. /**
  38578. * Detach the current controls from the specified dom element.
  38579. * @param element Defines the element to stop listening the inputs from
  38580. */
  38581. detachControl(element: Nullable<HTMLElement>): void;
  38582. /**
  38583. * Update the current camera state depending on the inputs that have been used this frame.
  38584. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38585. */
  38586. checkInputs(): void;
  38587. /**
  38588. * Gets the class name of the current input.
  38589. * @returns the class name
  38590. */
  38591. getClassName(): string;
  38592. /**
  38593. * Get the friendly name associated with the input class.
  38594. * @returns the input friendly name
  38595. */
  38596. getSimpleName(): string;
  38597. /**
  38598. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38599. * allow modification of the heightOffset value.
  38600. */
  38601. private _modifierHeightOffset;
  38602. /**
  38603. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38604. * allow modification of the rotationOffset value.
  38605. */
  38606. private _modifierRotationOffset;
  38607. /**
  38608. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38609. * allow modification of the radius value.
  38610. */
  38611. private _modifierRadius;
  38612. }
  38613. }
  38614. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38615. import { Nullable } from "babylonjs/types";
  38616. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38617. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38618. import { Observable } from "babylonjs/Misc/observable";
  38619. module "babylonjs/Cameras/freeCameraInputsManager" {
  38620. interface FreeCameraInputsManager {
  38621. /**
  38622. * @hidden
  38623. */
  38624. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38625. /**
  38626. * Add orientation input support to the input manager.
  38627. * @returns the current input manager
  38628. */
  38629. addDeviceOrientation(): FreeCameraInputsManager;
  38630. }
  38631. }
  38632. /**
  38633. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38634. * Screen rotation is taken into account.
  38635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38636. */
  38637. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38638. private _camera;
  38639. private _screenOrientationAngle;
  38640. private _constantTranform;
  38641. private _screenQuaternion;
  38642. private _alpha;
  38643. private _beta;
  38644. private _gamma;
  38645. /**
  38646. * Can be used to detect if a device orientation sensor is availible on a device
  38647. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38648. * @returns a promise that will resolve on orientation change
  38649. */
  38650. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38651. /**
  38652. * @hidden
  38653. */
  38654. _onDeviceOrientationChangedObservable: Observable<void>;
  38655. /**
  38656. * Instantiates a new input
  38657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38658. */
  38659. constructor();
  38660. /**
  38661. * Define the camera controlled by the input.
  38662. */
  38663. camera: FreeCamera;
  38664. /**
  38665. * Attach the input controls to a specific dom element to get the input from.
  38666. * @param element Defines the element the controls should be listened from
  38667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38668. */
  38669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38670. private _orientationChanged;
  38671. private _deviceOrientation;
  38672. /**
  38673. * Detach the current controls from the specified dom element.
  38674. * @param element Defines the element to stop listening the inputs from
  38675. */
  38676. detachControl(element: Nullable<HTMLElement>): void;
  38677. /**
  38678. * Update the current camera state depending on the inputs that have been used this frame.
  38679. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38680. */
  38681. checkInputs(): void;
  38682. /**
  38683. * Gets the class name of the current intput.
  38684. * @returns the class name
  38685. */
  38686. getClassName(): string;
  38687. /**
  38688. * Get the friendly name associated with the input class.
  38689. * @returns the input friendly name
  38690. */
  38691. getSimpleName(): string;
  38692. }
  38693. }
  38694. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38695. import { Nullable } from "babylonjs/types";
  38696. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38697. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38698. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38699. /**
  38700. * Manage the gamepad inputs to control a free camera.
  38701. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38702. */
  38703. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38704. /**
  38705. * Define the camera the input is attached to.
  38706. */
  38707. camera: FreeCamera;
  38708. /**
  38709. * Define the Gamepad controlling the input
  38710. */
  38711. gamepad: Nullable<Gamepad>;
  38712. /**
  38713. * Defines the gamepad rotation sensiblity.
  38714. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38715. */
  38716. gamepadAngularSensibility: number;
  38717. /**
  38718. * Defines the gamepad move sensiblity.
  38719. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38720. */
  38721. gamepadMoveSensibility: number;
  38722. private _onGamepadConnectedObserver;
  38723. private _onGamepadDisconnectedObserver;
  38724. private _cameraTransform;
  38725. private _deltaTransform;
  38726. private _vector3;
  38727. private _vector2;
  38728. /**
  38729. * Attach the input controls to a specific dom element to get the input from.
  38730. * @param element Defines the element the controls should be listened from
  38731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38732. */
  38733. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38734. /**
  38735. * Detach the current controls from the specified dom element.
  38736. * @param element Defines the element to stop listening the inputs from
  38737. */
  38738. detachControl(element: Nullable<HTMLElement>): void;
  38739. /**
  38740. * Update the current camera state depending on the inputs that have been used this frame.
  38741. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38742. */
  38743. checkInputs(): void;
  38744. /**
  38745. * Gets the class name of the current intput.
  38746. * @returns the class name
  38747. */
  38748. getClassName(): string;
  38749. /**
  38750. * Get the friendly name associated with the input class.
  38751. * @returns the input friendly name
  38752. */
  38753. getSimpleName(): string;
  38754. }
  38755. }
  38756. declare module "babylonjs/Misc/virtualJoystick" {
  38757. import { Nullable } from "babylonjs/types";
  38758. import { Vector3 } from "babylonjs/Maths/math";
  38759. /**
  38760. * Defines the potential axis of a Joystick
  38761. */
  38762. export enum JoystickAxis {
  38763. /** X axis */
  38764. X = 0,
  38765. /** Y axis */
  38766. Y = 1,
  38767. /** Z axis */
  38768. Z = 2
  38769. }
  38770. /**
  38771. * Class used to define virtual joystick (used in touch mode)
  38772. */
  38773. export class VirtualJoystick {
  38774. /**
  38775. * Gets or sets a boolean indicating that left and right values must be inverted
  38776. */
  38777. reverseLeftRight: boolean;
  38778. /**
  38779. * Gets or sets a boolean indicating that up and down values must be inverted
  38780. */
  38781. reverseUpDown: boolean;
  38782. /**
  38783. * Gets the offset value for the position (ie. the change of the position value)
  38784. */
  38785. deltaPosition: Vector3;
  38786. /**
  38787. * Gets a boolean indicating if the virtual joystick was pressed
  38788. */
  38789. pressed: boolean;
  38790. /**
  38791. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38792. */
  38793. static Canvas: Nullable<HTMLCanvasElement>;
  38794. private static _globalJoystickIndex;
  38795. private static vjCanvasContext;
  38796. private static vjCanvasWidth;
  38797. private static vjCanvasHeight;
  38798. private static halfWidth;
  38799. private _action;
  38800. private _axisTargetedByLeftAndRight;
  38801. private _axisTargetedByUpAndDown;
  38802. private _joystickSensibility;
  38803. private _inversedSensibility;
  38804. private _joystickPointerID;
  38805. private _joystickColor;
  38806. private _joystickPointerPos;
  38807. private _joystickPreviousPointerPos;
  38808. private _joystickPointerStartPos;
  38809. private _deltaJoystickVector;
  38810. private _leftJoystick;
  38811. private _touches;
  38812. private _onPointerDownHandlerRef;
  38813. private _onPointerMoveHandlerRef;
  38814. private _onPointerUpHandlerRef;
  38815. private _onResize;
  38816. /**
  38817. * Creates a new virtual joystick
  38818. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38819. */
  38820. constructor(leftJoystick?: boolean);
  38821. /**
  38822. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38823. * @param newJoystickSensibility defines the new sensibility
  38824. */
  38825. setJoystickSensibility(newJoystickSensibility: number): void;
  38826. private _onPointerDown;
  38827. private _onPointerMove;
  38828. private _onPointerUp;
  38829. /**
  38830. * Change the color of the virtual joystick
  38831. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38832. */
  38833. setJoystickColor(newColor: string): void;
  38834. /**
  38835. * Defines a callback to call when the joystick is touched
  38836. * @param action defines the callback
  38837. */
  38838. setActionOnTouch(action: () => any): void;
  38839. /**
  38840. * Defines which axis you'd like to control for left & right
  38841. * @param axis defines the axis to use
  38842. */
  38843. setAxisForLeftRight(axis: JoystickAxis): void;
  38844. /**
  38845. * Defines which axis you'd like to control for up & down
  38846. * @param axis defines the axis to use
  38847. */
  38848. setAxisForUpDown(axis: JoystickAxis): void;
  38849. private _drawVirtualJoystick;
  38850. /**
  38851. * Release internal HTML canvas
  38852. */
  38853. releaseCanvas(): void;
  38854. }
  38855. }
  38856. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38857. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38858. import { Nullable } from "babylonjs/types";
  38859. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38860. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38861. module "babylonjs/Cameras/freeCameraInputsManager" {
  38862. interface FreeCameraInputsManager {
  38863. /**
  38864. * Add virtual joystick input support to the input manager.
  38865. * @returns the current input manager
  38866. */
  38867. addVirtualJoystick(): FreeCameraInputsManager;
  38868. }
  38869. }
  38870. /**
  38871. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38872. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38873. */
  38874. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38875. /**
  38876. * Defines the camera the input is attached to.
  38877. */
  38878. camera: FreeCamera;
  38879. private _leftjoystick;
  38880. private _rightjoystick;
  38881. /**
  38882. * Gets the left stick of the virtual joystick.
  38883. * @returns The virtual Joystick
  38884. */
  38885. getLeftJoystick(): VirtualJoystick;
  38886. /**
  38887. * Gets the right stick of the virtual joystick.
  38888. * @returns The virtual Joystick
  38889. */
  38890. getRightJoystick(): VirtualJoystick;
  38891. /**
  38892. * Update the current camera state depending on the inputs that have been used this frame.
  38893. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38894. */
  38895. checkInputs(): void;
  38896. /**
  38897. * Attach the input controls to a specific dom element to get the input from.
  38898. * @param element Defines the element the controls should be listened from
  38899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38900. */
  38901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38902. /**
  38903. * Detach the current controls from the specified dom element.
  38904. * @param element Defines the element to stop listening the inputs from
  38905. */
  38906. detachControl(element: Nullable<HTMLElement>): void;
  38907. /**
  38908. * Gets the class name of the current intput.
  38909. * @returns the class name
  38910. */
  38911. getClassName(): string;
  38912. /**
  38913. * Get the friendly name associated with the input class.
  38914. * @returns the input friendly name
  38915. */
  38916. getSimpleName(): string;
  38917. }
  38918. }
  38919. declare module "babylonjs/Cameras/Inputs/index" {
  38920. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38921. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38922. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38923. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38924. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38925. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38926. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38927. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38928. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38929. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38930. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38931. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38932. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38933. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38934. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38935. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38936. }
  38937. declare module "babylonjs/Cameras/touchCamera" {
  38938. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38939. import { Scene } from "babylonjs/scene";
  38940. import { Vector3 } from "babylonjs/Maths/math";
  38941. /**
  38942. * This represents a FPS type of camera controlled by touch.
  38943. * This is like a universal camera minus the Gamepad controls.
  38944. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38945. */
  38946. export class TouchCamera extends FreeCamera {
  38947. /**
  38948. * Defines the touch sensibility for rotation.
  38949. * The higher the faster.
  38950. */
  38951. touchAngularSensibility: number;
  38952. /**
  38953. * Defines the touch sensibility for move.
  38954. * The higher the faster.
  38955. */
  38956. touchMoveSensibility: number;
  38957. /**
  38958. * Instantiates a new touch camera.
  38959. * This represents a FPS type of camera controlled by touch.
  38960. * This is like a universal camera minus the Gamepad controls.
  38961. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38962. * @param name Define the name of the camera in the scene
  38963. * @param position Define the start position of the camera in the scene
  38964. * @param scene Define the scene the camera belongs to
  38965. */
  38966. constructor(name: string, position: Vector3, scene: Scene);
  38967. /**
  38968. * Gets the current object class name.
  38969. * @return the class name
  38970. */
  38971. getClassName(): string;
  38972. /** @hidden */
  38973. _setupInputs(): void;
  38974. }
  38975. }
  38976. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38977. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38978. import { Scene } from "babylonjs/scene";
  38979. import { Vector3, Axis } from "babylonjs/Maths/math";
  38980. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38981. /**
  38982. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38983. * being tilted forward or back and left or right.
  38984. */
  38985. export class DeviceOrientationCamera extends FreeCamera {
  38986. private _initialQuaternion;
  38987. private _quaternionCache;
  38988. private _tmpDragQuaternion;
  38989. /**
  38990. * Creates a new device orientation camera
  38991. * @param name The name of the camera
  38992. * @param position The start position camera
  38993. * @param scene The scene the camera belongs to
  38994. */
  38995. constructor(name: string, position: Vector3, scene: Scene);
  38996. /**
  38997. * @hidden
  38998. * Disabled pointer input on first orientation sensor update (Default: true)
  38999. */
  39000. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39001. private _dragFactor;
  39002. /**
  39003. * Enabled turning on the y axis when the orientation sensor is active
  39004. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39005. */
  39006. enableHorizontalDragging(dragFactor?: number): void;
  39007. /**
  39008. * Gets the current instance class name ("DeviceOrientationCamera").
  39009. * This helps avoiding instanceof at run time.
  39010. * @returns the class name
  39011. */
  39012. getClassName(): string;
  39013. /**
  39014. * @hidden
  39015. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39016. */
  39017. _checkInputs(): void;
  39018. /**
  39019. * Reset the camera to its default orientation on the specified axis only.
  39020. * @param axis The axis to reset
  39021. */
  39022. resetToCurrentRotation(axis?: Axis): void;
  39023. }
  39024. }
  39025. declare module "babylonjs/Gamepads/xboxGamepad" {
  39026. import { Observable } from "babylonjs/Misc/observable";
  39027. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39028. /**
  39029. * Defines supported buttons for XBox360 compatible gamepads
  39030. */
  39031. export enum Xbox360Button {
  39032. /** A */
  39033. A = 0,
  39034. /** B */
  39035. B = 1,
  39036. /** X */
  39037. X = 2,
  39038. /** Y */
  39039. Y = 3,
  39040. /** Start */
  39041. Start = 4,
  39042. /** Back */
  39043. Back = 5,
  39044. /** Left button */
  39045. LB = 6,
  39046. /** Right button */
  39047. RB = 7,
  39048. /** Left stick */
  39049. LeftStick = 8,
  39050. /** Right stick */
  39051. RightStick = 9
  39052. }
  39053. /** Defines values for XBox360 DPad */
  39054. export enum Xbox360Dpad {
  39055. /** Up */
  39056. Up = 0,
  39057. /** Down */
  39058. Down = 1,
  39059. /** Left */
  39060. Left = 2,
  39061. /** Right */
  39062. Right = 3
  39063. }
  39064. /**
  39065. * Defines a XBox360 gamepad
  39066. */
  39067. export class Xbox360Pad extends Gamepad {
  39068. private _leftTrigger;
  39069. private _rightTrigger;
  39070. private _onlefttriggerchanged;
  39071. private _onrighttriggerchanged;
  39072. private _onbuttondown;
  39073. private _onbuttonup;
  39074. private _ondpaddown;
  39075. private _ondpadup;
  39076. /** Observable raised when a button is pressed */
  39077. onButtonDownObservable: Observable<Xbox360Button>;
  39078. /** Observable raised when a button is released */
  39079. onButtonUpObservable: Observable<Xbox360Button>;
  39080. /** Observable raised when a pad is pressed */
  39081. onPadDownObservable: Observable<Xbox360Dpad>;
  39082. /** Observable raised when a pad is released */
  39083. onPadUpObservable: Observable<Xbox360Dpad>;
  39084. private _buttonA;
  39085. private _buttonB;
  39086. private _buttonX;
  39087. private _buttonY;
  39088. private _buttonBack;
  39089. private _buttonStart;
  39090. private _buttonLB;
  39091. private _buttonRB;
  39092. private _buttonLeftStick;
  39093. private _buttonRightStick;
  39094. private _dPadUp;
  39095. private _dPadDown;
  39096. private _dPadLeft;
  39097. private _dPadRight;
  39098. private _isXboxOnePad;
  39099. /**
  39100. * Creates a new XBox360 gamepad object
  39101. * @param id defines the id of this gamepad
  39102. * @param index defines its index
  39103. * @param gamepad defines the internal HTML gamepad object
  39104. * @param xboxOne defines if it is a XBox One gamepad
  39105. */
  39106. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39107. /**
  39108. * Defines the callback to call when left trigger is pressed
  39109. * @param callback defines the callback to use
  39110. */
  39111. onlefttriggerchanged(callback: (value: number) => void): void;
  39112. /**
  39113. * Defines the callback to call when right trigger is pressed
  39114. * @param callback defines the callback to use
  39115. */
  39116. onrighttriggerchanged(callback: (value: number) => void): void;
  39117. /**
  39118. * Gets the left trigger value
  39119. */
  39120. /**
  39121. * Sets the left trigger value
  39122. */
  39123. leftTrigger: number;
  39124. /**
  39125. * Gets the right trigger value
  39126. */
  39127. /**
  39128. * Sets the right trigger value
  39129. */
  39130. rightTrigger: number;
  39131. /**
  39132. * Defines the callback to call when a button is pressed
  39133. * @param callback defines the callback to use
  39134. */
  39135. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39136. /**
  39137. * Defines the callback to call when a button is released
  39138. * @param callback defines the callback to use
  39139. */
  39140. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39141. /**
  39142. * Defines the callback to call when a pad is pressed
  39143. * @param callback defines the callback to use
  39144. */
  39145. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39146. /**
  39147. * Defines the callback to call when a pad is released
  39148. * @param callback defines the callback to use
  39149. */
  39150. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39151. private _setButtonValue;
  39152. private _setDPadValue;
  39153. /**
  39154. * Gets the value of the `A` button
  39155. */
  39156. /**
  39157. * Sets the value of the `A` button
  39158. */
  39159. buttonA: number;
  39160. /**
  39161. * Gets the value of the `B` button
  39162. */
  39163. /**
  39164. * Sets the value of the `B` button
  39165. */
  39166. buttonB: number;
  39167. /**
  39168. * Gets the value of the `X` button
  39169. */
  39170. /**
  39171. * Sets the value of the `X` button
  39172. */
  39173. buttonX: number;
  39174. /**
  39175. * Gets the value of the `Y` button
  39176. */
  39177. /**
  39178. * Sets the value of the `Y` button
  39179. */
  39180. buttonY: number;
  39181. /**
  39182. * Gets the value of the `Start` button
  39183. */
  39184. /**
  39185. * Sets the value of the `Start` button
  39186. */
  39187. buttonStart: number;
  39188. /**
  39189. * Gets the value of the `Back` button
  39190. */
  39191. /**
  39192. * Sets the value of the `Back` button
  39193. */
  39194. buttonBack: number;
  39195. /**
  39196. * Gets the value of the `Left` button
  39197. */
  39198. /**
  39199. * Sets the value of the `Left` button
  39200. */
  39201. buttonLB: number;
  39202. /**
  39203. * Gets the value of the `Right` button
  39204. */
  39205. /**
  39206. * Sets the value of the `Right` button
  39207. */
  39208. buttonRB: number;
  39209. /**
  39210. * Gets the value of the Left joystick
  39211. */
  39212. /**
  39213. * Sets the value of the Left joystick
  39214. */
  39215. buttonLeftStick: number;
  39216. /**
  39217. * Gets the value of the Right joystick
  39218. */
  39219. /**
  39220. * Sets the value of the Right joystick
  39221. */
  39222. buttonRightStick: number;
  39223. /**
  39224. * Gets the value of D-pad up
  39225. */
  39226. /**
  39227. * Sets the value of D-pad up
  39228. */
  39229. dPadUp: number;
  39230. /**
  39231. * Gets the value of D-pad down
  39232. */
  39233. /**
  39234. * Sets the value of D-pad down
  39235. */
  39236. dPadDown: number;
  39237. /**
  39238. * Gets the value of D-pad left
  39239. */
  39240. /**
  39241. * Sets the value of D-pad left
  39242. */
  39243. dPadLeft: number;
  39244. /**
  39245. * Gets the value of D-pad right
  39246. */
  39247. /**
  39248. * Sets the value of D-pad right
  39249. */
  39250. dPadRight: number;
  39251. /**
  39252. * Force the gamepad to synchronize with device values
  39253. */
  39254. update(): void;
  39255. /**
  39256. * Disposes the gamepad
  39257. */
  39258. dispose(): void;
  39259. }
  39260. }
  39261. declare module "babylonjs/Gamepads/gamepadManager" {
  39262. import { Observable } from "babylonjs/Misc/observable";
  39263. import { Nullable } from "babylonjs/types";
  39264. import { Scene } from "babylonjs/scene";
  39265. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39266. /**
  39267. * Manager for handling gamepads
  39268. */
  39269. export class GamepadManager {
  39270. private _scene?;
  39271. private _babylonGamepads;
  39272. private _oneGamepadConnected;
  39273. /** @hidden */
  39274. _isMonitoring: boolean;
  39275. private _gamepadEventSupported;
  39276. private _gamepadSupport;
  39277. /**
  39278. * observable to be triggered when the gamepad controller has been connected
  39279. */
  39280. onGamepadConnectedObservable: Observable<Gamepad>;
  39281. /**
  39282. * observable to be triggered when the gamepad controller has been disconnected
  39283. */
  39284. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39285. private _onGamepadConnectedEvent;
  39286. private _onGamepadDisconnectedEvent;
  39287. /**
  39288. * Initializes the gamepad manager
  39289. * @param _scene BabylonJS scene
  39290. */
  39291. constructor(_scene?: Scene | undefined);
  39292. /**
  39293. * The gamepads in the game pad manager
  39294. */
  39295. readonly gamepads: Gamepad[];
  39296. /**
  39297. * Get the gamepad controllers based on type
  39298. * @param type The type of gamepad controller
  39299. * @returns Nullable gamepad
  39300. */
  39301. getGamepadByType(type?: number): Nullable<Gamepad>;
  39302. /**
  39303. * Disposes the gamepad manager
  39304. */
  39305. dispose(): void;
  39306. private _addNewGamepad;
  39307. private _startMonitoringGamepads;
  39308. private _stopMonitoringGamepads;
  39309. /** @hidden */
  39310. _checkGamepadsStatus(): void;
  39311. private _updateGamepadObjects;
  39312. }
  39313. }
  39314. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39315. import { Nullable } from "babylonjs/types";
  39316. import { Scene } from "babylonjs/scene";
  39317. import { ISceneComponent } from "babylonjs/sceneComponent";
  39318. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39319. module "babylonjs/scene" {
  39320. interface Scene {
  39321. /** @hidden */
  39322. _gamepadManager: Nullable<GamepadManager>;
  39323. /**
  39324. * Gets the gamepad manager associated with the scene
  39325. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39326. */
  39327. gamepadManager: GamepadManager;
  39328. }
  39329. }
  39330. module "babylonjs/Cameras/freeCameraInputsManager" {
  39331. /**
  39332. * Interface representing a free camera inputs manager
  39333. */
  39334. interface FreeCameraInputsManager {
  39335. /**
  39336. * Adds gamepad input support to the FreeCameraInputsManager.
  39337. * @returns the FreeCameraInputsManager
  39338. */
  39339. addGamepad(): FreeCameraInputsManager;
  39340. }
  39341. }
  39342. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39343. /**
  39344. * Interface representing an arc rotate camera inputs manager
  39345. */
  39346. interface ArcRotateCameraInputsManager {
  39347. /**
  39348. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39349. * @returns the camera inputs manager
  39350. */
  39351. addGamepad(): ArcRotateCameraInputsManager;
  39352. }
  39353. }
  39354. /**
  39355. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39356. */
  39357. export class GamepadSystemSceneComponent implements ISceneComponent {
  39358. /**
  39359. * The component name helpfull to identify the component in the list of scene components.
  39360. */
  39361. readonly name: string;
  39362. /**
  39363. * The scene the component belongs to.
  39364. */
  39365. scene: Scene;
  39366. /**
  39367. * Creates a new instance of the component for the given scene
  39368. * @param scene Defines the scene to register the component in
  39369. */
  39370. constructor(scene: Scene);
  39371. /**
  39372. * Registers the component in a given scene
  39373. */
  39374. register(): void;
  39375. /**
  39376. * Rebuilds the elements related to this component in case of
  39377. * context lost for instance.
  39378. */
  39379. rebuild(): void;
  39380. /**
  39381. * Disposes the component and the associated ressources
  39382. */
  39383. dispose(): void;
  39384. private _beforeCameraUpdate;
  39385. }
  39386. }
  39387. declare module "babylonjs/Cameras/universalCamera" {
  39388. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39389. import { Scene } from "babylonjs/scene";
  39390. import { Vector3 } from "babylonjs/Maths/math";
  39391. import "babylonjs/Gamepads/gamepadSceneComponent";
  39392. /**
  39393. * 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,
  39394. * which still works and will still be found in many Playgrounds.
  39395. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39396. */
  39397. export class UniversalCamera extends TouchCamera {
  39398. /**
  39399. * Defines the gamepad rotation sensiblity.
  39400. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39401. */
  39402. gamepadAngularSensibility: number;
  39403. /**
  39404. * Defines the gamepad move sensiblity.
  39405. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39406. */
  39407. gamepadMoveSensibility: number;
  39408. /**
  39409. * 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,
  39410. * which still works and will still be found in many Playgrounds.
  39411. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39412. * @param name Define the name of the camera in the scene
  39413. * @param position Define the start position of the camera in the scene
  39414. * @param scene Define the scene the camera belongs to
  39415. */
  39416. constructor(name: string, position: Vector3, scene: Scene);
  39417. /**
  39418. * Gets the current object class name.
  39419. * @return the class name
  39420. */
  39421. getClassName(): string;
  39422. }
  39423. }
  39424. declare module "babylonjs/Cameras/gamepadCamera" {
  39425. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39426. import { Scene } from "babylonjs/scene";
  39427. import { Vector3 } from "babylonjs/Maths/math";
  39428. /**
  39429. * This represents a FPS type of camera. This is only here for back compat purpose.
  39430. * Please use the UniversalCamera instead as both are identical.
  39431. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39432. */
  39433. export class GamepadCamera extends UniversalCamera {
  39434. /**
  39435. * Instantiates a new Gamepad Camera
  39436. * This represents a FPS type of camera. This is only here for back compat purpose.
  39437. * Please use the UniversalCamera instead as both are identical.
  39438. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39439. * @param name Define the name of the camera in the scene
  39440. * @param position Define the start position of the camera in the scene
  39441. * @param scene Define the scene the camera belongs to
  39442. */
  39443. constructor(name: string, position: Vector3, scene: Scene);
  39444. /**
  39445. * Gets the current object class name.
  39446. * @return the class name
  39447. */
  39448. getClassName(): string;
  39449. }
  39450. }
  39451. declare module "babylonjs/Shaders/pass.fragment" {
  39452. /** @hidden */
  39453. export var passPixelShader: {
  39454. name: string;
  39455. shader: string;
  39456. };
  39457. }
  39458. declare module "babylonjs/Shaders/passCube.fragment" {
  39459. /** @hidden */
  39460. export var passCubePixelShader: {
  39461. name: string;
  39462. shader: string;
  39463. };
  39464. }
  39465. declare module "babylonjs/PostProcesses/passPostProcess" {
  39466. import { Nullable } from "babylonjs/types";
  39467. import { Camera } from "babylonjs/Cameras/camera";
  39468. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39469. import { Engine } from "babylonjs/Engines/engine";
  39470. import "babylonjs/Shaders/pass.fragment";
  39471. import "babylonjs/Shaders/passCube.fragment";
  39472. /**
  39473. * PassPostProcess which produces an output the same as it's input
  39474. */
  39475. export class PassPostProcess extends PostProcess {
  39476. /**
  39477. * Creates the PassPostProcess
  39478. * @param name The name of the effect.
  39479. * @param options The required width/height ratio to downsize to before computing the render pass.
  39480. * @param camera The camera to apply the render pass to.
  39481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39482. * @param engine The engine which the post process will be applied. (default: current engine)
  39483. * @param reusable If the post process can be reused on the same frame. (default: false)
  39484. * @param textureType The type of texture to be used when performing the post processing.
  39485. * @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)
  39486. */
  39487. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39488. }
  39489. /**
  39490. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39491. */
  39492. export class PassCubePostProcess extends PostProcess {
  39493. private _face;
  39494. /**
  39495. * Gets or sets the cube face to display.
  39496. * * 0 is +X
  39497. * * 1 is -X
  39498. * * 2 is +Y
  39499. * * 3 is -Y
  39500. * * 4 is +Z
  39501. * * 5 is -Z
  39502. */
  39503. face: number;
  39504. /**
  39505. * Creates the PassCubePostProcess
  39506. * @param name The name of the effect.
  39507. * @param options The required width/height ratio to downsize to before computing the render pass.
  39508. * @param camera The camera to apply the render pass to.
  39509. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39510. * @param engine The engine which the post process will be applied. (default: current engine)
  39511. * @param reusable If the post process can be reused on the same frame. (default: false)
  39512. * @param textureType The type of texture to be used when performing the post processing.
  39513. * @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)
  39514. */
  39515. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39516. }
  39517. }
  39518. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39519. /** @hidden */
  39520. export var anaglyphPixelShader: {
  39521. name: string;
  39522. shader: string;
  39523. };
  39524. }
  39525. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39526. import { Engine } from "babylonjs/Engines/engine";
  39527. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39528. import { Camera } from "babylonjs/Cameras/camera";
  39529. import "babylonjs/Shaders/anaglyph.fragment";
  39530. /**
  39531. * Postprocess used to generate anaglyphic rendering
  39532. */
  39533. export class AnaglyphPostProcess extends PostProcess {
  39534. private _passedProcess;
  39535. /**
  39536. * Creates a new AnaglyphPostProcess
  39537. * @param name defines postprocess name
  39538. * @param options defines creation options or target ratio scale
  39539. * @param rigCameras defines cameras using this postprocess
  39540. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39541. * @param engine defines hosting engine
  39542. * @param reusable defines if the postprocess will be reused multiple times per frame
  39543. */
  39544. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39545. }
  39546. }
  39547. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39548. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39549. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39550. import { Scene } from "babylonjs/scene";
  39551. import { Vector3 } from "babylonjs/Maths/math";
  39552. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39553. /**
  39554. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39555. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39556. */
  39557. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39558. /**
  39559. * Creates a new AnaglyphArcRotateCamera
  39560. * @param name defines camera name
  39561. * @param alpha defines alpha angle (in radians)
  39562. * @param beta defines beta angle (in radians)
  39563. * @param radius defines radius
  39564. * @param target defines camera target
  39565. * @param interaxialDistance defines distance between each color axis
  39566. * @param scene defines the hosting scene
  39567. */
  39568. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39569. /**
  39570. * Gets camera class name
  39571. * @returns AnaglyphArcRotateCamera
  39572. */
  39573. getClassName(): string;
  39574. }
  39575. }
  39576. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39577. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39578. import { Scene } from "babylonjs/scene";
  39579. import { Vector3 } from "babylonjs/Maths/math";
  39580. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39581. /**
  39582. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39583. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39584. */
  39585. export class AnaglyphFreeCamera extends FreeCamera {
  39586. /**
  39587. * Creates a new AnaglyphFreeCamera
  39588. * @param name defines camera name
  39589. * @param position defines initial position
  39590. * @param interaxialDistance defines distance between each color axis
  39591. * @param scene defines the hosting scene
  39592. */
  39593. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39594. /**
  39595. * Gets camera class name
  39596. * @returns AnaglyphFreeCamera
  39597. */
  39598. getClassName(): string;
  39599. }
  39600. }
  39601. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39602. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39603. import { Scene } from "babylonjs/scene";
  39604. import { Vector3 } from "babylonjs/Maths/math";
  39605. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39606. /**
  39607. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39608. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39609. */
  39610. export class AnaglyphGamepadCamera extends GamepadCamera {
  39611. /**
  39612. * Creates a new AnaglyphGamepadCamera
  39613. * @param name defines camera name
  39614. * @param position defines initial position
  39615. * @param interaxialDistance defines distance between each color axis
  39616. * @param scene defines the hosting scene
  39617. */
  39618. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39619. /**
  39620. * Gets camera class name
  39621. * @returns AnaglyphGamepadCamera
  39622. */
  39623. getClassName(): string;
  39624. }
  39625. }
  39626. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39627. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39628. import { Scene } from "babylonjs/scene";
  39629. import { Vector3 } from "babylonjs/Maths/math";
  39630. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39631. /**
  39632. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39633. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39634. */
  39635. export class AnaglyphUniversalCamera extends UniversalCamera {
  39636. /**
  39637. * Creates a new AnaglyphUniversalCamera
  39638. * @param name defines camera name
  39639. * @param position defines initial position
  39640. * @param interaxialDistance defines distance between each color axis
  39641. * @param scene defines the hosting scene
  39642. */
  39643. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39644. /**
  39645. * Gets camera class name
  39646. * @returns AnaglyphUniversalCamera
  39647. */
  39648. getClassName(): string;
  39649. }
  39650. }
  39651. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39652. /** @hidden */
  39653. export var stereoscopicInterlacePixelShader: {
  39654. name: string;
  39655. shader: string;
  39656. };
  39657. }
  39658. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39659. import { Camera } from "babylonjs/Cameras/camera";
  39660. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39661. import { Engine } from "babylonjs/Engines/engine";
  39662. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39663. /**
  39664. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39665. */
  39666. export class StereoscopicInterlacePostProcess extends PostProcess {
  39667. private _stepSize;
  39668. private _passedProcess;
  39669. /**
  39670. * Initializes a StereoscopicInterlacePostProcess
  39671. * @param name The name of the effect.
  39672. * @param rigCameras The rig cameras to be appled to the post process
  39673. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39675. * @param engine The engine which the post process will be applied. (default: current engine)
  39676. * @param reusable If the post process can be reused on the same frame. (default: false)
  39677. */
  39678. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39679. }
  39680. }
  39681. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39682. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39683. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39684. import { Scene } from "babylonjs/scene";
  39685. import { Vector3 } from "babylonjs/Maths/math";
  39686. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39687. /**
  39688. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39689. * @see http://doc.babylonjs.com/features/cameras
  39690. */
  39691. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39692. /**
  39693. * Creates a new StereoscopicArcRotateCamera
  39694. * @param name defines camera name
  39695. * @param alpha defines alpha angle (in radians)
  39696. * @param beta defines beta angle (in radians)
  39697. * @param radius defines radius
  39698. * @param target defines camera target
  39699. * @param interaxialDistance defines distance between each color axis
  39700. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39701. * @param scene defines the hosting scene
  39702. */
  39703. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39704. /**
  39705. * Gets camera class name
  39706. * @returns StereoscopicArcRotateCamera
  39707. */
  39708. getClassName(): string;
  39709. }
  39710. }
  39711. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39712. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39713. import { Scene } from "babylonjs/scene";
  39714. import { Vector3 } from "babylonjs/Maths/math";
  39715. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39716. /**
  39717. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39718. * @see http://doc.babylonjs.com/features/cameras
  39719. */
  39720. export class StereoscopicFreeCamera extends FreeCamera {
  39721. /**
  39722. * Creates a new StereoscopicFreeCamera
  39723. * @param name defines camera name
  39724. * @param position defines initial position
  39725. * @param interaxialDistance defines distance between each color axis
  39726. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39727. * @param scene defines the hosting scene
  39728. */
  39729. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39730. /**
  39731. * Gets camera class name
  39732. * @returns StereoscopicFreeCamera
  39733. */
  39734. getClassName(): string;
  39735. }
  39736. }
  39737. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39738. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39739. import { Scene } from "babylonjs/scene";
  39740. import { Vector3 } from "babylonjs/Maths/math";
  39741. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39742. /**
  39743. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39744. * @see http://doc.babylonjs.com/features/cameras
  39745. */
  39746. export class StereoscopicGamepadCamera extends GamepadCamera {
  39747. /**
  39748. * Creates a new StereoscopicGamepadCamera
  39749. * @param name defines camera name
  39750. * @param position defines initial position
  39751. * @param interaxialDistance defines distance between each color axis
  39752. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39753. * @param scene defines the hosting scene
  39754. */
  39755. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39756. /**
  39757. * Gets camera class name
  39758. * @returns StereoscopicGamepadCamera
  39759. */
  39760. getClassName(): string;
  39761. }
  39762. }
  39763. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39764. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39765. import { Scene } from "babylonjs/scene";
  39766. import { Vector3 } from "babylonjs/Maths/math";
  39767. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39768. /**
  39769. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39770. * @see http://doc.babylonjs.com/features/cameras
  39771. */
  39772. export class StereoscopicUniversalCamera extends UniversalCamera {
  39773. /**
  39774. * Creates a new StereoscopicUniversalCamera
  39775. * @param name defines camera name
  39776. * @param position defines initial position
  39777. * @param interaxialDistance defines distance between each color axis
  39778. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39779. * @param scene defines the hosting scene
  39780. */
  39781. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39782. /**
  39783. * Gets camera class name
  39784. * @returns StereoscopicUniversalCamera
  39785. */
  39786. getClassName(): string;
  39787. }
  39788. }
  39789. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39790. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39791. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39792. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39793. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39794. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39795. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39796. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39797. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39798. }
  39799. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39800. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39801. import { Scene } from "babylonjs/scene";
  39802. import { Vector3 } from "babylonjs/Maths/math";
  39803. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39804. /**
  39805. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39806. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39807. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39808. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39809. */
  39810. export class VirtualJoysticksCamera extends FreeCamera {
  39811. /**
  39812. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39813. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39814. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39815. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39816. * @param name Define the name of the camera in the scene
  39817. * @param position Define the start position of the camera in the scene
  39818. * @param scene Define the scene the camera belongs to
  39819. */
  39820. constructor(name: string, position: Vector3, scene: Scene);
  39821. /**
  39822. * Gets the current object class name.
  39823. * @return the class name
  39824. */
  39825. getClassName(): string;
  39826. }
  39827. }
  39828. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39829. import { Matrix } from "babylonjs/Maths/math";
  39830. /**
  39831. * This represents all the required metrics to create a VR camera.
  39832. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39833. */
  39834. export class VRCameraMetrics {
  39835. /**
  39836. * Define the horizontal resolution off the screen.
  39837. */
  39838. hResolution: number;
  39839. /**
  39840. * Define the vertical resolution off the screen.
  39841. */
  39842. vResolution: number;
  39843. /**
  39844. * Define the horizontal screen size.
  39845. */
  39846. hScreenSize: number;
  39847. /**
  39848. * Define the vertical screen size.
  39849. */
  39850. vScreenSize: number;
  39851. /**
  39852. * Define the vertical screen center position.
  39853. */
  39854. vScreenCenter: number;
  39855. /**
  39856. * Define the distance of the eyes to the screen.
  39857. */
  39858. eyeToScreenDistance: number;
  39859. /**
  39860. * Define the distance between both lenses
  39861. */
  39862. lensSeparationDistance: number;
  39863. /**
  39864. * Define the distance between both viewer's eyes.
  39865. */
  39866. interpupillaryDistance: number;
  39867. /**
  39868. * Define the distortion factor of the VR postprocess.
  39869. * Please, touch with care.
  39870. */
  39871. distortionK: number[];
  39872. /**
  39873. * Define the chromatic aberration correction factors for the VR post process.
  39874. */
  39875. chromaAbCorrection: number[];
  39876. /**
  39877. * Define the scale factor of the post process.
  39878. * The smaller the better but the slower.
  39879. */
  39880. postProcessScaleFactor: number;
  39881. /**
  39882. * Define an offset for the lens center.
  39883. */
  39884. lensCenterOffset: number;
  39885. /**
  39886. * Define if the current vr camera should compensate the distortion of the lense or not.
  39887. */
  39888. compensateDistortion: boolean;
  39889. /**
  39890. * Defines if multiview should be enabled when rendering (Default: false)
  39891. */
  39892. multiviewEnabled: boolean;
  39893. /**
  39894. * Gets the rendering aspect ratio based on the provided resolutions.
  39895. */
  39896. readonly aspectRatio: number;
  39897. /**
  39898. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39899. */
  39900. readonly aspectRatioFov: number;
  39901. /**
  39902. * @hidden
  39903. */
  39904. readonly leftHMatrix: Matrix;
  39905. /**
  39906. * @hidden
  39907. */
  39908. readonly rightHMatrix: Matrix;
  39909. /**
  39910. * @hidden
  39911. */
  39912. readonly leftPreViewMatrix: Matrix;
  39913. /**
  39914. * @hidden
  39915. */
  39916. readonly rightPreViewMatrix: Matrix;
  39917. /**
  39918. * Get the default VRMetrics based on the most generic setup.
  39919. * @returns the default vr metrics
  39920. */
  39921. static GetDefault(): VRCameraMetrics;
  39922. }
  39923. }
  39924. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39925. /** @hidden */
  39926. export var vrDistortionCorrectionPixelShader: {
  39927. name: string;
  39928. shader: string;
  39929. };
  39930. }
  39931. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39932. import { Camera } from "babylonjs/Cameras/camera";
  39933. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39934. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39935. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39936. /**
  39937. * VRDistortionCorrectionPostProcess used for mobile VR
  39938. */
  39939. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39940. private _isRightEye;
  39941. private _distortionFactors;
  39942. private _postProcessScaleFactor;
  39943. private _lensCenterOffset;
  39944. private _scaleIn;
  39945. private _scaleFactor;
  39946. private _lensCenter;
  39947. /**
  39948. * Initializes the VRDistortionCorrectionPostProcess
  39949. * @param name The name of the effect.
  39950. * @param camera The camera to apply the render pass to.
  39951. * @param isRightEye If this is for the right eye distortion
  39952. * @param vrMetrics All the required metrics for the VR camera
  39953. */
  39954. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39955. }
  39956. }
  39957. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39958. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39959. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39960. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39961. import { Scene } from "babylonjs/scene";
  39962. import { Vector3 } from "babylonjs/Maths/math";
  39963. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39964. import "babylonjs/Cameras/RigModes/vrRigMode";
  39965. /**
  39966. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39967. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39968. */
  39969. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39970. /**
  39971. * Creates a new VRDeviceOrientationArcRotateCamera
  39972. * @param name defines camera name
  39973. * @param alpha defines the camera rotation along the logitudinal axis
  39974. * @param beta defines the camera rotation along the latitudinal axis
  39975. * @param radius defines the camera distance from its target
  39976. * @param target defines the camera target
  39977. * @param scene defines the scene the camera belongs to
  39978. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39979. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39980. */
  39981. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39982. /**
  39983. * Gets camera class name
  39984. * @returns VRDeviceOrientationArcRotateCamera
  39985. */
  39986. getClassName(): string;
  39987. }
  39988. }
  39989. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39990. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39991. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39992. import { Scene } from "babylonjs/scene";
  39993. import { Vector3 } from "babylonjs/Maths/math";
  39994. import "babylonjs/Cameras/RigModes/vrRigMode";
  39995. /**
  39996. * Camera used to simulate VR rendering (based on FreeCamera)
  39997. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39998. */
  39999. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40000. /**
  40001. * Creates a new VRDeviceOrientationFreeCamera
  40002. * @param name defines camera name
  40003. * @param position defines the start position of the camera
  40004. * @param scene defines the scene the camera belongs to
  40005. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40006. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40007. */
  40008. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40009. /**
  40010. * Gets camera class name
  40011. * @returns VRDeviceOrientationFreeCamera
  40012. */
  40013. getClassName(): string;
  40014. }
  40015. }
  40016. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40017. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40018. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40019. import { Scene } from "babylonjs/scene";
  40020. import { Vector3 } from "babylonjs/Maths/math";
  40021. import "babylonjs/Gamepads/gamepadSceneComponent";
  40022. /**
  40023. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40024. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40025. */
  40026. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40027. /**
  40028. * Creates a new VRDeviceOrientationGamepadCamera
  40029. * @param name defines camera name
  40030. * @param position defines the start position of the camera
  40031. * @param scene defines the scene the camera belongs to
  40032. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40033. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40034. */
  40035. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40036. /**
  40037. * Gets camera class name
  40038. * @returns VRDeviceOrientationGamepadCamera
  40039. */
  40040. getClassName(): string;
  40041. }
  40042. }
  40043. declare module "babylonjs/Materials/pushMaterial" {
  40044. import { Nullable } from "babylonjs/types";
  40045. import { Scene } from "babylonjs/scene";
  40046. import { Matrix } from "babylonjs/Maths/math";
  40047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40048. import { Mesh } from "babylonjs/Meshes/mesh";
  40049. import { Material } from "babylonjs/Materials/material";
  40050. import { Effect } from "babylonjs/Materials/effect";
  40051. /**
  40052. * Base class of materials working in push mode in babylon JS
  40053. * @hidden
  40054. */
  40055. export class PushMaterial extends Material {
  40056. protected _activeEffect: Effect;
  40057. protected _normalMatrix: Matrix;
  40058. /**
  40059. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40060. * This means that the material can keep using a previous shader while a new one is being compiled.
  40061. * This is mostly used when shader parallel compilation is supported (true by default)
  40062. */
  40063. allowShaderHotSwapping: boolean;
  40064. constructor(name: string, scene: Scene);
  40065. getEffect(): Effect;
  40066. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40067. /**
  40068. * Binds the given world matrix to the active effect
  40069. *
  40070. * @param world the matrix to bind
  40071. */
  40072. bindOnlyWorldMatrix(world: Matrix): void;
  40073. /**
  40074. * Binds the given normal matrix to the active effect
  40075. *
  40076. * @param normalMatrix the matrix to bind
  40077. */
  40078. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40079. bind(world: Matrix, mesh?: Mesh): void;
  40080. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40081. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40082. }
  40083. }
  40084. declare module "babylonjs/Materials/materialFlags" {
  40085. /**
  40086. * This groups all the flags used to control the materials channel.
  40087. */
  40088. export class MaterialFlags {
  40089. private static _DiffuseTextureEnabled;
  40090. /**
  40091. * Are diffuse textures enabled in the application.
  40092. */
  40093. static DiffuseTextureEnabled: boolean;
  40094. private static _AmbientTextureEnabled;
  40095. /**
  40096. * Are ambient textures enabled in the application.
  40097. */
  40098. static AmbientTextureEnabled: boolean;
  40099. private static _OpacityTextureEnabled;
  40100. /**
  40101. * Are opacity textures enabled in the application.
  40102. */
  40103. static OpacityTextureEnabled: boolean;
  40104. private static _ReflectionTextureEnabled;
  40105. /**
  40106. * Are reflection textures enabled in the application.
  40107. */
  40108. static ReflectionTextureEnabled: boolean;
  40109. private static _EmissiveTextureEnabled;
  40110. /**
  40111. * Are emissive textures enabled in the application.
  40112. */
  40113. static EmissiveTextureEnabled: boolean;
  40114. private static _SpecularTextureEnabled;
  40115. /**
  40116. * Are specular textures enabled in the application.
  40117. */
  40118. static SpecularTextureEnabled: boolean;
  40119. private static _BumpTextureEnabled;
  40120. /**
  40121. * Are bump textures enabled in the application.
  40122. */
  40123. static BumpTextureEnabled: boolean;
  40124. private static _LightmapTextureEnabled;
  40125. /**
  40126. * Are lightmap textures enabled in the application.
  40127. */
  40128. static LightmapTextureEnabled: boolean;
  40129. private static _RefractionTextureEnabled;
  40130. /**
  40131. * Are refraction textures enabled in the application.
  40132. */
  40133. static RefractionTextureEnabled: boolean;
  40134. private static _ColorGradingTextureEnabled;
  40135. /**
  40136. * Are color grading textures enabled in the application.
  40137. */
  40138. static ColorGradingTextureEnabled: boolean;
  40139. private static _FresnelEnabled;
  40140. /**
  40141. * Are fresnels enabled in the application.
  40142. */
  40143. static FresnelEnabled: boolean;
  40144. private static _ClearCoatTextureEnabled;
  40145. /**
  40146. * Are clear coat textures enabled in the application.
  40147. */
  40148. static ClearCoatTextureEnabled: boolean;
  40149. private static _ClearCoatBumpTextureEnabled;
  40150. /**
  40151. * Are clear coat bump textures enabled in the application.
  40152. */
  40153. static ClearCoatBumpTextureEnabled: boolean;
  40154. private static _ClearCoatTintTextureEnabled;
  40155. /**
  40156. * Are clear coat tint textures enabled in the application.
  40157. */
  40158. static ClearCoatTintTextureEnabled: boolean;
  40159. private static _SheenTextureEnabled;
  40160. /**
  40161. * Are sheen textures enabled in the application.
  40162. */
  40163. static SheenTextureEnabled: boolean;
  40164. private static _AnisotropicTextureEnabled;
  40165. /**
  40166. * Are anisotropic textures enabled in the application.
  40167. */
  40168. static AnisotropicTextureEnabled: boolean;
  40169. private static _ThicknessTextureEnabled;
  40170. /**
  40171. * Are thickness textures enabled in the application.
  40172. */
  40173. static ThicknessTextureEnabled: boolean;
  40174. }
  40175. }
  40176. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40177. /** @hidden */
  40178. export var defaultFragmentDeclaration: {
  40179. name: string;
  40180. shader: string;
  40181. };
  40182. }
  40183. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40184. /** @hidden */
  40185. export var defaultUboDeclaration: {
  40186. name: string;
  40187. shader: string;
  40188. };
  40189. }
  40190. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40191. /** @hidden */
  40192. export var lightFragmentDeclaration: {
  40193. name: string;
  40194. shader: string;
  40195. };
  40196. }
  40197. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40198. /** @hidden */
  40199. export var lightUboDeclaration: {
  40200. name: string;
  40201. shader: string;
  40202. };
  40203. }
  40204. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40205. /** @hidden */
  40206. export var lightsFragmentFunctions: {
  40207. name: string;
  40208. shader: string;
  40209. };
  40210. }
  40211. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40212. /** @hidden */
  40213. export var shadowsFragmentFunctions: {
  40214. name: string;
  40215. shader: string;
  40216. };
  40217. }
  40218. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40219. /** @hidden */
  40220. export var fresnelFunction: {
  40221. name: string;
  40222. shader: string;
  40223. };
  40224. }
  40225. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40226. /** @hidden */
  40227. export var reflectionFunction: {
  40228. name: string;
  40229. shader: string;
  40230. };
  40231. }
  40232. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40233. /** @hidden */
  40234. export var bumpFragmentFunctions: {
  40235. name: string;
  40236. shader: string;
  40237. };
  40238. }
  40239. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40240. /** @hidden */
  40241. export var logDepthDeclaration: {
  40242. name: string;
  40243. shader: string;
  40244. };
  40245. }
  40246. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40247. /** @hidden */
  40248. export var bumpFragment: {
  40249. name: string;
  40250. shader: string;
  40251. };
  40252. }
  40253. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40254. /** @hidden */
  40255. export var depthPrePass: {
  40256. name: string;
  40257. shader: string;
  40258. };
  40259. }
  40260. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40261. /** @hidden */
  40262. export var lightFragment: {
  40263. name: string;
  40264. shader: string;
  40265. };
  40266. }
  40267. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40268. /** @hidden */
  40269. export var logDepthFragment: {
  40270. name: string;
  40271. shader: string;
  40272. };
  40273. }
  40274. declare module "babylonjs/Shaders/default.fragment" {
  40275. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40276. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40277. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40278. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40279. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40280. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40281. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40282. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40283. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40284. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40285. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40286. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40287. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40288. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40289. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40290. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40291. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40292. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40293. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40294. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40295. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40296. /** @hidden */
  40297. export var defaultPixelShader: {
  40298. name: string;
  40299. shader: string;
  40300. };
  40301. }
  40302. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40303. /** @hidden */
  40304. export var defaultVertexDeclaration: {
  40305. name: string;
  40306. shader: string;
  40307. };
  40308. }
  40309. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40310. /** @hidden */
  40311. export var bumpVertexDeclaration: {
  40312. name: string;
  40313. shader: string;
  40314. };
  40315. }
  40316. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40317. /** @hidden */
  40318. export var bumpVertex: {
  40319. name: string;
  40320. shader: string;
  40321. };
  40322. }
  40323. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40324. /** @hidden */
  40325. export var fogVertex: {
  40326. name: string;
  40327. shader: string;
  40328. };
  40329. }
  40330. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40331. /** @hidden */
  40332. export var shadowsVertex: {
  40333. name: string;
  40334. shader: string;
  40335. };
  40336. }
  40337. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40338. /** @hidden */
  40339. export var pointCloudVertex: {
  40340. name: string;
  40341. shader: string;
  40342. };
  40343. }
  40344. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40345. /** @hidden */
  40346. export var logDepthVertex: {
  40347. name: string;
  40348. shader: string;
  40349. };
  40350. }
  40351. declare module "babylonjs/Shaders/default.vertex" {
  40352. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40353. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40354. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40355. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40356. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40357. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40358. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40359. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40360. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40361. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40362. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40363. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40364. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40365. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40366. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40367. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40368. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40369. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40370. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40371. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40372. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40373. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40374. /** @hidden */
  40375. export var defaultVertexShader: {
  40376. name: string;
  40377. shader: string;
  40378. };
  40379. }
  40380. declare module "babylonjs/Materials/standardMaterial" {
  40381. import { SmartArray } from "babylonjs/Misc/smartArray";
  40382. import { IAnimatable } from "babylonjs/Misc/tools";
  40383. import { Nullable } from "babylonjs/types";
  40384. import { Scene } from "babylonjs/scene";
  40385. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40386. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40388. import { Mesh } from "babylonjs/Meshes/mesh";
  40389. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40390. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40391. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40392. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40393. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40395. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40396. import "babylonjs/Shaders/default.fragment";
  40397. import "babylonjs/Shaders/default.vertex";
  40398. /** @hidden */
  40399. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40400. MAINUV1: boolean;
  40401. MAINUV2: boolean;
  40402. DIFFUSE: boolean;
  40403. DIFFUSEDIRECTUV: number;
  40404. AMBIENT: boolean;
  40405. AMBIENTDIRECTUV: number;
  40406. OPACITY: boolean;
  40407. OPACITYDIRECTUV: number;
  40408. OPACITYRGB: boolean;
  40409. REFLECTION: boolean;
  40410. EMISSIVE: boolean;
  40411. EMISSIVEDIRECTUV: number;
  40412. SPECULAR: boolean;
  40413. SPECULARDIRECTUV: number;
  40414. BUMP: boolean;
  40415. BUMPDIRECTUV: number;
  40416. PARALLAX: boolean;
  40417. PARALLAXOCCLUSION: boolean;
  40418. SPECULAROVERALPHA: boolean;
  40419. CLIPPLANE: boolean;
  40420. CLIPPLANE2: boolean;
  40421. CLIPPLANE3: boolean;
  40422. CLIPPLANE4: boolean;
  40423. ALPHATEST: boolean;
  40424. DEPTHPREPASS: boolean;
  40425. ALPHAFROMDIFFUSE: boolean;
  40426. POINTSIZE: boolean;
  40427. FOG: boolean;
  40428. SPECULARTERM: boolean;
  40429. DIFFUSEFRESNEL: boolean;
  40430. OPACITYFRESNEL: boolean;
  40431. REFLECTIONFRESNEL: boolean;
  40432. REFRACTIONFRESNEL: boolean;
  40433. EMISSIVEFRESNEL: boolean;
  40434. FRESNEL: boolean;
  40435. NORMAL: boolean;
  40436. UV1: boolean;
  40437. UV2: boolean;
  40438. VERTEXCOLOR: boolean;
  40439. VERTEXALPHA: boolean;
  40440. NUM_BONE_INFLUENCERS: number;
  40441. BonesPerMesh: number;
  40442. BONETEXTURE: boolean;
  40443. INSTANCES: boolean;
  40444. GLOSSINESS: boolean;
  40445. ROUGHNESS: boolean;
  40446. EMISSIVEASILLUMINATION: boolean;
  40447. LINKEMISSIVEWITHDIFFUSE: boolean;
  40448. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40449. LIGHTMAP: boolean;
  40450. LIGHTMAPDIRECTUV: number;
  40451. OBJECTSPACE_NORMALMAP: boolean;
  40452. USELIGHTMAPASSHADOWMAP: boolean;
  40453. REFLECTIONMAP_3D: boolean;
  40454. REFLECTIONMAP_SPHERICAL: boolean;
  40455. REFLECTIONMAP_PLANAR: boolean;
  40456. REFLECTIONMAP_CUBIC: boolean;
  40457. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40458. REFLECTIONMAP_PROJECTION: boolean;
  40459. REFLECTIONMAP_SKYBOX: boolean;
  40460. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40461. REFLECTIONMAP_EXPLICIT: boolean;
  40462. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40463. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40464. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40465. INVERTCUBICMAP: boolean;
  40466. LOGARITHMICDEPTH: boolean;
  40467. REFRACTION: boolean;
  40468. REFRACTIONMAP_3D: boolean;
  40469. REFLECTIONOVERALPHA: boolean;
  40470. TWOSIDEDLIGHTING: boolean;
  40471. SHADOWFLOAT: boolean;
  40472. MORPHTARGETS: boolean;
  40473. MORPHTARGETS_NORMAL: boolean;
  40474. MORPHTARGETS_TANGENT: boolean;
  40475. MORPHTARGETS_UV: boolean;
  40476. NUM_MORPH_INFLUENCERS: number;
  40477. NONUNIFORMSCALING: boolean;
  40478. PREMULTIPLYALPHA: boolean;
  40479. IMAGEPROCESSING: boolean;
  40480. VIGNETTE: boolean;
  40481. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40482. VIGNETTEBLENDMODEOPAQUE: boolean;
  40483. TONEMAPPING: boolean;
  40484. TONEMAPPING_ACES: boolean;
  40485. CONTRAST: boolean;
  40486. COLORCURVES: boolean;
  40487. COLORGRADING: boolean;
  40488. COLORGRADING3D: boolean;
  40489. SAMPLER3DGREENDEPTH: boolean;
  40490. SAMPLER3DBGRMAP: boolean;
  40491. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40492. MULTIVIEW: boolean;
  40493. /**
  40494. * If the reflection texture on this material is in linear color space
  40495. * @hidden
  40496. */
  40497. IS_REFLECTION_LINEAR: boolean;
  40498. /**
  40499. * If the refraction texture on this material is in linear color space
  40500. * @hidden
  40501. */
  40502. IS_REFRACTION_LINEAR: boolean;
  40503. EXPOSURE: boolean;
  40504. constructor();
  40505. setReflectionMode(modeToEnable: string): void;
  40506. }
  40507. /**
  40508. * This is the default material used in Babylon. It is the best trade off between quality
  40509. * and performances.
  40510. * @see http://doc.babylonjs.com/babylon101/materials
  40511. */
  40512. export class StandardMaterial extends PushMaterial {
  40513. private _diffuseTexture;
  40514. /**
  40515. * The basic texture of the material as viewed under a light.
  40516. */
  40517. diffuseTexture: Nullable<BaseTexture>;
  40518. private _ambientTexture;
  40519. /**
  40520. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40521. */
  40522. ambientTexture: Nullable<BaseTexture>;
  40523. private _opacityTexture;
  40524. /**
  40525. * Define the transparency of the material from a texture.
  40526. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40527. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40528. */
  40529. opacityTexture: Nullable<BaseTexture>;
  40530. private _reflectionTexture;
  40531. /**
  40532. * Define the texture used to display the reflection.
  40533. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40534. */
  40535. reflectionTexture: Nullable<BaseTexture>;
  40536. private _emissiveTexture;
  40537. /**
  40538. * Define texture of the material as if self lit.
  40539. * This will be mixed in the final result even in the absence of light.
  40540. */
  40541. emissiveTexture: Nullable<BaseTexture>;
  40542. private _specularTexture;
  40543. /**
  40544. * Define how the color and intensity of the highlight given by the light in the material.
  40545. */
  40546. specularTexture: Nullable<BaseTexture>;
  40547. private _bumpTexture;
  40548. /**
  40549. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40550. * 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.
  40551. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40552. */
  40553. bumpTexture: Nullable<BaseTexture>;
  40554. private _lightmapTexture;
  40555. /**
  40556. * Complex lighting can be computationally expensive to compute at runtime.
  40557. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40558. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40559. */
  40560. lightmapTexture: Nullable<BaseTexture>;
  40561. private _refractionTexture;
  40562. /**
  40563. * Define the texture used to display the refraction.
  40564. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40565. */
  40566. refractionTexture: Nullable<BaseTexture>;
  40567. /**
  40568. * The color of the material lit by the environmental background lighting.
  40569. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40570. */
  40571. ambientColor: Color3;
  40572. /**
  40573. * The basic color of the material as viewed under a light.
  40574. */
  40575. diffuseColor: Color3;
  40576. /**
  40577. * Define how the color and intensity of the highlight given by the light in the material.
  40578. */
  40579. specularColor: Color3;
  40580. /**
  40581. * Define the color of the material as if self lit.
  40582. * This will be mixed in the final result even in the absence of light.
  40583. */
  40584. emissiveColor: Color3;
  40585. /**
  40586. * Defines how sharp are the highlights in the material.
  40587. * The bigger the value the sharper giving a more glossy feeling to the result.
  40588. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40589. */
  40590. specularPower: number;
  40591. private _useAlphaFromDiffuseTexture;
  40592. /**
  40593. * Does the transparency come from the diffuse texture alpha channel.
  40594. */
  40595. useAlphaFromDiffuseTexture: boolean;
  40596. private _useEmissiveAsIllumination;
  40597. /**
  40598. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40599. */
  40600. useEmissiveAsIllumination: boolean;
  40601. private _linkEmissiveWithDiffuse;
  40602. /**
  40603. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40604. * the emissive level when the final color is close to one.
  40605. */
  40606. linkEmissiveWithDiffuse: boolean;
  40607. private _useSpecularOverAlpha;
  40608. /**
  40609. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40610. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40611. */
  40612. useSpecularOverAlpha: boolean;
  40613. private _useReflectionOverAlpha;
  40614. /**
  40615. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40616. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40617. */
  40618. useReflectionOverAlpha: boolean;
  40619. private _disableLighting;
  40620. /**
  40621. * Does lights from the scene impacts this material.
  40622. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40623. */
  40624. disableLighting: boolean;
  40625. private _useObjectSpaceNormalMap;
  40626. /**
  40627. * Allows using an object space normal map (instead of tangent space).
  40628. */
  40629. useObjectSpaceNormalMap: boolean;
  40630. private _useParallax;
  40631. /**
  40632. * Is parallax enabled or not.
  40633. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40634. */
  40635. useParallax: boolean;
  40636. private _useParallaxOcclusion;
  40637. /**
  40638. * Is parallax occlusion enabled or not.
  40639. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40640. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40641. */
  40642. useParallaxOcclusion: boolean;
  40643. /**
  40644. * 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.
  40645. */
  40646. parallaxScaleBias: number;
  40647. private _roughness;
  40648. /**
  40649. * Helps to define how blurry the reflections should appears in the material.
  40650. */
  40651. roughness: number;
  40652. /**
  40653. * In case of refraction, define the value of the index of refraction.
  40654. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40655. */
  40656. indexOfRefraction: number;
  40657. /**
  40658. * Invert the refraction texture alongside the y axis.
  40659. * It can be useful with procedural textures or probe for instance.
  40660. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40661. */
  40662. invertRefractionY: boolean;
  40663. /**
  40664. * Defines the alpha limits in alpha test mode.
  40665. */
  40666. alphaCutOff: number;
  40667. private _useLightmapAsShadowmap;
  40668. /**
  40669. * In case of light mapping, define whether the map contains light or shadow informations.
  40670. */
  40671. useLightmapAsShadowmap: boolean;
  40672. private _diffuseFresnelParameters;
  40673. /**
  40674. * Define the diffuse fresnel parameters of the material.
  40675. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40676. */
  40677. diffuseFresnelParameters: FresnelParameters;
  40678. private _opacityFresnelParameters;
  40679. /**
  40680. * Define the opacity fresnel parameters of the material.
  40681. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40682. */
  40683. opacityFresnelParameters: FresnelParameters;
  40684. private _reflectionFresnelParameters;
  40685. /**
  40686. * Define the reflection fresnel parameters of the material.
  40687. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40688. */
  40689. reflectionFresnelParameters: FresnelParameters;
  40690. private _refractionFresnelParameters;
  40691. /**
  40692. * Define the refraction fresnel parameters of the material.
  40693. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40694. */
  40695. refractionFresnelParameters: FresnelParameters;
  40696. private _emissiveFresnelParameters;
  40697. /**
  40698. * Define the emissive fresnel parameters of the material.
  40699. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40700. */
  40701. emissiveFresnelParameters: FresnelParameters;
  40702. private _useReflectionFresnelFromSpecular;
  40703. /**
  40704. * If true automatically deducts the fresnels values from the material specularity.
  40705. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40706. */
  40707. useReflectionFresnelFromSpecular: boolean;
  40708. private _useGlossinessFromSpecularMapAlpha;
  40709. /**
  40710. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40711. */
  40712. useGlossinessFromSpecularMapAlpha: boolean;
  40713. private _maxSimultaneousLights;
  40714. /**
  40715. * Defines the maximum number of lights that can be used in the material
  40716. */
  40717. maxSimultaneousLights: number;
  40718. private _invertNormalMapX;
  40719. /**
  40720. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40721. */
  40722. invertNormalMapX: boolean;
  40723. private _invertNormalMapY;
  40724. /**
  40725. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40726. */
  40727. invertNormalMapY: boolean;
  40728. private _twoSidedLighting;
  40729. /**
  40730. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40731. */
  40732. twoSidedLighting: boolean;
  40733. /**
  40734. * Default configuration related to image processing available in the standard Material.
  40735. */
  40736. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40737. /**
  40738. * Gets the image processing configuration used either in this material.
  40739. */
  40740. /**
  40741. * Sets the Default image processing configuration used either in the this material.
  40742. *
  40743. * If sets to null, the scene one is in use.
  40744. */
  40745. imageProcessingConfiguration: ImageProcessingConfiguration;
  40746. /**
  40747. * Keep track of the image processing observer to allow dispose and replace.
  40748. */
  40749. private _imageProcessingObserver;
  40750. /**
  40751. * Attaches a new image processing configuration to the Standard Material.
  40752. * @param configuration
  40753. */
  40754. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40755. /**
  40756. * Gets wether the color curves effect is enabled.
  40757. */
  40758. /**
  40759. * Sets wether the color curves effect is enabled.
  40760. */
  40761. cameraColorCurvesEnabled: boolean;
  40762. /**
  40763. * Gets wether the color grading effect is enabled.
  40764. */
  40765. /**
  40766. * Gets wether the color grading effect is enabled.
  40767. */
  40768. cameraColorGradingEnabled: boolean;
  40769. /**
  40770. * Gets wether tonemapping is enabled or not.
  40771. */
  40772. /**
  40773. * Sets wether tonemapping is enabled or not
  40774. */
  40775. cameraToneMappingEnabled: boolean;
  40776. /**
  40777. * The camera exposure used on this material.
  40778. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40779. * This corresponds to a photographic exposure.
  40780. */
  40781. /**
  40782. * The camera exposure used on this material.
  40783. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40784. * This corresponds to a photographic exposure.
  40785. */
  40786. cameraExposure: number;
  40787. /**
  40788. * Gets The camera contrast used on this material.
  40789. */
  40790. /**
  40791. * Sets The camera contrast used on this material.
  40792. */
  40793. cameraContrast: number;
  40794. /**
  40795. * Gets the Color Grading 2D Lookup Texture.
  40796. */
  40797. /**
  40798. * Sets the Color Grading 2D Lookup Texture.
  40799. */
  40800. cameraColorGradingTexture: Nullable<BaseTexture>;
  40801. /**
  40802. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40803. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40804. * 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;
  40805. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40806. */
  40807. /**
  40808. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40809. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40810. * 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;
  40811. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40812. */
  40813. cameraColorCurves: Nullable<ColorCurves>;
  40814. /**
  40815. * Custom callback helping to override the default shader used in the material.
  40816. */
  40817. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40818. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40819. protected _worldViewProjectionMatrix: Matrix;
  40820. protected _globalAmbientColor: Color3;
  40821. protected _useLogarithmicDepth: boolean;
  40822. /**
  40823. * Instantiates a new standard material.
  40824. * This is the default material used in Babylon. It is the best trade off between quality
  40825. * and performances.
  40826. * @see http://doc.babylonjs.com/babylon101/materials
  40827. * @param name Define the name of the material in the scene
  40828. * @param scene Define the scene the material belong to
  40829. */
  40830. constructor(name: string, scene: Scene);
  40831. /**
  40832. * Gets a boolean indicating that current material needs to register RTT
  40833. */
  40834. readonly hasRenderTargetTextures: boolean;
  40835. /**
  40836. * Gets the current class name of the material e.g. "StandardMaterial"
  40837. * Mainly use in serialization.
  40838. * @returns the class name
  40839. */
  40840. getClassName(): string;
  40841. /**
  40842. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40843. * You can try switching to logarithmic depth.
  40844. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40845. */
  40846. useLogarithmicDepth: boolean;
  40847. /**
  40848. * Specifies if the material will require alpha blending
  40849. * @returns a boolean specifying if alpha blending is needed
  40850. */
  40851. needAlphaBlending(): boolean;
  40852. /**
  40853. * Specifies if this material should be rendered in alpha test mode
  40854. * @returns a boolean specifying if an alpha test is needed.
  40855. */
  40856. needAlphaTesting(): boolean;
  40857. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40858. /**
  40859. * Get the texture used for alpha test purpose.
  40860. * @returns the diffuse texture in case of the standard material.
  40861. */
  40862. getAlphaTestTexture(): Nullable<BaseTexture>;
  40863. /**
  40864. * Get if the submesh is ready to be used and all its information available.
  40865. * Child classes can use it to update shaders
  40866. * @param mesh defines the mesh to check
  40867. * @param subMesh defines which submesh to check
  40868. * @param useInstances specifies that instances should be used
  40869. * @returns a boolean indicating that the submesh is ready or not
  40870. */
  40871. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40872. /**
  40873. * Builds the material UBO layouts.
  40874. * Used internally during the effect preparation.
  40875. */
  40876. buildUniformLayout(): void;
  40877. /**
  40878. * Unbinds the material from the mesh
  40879. */
  40880. unbind(): void;
  40881. /**
  40882. * Binds the submesh to this material by preparing the effect and shader to draw
  40883. * @param world defines the world transformation matrix
  40884. * @param mesh defines the mesh containing the submesh
  40885. * @param subMesh defines the submesh to bind the material to
  40886. */
  40887. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40888. /**
  40889. * Get the list of animatables in the material.
  40890. * @returns the list of animatables object used in the material
  40891. */
  40892. getAnimatables(): IAnimatable[];
  40893. /**
  40894. * Gets the active textures from the material
  40895. * @returns an array of textures
  40896. */
  40897. getActiveTextures(): BaseTexture[];
  40898. /**
  40899. * Specifies if the material uses a texture
  40900. * @param texture defines the texture to check against the material
  40901. * @returns a boolean specifying if the material uses the texture
  40902. */
  40903. hasTexture(texture: BaseTexture): boolean;
  40904. /**
  40905. * Disposes the material
  40906. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40907. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40908. */
  40909. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40910. /**
  40911. * Makes a duplicate of the material, and gives it a new name
  40912. * @param name defines the new name for the duplicated material
  40913. * @returns the cloned material
  40914. */
  40915. clone(name: string): StandardMaterial;
  40916. /**
  40917. * Serializes this material in a JSON representation
  40918. * @returns the serialized material object
  40919. */
  40920. serialize(): any;
  40921. /**
  40922. * Creates a standard material from parsed material data
  40923. * @param source defines the JSON representation of the material
  40924. * @param scene defines the hosting scene
  40925. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40926. * @returns a new standard material
  40927. */
  40928. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40929. /**
  40930. * Are diffuse textures enabled in the application.
  40931. */
  40932. static DiffuseTextureEnabled: boolean;
  40933. /**
  40934. * Are ambient textures enabled in the application.
  40935. */
  40936. static AmbientTextureEnabled: boolean;
  40937. /**
  40938. * Are opacity textures enabled in the application.
  40939. */
  40940. static OpacityTextureEnabled: boolean;
  40941. /**
  40942. * Are reflection textures enabled in the application.
  40943. */
  40944. static ReflectionTextureEnabled: boolean;
  40945. /**
  40946. * Are emissive textures enabled in the application.
  40947. */
  40948. static EmissiveTextureEnabled: boolean;
  40949. /**
  40950. * Are specular textures enabled in the application.
  40951. */
  40952. static SpecularTextureEnabled: boolean;
  40953. /**
  40954. * Are bump textures enabled in the application.
  40955. */
  40956. static BumpTextureEnabled: boolean;
  40957. /**
  40958. * Are lightmap textures enabled in the application.
  40959. */
  40960. static LightmapTextureEnabled: boolean;
  40961. /**
  40962. * Are refraction textures enabled in the application.
  40963. */
  40964. static RefractionTextureEnabled: boolean;
  40965. /**
  40966. * Are color grading textures enabled in the application.
  40967. */
  40968. static ColorGradingTextureEnabled: boolean;
  40969. /**
  40970. * Are fresnels enabled in the application.
  40971. */
  40972. static FresnelEnabled: boolean;
  40973. }
  40974. }
  40975. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40976. import { Scene } from "babylonjs/scene";
  40977. import { Texture } from "babylonjs/Materials/Textures/texture";
  40978. /**
  40979. * A class extending Texture allowing drawing on a texture
  40980. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40981. */
  40982. export class DynamicTexture extends Texture {
  40983. private _generateMipMaps;
  40984. private _canvas;
  40985. private _context;
  40986. private _engine;
  40987. /**
  40988. * Creates a DynamicTexture
  40989. * @param name defines the name of the texture
  40990. * @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
  40991. * @param scene defines the scene where you want the texture
  40992. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40993. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40994. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40995. */
  40996. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40997. /**
  40998. * Get the current class name of the texture useful for serialization or dynamic coding.
  40999. * @returns "DynamicTexture"
  41000. */
  41001. getClassName(): string;
  41002. /**
  41003. * Gets the current state of canRescale
  41004. */
  41005. readonly canRescale: boolean;
  41006. private _recreate;
  41007. /**
  41008. * Scales the texture
  41009. * @param ratio the scale factor to apply to both width and height
  41010. */
  41011. scale(ratio: number): void;
  41012. /**
  41013. * Resizes the texture
  41014. * @param width the new width
  41015. * @param height the new height
  41016. */
  41017. scaleTo(width: number, height: number): void;
  41018. /**
  41019. * Gets the context of the canvas used by the texture
  41020. * @returns the canvas context of the dynamic texture
  41021. */
  41022. getContext(): CanvasRenderingContext2D;
  41023. /**
  41024. * Clears the texture
  41025. */
  41026. clear(): void;
  41027. /**
  41028. * Updates the texture
  41029. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41030. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41031. */
  41032. update(invertY?: boolean, premulAlpha?: boolean): void;
  41033. /**
  41034. * Draws text onto the texture
  41035. * @param text defines the text to be drawn
  41036. * @param x defines the placement of the text from the left
  41037. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41038. * @param font defines the font to be used with font-style, font-size, font-name
  41039. * @param color defines the color used for the text
  41040. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41041. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41042. * @param update defines whether texture is immediately update (default is true)
  41043. */
  41044. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41045. /**
  41046. * Clones the texture
  41047. * @returns the clone of the texture.
  41048. */
  41049. clone(): DynamicTexture;
  41050. /**
  41051. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41052. * @returns a serialized dynamic texture object
  41053. */
  41054. serialize(): any;
  41055. /** @hidden */
  41056. _rebuild(): void;
  41057. }
  41058. }
  41059. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41060. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41061. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41062. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41063. /** @hidden */
  41064. export var imageProcessingPixelShader: {
  41065. name: string;
  41066. shader: string;
  41067. };
  41068. }
  41069. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41070. import { Nullable } from "babylonjs/types";
  41071. import { Color4 } from "babylonjs/Maths/math";
  41072. import { Camera } from "babylonjs/Cameras/camera";
  41073. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41074. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41075. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41076. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41077. import { Engine } from "babylonjs/Engines/engine";
  41078. import "babylonjs/Shaders/imageProcessing.fragment";
  41079. import "babylonjs/Shaders/postprocess.vertex";
  41080. /**
  41081. * ImageProcessingPostProcess
  41082. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41083. */
  41084. export class ImageProcessingPostProcess extends PostProcess {
  41085. /**
  41086. * Default configuration related to image processing available in the PBR Material.
  41087. */
  41088. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41089. /**
  41090. * Gets the image processing configuration used either in this material.
  41091. */
  41092. /**
  41093. * Sets the Default image processing configuration used either in the this material.
  41094. *
  41095. * If sets to null, the scene one is in use.
  41096. */
  41097. imageProcessingConfiguration: ImageProcessingConfiguration;
  41098. /**
  41099. * Keep track of the image processing observer to allow dispose and replace.
  41100. */
  41101. private _imageProcessingObserver;
  41102. /**
  41103. * Attaches a new image processing configuration to the PBR Material.
  41104. * @param configuration
  41105. */
  41106. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41107. /**
  41108. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41109. */
  41110. /**
  41111. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41112. */
  41113. colorCurves: Nullable<ColorCurves>;
  41114. /**
  41115. * Gets wether the color curves effect is enabled.
  41116. */
  41117. /**
  41118. * Sets wether the color curves effect is enabled.
  41119. */
  41120. colorCurvesEnabled: boolean;
  41121. /**
  41122. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41123. */
  41124. /**
  41125. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41126. */
  41127. colorGradingTexture: Nullable<BaseTexture>;
  41128. /**
  41129. * Gets wether the color grading effect is enabled.
  41130. */
  41131. /**
  41132. * Gets wether the color grading effect is enabled.
  41133. */
  41134. colorGradingEnabled: boolean;
  41135. /**
  41136. * Gets exposure used in the effect.
  41137. */
  41138. /**
  41139. * Sets exposure used in the effect.
  41140. */
  41141. exposure: number;
  41142. /**
  41143. * Gets wether tonemapping is enabled or not.
  41144. */
  41145. /**
  41146. * Sets wether tonemapping is enabled or not
  41147. */
  41148. toneMappingEnabled: boolean;
  41149. /**
  41150. * Gets the type of tone mapping effect.
  41151. */
  41152. /**
  41153. * Sets the type of tone mapping effect.
  41154. */
  41155. toneMappingType: number;
  41156. /**
  41157. * Gets contrast used in the effect.
  41158. */
  41159. /**
  41160. * Sets contrast used in the effect.
  41161. */
  41162. contrast: number;
  41163. /**
  41164. * Gets Vignette stretch size.
  41165. */
  41166. /**
  41167. * Sets Vignette stretch size.
  41168. */
  41169. vignetteStretch: number;
  41170. /**
  41171. * Gets Vignette centre X Offset.
  41172. */
  41173. /**
  41174. * Sets Vignette centre X Offset.
  41175. */
  41176. vignetteCentreX: number;
  41177. /**
  41178. * Gets Vignette centre Y Offset.
  41179. */
  41180. /**
  41181. * Sets Vignette centre Y Offset.
  41182. */
  41183. vignetteCentreY: number;
  41184. /**
  41185. * Gets Vignette weight or intensity of the vignette effect.
  41186. */
  41187. /**
  41188. * Sets Vignette weight or intensity of the vignette effect.
  41189. */
  41190. vignetteWeight: number;
  41191. /**
  41192. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41193. * if vignetteEnabled is set to true.
  41194. */
  41195. /**
  41196. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41197. * if vignetteEnabled is set to true.
  41198. */
  41199. vignetteColor: Color4;
  41200. /**
  41201. * Gets Camera field of view used by the Vignette effect.
  41202. */
  41203. /**
  41204. * Sets Camera field of view used by the Vignette effect.
  41205. */
  41206. vignetteCameraFov: number;
  41207. /**
  41208. * Gets the vignette blend mode allowing different kind of effect.
  41209. */
  41210. /**
  41211. * Sets the vignette blend mode allowing different kind of effect.
  41212. */
  41213. vignetteBlendMode: number;
  41214. /**
  41215. * Gets wether the vignette effect is enabled.
  41216. */
  41217. /**
  41218. * Sets wether the vignette effect is enabled.
  41219. */
  41220. vignetteEnabled: boolean;
  41221. private _fromLinearSpace;
  41222. /**
  41223. * Gets wether the input of the processing is in Gamma or Linear Space.
  41224. */
  41225. /**
  41226. * Sets wether the input of the processing is in Gamma or Linear Space.
  41227. */
  41228. fromLinearSpace: boolean;
  41229. /**
  41230. * Defines cache preventing GC.
  41231. */
  41232. private _defines;
  41233. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41234. /**
  41235. * "ImageProcessingPostProcess"
  41236. * @returns "ImageProcessingPostProcess"
  41237. */
  41238. getClassName(): string;
  41239. protected _updateParameters(): void;
  41240. dispose(camera?: Camera): void;
  41241. }
  41242. }
  41243. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41244. import { Scene } from "babylonjs/scene";
  41245. import { Color3 } from "babylonjs/Maths/math";
  41246. import { Mesh } from "babylonjs/Meshes/mesh";
  41247. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41248. import { Nullable } from "babylonjs/types";
  41249. /**
  41250. * Class containing static functions to help procedurally build meshes
  41251. */
  41252. export class GroundBuilder {
  41253. /**
  41254. * Creates a ground mesh
  41255. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41256. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41258. * @param name defines the name of the mesh
  41259. * @param options defines the options used to create the mesh
  41260. * @param scene defines the hosting scene
  41261. * @returns the ground mesh
  41262. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41263. */
  41264. static CreateGround(name: string, options: {
  41265. width?: number;
  41266. height?: number;
  41267. subdivisions?: number;
  41268. subdivisionsX?: number;
  41269. subdivisionsY?: number;
  41270. updatable?: boolean;
  41271. }, scene: any): Mesh;
  41272. /**
  41273. * Creates a tiled ground mesh
  41274. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41275. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41276. * * 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
  41277. * * 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
  41278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41279. * @param name defines the name of the mesh
  41280. * @param options defines the options used to create the mesh
  41281. * @param scene defines the hosting scene
  41282. * @returns the tiled ground mesh
  41283. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41284. */
  41285. static CreateTiledGround(name: string, options: {
  41286. xmin: number;
  41287. zmin: number;
  41288. xmax: number;
  41289. zmax: number;
  41290. subdivisions?: {
  41291. w: number;
  41292. h: number;
  41293. };
  41294. precision?: {
  41295. w: number;
  41296. h: number;
  41297. };
  41298. updatable?: boolean;
  41299. }, scene?: Nullable<Scene>): Mesh;
  41300. /**
  41301. * Creates a ground mesh from a height map
  41302. * * The parameter `url` sets the URL of the height map image resource.
  41303. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41304. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41305. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41306. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41307. * * 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.
  41308. * * 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).
  41309. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41311. * @param name defines the name of the mesh
  41312. * @param url defines the url to the height map
  41313. * @param options defines the options used to create the mesh
  41314. * @param scene defines the hosting scene
  41315. * @returns the ground mesh
  41316. * @see https://doc.babylonjs.com/babylon101/height_map
  41317. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41318. */
  41319. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41320. width?: number;
  41321. height?: number;
  41322. subdivisions?: number;
  41323. minHeight?: number;
  41324. maxHeight?: number;
  41325. colorFilter?: Color3;
  41326. alphaFilter?: number;
  41327. updatable?: boolean;
  41328. onReady?: (mesh: GroundMesh) => void;
  41329. }, scene?: Nullable<Scene>): GroundMesh;
  41330. }
  41331. }
  41332. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41333. import { Vector4 } from "babylonjs/Maths/math";
  41334. import { Mesh } from "babylonjs/Meshes/mesh";
  41335. /**
  41336. * Class containing static functions to help procedurally build meshes
  41337. */
  41338. export class TorusBuilder {
  41339. /**
  41340. * Creates a torus mesh
  41341. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41342. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41343. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41347. * @param name defines the name of the mesh
  41348. * @param options defines the options used to create the mesh
  41349. * @param scene defines the hosting scene
  41350. * @returns the torus mesh
  41351. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41352. */
  41353. static CreateTorus(name: string, options: {
  41354. diameter?: number;
  41355. thickness?: number;
  41356. tessellation?: number;
  41357. updatable?: boolean;
  41358. sideOrientation?: number;
  41359. frontUVs?: Vector4;
  41360. backUVs?: Vector4;
  41361. }, scene: any): Mesh;
  41362. }
  41363. }
  41364. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41365. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41366. import { Mesh } from "babylonjs/Meshes/mesh";
  41367. /**
  41368. * Class containing static functions to help procedurally build meshes
  41369. */
  41370. export class CylinderBuilder {
  41371. /**
  41372. * Creates a cylinder or a cone mesh
  41373. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41374. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41375. * * 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.
  41376. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41377. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41378. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41379. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41380. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  41381. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41382. * * 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).
  41383. * * 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
  41384. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41385. * * 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
  41386. * * 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.
  41387. * * If `enclose` is false, a ring surface is one element.
  41388. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41389. * * 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
  41390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41391. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41393. * @param name defines the name of the mesh
  41394. * @param options defines the options used to create the mesh
  41395. * @param scene defines the hosting scene
  41396. * @returns the cylinder mesh
  41397. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41398. */
  41399. static CreateCylinder(name: string, options: {
  41400. height?: number;
  41401. diameterTop?: number;
  41402. diameterBottom?: number;
  41403. diameter?: number;
  41404. tessellation?: number;
  41405. subdivisions?: number;
  41406. arc?: number;
  41407. faceColors?: Color4[];
  41408. faceUV?: Vector4[];
  41409. updatable?: boolean;
  41410. hasRings?: boolean;
  41411. enclose?: boolean;
  41412. cap?: number;
  41413. sideOrientation?: number;
  41414. frontUVs?: Vector4;
  41415. backUVs?: Vector4;
  41416. }, scene: any): Mesh;
  41417. }
  41418. }
  41419. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41420. import { Observable } from "babylonjs/Misc/observable";
  41421. import { Nullable } from "babylonjs/types";
  41422. import { Camera } from "babylonjs/Cameras/camera";
  41423. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41424. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41425. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41426. import { Scene } from "babylonjs/scene";
  41427. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41428. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41430. import { Mesh } from "babylonjs/Meshes/mesh";
  41431. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41432. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41433. import "babylonjs/Meshes/Builders/groundBuilder";
  41434. import "babylonjs/Meshes/Builders/torusBuilder";
  41435. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41436. import "babylonjs/Gamepads/gamepadSceneComponent";
  41437. import "babylonjs/Animations/animatable";
  41438. /**
  41439. * Options to modify the vr teleportation behavior.
  41440. */
  41441. export interface VRTeleportationOptions {
  41442. /**
  41443. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41444. */
  41445. floorMeshName?: string;
  41446. /**
  41447. * A list of meshes to be used as the teleportation floor. (default: empty)
  41448. */
  41449. floorMeshes?: Mesh[];
  41450. }
  41451. /**
  41452. * Options to modify the vr experience helper's behavior.
  41453. */
  41454. export interface VRExperienceHelperOptions extends WebVROptions {
  41455. /**
  41456. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41457. */
  41458. createDeviceOrientationCamera?: boolean;
  41459. /**
  41460. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41461. */
  41462. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41463. /**
  41464. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41465. */
  41466. laserToggle?: boolean;
  41467. /**
  41468. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41469. */
  41470. floorMeshes?: Mesh[];
  41471. /**
  41472. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41473. */
  41474. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41475. }
  41476. /**
  41477. * Event containing information after VR has been entered
  41478. */
  41479. export class OnAfterEnteringVRObservableEvent {
  41480. /**
  41481. * If entering vr was successful
  41482. */
  41483. success: boolean;
  41484. }
  41485. /**
  41486. * Helps to quickly add VR support to an existing scene.
  41487. * See http://doc.babylonjs.com/how_to/webvr_helper
  41488. */
  41489. export class VRExperienceHelper {
  41490. /** Options to modify the vr experience helper's behavior. */
  41491. webVROptions: VRExperienceHelperOptions;
  41492. private _scene;
  41493. private _position;
  41494. private _btnVR;
  41495. private _btnVRDisplayed;
  41496. private _webVRsupported;
  41497. private _webVRready;
  41498. private _webVRrequesting;
  41499. private _webVRpresenting;
  41500. private _hasEnteredVR;
  41501. private _fullscreenVRpresenting;
  41502. private _canvas;
  41503. private _webVRCamera;
  41504. private _vrDeviceOrientationCamera;
  41505. private _deviceOrientationCamera;
  41506. private _existingCamera;
  41507. private _onKeyDown;
  41508. private _onVrDisplayPresentChange;
  41509. private _onVRDisplayChanged;
  41510. private _onVRRequestPresentStart;
  41511. private _onVRRequestPresentComplete;
  41512. /**
  41513. * Observable raised right before entering VR.
  41514. */
  41515. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41516. /**
  41517. * Observable raised when entering VR has completed.
  41518. */
  41519. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41520. /**
  41521. * Observable raised when exiting VR.
  41522. */
  41523. onExitingVRObservable: Observable<VRExperienceHelper>;
  41524. /**
  41525. * Observable raised when controller mesh is loaded.
  41526. */
  41527. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41528. /** Return this.onEnteringVRObservable
  41529. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41530. */
  41531. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41532. /** Return this.onExitingVRObservable
  41533. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41534. */
  41535. readonly onExitingVR: Observable<VRExperienceHelper>;
  41536. /** Return this.onControllerMeshLoadedObservable
  41537. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41538. */
  41539. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41540. private _rayLength;
  41541. private _useCustomVRButton;
  41542. private _teleportationRequested;
  41543. private _teleportActive;
  41544. private _floorMeshName;
  41545. private _floorMeshesCollection;
  41546. private _rotationAllowed;
  41547. private _teleportBackwardsVector;
  41548. private _teleportationTarget;
  41549. private _isDefaultTeleportationTarget;
  41550. private _postProcessMove;
  41551. private _teleportationFillColor;
  41552. private _teleportationBorderColor;
  41553. private _rotationAngle;
  41554. private _haloCenter;
  41555. private _cameraGazer;
  41556. private _padSensibilityUp;
  41557. private _padSensibilityDown;
  41558. private _leftController;
  41559. private _rightController;
  41560. /**
  41561. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41562. */
  41563. onNewMeshSelected: Observable<AbstractMesh>;
  41564. /**
  41565. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41566. */
  41567. onNewMeshPicked: Observable<PickingInfo>;
  41568. private _circleEase;
  41569. /**
  41570. * Observable raised before camera teleportation
  41571. */
  41572. onBeforeCameraTeleport: Observable<Vector3>;
  41573. /**
  41574. * Observable raised after camera teleportation
  41575. */
  41576. onAfterCameraTeleport: Observable<Vector3>;
  41577. /**
  41578. * Observable raised when current selected mesh gets unselected
  41579. */
  41580. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41581. private _raySelectionPredicate;
  41582. /**
  41583. * To be optionaly changed by user to define custom ray selection
  41584. */
  41585. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41586. /**
  41587. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41588. */
  41589. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41590. /**
  41591. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41592. */
  41593. teleportationEnabled: boolean;
  41594. private _defaultHeight;
  41595. private _teleportationInitialized;
  41596. private _interactionsEnabled;
  41597. private _interactionsRequested;
  41598. private _displayGaze;
  41599. private _displayLaserPointer;
  41600. /**
  41601. * The mesh used to display where the user is going to teleport.
  41602. */
  41603. /**
  41604. * Sets the mesh to be used to display where the user is going to teleport.
  41605. */
  41606. teleportationTarget: Mesh;
  41607. /**
  41608. * 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
  41609. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41610. * See http://doc.babylonjs.com/resources/baking_transformations
  41611. */
  41612. gazeTrackerMesh: Mesh;
  41613. /**
  41614. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41615. */
  41616. updateGazeTrackerScale: boolean;
  41617. /**
  41618. * If the gaze trackers color should be updated when selecting meshes
  41619. */
  41620. updateGazeTrackerColor: boolean;
  41621. /**
  41622. * The gaze tracking mesh corresponding to the left controller
  41623. */
  41624. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41625. /**
  41626. * The gaze tracking mesh corresponding to the right controller
  41627. */
  41628. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41629. /**
  41630. * If the ray of the gaze should be displayed.
  41631. */
  41632. /**
  41633. * Sets if the ray of the gaze should be displayed.
  41634. */
  41635. displayGaze: boolean;
  41636. /**
  41637. * If the ray of the LaserPointer should be displayed.
  41638. */
  41639. /**
  41640. * Sets if the ray of the LaserPointer should be displayed.
  41641. */
  41642. displayLaserPointer: boolean;
  41643. /**
  41644. * The deviceOrientationCamera used as the camera when not in VR.
  41645. */
  41646. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41647. /**
  41648. * Based on the current WebVR support, returns the current VR camera used.
  41649. */
  41650. readonly currentVRCamera: Nullable<Camera>;
  41651. /**
  41652. * The webVRCamera which is used when in VR.
  41653. */
  41654. readonly webVRCamera: WebVRFreeCamera;
  41655. /**
  41656. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41657. */
  41658. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41659. private readonly _teleportationRequestInitiated;
  41660. /**
  41661. * Defines wether or not Pointer lock should be requested when switching to
  41662. * full screen.
  41663. */
  41664. requestPointerLockOnFullScreen: boolean;
  41665. /**
  41666. * Instantiates a VRExperienceHelper.
  41667. * Helps to quickly add VR support to an existing scene.
  41668. * @param scene The scene the VRExperienceHelper belongs to.
  41669. * @param webVROptions Options to modify the vr experience helper's behavior.
  41670. */
  41671. constructor(scene: Scene,
  41672. /** Options to modify the vr experience helper's behavior. */
  41673. webVROptions?: VRExperienceHelperOptions);
  41674. private _onDefaultMeshLoaded;
  41675. private _onResize;
  41676. private _onFullscreenChange;
  41677. /**
  41678. * Gets a value indicating if we are currently in VR mode.
  41679. */
  41680. readonly isInVRMode: boolean;
  41681. private onVrDisplayPresentChange;
  41682. private onVRDisplayChanged;
  41683. private moveButtonToBottomRight;
  41684. private displayVRButton;
  41685. private updateButtonVisibility;
  41686. private _cachedAngularSensibility;
  41687. /**
  41688. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41689. * Otherwise, will use the fullscreen API.
  41690. */
  41691. enterVR(): void;
  41692. /**
  41693. * Attempt to exit VR, or fullscreen.
  41694. */
  41695. exitVR(): void;
  41696. /**
  41697. * The position of the vr experience helper.
  41698. */
  41699. /**
  41700. * Sets the position of the vr experience helper.
  41701. */
  41702. position: Vector3;
  41703. /**
  41704. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41705. */
  41706. enableInteractions(): void;
  41707. private readonly _noControllerIsActive;
  41708. private beforeRender;
  41709. private _isTeleportationFloor;
  41710. /**
  41711. * Adds a floor mesh to be used for teleportation.
  41712. * @param floorMesh the mesh to be used for teleportation.
  41713. */
  41714. addFloorMesh(floorMesh: Mesh): void;
  41715. /**
  41716. * Removes a floor mesh from being used for teleportation.
  41717. * @param floorMesh the mesh to be removed.
  41718. */
  41719. removeFloorMesh(floorMesh: Mesh): void;
  41720. /**
  41721. * Enables interactions and teleportation using the VR controllers and gaze.
  41722. * @param vrTeleportationOptions options to modify teleportation behavior.
  41723. */
  41724. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41725. private _onNewGamepadConnected;
  41726. private _tryEnableInteractionOnController;
  41727. private _onNewGamepadDisconnected;
  41728. private _enableInteractionOnController;
  41729. private _checkTeleportWithRay;
  41730. private _checkRotate;
  41731. private _checkTeleportBackwards;
  41732. private _enableTeleportationOnController;
  41733. private _createTeleportationCircles;
  41734. private _displayTeleportationTarget;
  41735. private _hideTeleportationTarget;
  41736. private _rotateCamera;
  41737. private _moveTeleportationSelectorTo;
  41738. private _workingVector;
  41739. private _workingQuaternion;
  41740. private _workingMatrix;
  41741. /**
  41742. * Teleports the users feet to the desired location
  41743. * @param location The location where the user's feet should be placed
  41744. */
  41745. teleportCamera(location: Vector3): void;
  41746. private _convertNormalToDirectionOfRay;
  41747. private _castRayAndSelectObject;
  41748. private _notifySelectedMeshUnselected;
  41749. /**
  41750. * Sets the color of the laser ray from the vr controllers.
  41751. * @param color new color for the ray.
  41752. */
  41753. changeLaserColor(color: Color3): void;
  41754. /**
  41755. * Sets the color of the ray from the vr headsets gaze.
  41756. * @param color new color for the ray.
  41757. */
  41758. changeGazeColor(color: Color3): void;
  41759. /**
  41760. * Exits VR and disposes of the vr experience helper
  41761. */
  41762. dispose(): void;
  41763. /**
  41764. * Gets the name of the VRExperienceHelper class
  41765. * @returns "VRExperienceHelper"
  41766. */
  41767. getClassName(): string;
  41768. }
  41769. }
  41770. declare module "babylonjs/Cameras/VR/index" {
  41771. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41772. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41773. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41774. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41775. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41776. export * from "babylonjs/Cameras/VR/webVRCamera";
  41777. }
  41778. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41779. import { Observable } from "babylonjs/Misc/observable";
  41780. import { Nullable } from "babylonjs/types";
  41781. import { IDisposable, Scene } from "babylonjs/scene";
  41782. import { Vector3 } from "babylonjs/Maths/math";
  41783. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41784. import { Ray } from "babylonjs/Culling/ray";
  41785. /**
  41786. * Manages an XRSession
  41787. * @see https://doc.babylonjs.com/how_to/webxr
  41788. */
  41789. export class WebXRSessionManager implements IDisposable {
  41790. private scene;
  41791. /**
  41792. * Fires every time a new xrFrame arrives which can be used to update the camera
  41793. */
  41794. onXRFrameObservable: Observable<any>;
  41795. /**
  41796. * Fires when the xr session is ended either by the device or manually done
  41797. */
  41798. onXRSessionEnded: Observable<any>;
  41799. /** @hidden */
  41800. _xrSession: XRSession;
  41801. /** @hidden */
  41802. _frameOfReference: XRFrameOfReference;
  41803. /** @hidden */
  41804. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41805. /** @hidden */
  41806. _currentXRFrame: Nullable<XRFrame>;
  41807. private _xrNavigator;
  41808. private _xrDevice;
  41809. private _tmpMatrix;
  41810. /**
  41811. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41812. * @param scene The scene which the session should be created for
  41813. */
  41814. constructor(scene: Scene);
  41815. /**
  41816. * Initializes the manager
  41817. * After initialization enterXR can be called to start an XR session
  41818. * @returns Promise which resolves after it is initialized
  41819. */
  41820. initializeAsync(): Promise<void>;
  41821. /**
  41822. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41823. * @param sessionCreationOptions xr options to create the session with
  41824. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41825. * @returns Promise which resolves after it enters XR
  41826. */
  41827. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41828. /**
  41829. * Stops the xrSession and restores the renderloop
  41830. * @returns Promise which resolves after it exits XR
  41831. */
  41832. exitXRAsync(): Promise<void>;
  41833. /**
  41834. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41835. * @param ray ray to cast into the environment
  41836. * @returns Promise which resolves with a collision point in the environment if it exists
  41837. */
  41838. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41839. /**
  41840. * Checks if a session would be supported for the creation options specified
  41841. * @param options creation options to check if they are supported
  41842. * @returns true if supported
  41843. */
  41844. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41845. /**
  41846. * @hidden
  41847. * Converts the render layer of xrSession to a render target
  41848. * @param session session to create render target for
  41849. * @param scene scene the new render target should be created for
  41850. */
  41851. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41852. /**
  41853. * Disposes of the session manager
  41854. */
  41855. dispose(): void;
  41856. }
  41857. }
  41858. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41859. import { Scene } from "babylonjs/scene";
  41860. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41861. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41862. /**
  41863. * WebXR Camera which holds the views for the xrSession
  41864. * @see https://doc.babylonjs.com/how_to/webxr
  41865. */
  41866. export class WebXRCamera extends FreeCamera {
  41867. private static _TmpMatrix;
  41868. /**
  41869. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41870. * @param name the name of the camera
  41871. * @param scene the scene to add the camera to
  41872. */
  41873. constructor(name: string, scene: Scene);
  41874. private _updateNumberOfRigCameras;
  41875. /** @hidden */
  41876. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41877. /**
  41878. * Updates the cameras position from the current pose information of the XR session
  41879. * @param xrSessionManager the session containing pose information
  41880. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41881. */
  41882. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41883. }
  41884. }
  41885. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41886. import { Nullable } from "babylonjs/types";
  41887. import { Observable } from "babylonjs/Misc/observable";
  41888. import { IDisposable, Scene } from "babylonjs/scene";
  41889. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41891. import { Ray } from "babylonjs/Culling/ray";
  41892. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41893. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41894. /**
  41895. * States of the webXR experience
  41896. */
  41897. export enum WebXRState {
  41898. /**
  41899. * Transitioning to being in XR mode
  41900. */
  41901. ENTERING_XR = 0,
  41902. /**
  41903. * Transitioning to non XR mode
  41904. */
  41905. EXITING_XR = 1,
  41906. /**
  41907. * In XR mode and presenting
  41908. */
  41909. IN_XR = 2,
  41910. /**
  41911. * Not entered XR mode
  41912. */
  41913. NOT_IN_XR = 3
  41914. }
  41915. /**
  41916. * Helper class used to enable XR
  41917. * @see https://doc.babylonjs.com/how_to/webxr
  41918. */
  41919. export class WebXRExperienceHelper implements IDisposable {
  41920. private scene;
  41921. /**
  41922. * 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
  41923. */
  41924. container: AbstractMesh;
  41925. /**
  41926. * Camera used to render xr content
  41927. */
  41928. camera: WebXRCamera;
  41929. /**
  41930. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41931. */
  41932. state: WebXRState;
  41933. private _setState;
  41934. private static _TmpVector;
  41935. /**
  41936. * Fires when the state of the experience helper has changed
  41937. */
  41938. onStateChangedObservable: Observable<WebXRState>;
  41939. /** @hidden */
  41940. _sessionManager: WebXRSessionManager;
  41941. private _nonVRCamera;
  41942. private _originalSceneAutoClear;
  41943. private _supported;
  41944. /**
  41945. * Creates the experience helper
  41946. * @param scene the scene to attach the experience helper to
  41947. * @returns a promise for the experience helper
  41948. */
  41949. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41950. /**
  41951. * Creates a WebXRExperienceHelper
  41952. * @param scene The scene the helper should be created in
  41953. */
  41954. private constructor();
  41955. /**
  41956. * Exits XR mode and returns the scene to its original state
  41957. * @returns promise that resolves after xr mode has exited
  41958. */
  41959. exitXRAsync(): Promise<void>;
  41960. /**
  41961. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41962. * @param sessionCreationOptions options for the XR session
  41963. * @param frameOfReference frame of reference of the XR session
  41964. * @returns promise that resolves after xr mode has entered
  41965. */
  41966. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41967. /**
  41968. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41969. * @param ray ray to cast into the environment
  41970. * @returns Promise which resolves with a collision point in the environment if it exists
  41971. */
  41972. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41973. /**
  41974. * Updates the global position of the camera by moving the camera's container
  41975. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41976. * @param position The desired global position of the camera
  41977. */
  41978. setPositionOfCameraUsingContainer(position: Vector3): void;
  41979. /**
  41980. * Rotates the xr camera by rotating the camera's container around the camera's position
  41981. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41982. * @param rotation the desired quaternion rotation to apply to the camera
  41983. */
  41984. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41985. /**
  41986. * Checks if the creation options are supported by the xr session
  41987. * @param options creation options
  41988. * @returns true if supported
  41989. */
  41990. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41991. /**
  41992. * Disposes of the experience helper
  41993. */
  41994. dispose(): void;
  41995. }
  41996. }
  41997. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41998. import { Nullable } from "babylonjs/types";
  41999. import { Observable } from "babylonjs/Misc/observable";
  42000. import { IDisposable, Scene } from "babylonjs/scene";
  42001. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42002. /**
  42003. * Button which can be used to enter a different mode of XR
  42004. */
  42005. export class WebXREnterExitUIButton {
  42006. /** button element */
  42007. element: HTMLElement;
  42008. /** XR initialization options for the button */
  42009. initializationOptions: XRSessionCreationOptions;
  42010. /**
  42011. * Creates a WebXREnterExitUIButton
  42012. * @param element button element
  42013. * @param initializationOptions XR initialization options for the button
  42014. */
  42015. constructor(
  42016. /** button element */
  42017. element: HTMLElement,
  42018. /** XR initialization options for the button */
  42019. initializationOptions: XRSessionCreationOptions);
  42020. /**
  42021. * Overwritable function which can be used to update the button's visuals when the state changes
  42022. * @param activeButton the current active button in the UI
  42023. */
  42024. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42025. }
  42026. /**
  42027. * Options to create the webXR UI
  42028. */
  42029. export class WebXREnterExitUIOptions {
  42030. /**
  42031. * Context to enter xr with
  42032. */
  42033. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  42034. /**
  42035. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42036. */
  42037. customButtons?: Array<WebXREnterExitUIButton>;
  42038. }
  42039. /**
  42040. * UI to allow the user to enter/exit XR mode
  42041. */
  42042. export class WebXREnterExitUI implements IDisposable {
  42043. private scene;
  42044. private _overlay;
  42045. private _buttons;
  42046. private _activeButton;
  42047. /**
  42048. * Fired every time the active button is changed.
  42049. *
  42050. * When xr is entered via a button that launches xr that button will be the callback parameter
  42051. *
  42052. * When exiting xr the callback parameter will be null)
  42053. */
  42054. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42055. /**
  42056. * Creates UI to allow the user to enter/exit XR mode
  42057. * @param scene the scene to add the ui to
  42058. * @param helper the xr experience helper to enter/exit xr with
  42059. * @param options options to configure the UI
  42060. * @returns the created ui
  42061. */
  42062. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42063. private constructor();
  42064. private _updateButtons;
  42065. /**
  42066. * Disposes of the object
  42067. */
  42068. dispose(): void;
  42069. }
  42070. }
  42071. declare module "babylonjs/Cameras/XR/webXRInput" {
  42072. import { IDisposable, Scene } from "babylonjs/scene";
  42073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42074. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42075. /**
  42076. * Represents an XR input
  42077. */
  42078. export class WebXRController {
  42079. /**
  42080. * 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
  42081. */
  42082. grip?: AbstractMesh;
  42083. /**
  42084. * Pointer which can be used to select objects or attach a visible laser to
  42085. */
  42086. pointer: AbstractMesh;
  42087. /**
  42088. * Creates the controller
  42089. * @see https://doc.babylonjs.com/how_to/webxr
  42090. * @param scene the scene which the controller should be associated to
  42091. */
  42092. constructor(scene: Scene);
  42093. /**
  42094. * Disposes of the object
  42095. */
  42096. dispose(): void;
  42097. }
  42098. /**
  42099. * XR input used to track XR inputs such as controllers/rays
  42100. */
  42101. export class WebXRInput implements IDisposable {
  42102. private helper;
  42103. /**
  42104. * XR controllers being tracked
  42105. */
  42106. controllers: Array<WebXRController>;
  42107. private _tmpMatrix;
  42108. private _frameObserver;
  42109. /**
  42110. * Initializes the WebXRInput
  42111. * @param helper experience helper which the input should be created for
  42112. */
  42113. constructor(helper: WebXRExperienceHelper);
  42114. /**
  42115. * Disposes of the object
  42116. */
  42117. dispose(): void;
  42118. }
  42119. }
  42120. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42121. import { Nullable } from "babylonjs/types";
  42122. import { IDisposable } from "babylonjs/scene";
  42123. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42124. /**
  42125. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42126. */
  42127. export class WebXRManagedOutputCanvas implements IDisposable {
  42128. private _canvas;
  42129. /**
  42130. * xrpresent context of the canvas which can be used to display/mirror xr content
  42131. */
  42132. canvasContext: Nullable<WebGLRenderingContext>;
  42133. /**
  42134. * Initializes the canvas to be added/removed upon entering/exiting xr
  42135. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42136. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42137. */
  42138. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42139. /**
  42140. * Disposes of the object
  42141. */
  42142. dispose(): void;
  42143. private _setManagedOutputCanvas;
  42144. private _addCanvas;
  42145. private _removeCanvas;
  42146. }
  42147. }
  42148. declare module "babylonjs/Cameras/XR/index" {
  42149. export * from "babylonjs/Cameras/XR/webXRCamera";
  42150. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  42151. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42152. export * from "babylonjs/Cameras/XR/webXRInput";
  42153. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42154. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  42155. }
  42156. declare module "babylonjs/Cameras/RigModes/index" {
  42157. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42158. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42159. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  42160. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  42161. }
  42162. declare module "babylonjs/Cameras/index" {
  42163. export * from "babylonjs/Cameras/Inputs/index";
  42164. export * from "babylonjs/Cameras/cameraInputsManager";
  42165. export * from "babylonjs/Cameras/camera";
  42166. export * from "babylonjs/Cameras/targetCamera";
  42167. export * from "babylonjs/Cameras/freeCamera";
  42168. export * from "babylonjs/Cameras/freeCameraInputsManager";
  42169. export * from "babylonjs/Cameras/touchCamera";
  42170. export * from "babylonjs/Cameras/arcRotateCamera";
  42171. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  42172. export * from "babylonjs/Cameras/deviceOrientationCamera";
  42173. export * from "babylonjs/Cameras/flyCamera";
  42174. export * from "babylonjs/Cameras/flyCameraInputsManager";
  42175. export * from "babylonjs/Cameras/followCamera";
  42176. export * from "babylonjs/Cameras/gamepadCamera";
  42177. export * from "babylonjs/Cameras/Stereoscopic/index";
  42178. export * from "babylonjs/Cameras/universalCamera";
  42179. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  42180. export * from "babylonjs/Cameras/VR/index";
  42181. export * from "babylonjs/Cameras/XR/index";
  42182. export * from "babylonjs/Cameras/RigModes/index";
  42183. }
  42184. declare module "babylonjs/Collisions/index" {
  42185. export * from "babylonjs/Collisions/collider";
  42186. export * from "babylonjs/Collisions/collisionCoordinator";
  42187. export * from "babylonjs/Collisions/pickingInfo";
  42188. export * from "babylonjs/Collisions/intersectionInfo";
  42189. export * from "babylonjs/Collisions/meshCollisionData";
  42190. }
  42191. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  42192. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  42193. import { Vector3, Plane } from "babylonjs/Maths/math";
  42194. import { Ray } from "babylonjs/Culling/ray";
  42195. /**
  42196. * Contains an array of blocks representing the octree
  42197. */
  42198. export interface IOctreeContainer<T> {
  42199. /**
  42200. * Blocks within the octree
  42201. */
  42202. blocks: Array<OctreeBlock<T>>;
  42203. }
  42204. /**
  42205. * Class used to store a cell in an octree
  42206. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42207. */
  42208. export class OctreeBlock<T> {
  42209. /**
  42210. * Gets the content of the current block
  42211. */
  42212. entries: T[];
  42213. /**
  42214. * Gets the list of block children
  42215. */
  42216. blocks: Array<OctreeBlock<T>>;
  42217. private _depth;
  42218. private _maxDepth;
  42219. private _capacity;
  42220. private _minPoint;
  42221. private _maxPoint;
  42222. private _boundingVectors;
  42223. private _creationFunc;
  42224. /**
  42225. * Creates a new block
  42226. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42227. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42228. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42229. * @param depth defines the current depth of this block in the octree
  42230. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42231. * @param creationFunc defines a callback to call when an element is added to the block
  42232. */
  42233. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42234. /**
  42235. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42236. */
  42237. readonly capacity: number;
  42238. /**
  42239. * Gets the minimum vector (in world space) of the block's bounding box
  42240. */
  42241. readonly minPoint: Vector3;
  42242. /**
  42243. * Gets the maximum vector (in world space) of the block's bounding box
  42244. */
  42245. readonly maxPoint: Vector3;
  42246. /**
  42247. * Add a new element to this block
  42248. * @param entry defines the element to add
  42249. */
  42250. addEntry(entry: T): void;
  42251. /**
  42252. * Remove an element from this block
  42253. * @param entry defines the element to remove
  42254. */
  42255. removeEntry(entry: T): void;
  42256. /**
  42257. * Add an array of elements to this block
  42258. * @param entries defines the array of elements to add
  42259. */
  42260. addEntries(entries: T[]): void;
  42261. /**
  42262. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42263. * @param frustumPlanes defines the frustum planes to test
  42264. * @param selection defines the array to store current content if selection is positive
  42265. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42266. */
  42267. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42268. /**
  42269. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42270. * @param sphereCenter defines the bounding sphere center
  42271. * @param sphereRadius defines the bounding sphere radius
  42272. * @param selection defines the array to store current content if selection is positive
  42273. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42274. */
  42275. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42276. /**
  42277. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42278. * @param ray defines the ray to test with
  42279. * @param selection defines the array to store current content if selection is positive
  42280. */
  42281. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42282. /**
  42283. * Subdivide the content into child blocks (this block will then be empty)
  42284. */
  42285. createInnerBlocks(): void;
  42286. /**
  42287. * @hidden
  42288. */
  42289. 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;
  42290. }
  42291. }
  42292. declare module "babylonjs/Culling/Octrees/octree" {
  42293. import { SmartArray } from "babylonjs/Misc/smartArray";
  42294. import { Vector3, Plane } from "babylonjs/Maths/math";
  42295. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42297. import { Ray } from "babylonjs/Culling/ray";
  42298. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  42299. /**
  42300. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42301. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42302. */
  42303. export class Octree<T> {
  42304. /** 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.) */
  42305. maxDepth: number;
  42306. /**
  42307. * Blocks within the octree containing objects
  42308. */
  42309. blocks: Array<OctreeBlock<T>>;
  42310. /**
  42311. * Content stored in the octree
  42312. */
  42313. dynamicContent: T[];
  42314. private _maxBlockCapacity;
  42315. private _selectionContent;
  42316. private _creationFunc;
  42317. /**
  42318. * Creates a octree
  42319. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42320. * @param creationFunc function to be used to instatiate the octree
  42321. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42322. * @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.)
  42323. */
  42324. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42325. /** 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.) */
  42326. maxDepth?: number);
  42327. /**
  42328. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42329. * @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);
  42330. * @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);
  42331. * @param entries meshes to be added to the octree blocks
  42332. */
  42333. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42334. /**
  42335. * Adds a mesh to the octree
  42336. * @param entry Mesh to add to the octree
  42337. */
  42338. addMesh(entry: T): void;
  42339. /**
  42340. * Remove an element from the octree
  42341. * @param entry defines the element to remove
  42342. */
  42343. removeMesh(entry: T): void;
  42344. /**
  42345. * Selects an array of meshes within the frustum
  42346. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42347. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42348. * @returns array of meshes within the frustum
  42349. */
  42350. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42351. /**
  42352. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42353. * @param sphereCenter defines the bounding sphere center
  42354. * @param sphereRadius defines the bounding sphere radius
  42355. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42356. * @returns an array of objects that intersect the sphere
  42357. */
  42358. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42359. /**
  42360. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42361. * @param ray defines the ray to test with
  42362. * @returns array of intersected objects
  42363. */
  42364. intersectsRay(ray: Ray): SmartArray<T>;
  42365. /**
  42366. * Adds a mesh into the octree block if it intersects the block
  42367. */
  42368. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42369. /**
  42370. * Adds a submesh into the octree block if it intersects the block
  42371. */
  42372. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42373. }
  42374. }
  42375. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  42376. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  42377. import { Scene } from "babylonjs/scene";
  42378. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42380. import { Ray } from "babylonjs/Culling/ray";
  42381. import { Octree } from "babylonjs/Culling/Octrees/octree";
  42382. import { Collider } from "babylonjs/Collisions/collider";
  42383. module "babylonjs/scene" {
  42384. interface Scene {
  42385. /**
  42386. * @hidden
  42387. * Backing Filed
  42388. */
  42389. _selectionOctree: Octree<AbstractMesh>;
  42390. /**
  42391. * Gets the octree used to boost mesh selection (picking)
  42392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42393. */
  42394. selectionOctree: Octree<AbstractMesh>;
  42395. /**
  42396. * Creates or updates the octree used to boost selection (picking)
  42397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42398. * @param maxCapacity defines the maximum capacity per leaf
  42399. * @param maxDepth defines the maximum depth of the octree
  42400. * @returns an octree of AbstractMesh
  42401. */
  42402. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42403. }
  42404. }
  42405. module "babylonjs/Meshes/abstractMesh" {
  42406. interface AbstractMesh {
  42407. /**
  42408. * @hidden
  42409. * Backing Field
  42410. */
  42411. _submeshesOctree: Octree<SubMesh>;
  42412. /**
  42413. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42414. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42415. * @param maxCapacity defines the maximum size of each block (64 by default)
  42416. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42417. * @returns the new octree
  42418. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42419. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42420. */
  42421. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42422. }
  42423. }
  42424. /**
  42425. * Defines the octree scene component responsible to manage any octrees
  42426. * in a given scene.
  42427. */
  42428. export class OctreeSceneComponent {
  42429. /**
  42430. * The component name help to identify the component in the list of scene components.
  42431. */
  42432. readonly name: string;
  42433. /**
  42434. * The scene the component belongs to.
  42435. */
  42436. scene: Scene;
  42437. /**
  42438. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42439. */
  42440. readonly checksIsEnabled: boolean;
  42441. /**
  42442. * Creates a new instance of the component for the given scene
  42443. * @param scene Defines the scene to register the component in
  42444. */
  42445. constructor(scene: Scene);
  42446. /**
  42447. * Registers the component in a given scene
  42448. */
  42449. register(): void;
  42450. /**
  42451. * Return the list of active meshes
  42452. * @returns the list of active meshes
  42453. */
  42454. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42455. /**
  42456. * Return the list of active sub meshes
  42457. * @param mesh The mesh to get the candidates sub meshes from
  42458. * @returns the list of active sub meshes
  42459. */
  42460. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42461. private _tempRay;
  42462. /**
  42463. * Return the list of sub meshes intersecting with a given local ray
  42464. * @param mesh defines the mesh to find the submesh for
  42465. * @param localRay defines the ray in local space
  42466. * @returns the list of intersecting sub meshes
  42467. */
  42468. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42469. /**
  42470. * Return the list of sub meshes colliding with a collider
  42471. * @param mesh defines the mesh to find the submesh for
  42472. * @param collider defines the collider to evaluate the collision against
  42473. * @returns the list of colliding sub meshes
  42474. */
  42475. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42476. /**
  42477. * Rebuilds the elements related to this component in case of
  42478. * context lost for instance.
  42479. */
  42480. rebuild(): void;
  42481. /**
  42482. * Disposes the component and the associated ressources.
  42483. */
  42484. dispose(): void;
  42485. }
  42486. }
  42487. declare module "babylonjs/Culling/Octrees/index" {
  42488. export * from "babylonjs/Culling/Octrees/octree";
  42489. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42490. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42491. }
  42492. declare module "babylonjs/Culling/index" {
  42493. export * from "babylonjs/Culling/boundingBox";
  42494. export * from "babylonjs/Culling/boundingInfo";
  42495. export * from "babylonjs/Culling/boundingSphere";
  42496. export * from "babylonjs/Culling/Octrees/index";
  42497. export * from "babylonjs/Culling/ray";
  42498. }
  42499. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42500. import { IDisposable, Scene } from "babylonjs/scene";
  42501. import { Nullable } from "babylonjs/types";
  42502. import { Observable } from "babylonjs/Misc/observable";
  42503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42504. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42505. import { Camera } from "babylonjs/Cameras/camera";
  42506. /**
  42507. * Renders a layer on top of an existing scene
  42508. */
  42509. export class UtilityLayerRenderer implements IDisposable {
  42510. /** the original scene that will be rendered on top of */
  42511. originalScene: Scene;
  42512. private _pointerCaptures;
  42513. private _lastPointerEvents;
  42514. private static _DefaultUtilityLayer;
  42515. private static _DefaultKeepDepthUtilityLayer;
  42516. private _sharedGizmoLight;
  42517. private _renderCamera;
  42518. /**
  42519. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42520. * @returns the camera that is used when rendering the utility layer
  42521. */
  42522. getRenderCamera(): Nullable<Camera>;
  42523. /**
  42524. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42525. * @param cam the camera that should be used when rendering the utility layer
  42526. */
  42527. setRenderCamera(cam: Nullable<Camera>): void;
  42528. /**
  42529. * @hidden
  42530. * Light which used by gizmos to get light shading
  42531. */
  42532. _getSharedGizmoLight(): HemisphericLight;
  42533. /**
  42534. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42535. */
  42536. pickUtilitySceneFirst: boolean;
  42537. /**
  42538. * 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)
  42539. */
  42540. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42541. /**
  42542. * 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)
  42543. */
  42544. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42545. /**
  42546. * The scene that is rendered on top of the original scene
  42547. */
  42548. utilityLayerScene: Scene;
  42549. /**
  42550. * If the utility layer should automatically be rendered on top of existing scene
  42551. */
  42552. shouldRender: boolean;
  42553. /**
  42554. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42555. */
  42556. onlyCheckPointerDownEvents: boolean;
  42557. /**
  42558. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42559. */
  42560. processAllEvents: boolean;
  42561. /**
  42562. * Observable raised when the pointer move from the utility layer scene to the main scene
  42563. */
  42564. onPointerOutObservable: Observable<number>;
  42565. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42566. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42567. private _afterRenderObserver;
  42568. private _sceneDisposeObserver;
  42569. private _originalPointerObserver;
  42570. /**
  42571. * Instantiates a UtilityLayerRenderer
  42572. * @param originalScene the original scene that will be rendered on top of
  42573. * @param handleEvents boolean indicating if the utility layer should handle events
  42574. */
  42575. constructor(
  42576. /** the original scene that will be rendered on top of */
  42577. originalScene: Scene, handleEvents?: boolean);
  42578. private _notifyObservers;
  42579. /**
  42580. * Renders the utility layers scene on top of the original scene
  42581. */
  42582. render(): void;
  42583. /**
  42584. * Disposes of the renderer
  42585. */
  42586. dispose(): void;
  42587. private _updateCamera;
  42588. }
  42589. }
  42590. declare module "babylonjs/Gizmos/gizmo" {
  42591. import { Nullable } from "babylonjs/types";
  42592. import { IDisposable } from "babylonjs/scene";
  42593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42594. import { Mesh } from "babylonjs/Meshes/mesh";
  42595. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42596. /**
  42597. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42598. */
  42599. export class Gizmo implements IDisposable {
  42600. /** The utility layer the gizmo will be added to */
  42601. gizmoLayer: UtilityLayerRenderer;
  42602. /**
  42603. * The root mesh of the gizmo
  42604. */
  42605. _rootMesh: Mesh;
  42606. private _attachedMesh;
  42607. /**
  42608. * Ratio for the scale of the gizmo (Default: 1)
  42609. */
  42610. scaleRatio: number;
  42611. /**
  42612. * If a custom mesh has been set (Default: false)
  42613. */
  42614. protected _customMeshSet: boolean;
  42615. /**
  42616. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42617. * * When set, interactions will be enabled
  42618. */
  42619. attachedMesh: Nullable<AbstractMesh>;
  42620. /**
  42621. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42622. * @param mesh The mesh to replace the default mesh of the gizmo
  42623. */
  42624. setCustomMesh(mesh: Mesh): void;
  42625. /**
  42626. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42627. */
  42628. updateGizmoRotationToMatchAttachedMesh: boolean;
  42629. /**
  42630. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42631. */
  42632. updateGizmoPositionToMatchAttachedMesh: boolean;
  42633. /**
  42634. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42635. */
  42636. protected _updateScale: boolean;
  42637. protected _interactionsEnabled: boolean;
  42638. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42639. private _beforeRenderObserver;
  42640. private _tempVector;
  42641. /**
  42642. * Creates a gizmo
  42643. * @param gizmoLayer The utility layer the gizmo will be added to
  42644. */
  42645. constructor(
  42646. /** The utility layer the gizmo will be added to */
  42647. gizmoLayer?: UtilityLayerRenderer);
  42648. /**
  42649. * Updates the gizmo to match the attached mesh's position/rotation
  42650. */
  42651. protected _update(): void;
  42652. /**
  42653. * Disposes of the gizmo
  42654. */
  42655. dispose(): void;
  42656. }
  42657. }
  42658. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42659. import { Observable } from "babylonjs/Misc/observable";
  42660. import { Nullable } from "babylonjs/types";
  42661. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42662. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42664. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42665. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42666. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42667. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42668. import { Scene } from "babylonjs/scene";
  42669. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42670. /**
  42671. * Single plane drag gizmo
  42672. */
  42673. export class PlaneDragGizmo extends Gizmo {
  42674. /**
  42675. * Drag behavior responsible for the gizmos dragging interactions
  42676. */
  42677. dragBehavior: PointerDragBehavior;
  42678. private _pointerObserver;
  42679. /**
  42680. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42681. */
  42682. snapDistance: number;
  42683. /**
  42684. * Event that fires each time the gizmo snaps to a new location.
  42685. * * snapDistance is the the change in distance
  42686. */
  42687. onSnapObservable: Observable<{
  42688. snapDistance: number;
  42689. }>;
  42690. private _plane;
  42691. private _coloredMaterial;
  42692. private _hoverMaterial;
  42693. private _isEnabled;
  42694. private _parent;
  42695. /** @hidden */
  42696. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42697. /** @hidden */
  42698. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42699. /**
  42700. * Creates a PlaneDragGizmo
  42701. * @param gizmoLayer The utility layer the gizmo will be added to
  42702. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42703. * @param color The color of the gizmo
  42704. */
  42705. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42706. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42707. /**
  42708. * If the gizmo is enabled
  42709. */
  42710. isEnabled: boolean;
  42711. /**
  42712. * Disposes of the gizmo
  42713. */
  42714. dispose(): void;
  42715. }
  42716. }
  42717. declare module "babylonjs/Gizmos/positionGizmo" {
  42718. import { Observable } from "babylonjs/Misc/observable";
  42719. import { Nullable } from "babylonjs/types";
  42720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42721. import { Mesh } from "babylonjs/Meshes/mesh";
  42722. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42723. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42724. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42725. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42726. /**
  42727. * Gizmo that enables dragging a mesh along 3 axis
  42728. */
  42729. export class PositionGizmo extends Gizmo {
  42730. /**
  42731. * Internal gizmo used for interactions on the x axis
  42732. */
  42733. xGizmo: AxisDragGizmo;
  42734. /**
  42735. * Internal gizmo used for interactions on the y axis
  42736. */
  42737. yGizmo: AxisDragGizmo;
  42738. /**
  42739. * Internal gizmo used for interactions on the z axis
  42740. */
  42741. zGizmo: AxisDragGizmo;
  42742. /**
  42743. * Internal gizmo used for interactions on the yz plane
  42744. */
  42745. xPlaneGizmo: PlaneDragGizmo;
  42746. /**
  42747. * Internal gizmo used for interactions on the xz plane
  42748. */
  42749. yPlaneGizmo: PlaneDragGizmo;
  42750. /**
  42751. * Internal gizmo used for interactions on the xy plane
  42752. */
  42753. zPlaneGizmo: PlaneDragGizmo;
  42754. /**
  42755. * private variables
  42756. */
  42757. private _meshAttached;
  42758. private _updateGizmoRotationToMatchAttachedMesh;
  42759. private _snapDistance;
  42760. private _scaleRatio;
  42761. /** Fires an event when any of it's sub gizmos are dragged */
  42762. onDragStartObservable: Observable<unknown>;
  42763. /** Fires an event when any of it's sub gizmos are released from dragging */
  42764. onDragEndObservable: Observable<unknown>;
  42765. /**
  42766. * If set to true, planar drag is enabled
  42767. */
  42768. private _planarGizmoEnabled;
  42769. attachedMesh: Nullable<AbstractMesh>;
  42770. /**
  42771. * Creates a PositionGizmo
  42772. * @param gizmoLayer The utility layer the gizmo will be added to
  42773. */
  42774. constructor(gizmoLayer?: UtilityLayerRenderer);
  42775. /**
  42776. * If the planar drag gizmo is enabled
  42777. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42778. */
  42779. planarGizmoEnabled: boolean;
  42780. updateGizmoRotationToMatchAttachedMesh: boolean;
  42781. /**
  42782. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42783. */
  42784. snapDistance: number;
  42785. /**
  42786. * Ratio for the scale of the gizmo (Default: 1)
  42787. */
  42788. scaleRatio: number;
  42789. /**
  42790. * Disposes of the gizmo
  42791. */
  42792. dispose(): void;
  42793. /**
  42794. * CustomMeshes are not supported by this gizmo
  42795. * @param mesh The mesh to replace the default mesh of the gizmo
  42796. */
  42797. setCustomMesh(mesh: Mesh): void;
  42798. }
  42799. }
  42800. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42801. import { Observable } from "babylonjs/Misc/observable";
  42802. import { Nullable } from "babylonjs/types";
  42803. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42804. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42806. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42807. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42808. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42809. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42810. import { Scene } from "babylonjs/scene";
  42811. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42812. /**
  42813. * Single axis drag gizmo
  42814. */
  42815. export class AxisDragGizmo extends Gizmo {
  42816. /**
  42817. * Drag behavior responsible for the gizmos dragging interactions
  42818. */
  42819. dragBehavior: PointerDragBehavior;
  42820. private _pointerObserver;
  42821. /**
  42822. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42823. */
  42824. snapDistance: number;
  42825. /**
  42826. * Event that fires each time the gizmo snaps to a new location.
  42827. * * snapDistance is the the change in distance
  42828. */
  42829. onSnapObservable: Observable<{
  42830. snapDistance: number;
  42831. }>;
  42832. private _isEnabled;
  42833. private _parent;
  42834. private _arrow;
  42835. private _coloredMaterial;
  42836. private _hoverMaterial;
  42837. /** @hidden */
  42838. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42839. /** @hidden */
  42840. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42841. /**
  42842. * Creates an AxisDragGizmo
  42843. * @param gizmoLayer The utility layer the gizmo will be added to
  42844. * @param dragAxis The axis which the gizmo will be able to drag on
  42845. * @param color The color of the gizmo
  42846. */
  42847. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42848. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42849. /**
  42850. * If the gizmo is enabled
  42851. */
  42852. isEnabled: boolean;
  42853. /**
  42854. * Disposes of the gizmo
  42855. */
  42856. dispose(): void;
  42857. }
  42858. }
  42859. declare module "babylonjs/Debug/axesViewer" {
  42860. import { Vector3 } from "babylonjs/Maths/math";
  42861. import { Nullable } from "babylonjs/types";
  42862. import { Scene } from "babylonjs/scene";
  42863. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42864. /**
  42865. * The Axes viewer will show 3 axes in a specific point in space
  42866. */
  42867. export class AxesViewer {
  42868. private _xAxis;
  42869. private _yAxis;
  42870. private _zAxis;
  42871. private _scaleLinesFactor;
  42872. private _instanced;
  42873. /**
  42874. * Gets the hosting scene
  42875. */
  42876. scene: Scene;
  42877. /**
  42878. * Gets or sets a number used to scale line length
  42879. */
  42880. scaleLines: number;
  42881. /** Gets the node hierarchy used to render x-axis */
  42882. readonly xAxis: TransformNode;
  42883. /** Gets the node hierarchy used to render y-axis */
  42884. readonly yAxis: TransformNode;
  42885. /** Gets the node hierarchy used to render z-axis */
  42886. readonly zAxis: TransformNode;
  42887. /**
  42888. * Creates a new AxesViewer
  42889. * @param scene defines the hosting scene
  42890. * @param scaleLines defines a number used to scale line length (1 by default)
  42891. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42892. * @param xAxis defines the node hierarchy used to render the x-axis
  42893. * @param yAxis defines the node hierarchy used to render the y-axis
  42894. * @param zAxis defines the node hierarchy used to render the z-axis
  42895. */
  42896. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42897. /**
  42898. * Force the viewer to update
  42899. * @param position defines the position of the viewer
  42900. * @param xaxis defines the x axis of the viewer
  42901. * @param yaxis defines the y axis of the viewer
  42902. * @param zaxis defines the z axis of the viewer
  42903. */
  42904. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42905. /**
  42906. * Creates an instance of this axes viewer.
  42907. * @returns a new axes viewer with instanced meshes
  42908. */
  42909. createInstance(): AxesViewer;
  42910. /** Releases resources */
  42911. dispose(): void;
  42912. private static _SetRenderingGroupId;
  42913. }
  42914. }
  42915. declare module "babylonjs/Debug/boneAxesViewer" {
  42916. import { Nullable } from "babylonjs/types";
  42917. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42918. import { Vector3 } from "babylonjs/Maths/math";
  42919. import { Mesh } from "babylonjs/Meshes/mesh";
  42920. import { Bone } from "babylonjs/Bones/bone";
  42921. import { Scene } from "babylonjs/scene";
  42922. /**
  42923. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42924. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42925. */
  42926. export class BoneAxesViewer extends AxesViewer {
  42927. /**
  42928. * Gets or sets the target mesh where to display the axes viewer
  42929. */
  42930. mesh: Nullable<Mesh>;
  42931. /**
  42932. * Gets or sets the target bone where to display the axes viewer
  42933. */
  42934. bone: Nullable<Bone>;
  42935. /** Gets current position */
  42936. pos: Vector3;
  42937. /** Gets direction of X axis */
  42938. xaxis: Vector3;
  42939. /** Gets direction of Y axis */
  42940. yaxis: Vector3;
  42941. /** Gets direction of Z axis */
  42942. zaxis: Vector3;
  42943. /**
  42944. * Creates a new BoneAxesViewer
  42945. * @param scene defines the hosting scene
  42946. * @param bone defines the target bone
  42947. * @param mesh defines the target mesh
  42948. * @param scaleLines defines a scaling factor for line length (1 by default)
  42949. */
  42950. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42951. /**
  42952. * Force the viewer to update
  42953. */
  42954. update(): void;
  42955. /** Releases resources */
  42956. dispose(): void;
  42957. }
  42958. }
  42959. declare module "babylonjs/Debug/debugLayer" {
  42960. import { Observable } from "babylonjs/Misc/observable";
  42961. import { Scene } from "babylonjs/scene";
  42962. /**
  42963. * Interface used to define scene explorer extensibility option
  42964. */
  42965. export interface IExplorerExtensibilityOption {
  42966. /**
  42967. * Define the option label
  42968. */
  42969. label: string;
  42970. /**
  42971. * Defines the action to execute on click
  42972. */
  42973. action: (entity: any) => void;
  42974. }
  42975. /**
  42976. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42977. */
  42978. export interface IExplorerExtensibilityGroup {
  42979. /**
  42980. * Defines a predicate to test if a given type mut be extended
  42981. */
  42982. predicate: (entity: any) => boolean;
  42983. /**
  42984. * Gets the list of options added to a type
  42985. */
  42986. entries: IExplorerExtensibilityOption[];
  42987. }
  42988. /**
  42989. * Interface used to define the options to use to create the Inspector
  42990. */
  42991. export interface IInspectorOptions {
  42992. /**
  42993. * Display in overlay mode (default: false)
  42994. */
  42995. overlay?: boolean;
  42996. /**
  42997. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42998. */
  42999. globalRoot?: HTMLElement;
  43000. /**
  43001. * Display the Scene explorer
  43002. */
  43003. showExplorer?: boolean;
  43004. /**
  43005. * Display the property inspector
  43006. */
  43007. showInspector?: boolean;
  43008. /**
  43009. * Display in embed mode (both panes on the right)
  43010. */
  43011. embedMode?: boolean;
  43012. /**
  43013. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43014. */
  43015. handleResize?: boolean;
  43016. /**
  43017. * Allow the panes to popup (default: true)
  43018. */
  43019. enablePopup?: boolean;
  43020. /**
  43021. * Allow the panes to be closed by users (default: true)
  43022. */
  43023. enableClose?: boolean;
  43024. /**
  43025. * Optional list of extensibility entries
  43026. */
  43027. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43028. /**
  43029. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43030. */
  43031. inspectorURL?: string;
  43032. }
  43033. module "babylonjs/scene" {
  43034. interface Scene {
  43035. /**
  43036. * @hidden
  43037. * Backing field
  43038. */
  43039. _debugLayer: DebugLayer;
  43040. /**
  43041. * Gets the debug layer (aka Inspector) associated with the scene
  43042. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43043. */
  43044. debugLayer: DebugLayer;
  43045. }
  43046. }
  43047. /**
  43048. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43049. * what is happening in your scene
  43050. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43051. */
  43052. export class DebugLayer {
  43053. /**
  43054. * Define the url to get the inspector script from.
  43055. * By default it uses the babylonjs CDN.
  43056. * @ignoreNaming
  43057. */
  43058. static InspectorURL: string;
  43059. private _scene;
  43060. private BJSINSPECTOR;
  43061. /**
  43062. * Observable triggered when a property is changed through the inspector.
  43063. */
  43064. onPropertyChangedObservable: Observable<{
  43065. object: any;
  43066. property: string;
  43067. value: any;
  43068. initialValue: any;
  43069. }>;
  43070. /**
  43071. * Instantiates a new debug layer.
  43072. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43073. * what is happening in your scene
  43074. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43075. * @param scene Defines the scene to inspect
  43076. */
  43077. constructor(scene: Scene);
  43078. /** Creates the inspector window. */
  43079. private _createInspector;
  43080. /**
  43081. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43082. * @param entity defines the entity to select
  43083. * @param lineContainerTitle defines the specific block to highlight
  43084. */
  43085. select(entity: any, lineContainerTitle?: string): void;
  43086. /** Get the inspector from bundle or global */
  43087. private _getGlobalInspector;
  43088. /**
  43089. * Get if the inspector is visible or not.
  43090. * @returns true if visible otherwise, false
  43091. */
  43092. isVisible(): boolean;
  43093. /**
  43094. * Hide the inspector and close its window.
  43095. */
  43096. hide(): void;
  43097. /**
  43098. * Launch the debugLayer.
  43099. * @param config Define the configuration of the inspector
  43100. * @return a promise fulfilled when the debug layer is visible
  43101. */
  43102. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43103. }
  43104. }
  43105. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  43106. import { Nullable } from "babylonjs/types";
  43107. import { Scene } from "babylonjs/scene";
  43108. import { Vector4, Color4 } from "babylonjs/Maths/math";
  43109. import { Mesh } from "babylonjs/Meshes/mesh";
  43110. /**
  43111. * Class containing static functions to help procedurally build meshes
  43112. */
  43113. export class BoxBuilder {
  43114. /**
  43115. * Creates a box mesh
  43116. * * The parameter `size` sets the size (float) of each box side (default 1)
  43117. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43118. * * 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)
  43119. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43123. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43124. * @param name defines the name of the mesh
  43125. * @param options defines the options used to create the mesh
  43126. * @param scene defines the hosting scene
  43127. * @returns the box mesh
  43128. */
  43129. static CreateBox(name: string, options: {
  43130. size?: number;
  43131. width?: number;
  43132. height?: number;
  43133. depth?: number;
  43134. faceUV?: Vector4[];
  43135. faceColors?: Color4[];
  43136. sideOrientation?: number;
  43137. frontUVs?: Vector4;
  43138. backUVs?: Vector4;
  43139. wrap?: boolean;
  43140. topBaseAt?: number;
  43141. bottomBaseAt?: number;
  43142. updatable?: boolean;
  43143. }, scene?: Nullable<Scene>): Mesh;
  43144. }
  43145. }
  43146. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  43147. import { Vector4 } from "babylonjs/Maths/math";
  43148. import { Mesh } from "babylonjs/Meshes/mesh";
  43149. /**
  43150. * Class containing static functions to help procedurally build meshes
  43151. */
  43152. export class SphereBuilder {
  43153. /**
  43154. * Creates a sphere mesh
  43155. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43156. * * 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`)
  43157. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43158. * * 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
  43159. * * 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)
  43160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43163. * @param name defines the name of the mesh
  43164. * @param options defines the options used to create the mesh
  43165. * @param scene defines the hosting scene
  43166. * @returns the sphere mesh
  43167. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43168. */
  43169. static CreateSphere(name: string, options: {
  43170. segments?: number;
  43171. diameter?: number;
  43172. diameterX?: number;
  43173. diameterY?: number;
  43174. diameterZ?: number;
  43175. arc?: number;
  43176. slice?: number;
  43177. sideOrientation?: number;
  43178. frontUVs?: Vector4;
  43179. backUVs?: Vector4;
  43180. updatable?: boolean;
  43181. }, scene: any): Mesh;
  43182. }
  43183. }
  43184. declare module "babylonjs/Debug/physicsViewer" {
  43185. import { Nullable } from "babylonjs/types";
  43186. import { Scene } from "babylonjs/scene";
  43187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43188. import { Mesh } from "babylonjs/Meshes/mesh";
  43189. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  43190. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  43191. /**
  43192. * Used to show the physics impostor around the specific mesh
  43193. */
  43194. export class PhysicsViewer {
  43195. /** @hidden */
  43196. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43197. /** @hidden */
  43198. protected _meshes: Array<Nullable<AbstractMesh>>;
  43199. /** @hidden */
  43200. protected _scene: Nullable<Scene>;
  43201. /** @hidden */
  43202. protected _numMeshes: number;
  43203. /** @hidden */
  43204. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43205. private _renderFunction;
  43206. private _utilityLayer;
  43207. private _debugBoxMesh;
  43208. private _debugSphereMesh;
  43209. private _debugCylinderMesh;
  43210. private _debugMaterial;
  43211. private _debugMeshMeshes;
  43212. /**
  43213. * Creates a new PhysicsViewer
  43214. * @param scene defines the hosting scene
  43215. */
  43216. constructor(scene: Scene);
  43217. /** @hidden */
  43218. protected _updateDebugMeshes(): void;
  43219. /**
  43220. * Renders a specified physic impostor
  43221. * @param impostor defines the impostor to render
  43222. * @param targetMesh defines the mesh represented by the impostor
  43223. * @returns the new debug mesh used to render the impostor
  43224. */
  43225. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43226. /**
  43227. * Hides a specified physic impostor
  43228. * @param impostor defines the impostor to hide
  43229. */
  43230. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43231. private _getDebugMaterial;
  43232. private _getDebugBoxMesh;
  43233. private _getDebugSphereMesh;
  43234. private _getDebugCylinderMesh;
  43235. private _getDebugMeshMesh;
  43236. private _getDebugMesh;
  43237. /** Releases all resources */
  43238. dispose(): void;
  43239. }
  43240. }
  43241. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  43242. import { Vector3, Color4 } from "babylonjs/Maths/math";
  43243. import { Nullable } from "babylonjs/types";
  43244. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43245. import { Scene } from "babylonjs/scene";
  43246. /**
  43247. * Class containing static functions to help procedurally build meshes
  43248. */
  43249. export class LinesBuilder {
  43250. /**
  43251. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43252. * * 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
  43253. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43254. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43255. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43256. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43257. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43258. * * 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
  43259. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43261. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43262. * @param name defines the name of the new line system
  43263. * @param options defines the options used to create the line system
  43264. * @param scene defines the hosting scene
  43265. * @returns a new line system mesh
  43266. */
  43267. static CreateLineSystem(name: string, options: {
  43268. lines: Vector3[][];
  43269. updatable?: boolean;
  43270. instance?: Nullable<LinesMesh>;
  43271. colors?: Nullable<Color4[][]>;
  43272. useVertexAlpha?: boolean;
  43273. }, scene: Nullable<Scene>): LinesMesh;
  43274. /**
  43275. * Creates a line mesh
  43276. * 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
  43277. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43278. * * The parameter `points` is an array successive Vector3
  43279. * * 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
  43280. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43281. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43282. * * When updating an instance, remember that only point positions can change, not the number of points
  43283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43284. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43285. * @param name defines the name of the new line system
  43286. * @param options defines the options used to create the line system
  43287. * @param scene defines the hosting scene
  43288. * @returns a new line mesh
  43289. */
  43290. static CreateLines(name: string, options: {
  43291. points: Vector3[];
  43292. updatable?: boolean;
  43293. instance?: Nullable<LinesMesh>;
  43294. colors?: Color4[];
  43295. useVertexAlpha?: boolean;
  43296. }, scene?: Nullable<Scene>): LinesMesh;
  43297. /**
  43298. * Creates a dashed line mesh
  43299. * * 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
  43300. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43301. * * The parameter `points` is an array successive Vector3
  43302. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43303. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43304. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43305. * * 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
  43306. * * When updating an instance, remember that only point positions can change, not the number of points
  43307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43308. * @param name defines the name of the mesh
  43309. * @param options defines the options used to create the mesh
  43310. * @param scene defines the hosting scene
  43311. * @returns the dashed line mesh
  43312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43313. */
  43314. static CreateDashedLines(name: string, options: {
  43315. points: Vector3[];
  43316. dashSize?: number;
  43317. gapSize?: number;
  43318. dashNb?: number;
  43319. updatable?: boolean;
  43320. instance?: LinesMesh;
  43321. }, scene?: Nullable<Scene>): LinesMesh;
  43322. }
  43323. }
  43324. declare module "babylonjs/Debug/rayHelper" {
  43325. import { Nullable } from "babylonjs/types";
  43326. import { Ray } from "babylonjs/Culling/ray";
  43327. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43328. import { Scene } from "babylonjs/scene";
  43329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43330. import "babylonjs/Meshes/Builders/linesBuilder";
  43331. /**
  43332. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43333. * in order to better appreciate the issue one might have.
  43334. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43335. */
  43336. export class RayHelper {
  43337. /**
  43338. * Defines the ray we are currently tryin to visualize.
  43339. */
  43340. ray: Nullable<Ray>;
  43341. private _renderPoints;
  43342. private _renderLine;
  43343. private _renderFunction;
  43344. private _scene;
  43345. private _updateToMeshFunction;
  43346. private _attachedToMesh;
  43347. private _meshSpaceDirection;
  43348. private _meshSpaceOrigin;
  43349. /**
  43350. * Helper function to create a colored helper in a scene in one line.
  43351. * @param ray Defines the ray we are currently tryin to visualize
  43352. * @param scene Defines the scene the ray is used in
  43353. * @param color Defines the color we want to see the ray in
  43354. * @returns The newly created ray helper.
  43355. */
  43356. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43357. /**
  43358. * Instantiate a new ray helper.
  43359. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43360. * in order to better appreciate the issue one might have.
  43361. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43362. * @param ray Defines the ray we are currently tryin to visualize
  43363. */
  43364. constructor(ray: Ray);
  43365. /**
  43366. * Shows the ray we are willing to debug.
  43367. * @param scene Defines the scene the ray needs to be rendered in
  43368. * @param color Defines the color the ray needs to be rendered in
  43369. */
  43370. show(scene: Scene, color?: Color3): void;
  43371. /**
  43372. * Hides the ray we are debugging.
  43373. */
  43374. hide(): void;
  43375. private _render;
  43376. /**
  43377. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43378. * @param mesh Defines the mesh we want the helper attached to
  43379. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43380. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43381. * @param length Defines the length of the ray
  43382. */
  43383. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43384. /**
  43385. * Detach the ray helper from the mesh it has previously been attached to.
  43386. */
  43387. detachFromMesh(): void;
  43388. private _updateToMesh;
  43389. /**
  43390. * Dispose the helper and release its associated resources.
  43391. */
  43392. dispose(): void;
  43393. }
  43394. }
  43395. declare module "babylonjs/Debug/skeletonViewer" {
  43396. import { Color3 } from "babylonjs/Maths/math";
  43397. import { Scene } from "babylonjs/scene";
  43398. import { Nullable } from "babylonjs/types";
  43399. import { Skeleton } from "babylonjs/Bones/skeleton";
  43400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43401. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43402. /**
  43403. * Class used to render a debug view of a given skeleton
  43404. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43405. */
  43406. export class SkeletonViewer {
  43407. /** defines the skeleton to render */
  43408. skeleton: Skeleton;
  43409. /** defines the mesh attached to the skeleton */
  43410. mesh: AbstractMesh;
  43411. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43412. autoUpdateBonesMatrices: boolean;
  43413. /** defines the rendering group id to use with the viewer */
  43414. renderingGroupId: number;
  43415. /** Gets or sets the color used to render the skeleton */
  43416. color: Color3;
  43417. private _scene;
  43418. private _debugLines;
  43419. private _debugMesh;
  43420. private _isEnabled;
  43421. private _renderFunction;
  43422. private _utilityLayer;
  43423. /**
  43424. * Returns the mesh used to render the bones
  43425. */
  43426. readonly debugMesh: Nullable<LinesMesh>;
  43427. /**
  43428. * Creates a new SkeletonViewer
  43429. * @param skeleton defines the skeleton to render
  43430. * @param mesh defines the mesh attached to the skeleton
  43431. * @param scene defines the hosting scene
  43432. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43433. * @param renderingGroupId defines the rendering group id to use with the viewer
  43434. */
  43435. constructor(
  43436. /** defines the skeleton to render */
  43437. skeleton: Skeleton,
  43438. /** defines the mesh attached to the skeleton */
  43439. mesh: AbstractMesh, scene: Scene,
  43440. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43441. autoUpdateBonesMatrices?: boolean,
  43442. /** defines the rendering group id to use with the viewer */
  43443. renderingGroupId?: number);
  43444. /** Gets or sets a boolean indicating if the viewer is enabled */
  43445. isEnabled: boolean;
  43446. private _getBonePosition;
  43447. private _getLinesForBonesWithLength;
  43448. private _getLinesForBonesNoLength;
  43449. /** Update the viewer to sync with current skeleton state */
  43450. update(): void;
  43451. /** Release associated resources */
  43452. dispose(): void;
  43453. }
  43454. }
  43455. declare module "babylonjs/Debug/index" {
  43456. export * from "babylonjs/Debug/axesViewer";
  43457. export * from "babylonjs/Debug/boneAxesViewer";
  43458. export * from "babylonjs/Debug/debugLayer";
  43459. export * from "babylonjs/Debug/physicsViewer";
  43460. export * from "babylonjs/Debug/rayHelper";
  43461. export * from "babylonjs/Debug/skeletonViewer";
  43462. }
  43463. declare module "babylonjs/Engines/nullEngine" {
  43464. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43465. import { Scene } from "babylonjs/scene";
  43466. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43467. import { Engine } from "babylonjs/Engines/engine";
  43468. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43469. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43470. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43471. import { Effect } from "babylonjs/Materials/effect";
  43472. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43473. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43474. /**
  43475. * Options to create the null engine
  43476. */
  43477. export class NullEngineOptions {
  43478. /**
  43479. * Render width (Default: 512)
  43480. */
  43481. renderWidth: number;
  43482. /**
  43483. * Render height (Default: 256)
  43484. */
  43485. renderHeight: number;
  43486. /**
  43487. * Texture size (Default: 512)
  43488. */
  43489. textureSize: number;
  43490. /**
  43491. * If delta time between frames should be constant
  43492. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43493. */
  43494. deterministicLockstep: boolean;
  43495. /**
  43496. * Maximum about of steps between frames (Default: 4)
  43497. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43498. */
  43499. lockstepMaxSteps: number;
  43500. }
  43501. /**
  43502. * The null engine class provides support for headless version of babylon.js.
  43503. * This can be used in server side scenario or for testing purposes
  43504. */
  43505. export class NullEngine extends Engine {
  43506. private _options;
  43507. /**
  43508. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43509. */
  43510. isDeterministicLockStep(): boolean;
  43511. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43512. getLockstepMaxSteps(): number;
  43513. /**
  43514. * Sets hardware scaling, used to save performance if needed
  43515. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43516. */
  43517. getHardwareScalingLevel(): number;
  43518. constructor(options?: NullEngineOptions);
  43519. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43520. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43521. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43522. getRenderWidth(useScreen?: boolean): number;
  43523. getRenderHeight(useScreen?: boolean): number;
  43524. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43525. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43526. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43527. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43528. bindSamplers(effect: Effect): void;
  43529. enableEffect(effect: Effect): void;
  43530. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43531. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43532. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43533. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43534. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43535. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43536. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43537. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43538. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43539. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43540. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43541. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43542. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43543. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43544. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43545. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43546. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43547. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43548. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43549. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43550. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43551. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43552. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43553. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43554. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43555. bindBuffers(vertexBuffers: {
  43556. [key: string]: VertexBuffer;
  43557. }, indexBuffer: DataBuffer, effect: Effect): void;
  43558. wipeCaches(bruteForce?: boolean): void;
  43559. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43560. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43561. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43562. /** @hidden */
  43563. _createTexture(): WebGLTexture;
  43564. /** @hidden */
  43565. _releaseTexture(texture: InternalTexture): void;
  43566. 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;
  43567. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43568. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43569. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43570. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43571. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43572. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43573. areAllEffectsReady(): boolean;
  43574. /**
  43575. * @hidden
  43576. * Get the current error code of the webGL context
  43577. * @returns the error code
  43578. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43579. */
  43580. getError(): number;
  43581. /** @hidden */
  43582. _getUnpackAlignement(): number;
  43583. /** @hidden */
  43584. _unpackFlipY(value: boolean): void;
  43585. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43586. /**
  43587. * Updates a dynamic vertex buffer.
  43588. * @param vertexBuffer the vertex buffer to update
  43589. * @param data the data used to update the vertex buffer
  43590. * @param byteOffset the byte offset of the data (optional)
  43591. * @param byteLength the byte length of the data (optional)
  43592. */
  43593. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43594. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43595. /** @hidden */
  43596. _bindTexture(channel: number, texture: InternalTexture): void;
  43597. /** @hidden */
  43598. _releaseBuffer(buffer: DataBuffer): boolean;
  43599. releaseEffects(): void;
  43600. displayLoadingUI(): void;
  43601. hideLoadingUI(): void;
  43602. /** @hidden */
  43603. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43604. /** @hidden */
  43605. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43606. /** @hidden */
  43607. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43608. /** @hidden */
  43609. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43610. }
  43611. }
  43612. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43613. import { Nullable, int } from "babylonjs/types";
  43614. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43615. /** @hidden */
  43616. export class _OcclusionDataStorage {
  43617. /** @hidden */
  43618. occlusionInternalRetryCounter: number;
  43619. /** @hidden */
  43620. isOcclusionQueryInProgress: boolean;
  43621. /** @hidden */
  43622. isOccluded: boolean;
  43623. /** @hidden */
  43624. occlusionRetryCount: number;
  43625. /** @hidden */
  43626. occlusionType: number;
  43627. /** @hidden */
  43628. occlusionQueryAlgorithmType: number;
  43629. }
  43630. module "babylonjs/Engines/engine" {
  43631. interface Engine {
  43632. /**
  43633. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43634. * @return the new query
  43635. */
  43636. createQuery(): WebGLQuery;
  43637. /**
  43638. * Delete and release a webGL query
  43639. * @param query defines the query to delete
  43640. * @return the current engine
  43641. */
  43642. deleteQuery(query: WebGLQuery): Engine;
  43643. /**
  43644. * Check if a given query has resolved and got its value
  43645. * @param query defines the query to check
  43646. * @returns true if the query got its value
  43647. */
  43648. isQueryResultAvailable(query: WebGLQuery): boolean;
  43649. /**
  43650. * Gets the value of a given query
  43651. * @param query defines the query to check
  43652. * @returns the value of the query
  43653. */
  43654. getQueryResult(query: WebGLQuery): number;
  43655. /**
  43656. * Initiates an occlusion query
  43657. * @param algorithmType defines the algorithm to use
  43658. * @param query defines the query to use
  43659. * @returns the current engine
  43660. * @see http://doc.babylonjs.com/features/occlusionquery
  43661. */
  43662. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43663. /**
  43664. * Ends an occlusion query
  43665. * @see http://doc.babylonjs.com/features/occlusionquery
  43666. * @param algorithmType defines the algorithm to use
  43667. * @returns the current engine
  43668. */
  43669. endOcclusionQuery(algorithmType: number): Engine;
  43670. /**
  43671. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43672. * Please note that only one query can be issued at a time
  43673. * @returns a time token used to track the time span
  43674. */
  43675. startTimeQuery(): Nullable<_TimeToken>;
  43676. /**
  43677. * Ends a time query
  43678. * @param token defines the token used to measure the time span
  43679. * @returns the time spent (in ns)
  43680. */
  43681. endTimeQuery(token: _TimeToken): int;
  43682. /** @hidden */
  43683. _currentNonTimestampToken: Nullable<_TimeToken>;
  43684. /** @hidden */
  43685. _createTimeQuery(): WebGLQuery;
  43686. /** @hidden */
  43687. _deleteTimeQuery(query: WebGLQuery): void;
  43688. /** @hidden */
  43689. _getGlAlgorithmType(algorithmType: number): number;
  43690. /** @hidden */
  43691. _getTimeQueryResult(query: WebGLQuery): any;
  43692. /** @hidden */
  43693. _getTimeQueryAvailability(query: WebGLQuery): any;
  43694. }
  43695. }
  43696. module "babylonjs/Meshes/abstractMesh" {
  43697. interface AbstractMesh {
  43698. /**
  43699. * Backing filed
  43700. * @hidden
  43701. */
  43702. __occlusionDataStorage: _OcclusionDataStorage;
  43703. /**
  43704. * Access property
  43705. * @hidden
  43706. */
  43707. _occlusionDataStorage: _OcclusionDataStorage;
  43708. /**
  43709. * 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.
  43710. * The default value is -1 which means don't break the query and wait till the result
  43711. * @see http://doc.babylonjs.com/features/occlusionquery
  43712. */
  43713. occlusionRetryCount: number;
  43714. /**
  43715. * 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:
  43716. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43717. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43718. * * 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.
  43719. * @see http://doc.babylonjs.com/features/occlusionquery
  43720. */
  43721. occlusionType: number;
  43722. /**
  43723. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43724. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43725. * * 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.
  43726. * @see http://doc.babylonjs.com/features/occlusionquery
  43727. */
  43728. occlusionQueryAlgorithmType: number;
  43729. /**
  43730. * 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
  43731. * @see http://doc.babylonjs.com/features/occlusionquery
  43732. */
  43733. isOccluded: boolean;
  43734. /**
  43735. * Flag to check the progress status of the query
  43736. * @see http://doc.babylonjs.com/features/occlusionquery
  43737. */
  43738. isOcclusionQueryInProgress: boolean;
  43739. }
  43740. }
  43741. }
  43742. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43743. import { Nullable } from "babylonjs/types";
  43744. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43745. /** @hidden */
  43746. export var _forceTransformFeedbackToBundle: boolean;
  43747. module "babylonjs/Engines/engine" {
  43748. interface Engine {
  43749. /**
  43750. * Creates a webGL transform feedback object
  43751. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43752. * @returns the webGL transform feedback object
  43753. */
  43754. createTransformFeedback(): WebGLTransformFeedback;
  43755. /**
  43756. * Delete a webGL transform feedback object
  43757. * @param value defines the webGL transform feedback object to delete
  43758. */
  43759. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43760. /**
  43761. * Bind a webGL transform feedback object to the webgl context
  43762. * @param value defines the webGL transform feedback object to bind
  43763. */
  43764. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43765. /**
  43766. * Begins a transform feedback operation
  43767. * @param usePoints defines if points or triangles must be used
  43768. */
  43769. beginTransformFeedback(usePoints: boolean): void;
  43770. /**
  43771. * Ends a transform feedback operation
  43772. */
  43773. endTransformFeedback(): void;
  43774. /**
  43775. * Specify the varyings to use with transform feedback
  43776. * @param program defines the associated webGL program
  43777. * @param value defines the list of strings representing the varying names
  43778. */
  43779. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43780. /**
  43781. * Bind a webGL buffer for a transform feedback operation
  43782. * @param value defines the webGL buffer to bind
  43783. */
  43784. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43785. }
  43786. }
  43787. }
  43788. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43789. import { Scene } from "babylonjs/scene";
  43790. import { Engine } from "babylonjs/Engines/engine";
  43791. import { Texture } from "babylonjs/Materials/Textures/texture";
  43792. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43793. import "babylonjs/Engines/Extensions/engine.multiRender";
  43794. /**
  43795. * Creation options of the multi render target texture.
  43796. */
  43797. export interface IMultiRenderTargetOptions {
  43798. /**
  43799. * Define if the texture needs to create mip maps after render.
  43800. */
  43801. generateMipMaps?: boolean;
  43802. /**
  43803. * Define the types of all the draw buffers we want to create
  43804. */
  43805. types?: number[];
  43806. /**
  43807. * Define the sampling modes of all the draw buffers we want to create
  43808. */
  43809. samplingModes?: number[];
  43810. /**
  43811. * Define if a depth buffer is required
  43812. */
  43813. generateDepthBuffer?: boolean;
  43814. /**
  43815. * Define if a stencil buffer is required
  43816. */
  43817. generateStencilBuffer?: boolean;
  43818. /**
  43819. * Define if a depth texture is required instead of a depth buffer
  43820. */
  43821. generateDepthTexture?: boolean;
  43822. /**
  43823. * Define the number of desired draw buffers
  43824. */
  43825. textureCount?: number;
  43826. /**
  43827. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43828. */
  43829. doNotChangeAspectRatio?: boolean;
  43830. /**
  43831. * Define the default type of the buffers we are creating
  43832. */
  43833. defaultType?: number;
  43834. }
  43835. /**
  43836. * A multi render target, like a render target provides the ability to render to a texture.
  43837. * Unlike the render target, it can render to several draw buffers in one draw.
  43838. * This is specially interesting in deferred rendering or for any effects requiring more than
  43839. * just one color from a single pass.
  43840. */
  43841. export class MultiRenderTarget extends RenderTargetTexture {
  43842. private _internalTextures;
  43843. private _textures;
  43844. private _multiRenderTargetOptions;
  43845. /**
  43846. * Get if draw buffers are currently supported by the used hardware and browser.
  43847. */
  43848. readonly isSupported: boolean;
  43849. /**
  43850. * Get the list of textures generated by the multi render target.
  43851. */
  43852. readonly textures: Texture[];
  43853. /**
  43854. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43855. */
  43856. readonly depthTexture: Texture;
  43857. /**
  43858. * Set the wrapping mode on U of all the textures we are rendering to.
  43859. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43860. */
  43861. wrapU: number;
  43862. /**
  43863. * Set the wrapping mode on V of all the textures we are rendering to.
  43864. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43865. */
  43866. wrapV: number;
  43867. /**
  43868. * Instantiate a new multi render target texture.
  43869. * A multi render target, like a render target provides the ability to render to a texture.
  43870. * Unlike the render target, it can render to several draw buffers in one draw.
  43871. * This is specially interesting in deferred rendering or for any effects requiring more than
  43872. * just one color from a single pass.
  43873. * @param name Define the name of the texture
  43874. * @param size Define the size of the buffers to render to
  43875. * @param count Define the number of target we are rendering into
  43876. * @param scene Define the scene the texture belongs to
  43877. * @param options Define the options used to create the multi render target
  43878. */
  43879. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43880. /** @hidden */
  43881. _rebuild(): void;
  43882. private _createInternalTextures;
  43883. private _createTextures;
  43884. /**
  43885. * Define the number of samples used if MSAA is enabled.
  43886. */
  43887. samples: number;
  43888. /**
  43889. * Resize all the textures in the multi render target.
  43890. * Be carrefull as it will recreate all the data in the new texture.
  43891. * @param size Define the new size
  43892. */
  43893. resize(size: any): void;
  43894. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43895. /**
  43896. * Dispose the render targets and their associated resources
  43897. */
  43898. dispose(): void;
  43899. /**
  43900. * Release all the underlying texture used as draw buffers.
  43901. */
  43902. releaseInternalTextures(): void;
  43903. }
  43904. }
  43905. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43906. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43907. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43908. import { Nullable } from "babylonjs/types";
  43909. module "babylonjs/Engines/engine" {
  43910. interface Engine {
  43911. /**
  43912. * Unbind a list of render target textures from the webGL context
  43913. * This is used only when drawBuffer extension or webGL2 are active
  43914. * @param textures defines the render target textures to unbind
  43915. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43916. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43917. */
  43918. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43919. /**
  43920. * Create a multi render target texture
  43921. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43922. * @param size defines the size of the texture
  43923. * @param options defines the creation options
  43924. * @returns the cube texture as an InternalTexture
  43925. */
  43926. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43927. /**
  43928. * Update the sample count for a given multiple render target texture
  43929. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43930. * @param textures defines the textures to update
  43931. * @param samples defines the sample count to set
  43932. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43933. */
  43934. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43935. }
  43936. }
  43937. }
  43938. declare module "babylonjs/Engines/Extensions/index" {
  43939. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43940. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43941. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43942. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43943. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43944. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43945. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43946. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43947. }
  43948. declare module "babylonjs/Engines/index" {
  43949. export * from "babylonjs/Engines/constants";
  43950. export * from "babylonjs/Engines/engine";
  43951. export * from "babylonjs/Engines/engineStore";
  43952. export * from "babylonjs/Engines/nullEngine";
  43953. export * from "babylonjs/Engines/Extensions/index";
  43954. export * from "babylonjs/Engines/IPipelineContext";
  43955. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43956. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  43957. }
  43958. declare module "babylonjs/Events/clipboardEvents" {
  43959. /**
  43960. * Gather the list of clipboard event types as constants.
  43961. */
  43962. export class ClipboardEventTypes {
  43963. /**
  43964. * The clipboard event is fired when a copy command is active (pressed).
  43965. */
  43966. static readonly COPY: number;
  43967. /**
  43968. * The clipboard event is fired when a cut command is active (pressed).
  43969. */
  43970. static readonly CUT: number;
  43971. /**
  43972. * The clipboard event is fired when a paste command is active (pressed).
  43973. */
  43974. static readonly PASTE: number;
  43975. }
  43976. /**
  43977. * This class is used to store clipboard related info for the onClipboardObservable event.
  43978. */
  43979. export class ClipboardInfo {
  43980. /**
  43981. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43982. */
  43983. type: number;
  43984. /**
  43985. * Defines the related dom event
  43986. */
  43987. event: ClipboardEvent;
  43988. /**
  43989. *Creates an instance of ClipboardInfo.
  43990. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43991. * @param event Defines the related dom event
  43992. */
  43993. constructor(
  43994. /**
  43995. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43996. */
  43997. type: number,
  43998. /**
  43999. * Defines the related dom event
  44000. */
  44001. event: ClipboardEvent);
  44002. /**
  44003. * Get the clipboard event's type from the keycode.
  44004. * @param keyCode Defines the keyCode for the current keyboard event.
  44005. * @return {number}
  44006. */
  44007. static GetTypeFromCharacter(keyCode: number): number;
  44008. }
  44009. }
  44010. declare module "babylonjs/Events/index" {
  44011. export * from "babylonjs/Events/keyboardEvents";
  44012. export * from "babylonjs/Events/pointerEvents";
  44013. export * from "babylonjs/Events/clipboardEvents";
  44014. }
  44015. declare module "babylonjs/Loading/sceneLoader" {
  44016. import { Observable } from "babylonjs/Misc/observable";
  44017. import { Nullable } from "babylonjs/types";
  44018. import { Scene } from "babylonjs/scene";
  44019. import { Engine } from "babylonjs/Engines/engine";
  44020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44021. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44022. import { AssetContainer } from "babylonjs/assetContainer";
  44023. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44024. import { Skeleton } from "babylonjs/Bones/skeleton";
  44025. /**
  44026. * Class used to represent data loading progression
  44027. */
  44028. export class SceneLoaderProgressEvent {
  44029. /** defines if data length to load can be evaluated */
  44030. readonly lengthComputable: boolean;
  44031. /** defines the loaded data length */
  44032. readonly loaded: number;
  44033. /** defines the data length to load */
  44034. readonly total: number;
  44035. /**
  44036. * Create a new progress event
  44037. * @param lengthComputable defines if data length to load can be evaluated
  44038. * @param loaded defines the loaded data length
  44039. * @param total defines the data length to load
  44040. */
  44041. constructor(
  44042. /** defines if data length to load can be evaluated */
  44043. lengthComputable: boolean,
  44044. /** defines the loaded data length */
  44045. loaded: number,
  44046. /** defines the data length to load */
  44047. total: number);
  44048. /**
  44049. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44050. * @param event defines the source event
  44051. * @returns a new SceneLoaderProgressEvent
  44052. */
  44053. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44054. }
  44055. /**
  44056. * Interface used by SceneLoader plugins to define supported file extensions
  44057. */
  44058. export interface ISceneLoaderPluginExtensions {
  44059. /**
  44060. * Defines the list of supported extensions
  44061. */
  44062. [extension: string]: {
  44063. isBinary: boolean;
  44064. };
  44065. }
  44066. /**
  44067. * Interface used by SceneLoader plugin factory
  44068. */
  44069. export interface ISceneLoaderPluginFactory {
  44070. /**
  44071. * Defines the name of the factory
  44072. */
  44073. name: string;
  44074. /**
  44075. * Function called to create a new plugin
  44076. * @return the new plugin
  44077. */
  44078. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44079. /**
  44080. * Boolean indicating if the plugin can direct load specific data
  44081. */
  44082. canDirectLoad?: (data: string) => boolean;
  44083. }
  44084. /**
  44085. * Interface used to define a SceneLoader plugin
  44086. */
  44087. export interface ISceneLoaderPlugin {
  44088. /**
  44089. * The friendly name of this plugin.
  44090. */
  44091. name: string;
  44092. /**
  44093. * The file extensions supported by this plugin.
  44094. */
  44095. extensions: string | ISceneLoaderPluginExtensions;
  44096. /**
  44097. * Import meshes into a scene.
  44098. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44099. * @param scene The scene to import into
  44100. * @param data The data to import
  44101. * @param rootUrl The root url for scene and resources
  44102. * @param meshes The meshes array to import into
  44103. * @param particleSystems The particle systems array to import into
  44104. * @param skeletons The skeletons array to import into
  44105. * @param onError The callback when import fails
  44106. * @returns True if successful or false otherwise
  44107. */
  44108. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44109. /**
  44110. * Load into a scene.
  44111. * @param scene The scene to load into
  44112. * @param data The data to import
  44113. * @param rootUrl The root url for scene and resources
  44114. * @param onError The callback when import fails
  44115. * @returns true if successful or false otherwise
  44116. */
  44117. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44118. /**
  44119. * The callback that returns true if the data can be directly loaded.
  44120. */
  44121. canDirectLoad?: (data: string) => boolean;
  44122. /**
  44123. * The callback that allows custom handling of the root url based on the response url.
  44124. */
  44125. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44126. /**
  44127. * Load into an asset container.
  44128. * @param scene The scene to load into
  44129. * @param data The data to import
  44130. * @param rootUrl The root url for scene and resources
  44131. * @param onError The callback when import fails
  44132. * @returns The loaded asset container
  44133. */
  44134. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44135. }
  44136. /**
  44137. * Interface used to define an async SceneLoader plugin
  44138. */
  44139. export interface ISceneLoaderPluginAsync {
  44140. /**
  44141. * The friendly name of this plugin.
  44142. */
  44143. name: string;
  44144. /**
  44145. * The file extensions supported by this plugin.
  44146. */
  44147. extensions: string | ISceneLoaderPluginExtensions;
  44148. /**
  44149. * Import meshes into a scene.
  44150. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44151. * @param scene The scene to import into
  44152. * @param data The data to import
  44153. * @param rootUrl The root url for scene and resources
  44154. * @param onProgress The callback when the load progresses
  44155. * @param fileName Defines the name of the file to load
  44156. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44157. */
  44158. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44159. meshes: AbstractMesh[];
  44160. particleSystems: IParticleSystem[];
  44161. skeletons: Skeleton[];
  44162. animationGroups: AnimationGroup[];
  44163. }>;
  44164. /**
  44165. * Load into a scene.
  44166. * @param scene The scene to load into
  44167. * @param data The data to import
  44168. * @param rootUrl The root url for scene and resources
  44169. * @param onProgress The callback when the load progresses
  44170. * @param fileName Defines the name of the file to load
  44171. * @returns Nothing
  44172. */
  44173. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44174. /**
  44175. * The callback that returns true if the data can be directly loaded.
  44176. */
  44177. canDirectLoad?: (data: string) => boolean;
  44178. /**
  44179. * The callback that allows custom handling of the root url based on the response url.
  44180. */
  44181. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44182. /**
  44183. * Load into an asset container.
  44184. * @param scene The scene to load into
  44185. * @param data The data to import
  44186. * @param rootUrl The root url for scene and resources
  44187. * @param onProgress The callback when the load progresses
  44188. * @param fileName Defines the name of the file to load
  44189. * @returns The loaded asset container
  44190. */
  44191. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44192. }
  44193. /**
  44194. * Class used to load scene from various file formats using registered plugins
  44195. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44196. */
  44197. export class SceneLoader {
  44198. /**
  44199. * No logging while loading
  44200. */
  44201. static readonly NO_LOGGING: number;
  44202. /**
  44203. * Minimal logging while loading
  44204. */
  44205. static readonly MINIMAL_LOGGING: number;
  44206. /**
  44207. * Summary logging while loading
  44208. */
  44209. static readonly SUMMARY_LOGGING: number;
  44210. /**
  44211. * Detailled logging while loading
  44212. */
  44213. static readonly DETAILED_LOGGING: number;
  44214. /**
  44215. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44216. */
  44217. static ForceFullSceneLoadingForIncremental: boolean;
  44218. /**
  44219. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44220. */
  44221. static ShowLoadingScreen: boolean;
  44222. /**
  44223. * Defines the current logging level (while loading the scene)
  44224. * @ignorenaming
  44225. */
  44226. static loggingLevel: number;
  44227. /**
  44228. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44229. */
  44230. static CleanBoneMatrixWeights: boolean;
  44231. /**
  44232. * Event raised when a plugin is used to load a scene
  44233. */
  44234. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44235. private static _registeredPlugins;
  44236. private static _getDefaultPlugin;
  44237. private static _getPluginForExtension;
  44238. private static _getPluginForDirectLoad;
  44239. private static _getPluginForFilename;
  44240. private static _getDirectLoad;
  44241. private static _loadData;
  44242. private static _getFileInfo;
  44243. /**
  44244. * Gets a plugin that can load the given extension
  44245. * @param extension defines the extension to load
  44246. * @returns a plugin or null if none works
  44247. */
  44248. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44249. /**
  44250. * Gets a boolean indicating that the given extension can be loaded
  44251. * @param extension defines the extension to load
  44252. * @returns true if the extension is supported
  44253. */
  44254. static IsPluginForExtensionAvailable(extension: string): boolean;
  44255. /**
  44256. * Adds a new plugin to the list of registered plugins
  44257. * @param plugin defines the plugin to add
  44258. */
  44259. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44260. /**
  44261. * Import meshes into a scene
  44262. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44263. * @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)
  44264. * @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)
  44265. * @param scene the instance of BABYLON.Scene to append to
  44266. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44267. * @param onProgress a callback with a progress event for each file being loaded
  44268. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44269. * @param pluginExtension the extension used to determine the plugin
  44270. * @returns The loaded plugin
  44271. */
  44272. 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>;
  44273. /**
  44274. * Import meshes into a scene
  44275. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44276. * @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)
  44277. * @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)
  44278. * @param scene the instance of BABYLON.Scene to append to
  44279. * @param onProgress a callback with a progress event for each file being loaded
  44280. * @param pluginExtension the extension used to determine the plugin
  44281. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44282. */
  44283. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44284. meshes: AbstractMesh[];
  44285. particleSystems: IParticleSystem[];
  44286. skeletons: Skeleton[];
  44287. animationGroups: AnimationGroup[];
  44288. }>;
  44289. /**
  44290. * Load a scene
  44291. * @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)
  44292. * @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)
  44293. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44294. * @param onSuccess a callback with the scene when import succeeds
  44295. * @param onProgress a callback with a progress event for each file being loaded
  44296. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44297. * @param pluginExtension the extension used to determine the plugin
  44298. * @returns The loaded plugin
  44299. */
  44300. 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>;
  44301. /**
  44302. * Load a scene
  44303. * @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)
  44304. * @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)
  44305. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44306. * @param onProgress a callback with a progress event for each file being loaded
  44307. * @param pluginExtension the extension used to determine the plugin
  44308. * @returns The loaded scene
  44309. */
  44310. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44311. /**
  44312. * Append a scene
  44313. * @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)
  44314. * @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)
  44315. * @param scene is the instance of BABYLON.Scene to append to
  44316. * @param onSuccess a callback with the scene when import succeeds
  44317. * @param onProgress a callback with a progress event for each file being loaded
  44318. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44319. * @param pluginExtension the extension used to determine the plugin
  44320. * @returns The loaded plugin
  44321. */
  44322. 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>;
  44323. /**
  44324. * Append a scene
  44325. * @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)
  44326. * @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)
  44327. * @param scene is the instance of BABYLON.Scene to append to
  44328. * @param onProgress a callback with a progress event for each file being loaded
  44329. * @param pluginExtension the extension used to determine the plugin
  44330. * @returns The given scene
  44331. */
  44332. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44333. /**
  44334. * Load a scene into an asset container
  44335. * @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)
  44336. * @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)
  44337. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44338. * @param onSuccess a callback with the scene when import succeeds
  44339. * @param onProgress a callback with a progress event for each file being loaded
  44340. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44341. * @param pluginExtension the extension used to determine the plugin
  44342. * @returns The loaded plugin
  44343. */
  44344. 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>;
  44345. /**
  44346. * Load a scene into an asset container
  44347. * @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)
  44348. * @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)
  44349. * @param scene is the instance of Scene to append to
  44350. * @param onProgress a callback with a progress event for each file being loaded
  44351. * @param pluginExtension the extension used to determine the plugin
  44352. * @returns The loaded asset container
  44353. */
  44354. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44355. }
  44356. }
  44357. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44358. import { Scene } from "babylonjs/scene";
  44359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44360. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44361. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44362. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44363. /**
  44364. * Google Daydream controller
  44365. */
  44366. export class DaydreamController extends WebVRController {
  44367. /**
  44368. * Base Url for the controller model.
  44369. */
  44370. static MODEL_BASE_URL: string;
  44371. /**
  44372. * File name for the controller model.
  44373. */
  44374. static MODEL_FILENAME: string;
  44375. /**
  44376. * Gamepad Id prefix used to identify Daydream Controller.
  44377. */
  44378. static readonly GAMEPAD_ID_PREFIX: string;
  44379. /**
  44380. * Creates a new DaydreamController from a gamepad
  44381. * @param vrGamepad the gamepad that the controller should be created from
  44382. */
  44383. constructor(vrGamepad: any);
  44384. /**
  44385. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44386. * @param scene scene in which to add meshes
  44387. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44388. */
  44389. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44390. /**
  44391. * Called once for each button that changed state since the last frame
  44392. * @param buttonIdx Which button index changed
  44393. * @param state New state of the button
  44394. * @param changes Which properties on the state changed since last frame
  44395. */
  44396. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44397. }
  44398. }
  44399. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44400. import { Scene } from "babylonjs/scene";
  44401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44402. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44403. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44404. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44405. /**
  44406. * Gear VR Controller
  44407. */
  44408. export class GearVRController extends WebVRController {
  44409. /**
  44410. * Base Url for the controller model.
  44411. */
  44412. static MODEL_BASE_URL: string;
  44413. /**
  44414. * File name for the controller model.
  44415. */
  44416. static MODEL_FILENAME: string;
  44417. /**
  44418. * Gamepad Id prefix used to identify this controller.
  44419. */
  44420. static readonly GAMEPAD_ID_PREFIX: string;
  44421. private readonly _buttonIndexToObservableNameMap;
  44422. /**
  44423. * Creates a new GearVRController from a gamepad
  44424. * @param vrGamepad the gamepad that the controller should be created from
  44425. */
  44426. constructor(vrGamepad: any);
  44427. /**
  44428. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44429. * @param scene scene in which to add meshes
  44430. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44431. */
  44432. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44433. /**
  44434. * Called once for each button that changed state since the last frame
  44435. * @param buttonIdx Which button index changed
  44436. * @param state New state of the button
  44437. * @param changes Which properties on the state changed since last frame
  44438. */
  44439. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44440. }
  44441. }
  44442. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44443. import { Scene } from "babylonjs/scene";
  44444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44445. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44446. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44447. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44448. /**
  44449. * Generic Controller
  44450. */
  44451. export class GenericController extends WebVRController {
  44452. /**
  44453. * Base Url for the controller model.
  44454. */
  44455. static readonly MODEL_BASE_URL: string;
  44456. /**
  44457. * File name for the controller model.
  44458. */
  44459. static readonly MODEL_FILENAME: string;
  44460. /**
  44461. * Creates a new GenericController from a gamepad
  44462. * @param vrGamepad the gamepad that the controller should be created from
  44463. */
  44464. constructor(vrGamepad: any);
  44465. /**
  44466. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44467. * @param scene scene in which to add meshes
  44468. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44469. */
  44470. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44471. /**
  44472. * Called once for each button that changed state since the last frame
  44473. * @param buttonIdx Which button index changed
  44474. * @param state New state of the button
  44475. * @param changes Which properties on the state changed since last frame
  44476. */
  44477. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44478. }
  44479. }
  44480. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44481. import { Observable } from "babylonjs/Misc/observable";
  44482. import { Scene } from "babylonjs/scene";
  44483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44484. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44485. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44486. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44487. /**
  44488. * Oculus Touch Controller
  44489. */
  44490. export class OculusTouchController extends WebVRController {
  44491. /**
  44492. * Base Url for the controller model.
  44493. */
  44494. static MODEL_BASE_URL: string;
  44495. /**
  44496. * File name for the left controller model.
  44497. */
  44498. static MODEL_LEFT_FILENAME: string;
  44499. /**
  44500. * File name for the right controller model.
  44501. */
  44502. static MODEL_RIGHT_FILENAME: string;
  44503. /**
  44504. * Base Url for the Quest controller model.
  44505. */
  44506. static QUEST_MODEL_BASE_URL: string;
  44507. /**
  44508. * @hidden
  44509. * If the controllers are running on a device that needs the updated Quest controller models
  44510. */
  44511. static _IsQuest: boolean;
  44512. /**
  44513. * Fired when the secondary trigger on this controller is modified
  44514. */
  44515. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44516. /**
  44517. * Fired when the thumb rest on this controller is modified
  44518. */
  44519. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44520. /**
  44521. * Creates a new OculusTouchController from a gamepad
  44522. * @param vrGamepad the gamepad that the controller should be created from
  44523. */
  44524. constructor(vrGamepad: any);
  44525. /**
  44526. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44527. * @param scene scene in which to add meshes
  44528. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44529. */
  44530. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44531. /**
  44532. * Fired when the A button on this controller is modified
  44533. */
  44534. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44535. /**
  44536. * Fired when the B button on this controller is modified
  44537. */
  44538. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44539. /**
  44540. * Fired when the X button on this controller is modified
  44541. */
  44542. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44543. /**
  44544. * Fired when the Y button on this controller is modified
  44545. */
  44546. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44547. /**
  44548. * Called once for each button that changed state since the last frame
  44549. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44550. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44551. * 2) secondary trigger (same)
  44552. * 3) A (right) X (left), touch, pressed = value
  44553. * 4) B / Y
  44554. * 5) thumb rest
  44555. * @param buttonIdx Which button index changed
  44556. * @param state New state of the button
  44557. * @param changes Which properties on the state changed since last frame
  44558. */
  44559. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44560. }
  44561. }
  44562. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44563. import { Scene } from "babylonjs/scene";
  44564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44565. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44566. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44567. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44568. import { Observable } from "babylonjs/Misc/observable";
  44569. /**
  44570. * Vive Controller
  44571. */
  44572. export class ViveController extends WebVRController {
  44573. /**
  44574. * Base Url for the controller model.
  44575. */
  44576. static MODEL_BASE_URL: string;
  44577. /**
  44578. * File name for the controller model.
  44579. */
  44580. static MODEL_FILENAME: string;
  44581. /**
  44582. * Creates a new ViveController from a gamepad
  44583. * @param vrGamepad the gamepad that the controller should be created from
  44584. */
  44585. constructor(vrGamepad: any);
  44586. /**
  44587. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44588. * @param scene scene in which to add meshes
  44589. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44590. */
  44591. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44592. /**
  44593. * Fired when the left button on this controller is modified
  44594. */
  44595. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44596. /**
  44597. * Fired when the right button on this controller is modified
  44598. */
  44599. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44600. /**
  44601. * Fired when the menu button on this controller is modified
  44602. */
  44603. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44604. /**
  44605. * Called once for each button that changed state since the last frame
  44606. * Vive mapping:
  44607. * 0: touchpad
  44608. * 1: trigger
  44609. * 2: left AND right buttons
  44610. * 3: menu button
  44611. * @param buttonIdx Which button index changed
  44612. * @param state New state of the button
  44613. * @param changes Which properties on the state changed since last frame
  44614. */
  44615. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44616. }
  44617. }
  44618. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44619. import { Observable } from "babylonjs/Misc/observable";
  44620. import { Scene } from "babylonjs/scene";
  44621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44622. import { Ray } from "babylonjs/Culling/ray";
  44623. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44624. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44625. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44626. /**
  44627. * Defines the WindowsMotionController object that the state of the windows motion controller
  44628. */
  44629. export class WindowsMotionController extends WebVRController {
  44630. /**
  44631. * The base url used to load the left and right controller models
  44632. */
  44633. static MODEL_BASE_URL: string;
  44634. /**
  44635. * The name of the left controller model file
  44636. */
  44637. static MODEL_LEFT_FILENAME: string;
  44638. /**
  44639. * The name of the right controller model file
  44640. */
  44641. static MODEL_RIGHT_FILENAME: string;
  44642. /**
  44643. * The controller name prefix for this controller type
  44644. */
  44645. static readonly GAMEPAD_ID_PREFIX: string;
  44646. /**
  44647. * The controller id pattern for this controller type
  44648. */
  44649. private static readonly GAMEPAD_ID_PATTERN;
  44650. private _loadedMeshInfo;
  44651. private readonly _mapping;
  44652. /**
  44653. * Fired when the trackpad on this controller is clicked
  44654. */
  44655. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44656. /**
  44657. * Fired when the trackpad on this controller is modified
  44658. */
  44659. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44660. /**
  44661. * The current x and y values of this controller's trackpad
  44662. */
  44663. trackpad: StickValues;
  44664. /**
  44665. * Creates a new WindowsMotionController from a gamepad
  44666. * @param vrGamepad the gamepad that the controller should be created from
  44667. */
  44668. constructor(vrGamepad: any);
  44669. /**
  44670. * Fired when the trigger on this controller is modified
  44671. */
  44672. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44673. /**
  44674. * Fired when the menu button on this controller is modified
  44675. */
  44676. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44677. /**
  44678. * Fired when the grip button on this controller is modified
  44679. */
  44680. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44681. /**
  44682. * Fired when the thumbstick button on this controller is modified
  44683. */
  44684. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44685. /**
  44686. * Fired when the touchpad button on this controller is modified
  44687. */
  44688. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44689. /**
  44690. * Fired when the touchpad values on this controller are modified
  44691. */
  44692. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44693. private _updateTrackpad;
  44694. /**
  44695. * Called once per frame by the engine.
  44696. */
  44697. update(): void;
  44698. /**
  44699. * Called once for each button that changed state since the last frame
  44700. * @param buttonIdx Which button index changed
  44701. * @param state New state of the button
  44702. * @param changes Which properties on the state changed since last frame
  44703. */
  44704. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44705. /**
  44706. * Moves the buttons on the controller mesh based on their current state
  44707. * @param buttonName the name of the button to move
  44708. * @param buttonValue the value of the button which determines the buttons new position
  44709. */
  44710. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44711. /**
  44712. * Moves the axis on the controller mesh based on its current state
  44713. * @param axis the index of the axis
  44714. * @param axisValue the value of the axis which determines the meshes new position
  44715. * @hidden
  44716. */
  44717. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44718. /**
  44719. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44720. * @param scene scene in which to add meshes
  44721. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44722. */
  44723. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44724. /**
  44725. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44726. * can be transformed by button presses and axes values, based on this._mapping.
  44727. *
  44728. * @param scene scene in which the meshes exist
  44729. * @param meshes list of meshes that make up the controller model to process
  44730. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44731. */
  44732. private processModel;
  44733. private createMeshInfo;
  44734. /**
  44735. * Gets the ray of the controller in the direction the controller is pointing
  44736. * @param length the length the resulting ray should be
  44737. * @returns a ray in the direction the controller is pointing
  44738. */
  44739. getForwardRay(length?: number): Ray;
  44740. /**
  44741. * Disposes of the controller
  44742. */
  44743. dispose(): void;
  44744. }
  44745. }
  44746. declare module "babylonjs/Gamepads/Controllers/index" {
  44747. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44748. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44749. export * from "babylonjs/Gamepads/Controllers/genericController";
  44750. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44751. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44752. export * from "babylonjs/Gamepads/Controllers/viveController";
  44753. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44754. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44755. }
  44756. declare module "babylonjs/Gamepads/index" {
  44757. export * from "babylonjs/Gamepads/Controllers/index";
  44758. export * from "babylonjs/Gamepads/gamepad";
  44759. export * from "babylonjs/Gamepads/gamepadManager";
  44760. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44761. export * from "babylonjs/Gamepads/xboxGamepad";
  44762. }
  44763. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44764. import { Scene } from "babylonjs/scene";
  44765. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44766. import { Mesh } from "babylonjs/Meshes/mesh";
  44767. import { Nullable } from "babylonjs/types";
  44768. /**
  44769. * Class containing static functions to help procedurally build meshes
  44770. */
  44771. export class PolyhedronBuilder {
  44772. /**
  44773. * Creates a polyhedron mesh
  44774. * * 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
  44775. * * The parameter `size` (positive float, default 1) sets the polygon size
  44776. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44777. * * 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`
  44778. * * 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
  44779. * * 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)`)
  44780. * * 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
  44781. * * 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
  44782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44785. * @param name defines the name of the mesh
  44786. * @param options defines the options used to create the mesh
  44787. * @param scene defines the hosting scene
  44788. * @returns the polyhedron mesh
  44789. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44790. */
  44791. static CreatePolyhedron(name: string, options: {
  44792. type?: number;
  44793. size?: number;
  44794. sizeX?: number;
  44795. sizeY?: number;
  44796. sizeZ?: number;
  44797. custom?: any;
  44798. faceUV?: Vector4[];
  44799. faceColors?: Color4[];
  44800. flat?: boolean;
  44801. updatable?: boolean;
  44802. sideOrientation?: number;
  44803. frontUVs?: Vector4;
  44804. backUVs?: Vector4;
  44805. }, scene?: Nullable<Scene>): Mesh;
  44806. }
  44807. }
  44808. declare module "babylonjs/Gizmos/scaleGizmo" {
  44809. import { Observable } from "babylonjs/Misc/observable";
  44810. import { Nullable } from "babylonjs/types";
  44811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44812. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44813. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44814. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44815. /**
  44816. * Gizmo that enables scaling a mesh along 3 axis
  44817. */
  44818. export class ScaleGizmo extends Gizmo {
  44819. /**
  44820. * Internal gizmo used for interactions on the x axis
  44821. */
  44822. xGizmo: AxisScaleGizmo;
  44823. /**
  44824. * Internal gizmo used for interactions on the y axis
  44825. */
  44826. yGizmo: AxisScaleGizmo;
  44827. /**
  44828. * Internal gizmo used for interactions on the z axis
  44829. */
  44830. zGizmo: AxisScaleGizmo;
  44831. /**
  44832. * Internal gizmo used to scale all axis equally
  44833. */
  44834. uniformScaleGizmo: AxisScaleGizmo;
  44835. private _meshAttached;
  44836. private _updateGizmoRotationToMatchAttachedMesh;
  44837. private _snapDistance;
  44838. private _scaleRatio;
  44839. private _uniformScalingMesh;
  44840. private _octahedron;
  44841. /** Fires an event when any of it's sub gizmos are dragged */
  44842. onDragStartObservable: Observable<unknown>;
  44843. /** Fires an event when any of it's sub gizmos are released from dragging */
  44844. onDragEndObservable: Observable<unknown>;
  44845. attachedMesh: Nullable<AbstractMesh>;
  44846. /**
  44847. * Creates a ScaleGizmo
  44848. * @param gizmoLayer The utility layer the gizmo will be added to
  44849. */
  44850. constructor(gizmoLayer?: UtilityLayerRenderer);
  44851. updateGizmoRotationToMatchAttachedMesh: boolean;
  44852. /**
  44853. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44854. */
  44855. snapDistance: number;
  44856. /**
  44857. * Ratio for the scale of the gizmo (Default: 1)
  44858. */
  44859. scaleRatio: number;
  44860. /**
  44861. * Disposes of the gizmo
  44862. */
  44863. dispose(): void;
  44864. }
  44865. }
  44866. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44867. import { Observable } from "babylonjs/Misc/observable";
  44868. import { Nullable } from "babylonjs/types";
  44869. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44871. import { Mesh } from "babylonjs/Meshes/mesh";
  44872. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44873. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44874. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44875. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44876. /**
  44877. * Single axis scale gizmo
  44878. */
  44879. export class AxisScaleGizmo extends Gizmo {
  44880. /**
  44881. * Drag behavior responsible for the gizmos dragging interactions
  44882. */
  44883. dragBehavior: PointerDragBehavior;
  44884. private _pointerObserver;
  44885. /**
  44886. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44887. */
  44888. snapDistance: number;
  44889. /**
  44890. * Event that fires each time the gizmo snaps to a new location.
  44891. * * snapDistance is the the change in distance
  44892. */
  44893. onSnapObservable: Observable<{
  44894. snapDistance: number;
  44895. }>;
  44896. /**
  44897. * If the scaling operation should be done on all axis (default: false)
  44898. */
  44899. uniformScaling: boolean;
  44900. private _isEnabled;
  44901. private _parent;
  44902. private _arrow;
  44903. private _coloredMaterial;
  44904. private _hoverMaterial;
  44905. /**
  44906. * Creates an AxisScaleGizmo
  44907. * @param gizmoLayer The utility layer the gizmo will be added to
  44908. * @param dragAxis The axis which the gizmo will be able to scale on
  44909. * @param color The color of the gizmo
  44910. */
  44911. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44912. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44913. /**
  44914. * If the gizmo is enabled
  44915. */
  44916. isEnabled: boolean;
  44917. /**
  44918. * Disposes of the gizmo
  44919. */
  44920. dispose(): void;
  44921. /**
  44922. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44923. * @param mesh The mesh to replace the default mesh of the gizmo
  44924. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44925. */
  44926. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44927. }
  44928. }
  44929. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44930. import { Observable } from "babylonjs/Misc/observable";
  44931. import { Nullable } from "babylonjs/types";
  44932. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44934. import { Mesh } from "babylonjs/Meshes/mesh";
  44935. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44936. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44937. import "babylonjs/Meshes/Builders/boxBuilder";
  44938. /**
  44939. * Bounding box gizmo
  44940. */
  44941. export class BoundingBoxGizmo extends Gizmo {
  44942. private _lineBoundingBox;
  44943. private _rotateSpheresParent;
  44944. private _scaleBoxesParent;
  44945. private _boundingDimensions;
  44946. private _renderObserver;
  44947. private _pointerObserver;
  44948. private _scaleDragSpeed;
  44949. private _tmpQuaternion;
  44950. private _tmpVector;
  44951. private _tmpRotationMatrix;
  44952. /**
  44953. * 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)
  44954. */
  44955. ignoreChildren: boolean;
  44956. /**
  44957. * 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)
  44958. */
  44959. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44960. /**
  44961. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44962. */
  44963. rotationSphereSize: number;
  44964. /**
  44965. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44966. */
  44967. scaleBoxSize: number;
  44968. /**
  44969. * 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)
  44970. */
  44971. fixedDragMeshScreenSize: boolean;
  44972. /**
  44973. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44974. */
  44975. fixedDragMeshScreenSizeDistanceFactor: number;
  44976. /**
  44977. * Fired when a rotation sphere or scale box is dragged
  44978. */
  44979. onDragStartObservable: Observable<{}>;
  44980. /**
  44981. * Fired when a scale box is dragged
  44982. */
  44983. onScaleBoxDragObservable: Observable<{}>;
  44984. /**
  44985. * Fired when a scale box drag is ended
  44986. */
  44987. onScaleBoxDragEndObservable: Observable<{}>;
  44988. /**
  44989. * Fired when a rotation sphere is dragged
  44990. */
  44991. onRotationSphereDragObservable: Observable<{}>;
  44992. /**
  44993. * Fired when a rotation sphere drag is ended
  44994. */
  44995. onRotationSphereDragEndObservable: Observable<{}>;
  44996. /**
  44997. * 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)
  44998. */
  44999. scalePivot: Nullable<Vector3>;
  45000. /**
  45001. * Mesh used as a pivot to rotate the attached mesh
  45002. */
  45003. private _anchorMesh;
  45004. private _existingMeshScale;
  45005. private _dragMesh;
  45006. private pointerDragBehavior;
  45007. private coloredMaterial;
  45008. private hoverColoredMaterial;
  45009. /**
  45010. * Sets the color of the bounding box gizmo
  45011. * @param color the color to set
  45012. */
  45013. setColor(color: Color3): void;
  45014. /**
  45015. * Creates an BoundingBoxGizmo
  45016. * @param gizmoLayer The utility layer the gizmo will be added to
  45017. * @param color The color of the gizmo
  45018. */
  45019. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45020. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45021. private _selectNode;
  45022. /**
  45023. * Updates the bounding box information for the Gizmo
  45024. */
  45025. updateBoundingBox(): void;
  45026. private _updateRotationSpheres;
  45027. private _updateScaleBoxes;
  45028. /**
  45029. * Enables rotation on the specified axis and disables rotation on the others
  45030. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45031. */
  45032. setEnabledRotationAxis(axis: string): void;
  45033. /**
  45034. * Enables/disables scaling
  45035. * @param enable if scaling should be enabled
  45036. */
  45037. setEnabledScaling(enable: boolean): void;
  45038. private _updateDummy;
  45039. /**
  45040. * Enables a pointer drag behavior on the bounding box of the gizmo
  45041. */
  45042. enableDragBehavior(): void;
  45043. /**
  45044. * Disposes of the gizmo
  45045. */
  45046. dispose(): void;
  45047. /**
  45048. * 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)
  45049. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45050. * @returns the bounding box mesh with the passed in mesh as a child
  45051. */
  45052. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45053. /**
  45054. * CustomMeshes are not supported by this gizmo
  45055. * @param mesh The mesh to replace the default mesh of the gizmo
  45056. */
  45057. setCustomMesh(mesh: Mesh): void;
  45058. }
  45059. }
  45060. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45061. import { Observable } from "babylonjs/Misc/observable";
  45062. import { Nullable } from "babylonjs/types";
  45063. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45065. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45066. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45067. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45068. import "babylonjs/Meshes/Builders/linesBuilder";
  45069. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45070. /**
  45071. * Single plane rotation gizmo
  45072. */
  45073. export class PlaneRotationGizmo extends Gizmo {
  45074. /**
  45075. * Drag behavior responsible for the gizmos dragging interactions
  45076. */
  45077. dragBehavior: PointerDragBehavior;
  45078. private _pointerObserver;
  45079. /**
  45080. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45081. */
  45082. snapDistance: number;
  45083. /**
  45084. * Event that fires each time the gizmo snaps to a new location.
  45085. * * snapDistance is the the change in distance
  45086. */
  45087. onSnapObservable: Observable<{
  45088. snapDistance: number;
  45089. }>;
  45090. private _isEnabled;
  45091. private _parent;
  45092. /**
  45093. * Creates a PlaneRotationGizmo
  45094. * @param gizmoLayer The utility layer the gizmo will be added to
  45095. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45096. * @param color The color of the gizmo
  45097. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45098. */
  45099. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45100. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45101. /**
  45102. * If the gizmo is enabled
  45103. */
  45104. isEnabled: boolean;
  45105. /**
  45106. * Disposes of the gizmo
  45107. */
  45108. dispose(): void;
  45109. }
  45110. }
  45111. declare module "babylonjs/Gizmos/rotationGizmo" {
  45112. import { Observable } from "babylonjs/Misc/observable";
  45113. import { Nullable } from "babylonjs/types";
  45114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45115. import { Mesh } from "babylonjs/Meshes/mesh";
  45116. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45117. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45118. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45119. /**
  45120. * Gizmo that enables rotating a mesh along 3 axis
  45121. */
  45122. export class RotationGizmo extends Gizmo {
  45123. /**
  45124. * Internal gizmo used for interactions on the x axis
  45125. */
  45126. xGizmo: PlaneRotationGizmo;
  45127. /**
  45128. * Internal gizmo used for interactions on the y axis
  45129. */
  45130. yGizmo: PlaneRotationGizmo;
  45131. /**
  45132. * Internal gizmo used for interactions on the z axis
  45133. */
  45134. zGizmo: PlaneRotationGizmo;
  45135. /** Fires an event when any of it's sub gizmos are dragged */
  45136. onDragStartObservable: Observable<unknown>;
  45137. /** Fires an event when any of it's sub gizmos are released from dragging */
  45138. onDragEndObservable: Observable<unknown>;
  45139. private _meshAttached;
  45140. attachedMesh: Nullable<AbstractMesh>;
  45141. /**
  45142. * Creates a RotationGizmo
  45143. * @param gizmoLayer The utility layer the gizmo will be added to
  45144. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45145. */
  45146. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45147. updateGizmoRotationToMatchAttachedMesh: boolean;
  45148. /**
  45149. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45150. */
  45151. snapDistance: number;
  45152. /**
  45153. * Ratio for the scale of the gizmo (Default: 1)
  45154. */
  45155. scaleRatio: number;
  45156. /**
  45157. * Disposes of the gizmo
  45158. */
  45159. dispose(): void;
  45160. /**
  45161. * CustomMeshes are not supported by this gizmo
  45162. * @param mesh The mesh to replace the default mesh of the gizmo
  45163. */
  45164. setCustomMesh(mesh: Mesh): void;
  45165. }
  45166. }
  45167. declare module "babylonjs/Gizmos/gizmoManager" {
  45168. import { Observable } from "babylonjs/Misc/observable";
  45169. import { Nullable } from "babylonjs/types";
  45170. import { Scene, IDisposable } from "babylonjs/scene";
  45171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45172. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45173. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45174. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45175. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45176. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45177. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45178. /**
  45179. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45180. */
  45181. export class GizmoManager implements IDisposable {
  45182. private scene;
  45183. /**
  45184. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45185. */
  45186. gizmos: {
  45187. positionGizmo: Nullable<PositionGizmo>;
  45188. rotationGizmo: Nullable<RotationGizmo>;
  45189. scaleGizmo: Nullable<ScaleGizmo>;
  45190. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45191. };
  45192. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45193. clearGizmoOnEmptyPointerEvent: boolean;
  45194. /** Fires an event when the manager is attached to a mesh */
  45195. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45196. private _gizmosEnabled;
  45197. private _pointerObserver;
  45198. private _attachedMesh;
  45199. private _boundingBoxColor;
  45200. private _defaultUtilityLayer;
  45201. private _defaultKeepDepthUtilityLayer;
  45202. /**
  45203. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45204. */
  45205. boundingBoxDragBehavior: SixDofDragBehavior;
  45206. /**
  45207. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45208. */
  45209. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45210. /**
  45211. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45212. */
  45213. usePointerToAttachGizmos: boolean;
  45214. /**
  45215. * Utility layer that the bounding box gizmo belongs to
  45216. */
  45217. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45218. /**
  45219. * Utility layer that all gizmos besides bounding box belong to
  45220. */
  45221. readonly utilityLayer: UtilityLayerRenderer;
  45222. /**
  45223. * Instatiates a gizmo manager
  45224. * @param scene the scene to overlay the gizmos on top of
  45225. */
  45226. constructor(scene: Scene);
  45227. /**
  45228. * Attaches a set of gizmos to the specified mesh
  45229. * @param mesh The mesh the gizmo's should be attached to
  45230. */
  45231. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45232. /**
  45233. * If the position gizmo is enabled
  45234. */
  45235. positionGizmoEnabled: boolean;
  45236. /**
  45237. * If the rotation gizmo is enabled
  45238. */
  45239. rotationGizmoEnabled: boolean;
  45240. /**
  45241. * If the scale gizmo is enabled
  45242. */
  45243. scaleGizmoEnabled: boolean;
  45244. /**
  45245. * If the boundingBox gizmo is enabled
  45246. */
  45247. boundingBoxGizmoEnabled: boolean;
  45248. /**
  45249. * Disposes of the gizmo manager
  45250. */
  45251. dispose(): void;
  45252. }
  45253. }
  45254. declare module "babylonjs/Lights/directionalLight" {
  45255. import { Camera } from "babylonjs/Cameras/camera";
  45256. import { Scene } from "babylonjs/scene";
  45257. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45259. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45260. import { Effect } from "babylonjs/Materials/effect";
  45261. /**
  45262. * A directional light is defined by a direction (what a surprise!).
  45263. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45264. * 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.
  45265. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45266. */
  45267. export class DirectionalLight extends ShadowLight {
  45268. private _shadowFrustumSize;
  45269. /**
  45270. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45271. */
  45272. /**
  45273. * Specifies a fix frustum size for the shadow generation.
  45274. */
  45275. shadowFrustumSize: number;
  45276. private _shadowOrthoScale;
  45277. /**
  45278. * Gets the shadow projection scale against the optimal computed one.
  45279. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45280. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45281. */
  45282. /**
  45283. * Sets the shadow projection scale against the optimal computed one.
  45284. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45285. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45286. */
  45287. shadowOrthoScale: number;
  45288. /**
  45289. * Automatically compute the projection matrix to best fit (including all the casters)
  45290. * on each frame.
  45291. */
  45292. autoUpdateExtends: boolean;
  45293. private _orthoLeft;
  45294. private _orthoRight;
  45295. private _orthoTop;
  45296. private _orthoBottom;
  45297. /**
  45298. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45299. * The directional light is emitted from everywhere in the given direction.
  45300. * It can cast shadows.
  45301. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45302. * @param name The friendly name of the light
  45303. * @param direction The direction of the light
  45304. * @param scene The scene the light belongs to
  45305. */
  45306. constructor(name: string, direction: Vector3, scene: Scene);
  45307. /**
  45308. * Returns the string "DirectionalLight".
  45309. * @return The class name
  45310. */
  45311. getClassName(): string;
  45312. /**
  45313. * Returns the integer 1.
  45314. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45315. */
  45316. getTypeID(): number;
  45317. /**
  45318. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45319. * Returns the DirectionalLight Shadow projection matrix.
  45320. */
  45321. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45322. /**
  45323. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45324. * Returns the DirectionalLight Shadow projection matrix.
  45325. */
  45326. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45327. /**
  45328. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45329. * Returns the DirectionalLight Shadow projection matrix.
  45330. */
  45331. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45332. protected _buildUniformLayout(): void;
  45333. /**
  45334. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45335. * @param effect The effect to update
  45336. * @param lightIndex The index of the light in the effect to update
  45337. * @returns The directional light
  45338. */
  45339. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45340. /**
  45341. * Gets the minZ used for shadow according to both the scene and the light.
  45342. *
  45343. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45344. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45345. * @param activeCamera The camera we are returning the min for
  45346. * @returns the depth min z
  45347. */
  45348. getDepthMinZ(activeCamera: Camera): number;
  45349. /**
  45350. * Gets the maxZ used for shadow according to both the scene and the light.
  45351. *
  45352. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45353. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45354. * @param activeCamera The camera we are returning the max for
  45355. * @returns the depth max z
  45356. */
  45357. getDepthMaxZ(activeCamera: Camera): number;
  45358. /**
  45359. * Prepares the list of defines specific to the light type.
  45360. * @param defines the list of defines
  45361. * @param lightIndex defines the index of the light for the effect
  45362. */
  45363. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45364. }
  45365. }
  45366. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45367. import { Mesh } from "babylonjs/Meshes/mesh";
  45368. /**
  45369. * Class containing static functions to help procedurally build meshes
  45370. */
  45371. export class HemisphereBuilder {
  45372. /**
  45373. * Creates a hemisphere mesh
  45374. * @param name defines the name of the mesh
  45375. * @param options defines the options used to create the mesh
  45376. * @param scene defines the hosting scene
  45377. * @returns the hemisphere mesh
  45378. */
  45379. static CreateHemisphere(name: string, options: {
  45380. segments?: number;
  45381. diameter?: number;
  45382. sideOrientation?: number;
  45383. }, scene: any): Mesh;
  45384. }
  45385. }
  45386. declare module "babylonjs/Lights/spotLight" {
  45387. import { Nullable } from "babylonjs/types";
  45388. import { Scene } from "babylonjs/scene";
  45389. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45391. import { Effect } from "babylonjs/Materials/effect";
  45392. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45393. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45394. /**
  45395. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45396. * These values define a cone of light starting from the position, emitting toward the direction.
  45397. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45398. * and the exponent defines the speed of the decay of the light with distance (reach).
  45399. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45400. */
  45401. export class SpotLight extends ShadowLight {
  45402. private _angle;
  45403. private _innerAngle;
  45404. private _cosHalfAngle;
  45405. private _lightAngleScale;
  45406. private _lightAngleOffset;
  45407. /**
  45408. * Gets the cone angle of the spot light in Radians.
  45409. */
  45410. /**
  45411. * Sets the cone angle of the spot light in Radians.
  45412. */
  45413. angle: number;
  45414. /**
  45415. * Only used in gltf falloff mode, this defines the angle where
  45416. * the directional falloff will start before cutting at angle which could be seen
  45417. * as outer angle.
  45418. */
  45419. /**
  45420. * Only used in gltf falloff mode, this defines the angle where
  45421. * the directional falloff will start before cutting at angle which could be seen
  45422. * as outer angle.
  45423. */
  45424. innerAngle: number;
  45425. private _shadowAngleScale;
  45426. /**
  45427. * Allows scaling the angle of the light for shadow generation only.
  45428. */
  45429. /**
  45430. * Allows scaling the angle of the light for shadow generation only.
  45431. */
  45432. shadowAngleScale: number;
  45433. /**
  45434. * The light decay speed with the distance from the emission spot.
  45435. */
  45436. exponent: number;
  45437. private _projectionTextureMatrix;
  45438. /**
  45439. * Allows reading the projecton texture
  45440. */
  45441. readonly projectionTextureMatrix: Matrix;
  45442. protected _projectionTextureLightNear: number;
  45443. /**
  45444. * Gets the near clip of the Spotlight for texture projection.
  45445. */
  45446. /**
  45447. * Sets the near clip of the Spotlight for texture projection.
  45448. */
  45449. projectionTextureLightNear: number;
  45450. protected _projectionTextureLightFar: number;
  45451. /**
  45452. * Gets the far clip of the Spotlight for texture projection.
  45453. */
  45454. /**
  45455. * Sets the far clip of the Spotlight for texture projection.
  45456. */
  45457. projectionTextureLightFar: number;
  45458. protected _projectionTextureUpDirection: Vector3;
  45459. /**
  45460. * Gets the Up vector of the Spotlight for texture projection.
  45461. */
  45462. /**
  45463. * Sets the Up vector of the Spotlight for texture projection.
  45464. */
  45465. projectionTextureUpDirection: Vector3;
  45466. private _projectionTexture;
  45467. /**
  45468. * Gets the projection texture of the light.
  45469. */
  45470. /**
  45471. * Sets the projection texture of the light.
  45472. */
  45473. projectionTexture: Nullable<BaseTexture>;
  45474. private _projectionTextureViewLightDirty;
  45475. private _projectionTextureProjectionLightDirty;
  45476. private _projectionTextureDirty;
  45477. private _projectionTextureViewTargetVector;
  45478. private _projectionTextureViewLightMatrix;
  45479. private _projectionTextureProjectionLightMatrix;
  45480. private _projectionTextureScalingMatrix;
  45481. /**
  45482. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45483. * It can cast shadows.
  45484. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45485. * @param name The light friendly name
  45486. * @param position The position of the spot light in the scene
  45487. * @param direction The direction of the light in the scene
  45488. * @param angle The cone angle of the light in Radians
  45489. * @param exponent The light decay speed with the distance from the emission spot
  45490. * @param scene The scene the lights belongs to
  45491. */
  45492. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45493. /**
  45494. * Returns the string "SpotLight".
  45495. * @returns the class name
  45496. */
  45497. getClassName(): string;
  45498. /**
  45499. * Returns the integer 2.
  45500. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45501. */
  45502. getTypeID(): number;
  45503. /**
  45504. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45505. */
  45506. protected _setDirection(value: Vector3): void;
  45507. /**
  45508. * Overrides the position setter to recompute the projection texture view light Matrix.
  45509. */
  45510. protected _setPosition(value: Vector3): void;
  45511. /**
  45512. * 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.
  45513. * Returns the SpotLight.
  45514. */
  45515. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45516. protected _computeProjectionTextureViewLightMatrix(): void;
  45517. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45518. /**
  45519. * Main function for light texture projection matrix computing.
  45520. */
  45521. protected _computeProjectionTextureMatrix(): void;
  45522. protected _buildUniformLayout(): void;
  45523. private _computeAngleValues;
  45524. /**
  45525. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45526. * @param effect The effect to update
  45527. * @param lightIndex The index of the light in the effect to update
  45528. * @returns The spot light
  45529. */
  45530. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45531. /**
  45532. * Disposes the light and the associated resources.
  45533. */
  45534. dispose(): void;
  45535. /**
  45536. * Prepares the list of defines specific to the light type.
  45537. * @param defines the list of defines
  45538. * @param lightIndex defines the index of the light for the effect
  45539. */
  45540. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45541. }
  45542. }
  45543. declare module "babylonjs/Gizmos/lightGizmo" {
  45544. import { Nullable } from "babylonjs/types";
  45545. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45546. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45547. import { Light } from "babylonjs/Lights/light";
  45548. /**
  45549. * Gizmo that enables viewing a light
  45550. */
  45551. export class LightGizmo extends Gizmo {
  45552. private _lightMesh;
  45553. private _material;
  45554. private cachedPosition;
  45555. private cachedForward;
  45556. /**
  45557. * Creates a LightGizmo
  45558. * @param gizmoLayer The utility layer the gizmo will be added to
  45559. */
  45560. constructor(gizmoLayer?: UtilityLayerRenderer);
  45561. private _light;
  45562. /**
  45563. * The light that the gizmo is attached to
  45564. */
  45565. light: Nullable<Light>;
  45566. /**
  45567. * @hidden
  45568. * Updates the gizmo to match the attached mesh's position/rotation
  45569. */
  45570. protected _update(): void;
  45571. private static _Scale;
  45572. /**
  45573. * Creates the lines for a light mesh
  45574. */
  45575. private static _createLightLines;
  45576. /**
  45577. * Disposes of the light gizmo
  45578. */
  45579. dispose(): void;
  45580. private static _CreateHemisphericLightMesh;
  45581. private static _CreatePointLightMesh;
  45582. private static _CreateSpotLightMesh;
  45583. private static _CreateDirectionalLightMesh;
  45584. }
  45585. }
  45586. declare module "babylonjs/Gizmos/index" {
  45587. export * from "babylonjs/Gizmos/axisDragGizmo";
  45588. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45589. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45590. export * from "babylonjs/Gizmos/gizmo";
  45591. export * from "babylonjs/Gizmos/gizmoManager";
  45592. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45593. export * from "babylonjs/Gizmos/positionGizmo";
  45594. export * from "babylonjs/Gizmos/rotationGizmo";
  45595. export * from "babylonjs/Gizmos/scaleGizmo";
  45596. export * from "babylonjs/Gizmos/lightGizmo";
  45597. }
  45598. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45599. /** @hidden */
  45600. export var backgroundFragmentDeclaration: {
  45601. name: string;
  45602. shader: string;
  45603. };
  45604. }
  45605. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45606. /** @hidden */
  45607. export var backgroundUboDeclaration: {
  45608. name: string;
  45609. shader: string;
  45610. };
  45611. }
  45612. declare module "babylonjs/Shaders/background.fragment" {
  45613. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45614. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45615. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45616. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45617. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45618. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45619. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45620. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45621. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45622. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45623. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45624. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45625. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45626. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45627. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45628. /** @hidden */
  45629. export var backgroundPixelShader: {
  45630. name: string;
  45631. shader: string;
  45632. };
  45633. }
  45634. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45635. /** @hidden */
  45636. export var backgroundVertexDeclaration: {
  45637. name: string;
  45638. shader: string;
  45639. };
  45640. }
  45641. declare module "babylonjs/Shaders/background.vertex" {
  45642. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45643. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45644. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45645. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45646. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45647. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45648. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45649. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45650. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45651. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45652. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45653. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45654. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45655. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45656. /** @hidden */
  45657. export var backgroundVertexShader: {
  45658. name: string;
  45659. shader: string;
  45660. };
  45661. }
  45662. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45663. import { Nullable, int, float } from "babylonjs/types";
  45664. import { Scene } from "babylonjs/scene";
  45665. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45666. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45668. import { Mesh } from "babylonjs/Meshes/mesh";
  45669. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45670. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45671. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45672. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45673. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45674. import "babylonjs/Shaders/background.fragment";
  45675. import "babylonjs/Shaders/background.vertex";
  45676. /**
  45677. * Background material used to create an efficient environement around your scene.
  45678. */
  45679. export class BackgroundMaterial extends PushMaterial {
  45680. /**
  45681. * Standard reflectance value at parallel view angle.
  45682. */
  45683. static StandardReflectance0: number;
  45684. /**
  45685. * Standard reflectance value at grazing angle.
  45686. */
  45687. static StandardReflectance90: number;
  45688. protected _primaryColor: Color3;
  45689. /**
  45690. * Key light Color (multiply against the environement texture)
  45691. */
  45692. primaryColor: Color3;
  45693. protected __perceptualColor: Nullable<Color3>;
  45694. /**
  45695. * Experimental Internal Use Only.
  45696. *
  45697. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45698. * This acts as a helper to set the primary color to a more "human friendly" value.
  45699. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45700. * output color as close as possible from the chosen value.
  45701. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45702. * part of lighting setup.)
  45703. */
  45704. _perceptualColor: Nullable<Color3>;
  45705. protected _primaryColorShadowLevel: float;
  45706. /**
  45707. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45708. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45709. */
  45710. primaryColorShadowLevel: float;
  45711. protected _primaryColorHighlightLevel: float;
  45712. /**
  45713. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45714. * The primary color is used at the level chosen to define what the white area would look.
  45715. */
  45716. primaryColorHighlightLevel: float;
  45717. protected _reflectionTexture: Nullable<BaseTexture>;
  45718. /**
  45719. * Reflection Texture used in the material.
  45720. * Should be author in a specific way for the best result (refer to the documentation).
  45721. */
  45722. reflectionTexture: Nullable<BaseTexture>;
  45723. protected _reflectionBlur: float;
  45724. /**
  45725. * Reflection Texture level of blur.
  45726. *
  45727. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45728. * texture twice.
  45729. */
  45730. reflectionBlur: float;
  45731. protected _diffuseTexture: Nullable<BaseTexture>;
  45732. /**
  45733. * Diffuse Texture used in the material.
  45734. * Should be author in a specific way for the best result (refer to the documentation).
  45735. */
  45736. diffuseTexture: Nullable<BaseTexture>;
  45737. protected _shadowLights: Nullable<IShadowLight[]>;
  45738. /**
  45739. * Specify the list of lights casting shadow on the material.
  45740. * All scene shadow lights will be included if null.
  45741. */
  45742. shadowLights: Nullable<IShadowLight[]>;
  45743. protected _shadowLevel: float;
  45744. /**
  45745. * Helps adjusting the shadow to a softer level if required.
  45746. * 0 means black shadows and 1 means no shadows.
  45747. */
  45748. shadowLevel: float;
  45749. protected _sceneCenter: Vector3;
  45750. /**
  45751. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45752. * It is usually zero but might be interesting to modify according to your setup.
  45753. */
  45754. sceneCenter: Vector3;
  45755. protected _opacityFresnel: boolean;
  45756. /**
  45757. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45758. * This helps ensuring a nice transition when the camera goes under the ground.
  45759. */
  45760. opacityFresnel: boolean;
  45761. protected _reflectionFresnel: boolean;
  45762. /**
  45763. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45764. * This helps adding a mirror texture on the ground.
  45765. */
  45766. reflectionFresnel: boolean;
  45767. protected _reflectionFalloffDistance: number;
  45768. /**
  45769. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45770. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45771. */
  45772. reflectionFalloffDistance: number;
  45773. protected _reflectionAmount: number;
  45774. /**
  45775. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45776. */
  45777. reflectionAmount: number;
  45778. protected _reflectionReflectance0: number;
  45779. /**
  45780. * This specifies the weight of the reflection at grazing angle.
  45781. */
  45782. reflectionReflectance0: number;
  45783. protected _reflectionReflectance90: number;
  45784. /**
  45785. * This specifies the weight of the reflection at a perpendicular point of view.
  45786. */
  45787. reflectionReflectance90: number;
  45788. /**
  45789. * Sets the reflection reflectance fresnel values according to the default standard
  45790. * empirically know to work well :-)
  45791. */
  45792. reflectionStandardFresnelWeight: number;
  45793. protected _useRGBColor: boolean;
  45794. /**
  45795. * Helps to directly use the maps channels instead of their level.
  45796. */
  45797. useRGBColor: boolean;
  45798. protected _enableNoise: boolean;
  45799. /**
  45800. * This helps reducing the banding effect that could occur on the background.
  45801. */
  45802. enableNoise: boolean;
  45803. /**
  45804. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45805. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45806. * Recommended to be keep at 1.0 except for special cases.
  45807. */
  45808. fovMultiplier: number;
  45809. private _fovMultiplier;
  45810. /**
  45811. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45812. */
  45813. useEquirectangularFOV: boolean;
  45814. private _maxSimultaneousLights;
  45815. /**
  45816. * Number of Simultaneous lights allowed on the material.
  45817. */
  45818. maxSimultaneousLights: int;
  45819. /**
  45820. * Default configuration related to image processing available in the Background Material.
  45821. */
  45822. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45823. /**
  45824. * Keep track of the image processing observer to allow dispose and replace.
  45825. */
  45826. private _imageProcessingObserver;
  45827. /**
  45828. * Attaches a new image processing configuration to the PBR Material.
  45829. * @param configuration (if null the scene configuration will be use)
  45830. */
  45831. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45832. /**
  45833. * Gets the image processing configuration used either in this material.
  45834. */
  45835. /**
  45836. * Sets the Default image processing configuration used either in the this material.
  45837. *
  45838. * If sets to null, the scene one is in use.
  45839. */
  45840. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45841. /**
  45842. * Gets wether the color curves effect is enabled.
  45843. */
  45844. /**
  45845. * Sets wether the color curves effect is enabled.
  45846. */
  45847. cameraColorCurvesEnabled: boolean;
  45848. /**
  45849. * Gets wether the color grading effect is enabled.
  45850. */
  45851. /**
  45852. * Gets wether the color grading effect is enabled.
  45853. */
  45854. cameraColorGradingEnabled: boolean;
  45855. /**
  45856. * Gets wether tonemapping is enabled or not.
  45857. */
  45858. /**
  45859. * Sets wether tonemapping is enabled or not
  45860. */
  45861. cameraToneMappingEnabled: boolean;
  45862. /**
  45863. * The camera exposure used on this material.
  45864. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45865. * This corresponds to a photographic exposure.
  45866. */
  45867. /**
  45868. * The camera exposure used on this material.
  45869. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45870. * This corresponds to a photographic exposure.
  45871. */
  45872. cameraExposure: float;
  45873. /**
  45874. * Gets The camera contrast used on this material.
  45875. */
  45876. /**
  45877. * Sets The camera contrast used on this material.
  45878. */
  45879. cameraContrast: float;
  45880. /**
  45881. * Gets the Color Grading 2D Lookup Texture.
  45882. */
  45883. /**
  45884. * Sets the Color Grading 2D Lookup Texture.
  45885. */
  45886. cameraColorGradingTexture: Nullable<BaseTexture>;
  45887. /**
  45888. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45889. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45890. * 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;
  45891. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45892. */
  45893. /**
  45894. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45895. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45896. * 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;
  45897. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45898. */
  45899. cameraColorCurves: Nullable<ColorCurves>;
  45900. /**
  45901. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45902. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45903. */
  45904. switchToBGR: boolean;
  45905. private _renderTargets;
  45906. private _reflectionControls;
  45907. private _white;
  45908. private _primaryShadowColor;
  45909. private _primaryHighlightColor;
  45910. /**
  45911. * Instantiates a Background Material in the given scene
  45912. * @param name The friendly name of the material
  45913. * @param scene The scene to add the material to
  45914. */
  45915. constructor(name: string, scene: Scene);
  45916. /**
  45917. * Gets a boolean indicating that current material needs to register RTT
  45918. */
  45919. readonly hasRenderTargetTextures: boolean;
  45920. /**
  45921. * The entire material has been created in order to prevent overdraw.
  45922. * @returns false
  45923. */
  45924. needAlphaTesting(): boolean;
  45925. /**
  45926. * The entire material has been created in order to prevent overdraw.
  45927. * @returns true if blending is enable
  45928. */
  45929. needAlphaBlending(): boolean;
  45930. /**
  45931. * Checks wether the material is ready to be rendered for a given mesh.
  45932. * @param mesh The mesh to render
  45933. * @param subMesh The submesh to check against
  45934. * @param useInstances Specify wether or not the material is used with instances
  45935. * @returns true if all the dependencies are ready (Textures, Effects...)
  45936. */
  45937. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45938. /**
  45939. * Compute the primary color according to the chosen perceptual color.
  45940. */
  45941. private _computePrimaryColorFromPerceptualColor;
  45942. /**
  45943. * Compute the highlights and shadow colors according to their chosen levels.
  45944. */
  45945. private _computePrimaryColors;
  45946. /**
  45947. * Build the uniform buffer used in the material.
  45948. */
  45949. buildUniformLayout(): void;
  45950. /**
  45951. * Unbind the material.
  45952. */
  45953. unbind(): void;
  45954. /**
  45955. * Bind only the world matrix to the material.
  45956. * @param world The world matrix to bind.
  45957. */
  45958. bindOnlyWorldMatrix(world: Matrix): void;
  45959. /**
  45960. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45961. * @param world The world matrix to bind.
  45962. * @param subMesh The submesh to bind for.
  45963. */
  45964. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45965. /**
  45966. * Dispose the material.
  45967. * @param forceDisposeEffect Force disposal of the associated effect.
  45968. * @param forceDisposeTextures Force disposal of the associated textures.
  45969. */
  45970. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45971. /**
  45972. * Clones the material.
  45973. * @param name The cloned name.
  45974. * @returns The cloned material.
  45975. */
  45976. clone(name: string): BackgroundMaterial;
  45977. /**
  45978. * Serializes the current material to its JSON representation.
  45979. * @returns The JSON representation.
  45980. */
  45981. serialize(): any;
  45982. /**
  45983. * Gets the class name of the material
  45984. * @returns "BackgroundMaterial"
  45985. */
  45986. getClassName(): string;
  45987. /**
  45988. * Parse a JSON input to create back a background material.
  45989. * @param source The JSON data to parse
  45990. * @param scene The scene to create the parsed material in
  45991. * @param rootUrl The root url of the assets the material depends upon
  45992. * @returns the instantiated BackgroundMaterial.
  45993. */
  45994. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45995. }
  45996. }
  45997. declare module "babylonjs/Helpers/environmentHelper" {
  45998. import { Observable } from "babylonjs/Misc/observable";
  45999. import { Nullable } from "babylonjs/types";
  46000. import { Scene } from "babylonjs/scene";
  46001. import { Vector3, Color3 } from "babylonjs/Maths/math";
  46002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46003. import { Mesh } from "babylonjs/Meshes/mesh";
  46004. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46005. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46006. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46007. import "babylonjs/Meshes/Builders/planeBuilder";
  46008. import "babylonjs/Meshes/Builders/boxBuilder";
  46009. /**
  46010. * Represents the different options available during the creation of
  46011. * a Environment helper.
  46012. *
  46013. * This can control the default ground, skybox and image processing setup of your scene.
  46014. */
  46015. export interface IEnvironmentHelperOptions {
  46016. /**
  46017. * Specifies wether or not to create a ground.
  46018. * True by default.
  46019. */
  46020. createGround: boolean;
  46021. /**
  46022. * Specifies the ground size.
  46023. * 15 by default.
  46024. */
  46025. groundSize: number;
  46026. /**
  46027. * The texture used on the ground for the main color.
  46028. * Comes from the BabylonJS CDN by default.
  46029. *
  46030. * Remarks: Can be either a texture or a url.
  46031. */
  46032. groundTexture: string | BaseTexture;
  46033. /**
  46034. * The color mixed in the ground texture by default.
  46035. * BabylonJS clearColor by default.
  46036. */
  46037. groundColor: Color3;
  46038. /**
  46039. * Specifies the ground opacity.
  46040. * 1 by default.
  46041. */
  46042. groundOpacity: number;
  46043. /**
  46044. * Enables the ground to receive shadows.
  46045. * True by default.
  46046. */
  46047. enableGroundShadow: boolean;
  46048. /**
  46049. * Helps preventing the shadow to be fully black on the ground.
  46050. * 0.5 by default.
  46051. */
  46052. groundShadowLevel: number;
  46053. /**
  46054. * Creates a mirror texture attach to the ground.
  46055. * false by default.
  46056. */
  46057. enableGroundMirror: boolean;
  46058. /**
  46059. * Specifies the ground mirror size ratio.
  46060. * 0.3 by default as the default kernel is 64.
  46061. */
  46062. groundMirrorSizeRatio: number;
  46063. /**
  46064. * Specifies the ground mirror blur kernel size.
  46065. * 64 by default.
  46066. */
  46067. groundMirrorBlurKernel: number;
  46068. /**
  46069. * Specifies the ground mirror visibility amount.
  46070. * 1 by default
  46071. */
  46072. groundMirrorAmount: number;
  46073. /**
  46074. * Specifies the ground mirror reflectance weight.
  46075. * This uses the standard weight of the background material to setup the fresnel effect
  46076. * of the mirror.
  46077. * 1 by default.
  46078. */
  46079. groundMirrorFresnelWeight: number;
  46080. /**
  46081. * Specifies the ground mirror Falloff distance.
  46082. * This can helps reducing the size of the reflection.
  46083. * 0 by Default.
  46084. */
  46085. groundMirrorFallOffDistance: number;
  46086. /**
  46087. * Specifies the ground mirror texture type.
  46088. * Unsigned Int by Default.
  46089. */
  46090. groundMirrorTextureType: number;
  46091. /**
  46092. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46093. * the shown objects.
  46094. */
  46095. groundYBias: number;
  46096. /**
  46097. * Specifies wether or not to create a skybox.
  46098. * True by default.
  46099. */
  46100. createSkybox: boolean;
  46101. /**
  46102. * Specifies the skybox size.
  46103. * 20 by default.
  46104. */
  46105. skyboxSize: number;
  46106. /**
  46107. * The texture used on the skybox for the main color.
  46108. * Comes from the BabylonJS CDN by default.
  46109. *
  46110. * Remarks: Can be either a texture or a url.
  46111. */
  46112. skyboxTexture: string | BaseTexture;
  46113. /**
  46114. * The color mixed in the skybox texture by default.
  46115. * BabylonJS clearColor by default.
  46116. */
  46117. skyboxColor: Color3;
  46118. /**
  46119. * The background rotation around the Y axis of the scene.
  46120. * This helps aligning the key lights of your scene with the background.
  46121. * 0 by default.
  46122. */
  46123. backgroundYRotation: number;
  46124. /**
  46125. * Compute automatically the size of the elements to best fit with the scene.
  46126. */
  46127. sizeAuto: boolean;
  46128. /**
  46129. * Default position of the rootMesh if autoSize is not true.
  46130. */
  46131. rootPosition: Vector3;
  46132. /**
  46133. * Sets up the image processing in the scene.
  46134. * true by default.
  46135. */
  46136. setupImageProcessing: boolean;
  46137. /**
  46138. * The texture used as your environment texture in the scene.
  46139. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46140. *
  46141. * Remarks: Can be either a texture or a url.
  46142. */
  46143. environmentTexture: string | BaseTexture;
  46144. /**
  46145. * The value of the exposure to apply to the scene.
  46146. * 0.6 by default if setupImageProcessing is true.
  46147. */
  46148. cameraExposure: number;
  46149. /**
  46150. * The value of the contrast to apply to the scene.
  46151. * 1.6 by default if setupImageProcessing is true.
  46152. */
  46153. cameraContrast: number;
  46154. /**
  46155. * Specifies wether or not tonemapping should be enabled in the scene.
  46156. * true by default if setupImageProcessing is true.
  46157. */
  46158. toneMappingEnabled: boolean;
  46159. }
  46160. /**
  46161. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46162. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46163. * It also helps with the default setup of your imageProcessing configuration.
  46164. */
  46165. export class EnvironmentHelper {
  46166. /**
  46167. * Default ground texture URL.
  46168. */
  46169. private static _groundTextureCDNUrl;
  46170. /**
  46171. * Default skybox texture URL.
  46172. */
  46173. private static _skyboxTextureCDNUrl;
  46174. /**
  46175. * Default environment texture URL.
  46176. */
  46177. private static _environmentTextureCDNUrl;
  46178. /**
  46179. * Creates the default options for the helper.
  46180. */
  46181. private static _getDefaultOptions;
  46182. private _rootMesh;
  46183. /**
  46184. * Gets the root mesh created by the helper.
  46185. */
  46186. readonly rootMesh: Mesh;
  46187. private _skybox;
  46188. /**
  46189. * Gets the skybox created by the helper.
  46190. */
  46191. readonly skybox: Nullable<Mesh>;
  46192. private _skyboxTexture;
  46193. /**
  46194. * Gets the skybox texture created by the helper.
  46195. */
  46196. readonly skyboxTexture: Nullable<BaseTexture>;
  46197. private _skyboxMaterial;
  46198. /**
  46199. * Gets the skybox material created by the helper.
  46200. */
  46201. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46202. private _ground;
  46203. /**
  46204. * Gets the ground mesh created by the helper.
  46205. */
  46206. readonly ground: Nullable<Mesh>;
  46207. private _groundTexture;
  46208. /**
  46209. * Gets the ground texture created by the helper.
  46210. */
  46211. readonly groundTexture: Nullable<BaseTexture>;
  46212. private _groundMirror;
  46213. /**
  46214. * Gets the ground mirror created by the helper.
  46215. */
  46216. readonly groundMirror: Nullable<MirrorTexture>;
  46217. /**
  46218. * Gets the ground mirror render list to helps pushing the meshes
  46219. * you wish in the ground reflection.
  46220. */
  46221. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46222. private _groundMaterial;
  46223. /**
  46224. * Gets the ground material created by the helper.
  46225. */
  46226. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46227. /**
  46228. * Stores the creation options.
  46229. */
  46230. private readonly _scene;
  46231. private _options;
  46232. /**
  46233. * This observable will be notified with any error during the creation of the environment,
  46234. * mainly texture creation errors.
  46235. */
  46236. onErrorObservable: Observable<{
  46237. message?: string;
  46238. exception?: any;
  46239. }>;
  46240. /**
  46241. * constructor
  46242. * @param options Defines the options we want to customize the helper
  46243. * @param scene The scene to add the material to
  46244. */
  46245. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46246. /**
  46247. * Updates the background according to the new options
  46248. * @param options
  46249. */
  46250. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46251. /**
  46252. * Sets the primary color of all the available elements.
  46253. * @param color the main color to affect to the ground and the background
  46254. */
  46255. setMainColor(color: Color3): void;
  46256. /**
  46257. * Setup the image processing according to the specified options.
  46258. */
  46259. private _setupImageProcessing;
  46260. /**
  46261. * Setup the environment texture according to the specified options.
  46262. */
  46263. private _setupEnvironmentTexture;
  46264. /**
  46265. * Setup the background according to the specified options.
  46266. */
  46267. private _setupBackground;
  46268. /**
  46269. * Get the scene sizes according to the setup.
  46270. */
  46271. private _getSceneSize;
  46272. /**
  46273. * Setup the ground according to the specified options.
  46274. */
  46275. private _setupGround;
  46276. /**
  46277. * Setup the ground material according to the specified options.
  46278. */
  46279. private _setupGroundMaterial;
  46280. /**
  46281. * Setup the ground diffuse texture according to the specified options.
  46282. */
  46283. private _setupGroundDiffuseTexture;
  46284. /**
  46285. * Setup the ground mirror texture according to the specified options.
  46286. */
  46287. private _setupGroundMirrorTexture;
  46288. /**
  46289. * Setup the ground to receive the mirror texture.
  46290. */
  46291. private _setupMirrorInGroundMaterial;
  46292. /**
  46293. * Setup the skybox according to the specified options.
  46294. */
  46295. private _setupSkybox;
  46296. /**
  46297. * Setup the skybox material according to the specified options.
  46298. */
  46299. private _setupSkyboxMaterial;
  46300. /**
  46301. * Setup the skybox reflection texture according to the specified options.
  46302. */
  46303. private _setupSkyboxReflectionTexture;
  46304. private _errorHandler;
  46305. /**
  46306. * Dispose all the elements created by the Helper.
  46307. */
  46308. dispose(): void;
  46309. }
  46310. }
  46311. declare module "babylonjs/Helpers/photoDome" {
  46312. import { Observable } from "babylonjs/Misc/observable";
  46313. import { Nullable } from "babylonjs/types";
  46314. import { Scene } from "babylonjs/scene";
  46315. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46316. import { Mesh } from "babylonjs/Meshes/mesh";
  46317. import { Texture } from "babylonjs/Materials/Textures/texture";
  46318. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46319. import "babylonjs/Meshes/Builders/sphereBuilder";
  46320. /**
  46321. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46322. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46323. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46324. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46325. */
  46326. export class PhotoDome extends TransformNode {
  46327. /**
  46328. * Define the image as a Monoscopic panoramic 360 image.
  46329. */
  46330. static readonly MODE_MONOSCOPIC: number;
  46331. /**
  46332. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46333. */
  46334. static readonly MODE_TOPBOTTOM: number;
  46335. /**
  46336. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46337. */
  46338. static readonly MODE_SIDEBYSIDE: number;
  46339. private _useDirectMapping;
  46340. /**
  46341. * The texture being displayed on the sphere
  46342. */
  46343. protected _photoTexture: Texture;
  46344. /**
  46345. * Gets or sets the texture being displayed on the sphere
  46346. */
  46347. photoTexture: Texture;
  46348. /**
  46349. * Observable raised when an error occured while loading the 360 image
  46350. */
  46351. onLoadErrorObservable: Observable<string>;
  46352. /**
  46353. * The skybox material
  46354. */
  46355. protected _material: BackgroundMaterial;
  46356. /**
  46357. * The surface used for the skybox
  46358. */
  46359. protected _mesh: Mesh;
  46360. /**
  46361. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46362. * Also see the options.resolution property.
  46363. */
  46364. fovMultiplier: number;
  46365. private _imageMode;
  46366. /**
  46367. * Gets or set the current video mode for the video. It can be:
  46368. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46369. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46370. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46371. */
  46372. imageMode: number;
  46373. /**
  46374. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46375. * @param name Element's name, child elements will append suffixes for their own names.
  46376. * @param urlsOfPhoto defines the url of the photo to display
  46377. * @param options defines an object containing optional or exposed sub element properties
  46378. * @param onError defines a callback called when an error occured while loading the texture
  46379. */
  46380. constructor(name: string, urlOfPhoto: string, options: {
  46381. resolution?: number;
  46382. size?: number;
  46383. useDirectMapping?: boolean;
  46384. faceForward?: boolean;
  46385. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46386. private _onBeforeCameraRenderObserver;
  46387. private _changeImageMode;
  46388. /**
  46389. * Releases resources associated with this node.
  46390. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46391. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46392. */
  46393. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46394. }
  46395. }
  46396. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46397. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46398. /** @hidden */
  46399. export var rgbdDecodePixelShader: {
  46400. name: string;
  46401. shader: string;
  46402. };
  46403. }
  46404. declare module "babylonjs/Misc/brdfTextureTools" {
  46405. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46406. import { Scene } from "babylonjs/scene";
  46407. import "babylonjs/Shaders/rgbdDecode.fragment";
  46408. /**
  46409. * Class used to host texture specific utilities
  46410. */
  46411. export class BRDFTextureTools {
  46412. /**
  46413. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46414. * @param texture the texture to expand.
  46415. */
  46416. private static _ExpandDefaultBRDFTexture;
  46417. /**
  46418. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46419. * @param scene defines the hosting scene
  46420. * @returns the environment BRDF texture
  46421. */
  46422. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46423. private static _environmentBRDFBase64Texture;
  46424. }
  46425. }
  46426. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46427. import { Nullable } from "babylonjs/types";
  46428. import { IAnimatable } from "babylonjs/Misc/tools";
  46429. import { Color3 } from "babylonjs/Maths/math";
  46430. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46431. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46432. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46433. import { Engine } from "babylonjs/Engines/engine";
  46434. import { Scene } from "babylonjs/scene";
  46435. /**
  46436. * @hidden
  46437. */
  46438. export interface IMaterialClearCoatDefines {
  46439. CLEARCOAT: boolean;
  46440. CLEARCOAT_DEFAULTIOR: boolean;
  46441. CLEARCOAT_TEXTURE: boolean;
  46442. CLEARCOAT_TEXTUREDIRECTUV: number;
  46443. CLEARCOAT_BUMP: boolean;
  46444. CLEARCOAT_BUMPDIRECTUV: number;
  46445. CLEARCOAT_TINT: boolean;
  46446. CLEARCOAT_TINT_TEXTURE: boolean;
  46447. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46448. /** @hidden */
  46449. _areTexturesDirty: boolean;
  46450. }
  46451. /**
  46452. * Define the code related to the clear coat parameters of the pbr material.
  46453. */
  46454. export class PBRClearCoatConfiguration {
  46455. /**
  46456. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46457. * The default fits with a polyurethane material.
  46458. */
  46459. private static readonly _DefaultIndexOfRefraction;
  46460. private _isEnabled;
  46461. /**
  46462. * Defines if the clear coat is enabled in the material.
  46463. */
  46464. isEnabled: boolean;
  46465. /**
  46466. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46467. */
  46468. intensity: number;
  46469. /**
  46470. * Defines the clear coat layer roughness.
  46471. */
  46472. roughness: number;
  46473. private _indexOfRefraction;
  46474. /**
  46475. * Defines the index of refraction of the clear coat.
  46476. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46477. * The default fits with a polyurethane material.
  46478. * Changing the default value is more performance intensive.
  46479. */
  46480. indexOfRefraction: number;
  46481. private _texture;
  46482. /**
  46483. * Stores the clear coat values in a texture.
  46484. */
  46485. texture: Nullable<BaseTexture>;
  46486. private _bumpTexture;
  46487. /**
  46488. * Define the clear coat specific bump texture.
  46489. */
  46490. bumpTexture: Nullable<BaseTexture>;
  46491. private _isTintEnabled;
  46492. /**
  46493. * Defines if the clear coat tint is enabled in the material.
  46494. */
  46495. isTintEnabled: boolean;
  46496. /**
  46497. * Defines the clear coat tint of the material.
  46498. * This is only use if tint is enabled
  46499. */
  46500. tintColor: Color3;
  46501. /**
  46502. * Defines the distance at which the tint color should be found in the
  46503. * clear coat media.
  46504. * This is only use if tint is enabled
  46505. */
  46506. tintColorAtDistance: number;
  46507. /**
  46508. * Defines the clear coat layer thickness.
  46509. * This is only use if tint is enabled
  46510. */
  46511. tintThickness: number;
  46512. private _tintTexture;
  46513. /**
  46514. * Stores the clear tint values in a texture.
  46515. * rgb is tint
  46516. * a is a thickness factor
  46517. */
  46518. tintTexture: Nullable<BaseTexture>;
  46519. /** @hidden */
  46520. private _internalMarkAllSubMeshesAsTexturesDirty;
  46521. /** @hidden */
  46522. _markAllSubMeshesAsTexturesDirty(): void;
  46523. /**
  46524. * Instantiate a new istance of clear coat configuration.
  46525. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46526. */
  46527. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46528. /**
  46529. * Gets wehter the submesh is ready to be used or not.
  46530. * @param defines the list of "defines" to update.
  46531. * @param scene defines the scene the material belongs to.
  46532. * @param engine defines the engine the material belongs to.
  46533. * @param disableBumpMap defines wether the material disables bump or not.
  46534. * @returns - boolean indicating that the submesh is ready or not.
  46535. */
  46536. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46537. /**
  46538. * Checks to see if a texture is used in the material.
  46539. * @param defines the list of "defines" to update.
  46540. * @param scene defines the scene to the material belongs to.
  46541. */
  46542. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46543. /**
  46544. * Binds the material data.
  46545. * @param uniformBuffer defines the Uniform buffer to fill in.
  46546. * @param scene defines the scene the material belongs to.
  46547. * @param engine defines the engine the material belongs to.
  46548. * @param disableBumpMap defines wether the material disables bump or not.
  46549. * @param isFrozen defines wether the material is frozen or not.
  46550. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46551. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46552. */
  46553. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46554. /**
  46555. * Checks to see if a texture is used in the material.
  46556. * @param texture - Base texture to use.
  46557. * @returns - Boolean specifying if a texture is used in the material.
  46558. */
  46559. hasTexture(texture: BaseTexture): boolean;
  46560. /**
  46561. * Returns an array of the actively used textures.
  46562. * @param activeTextures Array of BaseTextures
  46563. */
  46564. getActiveTextures(activeTextures: BaseTexture[]): void;
  46565. /**
  46566. * Returns the animatable textures.
  46567. * @param animatables Array of animatable textures.
  46568. */
  46569. getAnimatables(animatables: IAnimatable[]): void;
  46570. /**
  46571. * Disposes the resources of the material.
  46572. * @param forceDisposeTextures - Forces the disposal of all textures.
  46573. */
  46574. dispose(forceDisposeTextures?: boolean): void;
  46575. /**
  46576. * Get the current class name of the texture useful for serialization or dynamic coding.
  46577. * @returns "PBRClearCoatConfiguration"
  46578. */
  46579. getClassName(): string;
  46580. /**
  46581. * Add fallbacks to the effect fallbacks list.
  46582. * @param defines defines the Base texture to use.
  46583. * @param fallbacks defines the current fallback list.
  46584. * @param currentRank defines the current fallback rank.
  46585. * @returns the new fallback rank.
  46586. */
  46587. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46588. /**
  46589. * Add the required uniforms to the current list.
  46590. * @param uniforms defines the current uniform list.
  46591. */
  46592. static AddUniforms(uniforms: string[]): void;
  46593. /**
  46594. * Add the required samplers to the current list.
  46595. * @param samplers defines the current sampler list.
  46596. */
  46597. static AddSamplers(samplers: string[]): void;
  46598. /**
  46599. * Add the required uniforms to the current buffer.
  46600. * @param uniformBuffer defines the current uniform buffer.
  46601. */
  46602. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46603. /**
  46604. * Makes a duplicate of the current configuration into another one.
  46605. * @param clearCoatConfiguration define the config where to copy the info
  46606. */
  46607. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46608. /**
  46609. * Serializes this clear coat configuration.
  46610. * @returns - An object with the serialized config.
  46611. */
  46612. serialize(): any;
  46613. /**
  46614. * Parses a anisotropy Configuration from a serialized object.
  46615. * @param source - Serialized object.
  46616. * @param scene Defines the scene we are parsing for
  46617. * @param rootUrl Defines the rootUrl to load from
  46618. */
  46619. parse(source: any, scene: Scene, rootUrl: string): void;
  46620. }
  46621. }
  46622. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46623. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46624. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46626. import { Vector2 } from "babylonjs/Maths/math";
  46627. import { Scene } from "babylonjs/scene";
  46628. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46629. import { IAnimatable } from "babylonjs/Misc/tools";
  46630. import { Nullable } from "babylonjs/types";
  46631. /**
  46632. * @hidden
  46633. */
  46634. export interface IMaterialAnisotropicDefines {
  46635. ANISOTROPIC: boolean;
  46636. ANISOTROPIC_TEXTURE: boolean;
  46637. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46638. MAINUV1: boolean;
  46639. _areTexturesDirty: boolean;
  46640. _needUVs: boolean;
  46641. }
  46642. /**
  46643. * Define the code related to the anisotropic parameters of the pbr material.
  46644. */
  46645. export class PBRAnisotropicConfiguration {
  46646. private _isEnabled;
  46647. /**
  46648. * Defines if the anisotropy is enabled in the material.
  46649. */
  46650. isEnabled: boolean;
  46651. /**
  46652. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46653. */
  46654. intensity: number;
  46655. /**
  46656. * Defines if the effect is along the tangents, bitangents or in between.
  46657. * By default, the effect is "strectching" the highlights along the tangents.
  46658. */
  46659. direction: Vector2;
  46660. private _texture;
  46661. /**
  46662. * Stores the anisotropy values in a texture.
  46663. * rg is direction (like normal from -1 to 1)
  46664. * b is a intensity
  46665. */
  46666. texture: Nullable<BaseTexture>;
  46667. /** @hidden */
  46668. private _internalMarkAllSubMeshesAsTexturesDirty;
  46669. /** @hidden */
  46670. _markAllSubMeshesAsTexturesDirty(): void;
  46671. /**
  46672. * Instantiate a new istance of anisotropy configuration.
  46673. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46674. */
  46675. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46676. /**
  46677. * Specifies that the submesh is ready to be used.
  46678. * @param defines the list of "defines" to update.
  46679. * @param scene defines the scene the material belongs to.
  46680. * @returns - boolean indicating that the submesh is ready or not.
  46681. */
  46682. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46683. /**
  46684. * Checks to see if a texture is used in the material.
  46685. * @param defines the list of "defines" to update.
  46686. * @param mesh the mesh we are preparing the defines for.
  46687. * @param scene defines the scene the material belongs to.
  46688. */
  46689. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46690. /**
  46691. * Binds the material data.
  46692. * @param uniformBuffer defines the Uniform buffer to fill in.
  46693. * @param scene defines the scene the material belongs to.
  46694. * @param isFrozen defines wether the material is frozen or not.
  46695. */
  46696. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46697. /**
  46698. * Checks to see if a texture is used in the material.
  46699. * @param texture - Base texture to use.
  46700. * @returns - Boolean specifying if a texture is used in the material.
  46701. */
  46702. hasTexture(texture: BaseTexture): boolean;
  46703. /**
  46704. * Returns an array of the actively used textures.
  46705. * @param activeTextures Array of BaseTextures
  46706. */
  46707. getActiveTextures(activeTextures: BaseTexture[]): void;
  46708. /**
  46709. * Returns the animatable textures.
  46710. * @param animatables Array of animatable textures.
  46711. */
  46712. getAnimatables(animatables: IAnimatable[]): void;
  46713. /**
  46714. * Disposes the resources of the material.
  46715. * @param forceDisposeTextures - Forces the disposal of all textures.
  46716. */
  46717. dispose(forceDisposeTextures?: boolean): void;
  46718. /**
  46719. * Get the current class name of the texture useful for serialization or dynamic coding.
  46720. * @returns "PBRAnisotropicConfiguration"
  46721. */
  46722. getClassName(): string;
  46723. /**
  46724. * Add fallbacks to the effect fallbacks list.
  46725. * @param defines defines the Base texture to use.
  46726. * @param fallbacks defines the current fallback list.
  46727. * @param currentRank defines the current fallback rank.
  46728. * @returns the new fallback rank.
  46729. */
  46730. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46731. /**
  46732. * Add the required uniforms to the current list.
  46733. * @param uniforms defines the current uniform list.
  46734. */
  46735. static AddUniforms(uniforms: string[]): void;
  46736. /**
  46737. * Add the required uniforms to the current buffer.
  46738. * @param uniformBuffer defines the current uniform buffer.
  46739. */
  46740. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46741. /**
  46742. * Add the required samplers to the current list.
  46743. * @param samplers defines the current sampler list.
  46744. */
  46745. static AddSamplers(samplers: string[]): void;
  46746. /**
  46747. * Makes a duplicate of the current configuration into another one.
  46748. * @param anisotropicConfiguration define the config where to copy the info
  46749. */
  46750. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46751. /**
  46752. * Serializes this anisotropy configuration.
  46753. * @returns - An object with the serialized config.
  46754. */
  46755. serialize(): any;
  46756. /**
  46757. * Parses a anisotropy Configuration from a serialized object.
  46758. * @param source - Serialized object.
  46759. * @param scene Defines the scene we are parsing for
  46760. * @param rootUrl Defines the rootUrl to load from
  46761. */
  46762. parse(source: any, scene: Scene, rootUrl: string): void;
  46763. }
  46764. }
  46765. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46766. import { Scene } from "babylonjs/scene";
  46767. /**
  46768. * @hidden
  46769. */
  46770. export interface IMaterialBRDFDefines {
  46771. BRDF_V_HEIGHT_CORRELATED: boolean;
  46772. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46773. SPHERICAL_HARMONICS: boolean;
  46774. /** @hidden */
  46775. _areMiscDirty: boolean;
  46776. }
  46777. /**
  46778. * Define the code related to the BRDF parameters of the pbr material.
  46779. */
  46780. export class PBRBRDFConfiguration {
  46781. /**
  46782. * Default value used for the energy conservation.
  46783. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46784. */
  46785. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46786. /**
  46787. * Default value used for the Smith Visibility Height Correlated mode.
  46788. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46789. */
  46790. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46791. /**
  46792. * Default value used for the IBL diffuse part.
  46793. * This can help switching back to the polynomials mode globally which is a tiny bit
  46794. * less GPU intensive at the drawback of a lower quality.
  46795. */
  46796. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46797. private _useEnergyConservation;
  46798. /**
  46799. * Defines if the material uses energy conservation.
  46800. */
  46801. useEnergyConservation: boolean;
  46802. private _useSmithVisibilityHeightCorrelated;
  46803. /**
  46804. * LEGACY Mode set to false
  46805. * Defines if the material uses height smith correlated visibility term.
  46806. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46807. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46808. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46809. * Not relying on height correlated will also disable energy conservation.
  46810. */
  46811. useSmithVisibilityHeightCorrelated: boolean;
  46812. private _useSphericalHarmonics;
  46813. /**
  46814. * LEGACY Mode set to false
  46815. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46816. * diffuse part of the IBL.
  46817. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46818. * to the ground truth.
  46819. */
  46820. useSphericalHarmonics: boolean;
  46821. /** @hidden */
  46822. private _internalMarkAllSubMeshesAsMiscDirty;
  46823. /** @hidden */
  46824. _markAllSubMeshesAsMiscDirty(): void;
  46825. /**
  46826. * Instantiate a new istance of clear coat configuration.
  46827. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46828. */
  46829. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46830. /**
  46831. * Checks to see if a texture is used in the material.
  46832. * @param defines the list of "defines" to update.
  46833. */
  46834. prepareDefines(defines: IMaterialBRDFDefines): void;
  46835. /**
  46836. * Get the current class name of the texture useful for serialization or dynamic coding.
  46837. * @returns "PBRClearCoatConfiguration"
  46838. */
  46839. getClassName(): string;
  46840. /**
  46841. * Makes a duplicate of the current configuration into another one.
  46842. * @param brdfConfiguration define the config where to copy the info
  46843. */
  46844. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46845. /**
  46846. * Serializes this BRDF configuration.
  46847. * @returns - An object with the serialized config.
  46848. */
  46849. serialize(): any;
  46850. /**
  46851. * Parses a anisotropy Configuration from a serialized object.
  46852. * @param source - Serialized object.
  46853. * @param scene Defines the scene we are parsing for
  46854. * @param rootUrl Defines the rootUrl to load from
  46855. */
  46856. parse(source: any, scene: Scene, rootUrl: string): void;
  46857. }
  46858. }
  46859. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46860. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46861. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46862. import { Color3 } from "babylonjs/Maths/math";
  46863. import { Scene } from "babylonjs/scene";
  46864. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46865. import { IAnimatable } from "babylonjs/Misc/tools";
  46866. import { Nullable } from "babylonjs/types";
  46867. /**
  46868. * @hidden
  46869. */
  46870. export interface IMaterialSheenDefines {
  46871. SHEEN: boolean;
  46872. SHEEN_TEXTURE: boolean;
  46873. SHEEN_TEXTUREDIRECTUV: number;
  46874. SHEEN_LINKWITHALBEDO: boolean;
  46875. /** @hidden */
  46876. _areTexturesDirty: boolean;
  46877. }
  46878. /**
  46879. * Define the code related to the Sheen parameters of the pbr material.
  46880. */
  46881. export class PBRSheenConfiguration {
  46882. private _isEnabled;
  46883. /**
  46884. * Defines if the material uses sheen.
  46885. */
  46886. isEnabled: boolean;
  46887. private _linkSheenWithAlbedo;
  46888. /**
  46889. * Defines if the sheen is linked to the sheen color.
  46890. */
  46891. linkSheenWithAlbedo: boolean;
  46892. /**
  46893. * Defines the sheen intensity.
  46894. */
  46895. intensity: number;
  46896. /**
  46897. * Defines the sheen color.
  46898. */
  46899. color: Color3;
  46900. private _texture;
  46901. /**
  46902. * Stores the sheen tint values in a texture.
  46903. * rgb is tint
  46904. * a is a intensity
  46905. */
  46906. texture: Nullable<BaseTexture>;
  46907. /** @hidden */
  46908. private _internalMarkAllSubMeshesAsTexturesDirty;
  46909. /** @hidden */
  46910. _markAllSubMeshesAsTexturesDirty(): void;
  46911. /**
  46912. * Instantiate a new istance of clear coat configuration.
  46913. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46914. */
  46915. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46916. /**
  46917. * Specifies that the submesh is ready to be used.
  46918. * @param defines the list of "defines" to update.
  46919. * @param scene defines the scene the material belongs to.
  46920. * @returns - boolean indicating that the submesh is ready or not.
  46921. */
  46922. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46923. /**
  46924. * Checks to see if a texture is used in the material.
  46925. * @param defines the list of "defines" to update.
  46926. * @param scene defines the scene the material belongs to.
  46927. */
  46928. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46929. /**
  46930. * Binds the material data.
  46931. * @param uniformBuffer defines the Uniform buffer to fill in.
  46932. * @param scene defines the scene the material belongs to.
  46933. * @param isFrozen defines wether the material is frozen or not.
  46934. */
  46935. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46936. /**
  46937. * Checks to see if a texture is used in the material.
  46938. * @param texture - Base texture to use.
  46939. * @returns - Boolean specifying if a texture is used in the material.
  46940. */
  46941. hasTexture(texture: BaseTexture): boolean;
  46942. /**
  46943. * Returns an array of the actively used textures.
  46944. * @param activeTextures Array of BaseTextures
  46945. */
  46946. getActiveTextures(activeTextures: BaseTexture[]): void;
  46947. /**
  46948. * Returns the animatable textures.
  46949. * @param animatables Array of animatable textures.
  46950. */
  46951. getAnimatables(animatables: IAnimatable[]): void;
  46952. /**
  46953. * Disposes the resources of the material.
  46954. * @param forceDisposeTextures - Forces the disposal of all textures.
  46955. */
  46956. dispose(forceDisposeTextures?: boolean): void;
  46957. /**
  46958. * Get the current class name of the texture useful for serialization or dynamic coding.
  46959. * @returns "PBRSheenConfiguration"
  46960. */
  46961. getClassName(): string;
  46962. /**
  46963. * Add fallbacks to the effect fallbacks list.
  46964. * @param defines defines the Base texture to use.
  46965. * @param fallbacks defines the current fallback list.
  46966. * @param currentRank defines the current fallback rank.
  46967. * @returns the new fallback rank.
  46968. */
  46969. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46970. /**
  46971. * Add the required uniforms to the current list.
  46972. * @param uniforms defines the current uniform list.
  46973. */
  46974. static AddUniforms(uniforms: string[]): void;
  46975. /**
  46976. * Add the required uniforms to the current buffer.
  46977. * @param uniformBuffer defines the current uniform buffer.
  46978. */
  46979. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46980. /**
  46981. * Add the required samplers to the current list.
  46982. * @param samplers defines the current sampler list.
  46983. */
  46984. static AddSamplers(samplers: string[]): void;
  46985. /**
  46986. * Makes a duplicate of the current configuration into another one.
  46987. * @param sheenConfiguration define the config where to copy the info
  46988. */
  46989. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46990. /**
  46991. * Serializes this BRDF configuration.
  46992. * @returns - An object with the serialized config.
  46993. */
  46994. serialize(): any;
  46995. /**
  46996. * Parses a anisotropy Configuration from a serialized object.
  46997. * @param source - Serialized object.
  46998. * @param scene Defines the scene we are parsing for
  46999. * @param rootUrl Defines the rootUrl to load from
  47000. */
  47001. parse(source: any, scene: Scene, rootUrl: string): void;
  47002. }
  47003. }
  47004. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47005. import { Nullable } from "babylonjs/types";
  47006. import { IAnimatable } from "babylonjs/Misc/tools";
  47007. import { Color3 } from "babylonjs/Maths/math";
  47008. import { SmartArray } from "babylonjs/Misc/smartArray";
  47009. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47010. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47011. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47012. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47013. import { Engine } from "babylonjs/Engines/engine";
  47014. import { Scene } from "babylonjs/scene";
  47015. /**
  47016. * @hidden
  47017. */
  47018. export interface IMaterialSubSurfaceDefines {
  47019. SUBSURFACE: boolean;
  47020. SS_REFRACTION: boolean;
  47021. SS_TRANSLUCENCY: boolean;
  47022. SS_SCATERRING: boolean;
  47023. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47024. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47025. SS_REFRACTIONMAP_3D: boolean;
  47026. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47027. SS_LODINREFRACTIONALPHA: boolean;
  47028. SS_GAMMAREFRACTION: boolean;
  47029. SS_RGBDREFRACTION: boolean;
  47030. SS_LINEARSPECULARREFRACTION: boolean;
  47031. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47032. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47033. /** @hidden */
  47034. _areTexturesDirty: boolean;
  47035. }
  47036. /**
  47037. * Define the code related to the sub surface parameters of the pbr material.
  47038. */
  47039. export class PBRSubSurfaceConfiguration {
  47040. private _isRefractionEnabled;
  47041. /**
  47042. * Defines if the refraction is enabled in the material.
  47043. */
  47044. isRefractionEnabled: boolean;
  47045. private _isTranslucencyEnabled;
  47046. /**
  47047. * Defines if the translucency is enabled in the material.
  47048. */
  47049. isTranslucencyEnabled: boolean;
  47050. private _isScatteringEnabled;
  47051. /**
  47052. * Defines the refraction intensity of the material.
  47053. * The refraction when enabled replaces the Diffuse part of the material.
  47054. * The intensity helps transitionning between diffuse and refraction.
  47055. */
  47056. refractionIntensity: number;
  47057. /**
  47058. * Defines the translucency intensity of the material.
  47059. * When translucency has been enabled, this defines how much of the "translucency"
  47060. * is addded to the diffuse part of the material.
  47061. */
  47062. translucencyIntensity: number;
  47063. /**
  47064. * Defines the scattering intensity of the material.
  47065. * When scattering has been enabled, this defines how much of the "scattered light"
  47066. * is addded to the diffuse part of the material.
  47067. */
  47068. scatteringIntensity: number;
  47069. private _thicknessTexture;
  47070. /**
  47071. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47072. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47073. * 0 would mean minimumThickness
  47074. * 1 would mean maximumThickness
  47075. * The other channels might be use as a mask to vary the different effects intensity.
  47076. */
  47077. thicknessTexture: Nullable<BaseTexture>;
  47078. private _refractionTexture;
  47079. /**
  47080. * Defines the texture to use for refraction.
  47081. */
  47082. refractionTexture: Nullable<BaseTexture>;
  47083. private _indexOfRefraction;
  47084. /**
  47085. * Defines the index of refraction used in the material.
  47086. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47087. */
  47088. indexOfRefraction: number;
  47089. private _invertRefractionY;
  47090. /**
  47091. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47092. */
  47093. invertRefractionY: boolean;
  47094. private _linkRefractionWithTransparency;
  47095. /**
  47096. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47097. * Materials half opaque for instance using refraction could benefit from this control.
  47098. */
  47099. linkRefractionWithTransparency: boolean;
  47100. /**
  47101. * Defines the minimum thickness stored in the thickness map.
  47102. * If no thickness map is defined, this value will be used to simulate thickness.
  47103. */
  47104. minimumThickness: number;
  47105. /**
  47106. * Defines the maximum thickness stored in the thickness map.
  47107. */
  47108. maximumThickness: number;
  47109. /**
  47110. * Defines the volume tint of the material.
  47111. * This is used for both translucency and scattering.
  47112. */
  47113. tintColor: Color3;
  47114. /**
  47115. * Defines the distance at which the tint color should be found in the media.
  47116. * This is used for refraction only.
  47117. */
  47118. tintColorAtDistance: number;
  47119. /**
  47120. * Defines how far each channel transmit through the media.
  47121. * It is defined as a color to simplify it selection.
  47122. */
  47123. diffusionDistance: Color3;
  47124. private _useMaskFromThicknessTexture;
  47125. /**
  47126. * Stores the intensity of the different subsurface effects in the thickness texture.
  47127. * * the green channel is the translucency intensity.
  47128. * * the blue channel is the scattering intensity.
  47129. * * the alpha channel is the refraction intensity.
  47130. */
  47131. useMaskFromThicknessTexture: boolean;
  47132. /** @hidden */
  47133. private _internalMarkAllSubMeshesAsTexturesDirty;
  47134. /** @hidden */
  47135. _markAllSubMeshesAsTexturesDirty(): void;
  47136. /**
  47137. * Instantiate a new istance of sub surface configuration.
  47138. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47139. */
  47140. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47141. /**
  47142. * Gets wehter the submesh is ready to be used or not.
  47143. * @param defines the list of "defines" to update.
  47144. * @param scene defines the scene the material belongs to.
  47145. * @returns - boolean indicating that the submesh is ready or not.
  47146. */
  47147. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47148. /**
  47149. * Checks to see if a texture is used in the material.
  47150. * @param defines the list of "defines" to update.
  47151. * @param scene defines the scene to the material belongs to.
  47152. */
  47153. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47154. /**
  47155. * Binds the material data.
  47156. * @param uniformBuffer defines the Uniform buffer to fill in.
  47157. * @param scene defines the scene the material belongs to.
  47158. * @param engine defines the engine the material belongs to.
  47159. * @param isFrozen defines wether the material is frozen or not.
  47160. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47161. */
  47162. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47163. /**
  47164. * Unbinds the material from the mesh.
  47165. * @param activeEffect defines the effect that should be unbound from.
  47166. * @returns true if unbound, otherwise false
  47167. */
  47168. unbind(activeEffect: Effect): boolean;
  47169. /**
  47170. * Returns the texture used for refraction or null if none is used.
  47171. * @param scene defines the scene the material belongs to.
  47172. * @returns - Refraction texture if present. If no refraction texture and refraction
  47173. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47174. */
  47175. private _getRefractionTexture;
  47176. /**
  47177. * Returns true if alpha blending should be disabled.
  47178. */
  47179. readonly disableAlphaBlending: boolean;
  47180. /**
  47181. * Fills the list of render target textures.
  47182. * @param renderTargets the list of render targets to update
  47183. */
  47184. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47185. /**
  47186. * Checks to see if a texture is used in the material.
  47187. * @param texture - Base texture to use.
  47188. * @returns - Boolean specifying if a texture is used in the material.
  47189. */
  47190. hasTexture(texture: BaseTexture): boolean;
  47191. /**
  47192. * Gets a boolean indicating that current material needs to register RTT
  47193. * @returns true if this uses a render target otherwise false.
  47194. */
  47195. hasRenderTargetTextures(): boolean;
  47196. /**
  47197. * Returns an array of the actively used textures.
  47198. * @param activeTextures Array of BaseTextures
  47199. */
  47200. getActiveTextures(activeTextures: BaseTexture[]): void;
  47201. /**
  47202. * Returns the animatable textures.
  47203. * @param animatables Array of animatable textures.
  47204. */
  47205. getAnimatables(animatables: IAnimatable[]): void;
  47206. /**
  47207. * Disposes the resources of the material.
  47208. * @param forceDisposeTextures - Forces the disposal of all textures.
  47209. */
  47210. dispose(forceDisposeTextures?: boolean): void;
  47211. /**
  47212. * Get the current class name of the texture useful for serialization or dynamic coding.
  47213. * @returns "PBRSubSurfaceConfiguration"
  47214. */
  47215. getClassName(): string;
  47216. /**
  47217. * Add fallbacks to the effect fallbacks list.
  47218. * @param defines defines the Base texture to use.
  47219. * @param fallbacks defines the current fallback list.
  47220. * @param currentRank defines the current fallback rank.
  47221. * @returns the new fallback rank.
  47222. */
  47223. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47224. /**
  47225. * Add the required uniforms to the current list.
  47226. * @param uniforms defines the current uniform list.
  47227. */
  47228. static AddUniforms(uniforms: string[]): void;
  47229. /**
  47230. * Add the required samplers to the current list.
  47231. * @param samplers defines the current sampler list.
  47232. */
  47233. static AddSamplers(samplers: string[]): void;
  47234. /**
  47235. * Add the required uniforms to the current buffer.
  47236. * @param uniformBuffer defines the current uniform buffer.
  47237. */
  47238. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47239. /**
  47240. * Makes a duplicate of the current configuration into another one.
  47241. * @param configuration define the config where to copy the info
  47242. */
  47243. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47244. /**
  47245. * Serializes this Sub Surface configuration.
  47246. * @returns - An object with the serialized config.
  47247. */
  47248. serialize(): any;
  47249. /**
  47250. * Parses a anisotropy Configuration from a serialized object.
  47251. * @param source - Serialized object.
  47252. * @param scene Defines the scene we are parsing for
  47253. * @param rootUrl Defines the rootUrl to load from
  47254. */
  47255. parse(source: any, scene: Scene, rootUrl: string): void;
  47256. }
  47257. }
  47258. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47259. /** @hidden */
  47260. export var pbrFragmentDeclaration: {
  47261. name: string;
  47262. shader: string;
  47263. };
  47264. }
  47265. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47266. /** @hidden */
  47267. export var pbrUboDeclaration: {
  47268. name: string;
  47269. shader: string;
  47270. };
  47271. }
  47272. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47273. /** @hidden */
  47274. export var pbrFragmentExtraDeclaration: {
  47275. name: string;
  47276. shader: string;
  47277. };
  47278. }
  47279. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47280. /** @hidden */
  47281. export var pbrFragmentSamplersDeclaration: {
  47282. name: string;
  47283. shader: string;
  47284. };
  47285. }
  47286. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47287. /** @hidden */
  47288. export var pbrHelperFunctions: {
  47289. name: string;
  47290. shader: string;
  47291. };
  47292. }
  47293. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47294. /** @hidden */
  47295. export var harmonicsFunctions: {
  47296. name: string;
  47297. shader: string;
  47298. };
  47299. }
  47300. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47301. /** @hidden */
  47302. export var pbrDirectLightingSetupFunctions: {
  47303. name: string;
  47304. shader: string;
  47305. };
  47306. }
  47307. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47308. /** @hidden */
  47309. export var pbrDirectLightingFalloffFunctions: {
  47310. name: string;
  47311. shader: string;
  47312. };
  47313. }
  47314. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47315. /** @hidden */
  47316. export var pbrBRDFFunctions: {
  47317. name: string;
  47318. shader: string;
  47319. };
  47320. }
  47321. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47322. /** @hidden */
  47323. export var pbrDirectLightingFunctions: {
  47324. name: string;
  47325. shader: string;
  47326. };
  47327. }
  47328. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47329. /** @hidden */
  47330. export var pbrIBLFunctions: {
  47331. name: string;
  47332. shader: string;
  47333. };
  47334. }
  47335. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47336. /** @hidden */
  47337. export var pbrDebug: {
  47338. name: string;
  47339. shader: string;
  47340. };
  47341. }
  47342. declare module "babylonjs/Shaders/pbr.fragment" {
  47343. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47344. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47345. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47346. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47347. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47348. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47349. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47350. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47351. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47352. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47353. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47354. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47355. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47356. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47357. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47358. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47359. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47360. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47361. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47362. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47363. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47364. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47365. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47366. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47367. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47368. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47369. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47370. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47371. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47372. /** @hidden */
  47373. export var pbrPixelShader: {
  47374. name: string;
  47375. shader: string;
  47376. };
  47377. }
  47378. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47379. /** @hidden */
  47380. export var pbrVertexDeclaration: {
  47381. name: string;
  47382. shader: string;
  47383. };
  47384. }
  47385. declare module "babylonjs/Shaders/pbr.vertex" {
  47386. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47387. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47388. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47389. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47390. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47391. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47392. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47393. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47394. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47395. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47396. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47397. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47398. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47399. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47400. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47401. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47402. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47403. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47404. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47405. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47406. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47407. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47408. /** @hidden */
  47409. export var pbrVertexShader: {
  47410. name: string;
  47411. shader: string;
  47412. };
  47413. }
  47414. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47415. import { IAnimatable } from "babylonjs/Misc/tools";
  47416. import { Nullable } from "babylonjs/types";
  47417. import { Scene } from "babylonjs/scene";
  47418. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47419. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47421. import { Mesh } from "babylonjs/Meshes/mesh";
  47422. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47423. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47424. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47425. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47426. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47427. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47428. import { Material } from "babylonjs/Materials/material";
  47429. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47430. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47431. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47432. import "babylonjs/Shaders/pbr.fragment";
  47433. import "babylonjs/Shaders/pbr.vertex";
  47434. /**
  47435. * Manages the defines for the PBR Material.
  47436. * @hidden
  47437. */
  47438. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47439. PBR: boolean;
  47440. MAINUV1: boolean;
  47441. MAINUV2: boolean;
  47442. UV1: boolean;
  47443. UV2: boolean;
  47444. ALBEDO: boolean;
  47445. ALBEDODIRECTUV: number;
  47446. VERTEXCOLOR: boolean;
  47447. AMBIENT: boolean;
  47448. AMBIENTDIRECTUV: number;
  47449. AMBIENTINGRAYSCALE: boolean;
  47450. OPACITY: boolean;
  47451. VERTEXALPHA: boolean;
  47452. OPACITYDIRECTUV: number;
  47453. OPACITYRGB: boolean;
  47454. ALPHATEST: boolean;
  47455. DEPTHPREPASS: boolean;
  47456. ALPHABLEND: boolean;
  47457. ALPHAFROMALBEDO: boolean;
  47458. ALPHATESTVALUE: string;
  47459. SPECULAROVERALPHA: boolean;
  47460. RADIANCEOVERALPHA: boolean;
  47461. ALPHAFRESNEL: boolean;
  47462. LINEARALPHAFRESNEL: boolean;
  47463. PREMULTIPLYALPHA: boolean;
  47464. EMISSIVE: boolean;
  47465. EMISSIVEDIRECTUV: number;
  47466. REFLECTIVITY: boolean;
  47467. REFLECTIVITYDIRECTUV: number;
  47468. SPECULARTERM: boolean;
  47469. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47470. MICROSURFACEAUTOMATIC: boolean;
  47471. LODBASEDMICROSFURACE: boolean;
  47472. MICROSURFACEMAP: boolean;
  47473. MICROSURFACEMAPDIRECTUV: number;
  47474. METALLICWORKFLOW: boolean;
  47475. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47476. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47477. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47478. AOSTOREINMETALMAPRED: boolean;
  47479. ENVIRONMENTBRDF: boolean;
  47480. ENVIRONMENTBRDF_RGBD: boolean;
  47481. NORMAL: boolean;
  47482. TANGENT: boolean;
  47483. BUMP: boolean;
  47484. BUMPDIRECTUV: number;
  47485. OBJECTSPACE_NORMALMAP: boolean;
  47486. PARALLAX: boolean;
  47487. PARALLAXOCCLUSION: boolean;
  47488. NORMALXYSCALE: boolean;
  47489. LIGHTMAP: boolean;
  47490. LIGHTMAPDIRECTUV: number;
  47491. USELIGHTMAPASSHADOWMAP: boolean;
  47492. GAMMALIGHTMAP: boolean;
  47493. REFLECTION: boolean;
  47494. REFLECTIONMAP_3D: boolean;
  47495. REFLECTIONMAP_SPHERICAL: boolean;
  47496. REFLECTIONMAP_PLANAR: boolean;
  47497. REFLECTIONMAP_CUBIC: boolean;
  47498. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47499. REFLECTIONMAP_PROJECTION: boolean;
  47500. REFLECTIONMAP_SKYBOX: boolean;
  47501. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47502. REFLECTIONMAP_EXPLICIT: boolean;
  47503. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47504. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47505. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47506. INVERTCUBICMAP: boolean;
  47507. USESPHERICALFROMREFLECTIONMAP: boolean;
  47508. USEIRRADIANCEMAP: boolean;
  47509. SPHERICAL_HARMONICS: boolean;
  47510. USESPHERICALINVERTEX: boolean;
  47511. REFLECTIONMAP_OPPOSITEZ: boolean;
  47512. LODINREFLECTIONALPHA: boolean;
  47513. GAMMAREFLECTION: boolean;
  47514. RGBDREFLECTION: boolean;
  47515. LINEARSPECULARREFLECTION: boolean;
  47516. RADIANCEOCCLUSION: boolean;
  47517. HORIZONOCCLUSION: boolean;
  47518. INSTANCES: boolean;
  47519. NUM_BONE_INFLUENCERS: number;
  47520. BonesPerMesh: number;
  47521. BONETEXTURE: boolean;
  47522. NONUNIFORMSCALING: boolean;
  47523. MORPHTARGETS: boolean;
  47524. MORPHTARGETS_NORMAL: boolean;
  47525. MORPHTARGETS_TANGENT: boolean;
  47526. MORPHTARGETS_UV: boolean;
  47527. NUM_MORPH_INFLUENCERS: number;
  47528. IMAGEPROCESSING: boolean;
  47529. VIGNETTE: boolean;
  47530. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47531. VIGNETTEBLENDMODEOPAQUE: boolean;
  47532. TONEMAPPING: boolean;
  47533. TONEMAPPING_ACES: boolean;
  47534. CONTRAST: boolean;
  47535. COLORCURVES: boolean;
  47536. COLORGRADING: boolean;
  47537. COLORGRADING3D: boolean;
  47538. SAMPLER3DGREENDEPTH: boolean;
  47539. SAMPLER3DBGRMAP: boolean;
  47540. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47541. EXPOSURE: boolean;
  47542. MULTIVIEW: boolean;
  47543. USEPHYSICALLIGHTFALLOFF: boolean;
  47544. USEGLTFLIGHTFALLOFF: boolean;
  47545. TWOSIDEDLIGHTING: boolean;
  47546. SHADOWFLOAT: boolean;
  47547. CLIPPLANE: boolean;
  47548. CLIPPLANE2: boolean;
  47549. CLIPPLANE3: boolean;
  47550. CLIPPLANE4: boolean;
  47551. POINTSIZE: boolean;
  47552. FOG: boolean;
  47553. LOGARITHMICDEPTH: boolean;
  47554. FORCENORMALFORWARD: boolean;
  47555. SPECULARAA: boolean;
  47556. CLEARCOAT: boolean;
  47557. CLEARCOAT_DEFAULTIOR: boolean;
  47558. CLEARCOAT_TEXTURE: boolean;
  47559. CLEARCOAT_TEXTUREDIRECTUV: number;
  47560. CLEARCOAT_BUMP: boolean;
  47561. CLEARCOAT_BUMPDIRECTUV: number;
  47562. CLEARCOAT_TINT: boolean;
  47563. CLEARCOAT_TINT_TEXTURE: boolean;
  47564. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47565. ANISOTROPIC: boolean;
  47566. ANISOTROPIC_TEXTURE: boolean;
  47567. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47568. BRDF_V_HEIGHT_CORRELATED: boolean;
  47569. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47570. SHEEN: boolean;
  47571. SHEEN_TEXTURE: boolean;
  47572. SHEEN_TEXTUREDIRECTUV: number;
  47573. SHEEN_LINKWITHALBEDO: boolean;
  47574. SUBSURFACE: boolean;
  47575. SS_REFRACTION: boolean;
  47576. SS_TRANSLUCENCY: boolean;
  47577. SS_SCATERRING: boolean;
  47578. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47579. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47580. SS_REFRACTIONMAP_3D: boolean;
  47581. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47582. SS_LODINREFRACTIONALPHA: boolean;
  47583. SS_GAMMAREFRACTION: boolean;
  47584. SS_RGBDREFRACTION: boolean;
  47585. SS_LINEARSPECULARREFRACTION: boolean;
  47586. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47587. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47588. UNLIT: boolean;
  47589. DEBUGMODE: number;
  47590. /**
  47591. * Initializes the PBR Material defines.
  47592. */
  47593. constructor();
  47594. /**
  47595. * Resets the PBR Material defines.
  47596. */
  47597. reset(): void;
  47598. }
  47599. /**
  47600. * The Physically based material base class of BJS.
  47601. *
  47602. * This offers the main features of a standard PBR material.
  47603. * For more information, please refer to the documentation :
  47604. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47605. */
  47606. export abstract class PBRBaseMaterial extends PushMaterial {
  47607. /**
  47608. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47609. */
  47610. static readonly PBRMATERIAL_OPAQUE: number;
  47611. /**
  47612. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47613. */
  47614. static readonly PBRMATERIAL_ALPHATEST: number;
  47615. /**
  47616. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47617. */
  47618. static readonly PBRMATERIAL_ALPHABLEND: number;
  47619. /**
  47620. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47621. * They are also discarded below the alpha cutoff threshold to improve performances.
  47622. */
  47623. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47624. /**
  47625. * Defines the default value of how much AO map is occluding the analytical lights
  47626. * (point spot...).
  47627. */
  47628. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47629. /**
  47630. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47631. */
  47632. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47633. /**
  47634. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47635. * to enhance interoperability with other engines.
  47636. */
  47637. static readonly LIGHTFALLOFF_GLTF: number;
  47638. /**
  47639. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47640. * to enhance interoperability with other materials.
  47641. */
  47642. static readonly LIGHTFALLOFF_STANDARD: number;
  47643. /**
  47644. * Intensity of the direct lights e.g. the four lights available in your scene.
  47645. * This impacts both the direct diffuse and specular highlights.
  47646. */
  47647. protected _directIntensity: number;
  47648. /**
  47649. * Intensity of the emissive part of the material.
  47650. * This helps controlling the emissive effect without modifying the emissive color.
  47651. */
  47652. protected _emissiveIntensity: number;
  47653. /**
  47654. * Intensity of the environment e.g. how much the environment will light the object
  47655. * either through harmonics for rough material or through the refelction for shiny ones.
  47656. */
  47657. protected _environmentIntensity: number;
  47658. /**
  47659. * This is a special control allowing the reduction of the specular highlights coming from the
  47660. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47661. */
  47662. protected _specularIntensity: number;
  47663. /**
  47664. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47665. */
  47666. private _lightingInfos;
  47667. /**
  47668. * Debug Control allowing disabling the bump map on this material.
  47669. */
  47670. protected _disableBumpMap: boolean;
  47671. /**
  47672. * AKA Diffuse Texture in standard nomenclature.
  47673. */
  47674. protected _albedoTexture: Nullable<BaseTexture>;
  47675. /**
  47676. * AKA Occlusion Texture in other nomenclature.
  47677. */
  47678. protected _ambientTexture: Nullable<BaseTexture>;
  47679. /**
  47680. * AKA Occlusion Texture Intensity in other nomenclature.
  47681. */
  47682. protected _ambientTextureStrength: number;
  47683. /**
  47684. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47685. * 1 means it completely occludes it
  47686. * 0 mean it has no impact
  47687. */
  47688. protected _ambientTextureImpactOnAnalyticalLights: number;
  47689. /**
  47690. * Stores the alpha values in a texture.
  47691. */
  47692. protected _opacityTexture: Nullable<BaseTexture>;
  47693. /**
  47694. * Stores the reflection values in a texture.
  47695. */
  47696. protected _reflectionTexture: Nullable<BaseTexture>;
  47697. /**
  47698. * Stores the emissive values in a texture.
  47699. */
  47700. protected _emissiveTexture: Nullable<BaseTexture>;
  47701. /**
  47702. * AKA Specular texture in other nomenclature.
  47703. */
  47704. protected _reflectivityTexture: Nullable<BaseTexture>;
  47705. /**
  47706. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47707. */
  47708. protected _metallicTexture: Nullable<BaseTexture>;
  47709. /**
  47710. * Specifies the metallic scalar of the metallic/roughness workflow.
  47711. * Can also be used to scale the metalness values of the metallic texture.
  47712. */
  47713. protected _metallic: Nullable<number>;
  47714. /**
  47715. * Specifies the roughness scalar of the metallic/roughness workflow.
  47716. * Can also be used to scale the roughness values of the metallic texture.
  47717. */
  47718. protected _roughness: Nullable<number>;
  47719. /**
  47720. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47721. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47722. */
  47723. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47724. /**
  47725. * Stores surface normal data used to displace a mesh in a texture.
  47726. */
  47727. protected _bumpTexture: Nullable<BaseTexture>;
  47728. /**
  47729. * Stores the pre-calculated light information of a mesh in a texture.
  47730. */
  47731. protected _lightmapTexture: Nullable<BaseTexture>;
  47732. /**
  47733. * The color of a material in ambient lighting.
  47734. */
  47735. protected _ambientColor: Color3;
  47736. /**
  47737. * AKA Diffuse Color in other nomenclature.
  47738. */
  47739. protected _albedoColor: Color3;
  47740. /**
  47741. * AKA Specular Color in other nomenclature.
  47742. */
  47743. protected _reflectivityColor: Color3;
  47744. /**
  47745. * The color applied when light is reflected from a material.
  47746. */
  47747. protected _reflectionColor: Color3;
  47748. /**
  47749. * The color applied when light is emitted from a material.
  47750. */
  47751. protected _emissiveColor: Color3;
  47752. /**
  47753. * AKA Glossiness in other nomenclature.
  47754. */
  47755. protected _microSurface: number;
  47756. /**
  47757. * Specifies that the material will use the light map as a show map.
  47758. */
  47759. protected _useLightmapAsShadowmap: boolean;
  47760. /**
  47761. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47762. * makes the reflect vector face the model (under horizon).
  47763. */
  47764. protected _useHorizonOcclusion: boolean;
  47765. /**
  47766. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47767. * too much the area relying on ambient texture to define their ambient occlusion.
  47768. */
  47769. protected _useRadianceOcclusion: boolean;
  47770. /**
  47771. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47772. */
  47773. protected _useAlphaFromAlbedoTexture: boolean;
  47774. /**
  47775. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47776. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47777. */
  47778. protected _useSpecularOverAlpha: boolean;
  47779. /**
  47780. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47781. */
  47782. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47783. /**
  47784. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47785. */
  47786. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47787. /**
  47788. * Specifies if the metallic texture contains the roughness information in its green channel.
  47789. */
  47790. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47791. /**
  47792. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47793. */
  47794. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47795. /**
  47796. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47797. */
  47798. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47799. /**
  47800. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47801. */
  47802. protected _useAmbientInGrayScale: boolean;
  47803. /**
  47804. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47805. * The material will try to infer what glossiness each pixel should be.
  47806. */
  47807. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47808. /**
  47809. * Defines the falloff type used in this material.
  47810. * It by default is Physical.
  47811. */
  47812. protected _lightFalloff: number;
  47813. /**
  47814. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47815. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47816. */
  47817. protected _useRadianceOverAlpha: boolean;
  47818. /**
  47819. * Allows using an object space normal map (instead of tangent space).
  47820. */
  47821. protected _useObjectSpaceNormalMap: boolean;
  47822. /**
  47823. * Allows using the bump map in parallax mode.
  47824. */
  47825. protected _useParallax: boolean;
  47826. /**
  47827. * Allows using the bump map in parallax occlusion mode.
  47828. */
  47829. protected _useParallaxOcclusion: boolean;
  47830. /**
  47831. * Controls the scale bias of the parallax mode.
  47832. */
  47833. protected _parallaxScaleBias: number;
  47834. /**
  47835. * If sets to true, disables all the lights affecting the material.
  47836. */
  47837. protected _disableLighting: boolean;
  47838. /**
  47839. * Number of Simultaneous lights allowed on the material.
  47840. */
  47841. protected _maxSimultaneousLights: number;
  47842. /**
  47843. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47844. */
  47845. protected _invertNormalMapX: boolean;
  47846. /**
  47847. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47848. */
  47849. protected _invertNormalMapY: boolean;
  47850. /**
  47851. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47852. */
  47853. protected _twoSidedLighting: boolean;
  47854. /**
  47855. * Defines the alpha limits in alpha test mode.
  47856. */
  47857. protected _alphaCutOff: number;
  47858. /**
  47859. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47860. */
  47861. protected _forceAlphaTest: boolean;
  47862. /**
  47863. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47864. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47865. */
  47866. protected _useAlphaFresnel: boolean;
  47867. /**
  47868. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47869. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47870. */
  47871. protected _useLinearAlphaFresnel: boolean;
  47872. /**
  47873. * The transparency mode of the material.
  47874. */
  47875. protected _transparencyMode: Nullable<number>;
  47876. /**
  47877. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47878. * from cos thetav and roughness:
  47879. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47880. */
  47881. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47882. /**
  47883. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47884. */
  47885. protected _forceIrradianceInFragment: boolean;
  47886. /**
  47887. * Force normal to face away from face.
  47888. */
  47889. protected _forceNormalForward: boolean;
  47890. /**
  47891. * Enables specular anti aliasing in the PBR shader.
  47892. * It will both interacts on the Geometry for analytical and IBL lighting.
  47893. * It also prefilter the roughness map based on the bump values.
  47894. */
  47895. protected _enableSpecularAntiAliasing: boolean;
  47896. /**
  47897. * Default configuration related to image processing available in the PBR Material.
  47898. */
  47899. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47900. /**
  47901. * Keep track of the image processing observer to allow dispose and replace.
  47902. */
  47903. private _imageProcessingObserver;
  47904. /**
  47905. * Attaches a new image processing configuration to the PBR Material.
  47906. * @param configuration
  47907. */
  47908. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47909. /**
  47910. * Stores the available render targets.
  47911. */
  47912. private _renderTargets;
  47913. /**
  47914. * Sets the global ambient color for the material used in lighting calculations.
  47915. */
  47916. private _globalAmbientColor;
  47917. /**
  47918. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47919. */
  47920. private _useLogarithmicDepth;
  47921. /**
  47922. * If set to true, no lighting calculations will be applied.
  47923. */
  47924. private _unlit;
  47925. private _debugMode;
  47926. /**
  47927. * @hidden
  47928. * This is reserved for the inspector.
  47929. * Defines the material debug mode.
  47930. * It helps seeing only some components of the material while troubleshooting.
  47931. */
  47932. debugMode: number;
  47933. /**
  47934. * @hidden
  47935. * This is reserved for the inspector.
  47936. * Specify from where on screen the debug mode should start.
  47937. * The value goes from -1 (full screen) to 1 (not visible)
  47938. * It helps with side by side comparison against the final render
  47939. * This defaults to -1
  47940. */
  47941. private debugLimit;
  47942. /**
  47943. * @hidden
  47944. * This is reserved for the inspector.
  47945. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47946. * You can use the factor to better multiply the final value.
  47947. */
  47948. private debugFactor;
  47949. /**
  47950. * Defines the clear coat layer parameters for the material.
  47951. */
  47952. readonly clearCoat: PBRClearCoatConfiguration;
  47953. /**
  47954. * Defines the anisotropic parameters for the material.
  47955. */
  47956. readonly anisotropy: PBRAnisotropicConfiguration;
  47957. /**
  47958. * Defines the BRDF parameters for the material.
  47959. */
  47960. readonly brdf: PBRBRDFConfiguration;
  47961. /**
  47962. * Defines the Sheen parameters for the material.
  47963. */
  47964. readonly sheen: PBRSheenConfiguration;
  47965. /**
  47966. * Defines the SubSurface parameters for the material.
  47967. */
  47968. readonly subSurface: PBRSubSurfaceConfiguration;
  47969. /**
  47970. * Custom callback helping to override the default shader used in the material.
  47971. */
  47972. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47973. /**
  47974. * Instantiates a new PBRMaterial instance.
  47975. *
  47976. * @param name The material name
  47977. * @param scene The scene the material will be use in.
  47978. */
  47979. constructor(name: string, scene: Scene);
  47980. /**
  47981. * Gets a boolean indicating that current material needs to register RTT
  47982. */
  47983. readonly hasRenderTargetTextures: boolean;
  47984. /**
  47985. * Gets the name of the material class.
  47986. */
  47987. getClassName(): string;
  47988. /**
  47989. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47990. */
  47991. /**
  47992. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47993. */
  47994. useLogarithmicDepth: boolean;
  47995. /**
  47996. * Gets the current transparency mode.
  47997. */
  47998. /**
  47999. * Sets the transparency mode of the material.
  48000. *
  48001. * | Value | Type | Description |
  48002. * | ----- | ----------------------------------- | ----------- |
  48003. * | 0 | OPAQUE | |
  48004. * | 1 | ALPHATEST | |
  48005. * | 2 | ALPHABLEND | |
  48006. * | 3 | ALPHATESTANDBLEND | |
  48007. *
  48008. */
  48009. transparencyMode: Nullable<number>;
  48010. /**
  48011. * Returns true if alpha blending should be disabled.
  48012. */
  48013. private readonly _disableAlphaBlending;
  48014. /**
  48015. * Specifies whether or not this material should be rendered in alpha blend mode.
  48016. */
  48017. needAlphaBlending(): boolean;
  48018. /**
  48019. * Specifies if the mesh will require alpha blending.
  48020. * @param mesh - BJS mesh.
  48021. */
  48022. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48023. /**
  48024. * Specifies whether or not this material should be rendered in alpha test mode.
  48025. */
  48026. needAlphaTesting(): boolean;
  48027. /**
  48028. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48029. */
  48030. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48031. /**
  48032. * Gets the texture used for the alpha test.
  48033. */
  48034. getAlphaTestTexture(): Nullable<BaseTexture>;
  48035. /**
  48036. * Specifies that the submesh is ready to be used.
  48037. * @param mesh - BJS mesh.
  48038. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48039. * @param useInstances - Specifies that instances should be used.
  48040. * @returns - boolean indicating that the submesh is ready or not.
  48041. */
  48042. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48043. /**
  48044. * Specifies if the material uses metallic roughness workflow.
  48045. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48046. */
  48047. isMetallicWorkflow(): boolean;
  48048. private _prepareEffect;
  48049. private _prepareDefines;
  48050. /**
  48051. * Force shader compilation
  48052. */
  48053. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48054. clipPlane: boolean;
  48055. }>): void;
  48056. /**
  48057. * Initializes the uniform buffer layout for the shader.
  48058. */
  48059. buildUniformLayout(): void;
  48060. /**
  48061. * Unbinds the material from the mesh
  48062. */
  48063. unbind(): void;
  48064. /**
  48065. * Binds the submesh data.
  48066. * @param world - The world matrix.
  48067. * @param mesh - The BJS mesh.
  48068. * @param subMesh - A submesh of the BJS mesh.
  48069. */
  48070. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48071. /**
  48072. * Returns the animatable textures.
  48073. * @returns - Array of animatable textures.
  48074. */
  48075. getAnimatables(): IAnimatable[];
  48076. /**
  48077. * Returns the texture used for reflections.
  48078. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48079. */
  48080. private _getReflectionTexture;
  48081. /**
  48082. * Returns an array of the actively used textures.
  48083. * @returns - Array of BaseTextures
  48084. */
  48085. getActiveTextures(): BaseTexture[];
  48086. /**
  48087. * Checks to see if a texture is used in the material.
  48088. * @param texture - Base texture to use.
  48089. * @returns - Boolean specifying if a texture is used in the material.
  48090. */
  48091. hasTexture(texture: BaseTexture): boolean;
  48092. /**
  48093. * Disposes the resources of the material.
  48094. * @param forceDisposeEffect - Forces the disposal of effects.
  48095. * @param forceDisposeTextures - Forces the disposal of all textures.
  48096. */
  48097. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48098. }
  48099. }
  48100. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48101. import { Nullable } from "babylonjs/types";
  48102. import { Scene } from "babylonjs/scene";
  48103. import { Color3 } from "babylonjs/Maths/math";
  48104. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48105. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48106. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48107. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48108. /**
  48109. * The Physically based material of BJS.
  48110. *
  48111. * This offers the main features of a standard PBR material.
  48112. * For more information, please refer to the documentation :
  48113. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48114. */
  48115. export class PBRMaterial extends PBRBaseMaterial {
  48116. /**
  48117. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48118. */
  48119. static readonly PBRMATERIAL_OPAQUE: number;
  48120. /**
  48121. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48122. */
  48123. static readonly PBRMATERIAL_ALPHATEST: number;
  48124. /**
  48125. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48126. */
  48127. static readonly PBRMATERIAL_ALPHABLEND: number;
  48128. /**
  48129. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48130. * They are also discarded below the alpha cutoff threshold to improve performances.
  48131. */
  48132. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48133. /**
  48134. * Defines the default value of how much AO map is occluding the analytical lights
  48135. * (point spot...).
  48136. */
  48137. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48138. /**
  48139. * Intensity of the direct lights e.g. the four lights available in your scene.
  48140. * This impacts both the direct diffuse and specular highlights.
  48141. */
  48142. directIntensity: number;
  48143. /**
  48144. * Intensity of the emissive part of the material.
  48145. * This helps controlling the emissive effect without modifying the emissive color.
  48146. */
  48147. emissiveIntensity: number;
  48148. /**
  48149. * Intensity of the environment e.g. how much the environment will light the object
  48150. * either through harmonics for rough material or through the refelction for shiny ones.
  48151. */
  48152. environmentIntensity: number;
  48153. /**
  48154. * This is a special control allowing the reduction of the specular highlights coming from the
  48155. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48156. */
  48157. specularIntensity: number;
  48158. /**
  48159. * Debug Control allowing disabling the bump map on this material.
  48160. */
  48161. disableBumpMap: boolean;
  48162. /**
  48163. * AKA Diffuse Texture in standard nomenclature.
  48164. */
  48165. albedoTexture: BaseTexture;
  48166. /**
  48167. * AKA Occlusion Texture in other nomenclature.
  48168. */
  48169. ambientTexture: BaseTexture;
  48170. /**
  48171. * AKA Occlusion Texture Intensity in other nomenclature.
  48172. */
  48173. ambientTextureStrength: number;
  48174. /**
  48175. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48176. * 1 means it completely occludes it
  48177. * 0 mean it has no impact
  48178. */
  48179. ambientTextureImpactOnAnalyticalLights: number;
  48180. /**
  48181. * Stores the alpha values in a texture.
  48182. */
  48183. opacityTexture: BaseTexture;
  48184. /**
  48185. * Stores the reflection values in a texture.
  48186. */
  48187. reflectionTexture: Nullable<BaseTexture>;
  48188. /**
  48189. * Stores the emissive values in a texture.
  48190. */
  48191. emissiveTexture: BaseTexture;
  48192. /**
  48193. * AKA Specular texture in other nomenclature.
  48194. */
  48195. reflectivityTexture: BaseTexture;
  48196. /**
  48197. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48198. */
  48199. metallicTexture: BaseTexture;
  48200. /**
  48201. * Specifies the metallic scalar of the metallic/roughness workflow.
  48202. * Can also be used to scale the metalness values of the metallic texture.
  48203. */
  48204. metallic: Nullable<number>;
  48205. /**
  48206. * Specifies the roughness scalar of the metallic/roughness workflow.
  48207. * Can also be used to scale the roughness values of the metallic texture.
  48208. */
  48209. roughness: Nullable<number>;
  48210. /**
  48211. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48212. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48213. */
  48214. microSurfaceTexture: BaseTexture;
  48215. /**
  48216. * Stores surface normal data used to displace a mesh in a texture.
  48217. */
  48218. bumpTexture: BaseTexture;
  48219. /**
  48220. * Stores the pre-calculated light information of a mesh in a texture.
  48221. */
  48222. lightmapTexture: BaseTexture;
  48223. /**
  48224. * Stores the refracted light information in a texture.
  48225. */
  48226. refractionTexture: Nullable<BaseTexture>;
  48227. /**
  48228. * The color of a material in ambient lighting.
  48229. */
  48230. ambientColor: Color3;
  48231. /**
  48232. * AKA Diffuse Color in other nomenclature.
  48233. */
  48234. albedoColor: Color3;
  48235. /**
  48236. * AKA Specular Color in other nomenclature.
  48237. */
  48238. reflectivityColor: Color3;
  48239. /**
  48240. * The color reflected from the material.
  48241. */
  48242. reflectionColor: Color3;
  48243. /**
  48244. * The color emitted from the material.
  48245. */
  48246. emissiveColor: Color3;
  48247. /**
  48248. * AKA Glossiness in other nomenclature.
  48249. */
  48250. microSurface: number;
  48251. /**
  48252. * source material index of refraction (IOR)' / 'destination material IOR.
  48253. */
  48254. indexOfRefraction: number;
  48255. /**
  48256. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48257. */
  48258. invertRefractionY: boolean;
  48259. /**
  48260. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48261. * Materials half opaque for instance using refraction could benefit from this control.
  48262. */
  48263. linkRefractionWithTransparency: boolean;
  48264. /**
  48265. * If true, the light map contains occlusion information instead of lighting info.
  48266. */
  48267. useLightmapAsShadowmap: boolean;
  48268. /**
  48269. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48270. */
  48271. useAlphaFromAlbedoTexture: boolean;
  48272. /**
  48273. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48274. */
  48275. forceAlphaTest: boolean;
  48276. /**
  48277. * Defines the alpha limits in alpha test mode.
  48278. */
  48279. alphaCutOff: number;
  48280. /**
  48281. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48282. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48283. */
  48284. useSpecularOverAlpha: boolean;
  48285. /**
  48286. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48287. */
  48288. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48289. /**
  48290. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48291. */
  48292. useRoughnessFromMetallicTextureAlpha: boolean;
  48293. /**
  48294. * Specifies if the metallic texture contains the roughness information in its green channel.
  48295. */
  48296. useRoughnessFromMetallicTextureGreen: boolean;
  48297. /**
  48298. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48299. */
  48300. useMetallnessFromMetallicTextureBlue: boolean;
  48301. /**
  48302. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48303. */
  48304. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48305. /**
  48306. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48307. */
  48308. useAmbientInGrayScale: boolean;
  48309. /**
  48310. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48311. * The material will try to infer what glossiness each pixel should be.
  48312. */
  48313. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48314. /**
  48315. * BJS is using an harcoded light falloff based on a manually sets up range.
  48316. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48317. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48318. */
  48319. /**
  48320. * BJS is using an harcoded light falloff based on a manually sets up range.
  48321. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48322. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48323. */
  48324. usePhysicalLightFalloff: boolean;
  48325. /**
  48326. * In order to support the falloff compatibility with gltf, a special mode has been added
  48327. * to reproduce the gltf light falloff.
  48328. */
  48329. /**
  48330. * In order to support the falloff compatibility with gltf, a special mode has been added
  48331. * to reproduce the gltf light falloff.
  48332. */
  48333. useGLTFLightFalloff: boolean;
  48334. /**
  48335. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48336. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48337. */
  48338. useRadianceOverAlpha: boolean;
  48339. /**
  48340. * Allows using an object space normal map (instead of tangent space).
  48341. */
  48342. useObjectSpaceNormalMap: boolean;
  48343. /**
  48344. * Allows using the bump map in parallax mode.
  48345. */
  48346. useParallax: boolean;
  48347. /**
  48348. * Allows using the bump map in parallax occlusion mode.
  48349. */
  48350. useParallaxOcclusion: boolean;
  48351. /**
  48352. * Controls the scale bias of the parallax mode.
  48353. */
  48354. parallaxScaleBias: number;
  48355. /**
  48356. * If sets to true, disables all the lights affecting the material.
  48357. */
  48358. disableLighting: boolean;
  48359. /**
  48360. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48361. */
  48362. forceIrradianceInFragment: boolean;
  48363. /**
  48364. * Number of Simultaneous lights allowed on the material.
  48365. */
  48366. maxSimultaneousLights: number;
  48367. /**
  48368. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48369. */
  48370. invertNormalMapX: boolean;
  48371. /**
  48372. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48373. */
  48374. invertNormalMapY: boolean;
  48375. /**
  48376. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48377. */
  48378. twoSidedLighting: boolean;
  48379. /**
  48380. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48381. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48382. */
  48383. useAlphaFresnel: boolean;
  48384. /**
  48385. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48386. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48387. */
  48388. useLinearAlphaFresnel: boolean;
  48389. /**
  48390. * Let user defines the brdf lookup texture used for IBL.
  48391. * A default 8bit version is embedded but you could point at :
  48392. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  48393. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48394. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48395. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48396. */
  48397. environmentBRDFTexture: Nullable<BaseTexture>;
  48398. /**
  48399. * Force normal to face away from face.
  48400. */
  48401. forceNormalForward: boolean;
  48402. /**
  48403. * Enables specular anti aliasing in the PBR shader.
  48404. * It will both interacts on the Geometry for analytical and IBL lighting.
  48405. * It also prefilter the roughness map based on the bump values.
  48406. */
  48407. enableSpecularAntiAliasing: boolean;
  48408. /**
  48409. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48410. * makes the reflect vector face the model (under horizon).
  48411. */
  48412. useHorizonOcclusion: boolean;
  48413. /**
  48414. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48415. * too much the area relying on ambient texture to define their ambient occlusion.
  48416. */
  48417. useRadianceOcclusion: boolean;
  48418. /**
  48419. * If set to true, no lighting calculations will be applied.
  48420. */
  48421. unlit: boolean;
  48422. /**
  48423. * Gets the image processing configuration used either in this material.
  48424. */
  48425. /**
  48426. * Sets the Default image processing configuration used either in the this material.
  48427. *
  48428. * If sets to null, the scene one is in use.
  48429. */
  48430. imageProcessingConfiguration: ImageProcessingConfiguration;
  48431. /**
  48432. * Gets wether the color curves effect is enabled.
  48433. */
  48434. /**
  48435. * Sets wether the color curves effect is enabled.
  48436. */
  48437. cameraColorCurvesEnabled: boolean;
  48438. /**
  48439. * Gets wether the color grading effect is enabled.
  48440. */
  48441. /**
  48442. * Gets wether the color grading effect is enabled.
  48443. */
  48444. cameraColorGradingEnabled: boolean;
  48445. /**
  48446. * Gets wether tonemapping is enabled or not.
  48447. */
  48448. /**
  48449. * Sets wether tonemapping is enabled or not
  48450. */
  48451. cameraToneMappingEnabled: boolean;
  48452. /**
  48453. * The camera exposure used on this material.
  48454. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48455. * This corresponds to a photographic exposure.
  48456. */
  48457. /**
  48458. * The camera exposure used on this material.
  48459. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48460. * This corresponds to a photographic exposure.
  48461. */
  48462. cameraExposure: number;
  48463. /**
  48464. * Gets The camera contrast used on this material.
  48465. */
  48466. /**
  48467. * Sets The camera contrast used on this material.
  48468. */
  48469. cameraContrast: number;
  48470. /**
  48471. * Gets the Color Grading 2D Lookup Texture.
  48472. */
  48473. /**
  48474. * Sets the Color Grading 2D Lookup Texture.
  48475. */
  48476. cameraColorGradingTexture: Nullable<BaseTexture>;
  48477. /**
  48478. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48479. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48480. * 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;
  48481. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48482. */
  48483. /**
  48484. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48485. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48486. * 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;
  48487. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48488. */
  48489. cameraColorCurves: Nullable<ColorCurves>;
  48490. /**
  48491. * Instantiates a new PBRMaterial instance.
  48492. *
  48493. * @param name The material name
  48494. * @param scene The scene the material will be use in.
  48495. */
  48496. constructor(name: string, scene: Scene);
  48497. /**
  48498. * Returns the name of this material class.
  48499. */
  48500. getClassName(): string;
  48501. /**
  48502. * Makes a duplicate of the current material.
  48503. * @param name - name to use for the new material.
  48504. */
  48505. clone(name: string): PBRMaterial;
  48506. /**
  48507. * Serializes this PBR Material.
  48508. * @returns - An object with the serialized material.
  48509. */
  48510. serialize(): any;
  48511. /**
  48512. * Parses a PBR Material from a serialized object.
  48513. * @param source - Serialized object.
  48514. * @param scene - BJS scene instance.
  48515. * @param rootUrl - url for the scene object
  48516. * @returns - PBRMaterial
  48517. */
  48518. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48519. }
  48520. }
  48521. declare module "babylonjs/Misc/dds" {
  48522. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48523. import { Engine } from "babylonjs/Engines/engine";
  48524. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48525. import { Nullable } from "babylonjs/types";
  48526. import { Scene } from "babylonjs/scene";
  48527. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48528. /**
  48529. * Direct draw surface info
  48530. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48531. */
  48532. export interface DDSInfo {
  48533. /**
  48534. * Width of the texture
  48535. */
  48536. width: number;
  48537. /**
  48538. * Width of the texture
  48539. */
  48540. height: number;
  48541. /**
  48542. * Number of Mipmaps for the texture
  48543. * @see https://en.wikipedia.org/wiki/Mipmap
  48544. */
  48545. mipmapCount: number;
  48546. /**
  48547. * If the textures format is a known fourCC format
  48548. * @see https://www.fourcc.org/
  48549. */
  48550. isFourCC: boolean;
  48551. /**
  48552. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48553. */
  48554. isRGB: boolean;
  48555. /**
  48556. * If the texture is a lumincance format
  48557. */
  48558. isLuminance: boolean;
  48559. /**
  48560. * If this is a cube texture
  48561. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48562. */
  48563. isCube: boolean;
  48564. /**
  48565. * If the texture is a compressed format eg. FOURCC_DXT1
  48566. */
  48567. isCompressed: boolean;
  48568. /**
  48569. * The dxgiFormat of the texture
  48570. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48571. */
  48572. dxgiFormat: number;
  48573. /**
  48574. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48575. */
  48576. textureType: number;
  48577. /**
  48578. * Sphericle polynomial created for the dds texture
  48579. */
  48580. sphericalPolynomial?: SphericalPolynomial;
  48581. }
  48582. /**
  48583. * Class used to provide DDS decompression tools
  48584. */
  48585. export class DDSTools {
  48586. /**
  48587. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48588. */
  48589. static StoreLODInAlphaChannel: boolean;
  48590. /**
  48591. * Gets DDS information from an array buffer
  48592. * @param arrayBuffer defines the array buffer to read data from
  48593. * @returns the DDS information
  48594. */
  48595. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48596. private static _FloatView;
  48597. private static _Int32View;
  48598. private static _ToHalfFloat;
  48599. private static _FromHalfFloat;
  48600. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48601. private static _GetHalfFloatRGBAArrayBuffer;
  48602. private static _GetFloatRGBAArrayBuffer;
  48603. private static _GetFloatAsUIntRGBAArrayBuffer;
  48604. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48605. private static _GetRGBAArrayBuffer;
  48606. private static _ExtractLongWordOrder;
  48607. private static _GetRGBArrayBuffer;
  48608. private static _GetLuminanceArrayBuffer;
  48609. /**
  48610. * Uploads DDS Levels to a Babylon Texture
  48611. * @hidden
  48612. */
  48613. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48614. }
  48615. module "babylonjs/Engines/engine" {
  48616. interface Engine {
  48617. /**
  48618. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48619. * @param rootUrl defines the url where the file to load is located
  48620. * @param scene defines the current scene
  48621. * @param lodScale defines scale to apply to the mip map selection
  48622. * @param lodOffset defines offset to apply to the mip map selection
  48623. * @param onLoad defines an optional callback raised when the texture is loaded
  48624. * @param onError defines an optional callback raised if there is an issue to load the texture
  48625. * @param format defines the format of the data
  48626. * @param forcedExtension defines the extension to use to pick the right loader
  48627. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48628. * @returns the cube texture as an InternalTexture
  48629. */
  48630. 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;
  48631. }
  48632. }
  48633. }
  48634. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48635. import { Nullable } from "babylonjs/types";
  48636. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48637. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48638. /**
  48639. * Implementation of the DDS Texture Loader.
  48640. * @hidden
  48641. */
  48642. export class _DDSTextureLoader implements IInternalTextureLoader {
  48643. /**
  48644. * Defines wether the loader supports cascade loading the different faces.
  48645. */
  48646. readonly supportCascades: boolean;
  48647. /**
  48648. * This returns if the loader support the current file information.
  48649. * @param extension defines the file extension of the file being loaded
  48650. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48651. * @param fallback defines the fallback internal texture if any
  48652. * @param isBase64 defines whether the texture is encoded as a base64
  48653. * @param isBuffer defines whether the texture data are stored as a buffer
  48654. * @returns true if the loader can load the specified file
  48655. */
  48656. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48657. /**
  48658. * Transform the url before loading if required.
  48659. * @param rootUrl the url of the texture
  48660. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48661. * @returns the transformed texture
  48662. */
  48663. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48664. /**
  48665. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48666. * @param rootUrl the url of the texture
  48667. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48668. * @returns the fallback texture
  48669. */
  48670. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48671. /**
  48672. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48673. * @param data contains the texture data
  48674. * @param texture defines the BabylonJS internal texture
  48675. * @param createPolynomials will be true if polynomials have been requested
  48676. * @param onLoad defines the callback to trigger once the texture is ready
  48677. * @param onError defines the callback to trigger in case of error
  48678. */
  48679. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48680. /**
  48681. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48682. * @param data contains the texture data
  48683. * @param texture defines the BabylonJS internal texture
  48684. * @param callback defines the method to call once ready to upload
  48685. */
  48686. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48687. }
  48688. }
  48689. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48690. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48691. /** @hidden */
  48692. export var rgbdEncodePixelShader: {
  48693. name: string;
  48694. shader: string;
  48695. };
  48696. }
  48697. declare module "babylonjs/Misc/environmentTextureTools" {
  48698. import { Nullable } from "babylonjs/types";
  48699. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48700. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48701. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48702. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48703. import "babylonjs/Shaders/rgbdEncode.fragment";
  48704. import "babylonjs/Shaders/rgbdDecode.fragment";
  48705. /**
  48706. * Raw texture data and descriptor sufficient for WebGL texture upload
  48707. */
  48708. export interface EnvironmentTextureInfo {
  48709. /**
  48710. * Version of the environment map
  48711. */
  48712. version: number;
  48713. /**
  48714. * Width of image
  48715. */
  48716. width: number;
  48717. /**
  48718. * Irradiance information stored in the file.
  48719. */
  48720. irradiance: any;
  48721. /**
  48722. * Specular information stored in the file.
  48723. */
  48724. specular: any;
  48725. }
  48726. /**
  48727. * Sets of helpers addressing the serialization and deserialization of environment texture
  48728. * stored in a BabylonJS env file.
  48729. * Those files are usually stored as .env files.
  48730. */
  48731. export class EnvironmentTextureTools {
  48732. /**
  48733. * Magic number identifying the env file.
  48734. */
  48735. private static _MagicBytes;
  48736. /**
  48737. * Gets the environment info from an env file.
  48738. * @param data The array buffer containing the .env bytes.
  48739. * @returns the environment file info (the json header) if successfully parsed.
  48740. */
  48741. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48742. /**
  48743. * Creates an environment texture from a loaded cube texture.
  48744. * @param texture defines the cube texture to convert in env file
  48745. * @return a promise containing the environment data if succesfull.
  48746. */
  48747. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48748. /**
  48749. * Creates a JSON representation of the spherical data.
  48750. * @param texture defines the texture containing the polynomials
  48751. * @return the JSON representation of the spherical info
  48752. */
  48753. private static _CreateEnvTextureIrradiance;
  48754. /**
  48755. * Uploads the texture info contained in the env file to the GPU.
  48756. * @param texture defines the internal texture to upload to
  48757. * @param arrayBuffer defines the buffer cotaining the data to load
  48758. * @param info defines the texture info retrieved through the GetEnvInfo method
  48759. * @returns a promise
  48760. */
  48761. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48762. /**
  48763. * Uploads the levels of image data to the GPU.
  48764. * @param texture defines the internal texture to upload to
  48765. * @param imageData defines the array buffer views of image data [mipmap][face]
  48766. * @returns a promise
  48767. */
  48768. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48769. /**
  48770. * Uploads spherical polynomials information to the texture.
  48771. * @param texture defines the texture we are trying to upload the information to
  48772. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48773. */
  48774. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48775. /** @hidden */
  48776. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48777. }
  48778. }
  48779. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48780. import { Nullable } from "babylonjs/types";
  48781. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48782. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48783. /**
  48784. * Implementation of the ENV Texture Loader.
  48785. * @hidden
  48786. */
  48787. export class _ENVTextureLoader implements IInternalTextureLoader {
  48788. /**
  48789. * Defines wether the loader supports cascade loading the different faces.
  48790. */
  48791. readonly supportCascades: boolean;
  48792. /**
  48793. * This returns if the loader support the current file information.
  48794. * @param extension defines the file extension of the file being loaded
  48795. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48796. * @param fallback defines the fallback internal texture if any
  48797. * @param isBase64 defines whether the texture is encoded as a base64
  48798. * @param isBuffer defines whether the texture data are stored as a buffer
  48799. * @returns true if the loader can load the specified file
  48800. */
  48801. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48802. /**
  48803. * Transform the url before loading if required.
  48804. * @param rootUrl the url of the texture
  48805. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48806. * @returns the transformed texture
  48807. */
  48808. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48809. /**
  48810. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48811. * @param rootUrl the url of the texture
  48812. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48813. * @returns the fallback texture
  48814. */
  48815. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48816. /**
  48817. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48818. * @param data contains the texture data
  48819. * @param texture defines the BabylonJS internal texture
  48820. * @param createPolynomials will be true if polynomials have been requested
  48821. * @param onLoad defines the callback to trigger once the texture is ready
  48822. * @param onError defines the callback to trigger in case of error
  48823. */
  48824. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48825. /**
  48826. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48827. * @param data contains the texture data
  48828. * @param texture defines the BabylonJS internal texture
  48829. * @param callback defines the method to call once ready to upload
  48830. */
  48831. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48832. }
  48833. }
  48834. declare module "babylonjs/Misc/khronosTextureContainer" {
  48835. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48836. /**
  48837. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48838. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48839. */
  48840. export class KhronosTextureContainer {
  48841. /** contents of the KTX container file */
  48842. arrayBuffer: any;
  48843. private static HEADER_LEN;
  48844. private static COMPRESSED_2D;
  48845. private static COMPRESSED_3D;
  48846. private static TEX_2D;
  48847. private static TEX_3D;
  48848. /**
  48849. * Gets the openGL type
  48850. */
  48851. glType: number;
  48852. /**
  48853. * Gets the openGL type size
  48854. */
  48855. glTypeSize: number;
  48856. /**
  48857. * Gets the openGL format
  48858. */
  48859. glFormat: number;
  48860. /**
  48861. * Gets the openGL internal format
  48862. */
  48863. glInternalFormat: number;
  48864. /**
  48865. * Gets the base internal format
  48866. */
  48867. glBaseInternalFormat: number;
  48868. /**
  48869. * Gets image width in pixel
  48870. */
  48871. pixelWidth: number;
  48872. /**
  48873. * Gets image height in pixel
  48874. */
  48875. pixelHeight: number;
  48876. /**
  48877. * Gets image depth in pixels
  48878. */
  48879. pixelDepth: number;
  48880. /**
  48881. * Gets the number of array elements
  48882. */
  48883. numberOfArrayElements: number;
  48884. /**
  48885. * Gets the number of faces
  48886. */
  48887. numberOfFaces: number;
  48888. /**
  48889. * Gets the number of mipmap levels
  48890. */
  48891. numberOfMipmapLevels: number;
  48892. /**
  48893. * Gets the bytes of key value data
  48894. */
  48895. bytesOfKeyValueData: number;
  48896. /**
  48897. * Gets the load type
  48898. */
  48899. loadType: number;
  48900. /**
  48901. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48902. */
  48903. isInvalid: boolean;
  48904. /**
  48905. * Creates a new KhronosTextureContainer
  48906. * @param arrayBuffer contents of the KTX container file
  48907. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48908. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48909. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48910. */
  48911. constructor(
  48912. /** contents of the KTX container file */
  48913. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48914. /**
  48915. * Uploads KTX content to a Babylon Texture.
  48916. * It is assumed that the texture has already been created & is currently bound
  48917. * @hidden
  48918. */
  48919. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48920. private _upload2DCompressedLevels;
  48921. }
  48922. }
  48923. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48924. import { Nullable } from "babylonjs/types";
  48925. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48926. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48927. /**
  48928. * Implementation of the KTX Texture Loader.
  48929. * @hidden
  48930. */
  48931. export class _KTXTextureLoader implements IInternalTextureLoader {
  48932. /**
  48933. * Defines wether the loader supports cascade loading the different faces.
  48934. */
  48935. readonly supportCascades: boolean;
  48936. /**
  48937. * This returns if the loader support the current file information.
  48938. * @param extension defines the file extension of the file being loaded
  48939. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48940. * @param fallback defines the fallback internal texture if any
  48941. * @param isBase64 defines whether the texture is encoded as a base64
  48942. * @param isBuffer defines whether the texture data are stored as a buffer
  48943. * @returns true if the loader can load the specified file
  48944. */
  48945. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48946. /**
  48947. * Transform the url before loading if required.
  48948. * @param rootUrl the url of the texture
  48949. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48950. * @returns the transformed texture
  48951. */
  48952. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48953. /**
  48954. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48955. * @param rootUrl the url of the texture
  48956. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48957. * @returns the fallback texture
  48958. */
  48959. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48960. /**
  48961. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48962. * @param data contains the texture data
  48963. * @param texture defines the BabylonJS internal texture
  48964. * @param createPolynomials will be true if polynomials have been requested
  48965. * @param onLoad defines the callback to trigger once the texture is ready
  48966. * @param onError defines the callback to trigger in case of error
  48967. */
  48968. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48969. /**
  48970. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48971. * @param data contains the texture data
  48972. * @param texture defines the BabylonJS internal texture
  48973. * @param callback defines the method to call once ready to upload
  48974. */
  48975. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48976. }
  48977. }
  48978. declare module "babylonjs/Helpers/sceneHelpers" {
  48979. import { Nullable } from "babylonjs/types";
  48980. import { Mesh } from "babylonjs/Meshes/mesh";
  48981. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48982. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48983. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48984. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48985. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48986. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48987. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48988. import "babylonjs/Meshes/Builders/boxBuilder";
  48989. /** @hidden */
  48990. export var _forceSceneHelpersToBundle: boolean;
  48991. module "babylonjs/scene" {
  48992. interface Scene {
  48993. /**
  48994. * Creates a default light for the scene.
  48995. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48996. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48997. */
  48998. createDefaultLight(replace?: boolean): void;
  48999. /**
  49000. * Creates a default camera for the scene.
  49001. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49002. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49003. * @param replace has default false, when true replaces the active camera in the scene
  49004. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49005. */
  49006. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49007. /**
  49008. * Creates a default camera and a default light.
  49009. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49010. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49011. * @param replace has the default false, when true replaces the active camera/light in the scene
  49012. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49013. */
  49014. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49015. /**
  49016. * Creates a new sky box
  49017. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49018. * @param environmentTexture defines the texture to use as environment texture
  49019. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49020. * @param scale defines the overall scale of the skybox
  49021. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49022. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49023. * @returns a new mesh holding the sky box
  49024. */
  49025. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49026. /**
  49027. * Creates a new environment
  49028. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49029. * @param options defines the options you can use to configure the environment
  49030. * @returns the new EnvironmentHelper
  49031. */
  49032. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49033. /**
  49034. * Creates a new VREXperienceHelper
  49035. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49036. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49037. * @returns a new VREXperienceHelper
  49038. */
  49039. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49040. /**
  49041. * Creates a new XREXperienceHelper
  49042. * @see http://doc.babylonjs.com/how_to/webxr
  49043. * @returns a promise for a new XREXperienceHelper
  49044. */
  49045. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  49046. }
  49047. }
  49048. }
  49049. declare module "babylonjs/Helpers/videoDome" {
  49050. import { Scene } from "babylonjs/scene";
  49051. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49052. import { Mesh } from "babylonjs/Meshes/mesh";
  49053. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49054. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49055. import "babylonjs/Meshes/Builders/sphereBuilder";
  49056. /**
  49057. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49058. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49059. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49060. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49061. */
  49062. export class VideoDome extends TransformNode {
  49063. /**
  49064. * Define the video source as a Monoscopic panoramic 360 video.
  49065. */
  49066. static readonly MODE_MONOSCOPIC: number;
  49067. /**
  49068. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49069. */
  49070. static readonly MODE_TOPBOTTOM: number;
  49071. /**
  49072. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49073. */
  49074. static readonly MODE_SIDEBYSIDE: number;
  49075. private _useDirectMapping;
  49076. /**
  49077. * The video texture being displayed on the sphere
  49078. */
  49079. protected _videoTexture: VideoTexture;
  49080. /**
  49081. * Gets the video texture being displayed on the sphere
  49082. */
  49083. readonly videoTexture: VideoTexture;
  49084. /**
  49085. * The skybox material
  49086. */
  49087. protected _material: BackgroundMaterial;
  49088. /**
  49089. * The surface used for the skybox
  49090. */
  49091. protected _mesh: Mesh;
  49092. /**
  49093. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49094. * Also see the options.resolution property.
  49095. */
  49096. fovMultiplier: number;
  49097. private _videoMode;
  49098. /**
  49099. * Gets or set the current video mode for the video. It can be:
  49100. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49101. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49102. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49103. */
  49104. videoMode: number;
  49105. /**
  49106. * Oberserver used in Stereoscopic VR Mode.
  49107. */
  49108. private _onBeforeCameraRenderObserver;
  49109. /**
  49110. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49111. * @param name Element's name, child elements will append suffixes for their own names.
  49112. * @param urlsOrVideo defines the url(s) or the video element to use
  49113. * @param options An object containing optional or exposed sub element properties
  49114. */
  49115. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49116. resolution?: number;
  49117. clickToPlay?: boolean;
  49118. autoPlay?: boolean;
  49119. loop?: boolean;
  49120. size?: number;
  49121. poster?: string;
  49122. faceForward?: boolean;
  49123. useDirectMapping?: boolean;
  49124. }, scene: Scene);
  49125. private _changeVideoMode;
  49126. /**
  49127. * Releases resources associated with this node.
  49128. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49129. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49130. */
  49131. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49132. }
  49133. }
  49134. declare module "babylonjs/Helpers/index" {
  49135. export * from "babylonjs/Helpers/environmentHelper";
  49136. export * from "babylonjs/Helpers/photoDome";
  49137. export * from "babylonjs/Helpers/sceneHelpers";
  49138. export * from "babylonjs/Helpers/videoDome";
  49139. }
  49140. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49141. import { PerfCounter } from "babylonjs/Misc/tools";
  49142. import { IDisposable } from "babylonjs/scene";
  49143. import { Engine } from "babylonjs/Engines/engine";
  49144. /**
  49145. * This class can be used to get instrumentation data from a Babylon engine
  49146. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49147. */
  49148. export class EngineInstrumentation implements IDisposable {
  49149. /**
  49150. * Define the instrumented engine.
  49151. */
  49152. engine: Engine;
  49153. private _captureGPUFrameTime;
  49154. private _gpuFrameTimeToken;
  49155. private _gpuFrameTime;
  49156. private _captureShaderCompilationTime;
  49157. private _shaderCompilationTime;
  49158. private _onBeginFrameObserver;
  49159. private _onEndFrameObserver;
  49160. private _onBeforeShaderCompilationObserver;
  49161. private _onAfterShaderCompilationObserver;
  49162. /**
  49163. * Gets the perf counter used for GPU frame time
  49164. */
  49165. readonly gpuFrameTimeCounter: PerfCounter;
  49166. /**
  49167. * Gets the GPU frame time capture status
  49168. */
  49169. /**
  49170. * Enable or disable the GPU frame time capture
  49171. */
  49172. captureGPUFrameTime: boolean;
  49173. /**
  49174. * Gets the perf counter used for shader compilation time
  49175. */
  49176. readonly shaderCompilationTimeCounter: PerfCounter;
  49177. /**
  49178. * Gets the shader compilation time capture status
  49179. */
  49180. /**
  49181. * Enable or disable the shader compilation time capture
  49182. */
  49183. captureShaderCompilationTime: boolean;
  49184. /**
  49185. * Instantiates a new engine instrumentation.
  49186. * This class can be used to get instrumentation data from a Babylon engine
  49187. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49188. * @param engine Defines the engine to instrument
  49189. */
  49190. constructor(
  49191. /**
  49192. * Define the instrumented engine.
  49193. */
  49194. engine: Engine);
  49195. /**
  49196. * Dispose and release associated resources.
  49197. */
  49198. dispose(): void;
  49199. }
  49200. }
  49201. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49202. import { PerfCounter } from "babylonjs/Misc/tools";
  49203. import { Scene, IDisposable } from "babylonjs/scene";
  49204. /**
  49205. * This class can be used to get instrumentation data from a Babylon engine
  49206. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49207. */
  49208. export class SceneInstrumentation implements IDisposable {
  49209. /**
  49210. * Defines the scene to instrument
  49211. */
  49212. scene: Scene;
  49213. private _captureActiveMeshesEvaluationTime;
  49214. private _activeMeshesEvaluationTime;
  49215. private _captureRenderTargetsRenderTime;
  49216. private _renderTargetsRenderTime;
  49217. private _captureFrameTime;
  49218. private _frameTime;
  49219. private _captureRenderTime;
  49220. private _renderTime;
  49221. private _captureInterFrameTime;
  49222. private _interFrameTime;
  49223. private _captureParticlesRenderTime;
  49224. private _particlesRenderTime;
  49225. private _captureSpritesRenderTime;
  49226. private _spritesRenderTime;
  49227. private _capturePhysicsTime;
  49228. private _physicsTime;
  49229. private _captureAnimationsTime;
  49230. private _animationsTime;
  49231. private _captureCameraRenderTime;
  49232. private _cameraRenderTime;
  49233. private _onBeforeActiveMeshesEvaluationObserver;
  49234. private _onAfterActiveMeshesEvaluationObserver;
  49235. private _onBeforeRenderTargetsRenderObserver;
  49236. private _onAfterRenderTargetsRenderObserver;
  49237. private _onAfterRenderObserver;
  49238. private _onBeforeDrawPhaseObserver;
  49239. private _onAfterDrawPhaseObserver;
  49240. private _onBeforeAnimationsObserver;
  49241. private _onBeforeParticlesRenderingObserver;
  49242. private _onAfterParticlesRenderingObserver;
  49243. private _onBeforeSpritesRenderingObserver;
  49244. private _onAfterSpritesRenderingObserver;
  49245. private _onBeforePhysicsObserver;
  49246. private _onAfterPhysicsObserver;
  49247. private _onAfterAnimationsObserver;
  49248. private _onBeforeCameraRenderObserver;
  49249. private _onAfterCameraRenderObserver;
  49250. /**
  49251. * Gets the perf counter used for active meshes evaluation time
  49252. */
  49253. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49254. /**
  49255. * Gets the active meshes evaluation time capture status
  49256. */
  49257. /**
  49258. * Enable or disable the active meshes evaluation time capture
  49259. */
  49260. captureActiveMeshesEvaluationTime: boolean;
  49261. /**
  49262. * Gets the perf counter used for render targets render time
  49263. */
  49264. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49265. /**
  49266. * Gets the render targets render time capture status
  49267. */
  49268. /**
  49269. * Enable or disable the render targets render time capture
  49270. */
  49271. captureRenderTargetsRenderTime: boolean;
  49272. /**
  49273. * Gets the perf counter used for particles render time
  49274. */
  49275. readonly particlesRenderTimeCounter: PerfCounter;
  49276. /**
  49277. * Gets the particles render time capture status
  49278. */
  49279. /**
  49280. * Enable or disable the particles render time capture
  49281. */
  49282. captureParticlesRenderTime: boolean;
  49283. /**
  49284. * Gets the perf counter used for sprites render time
  49285. */
  49286. readonly spritesRenderTimeCounter: PerfCounter;
  49287. /**
  49288. * Gets the sprites render time capture status
  49289. */
  49290. /**
  49291. * Enable or disable the sprites render time capture
  49292. */
  49293. captureSpritesRenderTime: boolean;
  49294. /**
  49295. * Gets the perf counter used for physics time
  49296. */
  49297. readonly physicsTimeCounter: PerfCounter;
  49298. /**
  49299. * Gets the physics time capture status
  49300. */
  49301. /**
  49302. * Enable or disable the physics time capture
  49303. */
  49304. capturePhysicsTime: boolean;
  49305. /**
  49306. * Gets the perf counter used for animations time
  49307. */
  49308. readonly animationsTimeCounter: PerfCounter;
  49309. /**
  49310. * Gets the animations time capture status
  49311. */
  49312. /**
  49313. * Enable or disable the animations time capture
  49314. */
  49315. captureAnimationsTime: boolean;
  49316. /**
  49317. * Gets the perf counter used for frame time capture
  49318. */
  49319. readonly frameTimeCounter: PerfCounter;
  49320. /**
  49321. * Gets the frame time capture status
  49322. */
  49323. /**
  49324. * Enable or disable the frame time capture
  49325. */
  49326. captureFrameTime: boolean;
  49327. /**
  49328. * Gets the perf counter used for inter-frames time capture
  49329. */
  49330. readonly interFrameTimeCounter: PerfCounter;
  49331. /**
  49332. * Gets the inter-frames time capture status
  49333. */
  49334. /**
  49335. * Enable or disable the inter-frames time capture
  49336. */
  49337. captureInterFrameTime: boolean;
  49338. /**
  49339. * Gets the perf counter used for render time capture
  49340. */
  49341. readonly renderTimeCounter: PerfCounter;
  49342. /**
  49343. * Gets the render time capture status
  49344. */
  49345. /**
  49346. * Enable or disable the render time capture
  49347. */
  49348. captureRenderTime: boolean;
  49349. /**
  49350. * Gets the perf counter used for camera render time capture
  49351. */
  49352. readonly cameraRenderTimeCounter: PerfCounter;
  49353. /**
  49354. * Gets the camera render time capture status
  49355. */
  49356. /**
  49357. * Enable or disable the camera render time capture
  49358. */
  49359. captureCameraRenderTime: boolean;
  49360. /**
  49361. * Gets the perf counter used for draw calls
  49362. */
  49363. readonly drawCallsCounter: PerfCounter;
  49364. /**
  49365. * Instantiates a new scene instrumentation.
  49366. * This class can be used to get instrumentation data from a Babylon engine
  49367. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49368. * @param scene Defines the scene to instrument
  49369. */
  49370. constructor(
  49371. /**
  49372. * Defines the scene to instrument
  49373. */
  49374. scene: Scene);
  49375. /**
  49376. * Dispose and release associated resources.
  49377. */
  49378. dispose(): void;
  49379. }
  49380. }
  49381. declare module "babylonjs/Instrumentation/index" {
  49382. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49383. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49384. export * from "babylonjs/Instrumentation/timeToken";
  49385. }
  49386. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49387. /** @hidden */
  49388. export var glowMapGenerationPixelShader: {
  49389. name: string;
  49390. shader: string;
  49391. };
  49392. }
  49393. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49394. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49395. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49396. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49397. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49398. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49399. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49400. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49401. /** @hidden */
  49402. export var glowMapGenerationVertexShader: {
  49403. name: string;
  49404. shader: string;
  49405. };
  49406. }
  49407. declare module "babylonjs/Layers/effectLayer" {
  49408. import { Observable } from "babylonjs/Misc/observable";
  49409. import { Nullable } from "babylonjs/types";
  49410. import { Camera } from "babylonjs/Cameras/camera";
  49411. import { Scene } from "babylonjs/scene";
  49412. import { Color4, ISize } from "babylonjs/Maths/math";
  49413. import { Engine } from "babylonjs/Engines/engine";
  49414. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49416. import { Mesh } from "babylonjs/Meshes/mesh";
  49417. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49418. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49419. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49420. import { Effect } from "babylonjs/Materials/effect";
  49421. import { Material } from "babylonjs/Materials/material";
  49422. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49423. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49424. /**
  49425. * Effect layer options. This helps customizing the behaviour
  49426. * of the effect layer.
  49427. */
  49428. export interface IEffectLayerOptions {
  49429. /**
  49430. * Multiplication factor apply to the canvas size to compute the render target size
  49431. * used to generated the objects (the smaller the faster).
  49432. */
  49433. mainTextureRatio: number;
  49434. /**
  49435. * Enforces a fixed size texture to ensure effect stability across devices.
  49436. */
  49437. mainTextureFixedSize?: number;
  49438. /**
  49439. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49440. */
  49441. alphaBlendingMode: number;
  49442. /**
  49443. * The camera attached to the layer.
  49444. */
  49445. camera: Nullable<Camera>;
  49446. /**
  49447. * The rendering group to draw the layer in.
  49448. */
  49449. renderingGroupId: number;
  49450. }
  49451. /**
  49452. * The effect layer Helps adding post process effect blended with the main pass.
  49453. *
  49454. * This can be for instance use to generate glow or higlight effects on the scene.
  49455. *
  49456. * The effect layer class can not be used directly and is intented to inherited from to be
  49457. * customized per effects.
  49458. */
  49459. export abstract class EffectLayer {
  49460. private _vertexBuffers;
  49461. private _indexBuffer;
  49462. private _cachedDefines;
  49463. private _effectLayerMapGenerationEffect;
  49464. private _effectLayerOptions;
  49465. private _mergeEffect;
  49466. protected _scene: Scene;
  49467. protected _engine: Engine;
  49468. protected _maxSize: number;
  49469. protected _mainTextureDesiredSize: ISize;
  49470. protected _mainTexture: RenderTargetTexture;
  49471. protected _shouldRender: boolean;
  49472. protected _postProcesses: PostProcess[];
  49473. protected _textures: BaseTexture[];
  49474. protected _emissiveTextureAndColor: {
  49475. texture: Nullable<BaseTexture>;
  49476. color: Color4;
  49477. };
  49478. /**
  49479. * The name of the layer
  49480. */
  49481. name: string;
  49482. /**
  49483. * The clear color of the texture used to generate the glow map.
  49484. */
  49485. neutralColor: Color4;
  49486. /**
  49487. * Specifies wether the highlight layer is enabled or not.
  49488. */
  49489. isEnabled: boolean;
  49490. /**
  49491. * Gets the camera attached to the layer.
  49492. */
  49493. readonly camera: Nullable<Camera>;
  49494. /**
  49495. * Gets the rendering group id the layer should render in.
  49496. */
  49497. readonly renderingGroupId: number;
  49498. /**
  49499. * An event triggered when the effect layer has been disposed.
  49500. */
  49501. onDisposeObservable: Observable<EffectLayer>;
  49502. /**
  49503. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49504. */
  49505. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49506. /**
  49507. * An event triggered when the generated texture is being merged in the scene.
  49508. */
  49509. onBeforeComposeObservable: Observable<EffectLayer>;
  49510. /**
  49511. * An event triggered when the generated texture has been merged in the scene.
  49512. */
  49513. onAfterComposeObservable: Observable<EffectLayer>;
  49514. /**
  49515. * An event triggered when the efffect layer changes its size.
  49516. */
  49517. onSizeChangedObservable: Observable<EffectLayer>;
  49518. /** @hidden */
  49519. static _SceneComponentInitialization: (scene: Scene) => void;
  49520. /**
  49521. * Instantiates a new effect Layer and references it in the scene.
  49522. * @param name The name of the layer
  49523. * @param scene The scene to use the layer in
  49524. */
  49525. constructor(
  49526. /** The Friendly of the effect in the scene */
  49527. name: string, scene: Scene);
  49528. /**
  49529. * Get the effect name of the layer.
  49530. * @return The effect name
  49531. */
  49532. abstract getEffectName(): string;
  49533. /**
  49534. * Checks for the readiness of the element composing the layer.
  49535. * @param subMesh the mesh to check for
  49536. * @param useInstances specify wether or not to use instances to render the mesh
  49537. * @return true if ready otherwise, false
  49538. */
  49539. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49540. /**
  49541. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49542. * @returns true if the effect requires stencil during the main canvas render pass.
  49543. */
  49544. abstract needStencil(): boolean;
  49545. /**
  49546. * Create the merge effect. This is the shader use to blit the information back
  49547. * to the main canvas at the end of the scene rendering.
  49548. * @returns The effect containing the shader used to merge the effect on the main canvas
  49549. */
  49550. protected abstract _createMergeEffect(): Effect;
  49551. /**
  49552. * Creates the render target textures and post processes used in the effect layer.
  49553. */
  49554. protected abstract _createTextureAndPostProcesses(): void;
  49555. /**
  49556. * Implementation specific of rendering the generating effect on the main canvas.
  49557. * @param effect The effect used to render through
  49558. */
  49559. protected abstract _internalRender(effect: Effect): void;
  49560. /**
  49561. * Sets the required values for both the emissive texture and and the main color.
  49562. */
  49563. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49564. /**
  49565. * Free any resources and references associated to a mesh.
  49566. * Internal use
  49567. * @param mesh The mesh to free.
  49568. */
  49569. abstract _disposeMesh(mesh: Mesh): void;
  49570. /**
  49571. * Serializes this layer (Glow or Highlight for example)
  49572. * @returns a serialized layer object
  49573. */
  49574. abstract serialize?(): any;
  49575. /**
  49576. * Initializes the effect layer with the required options.
  49577. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49578. */
  49579. protected _init(options: Partial<IEffectLayerOptions>): void;
  49580. /**
  49581. * Generates the index buffer of the full screen quad blending to the main canvas.
  49582. */
  49583. private _generateIndexBuffer;
  49584. /**
  49585. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49586. */
  49587. private _generateVertexBuffer;
  49588. /**
  49589. * Sets the main texture desired size which is the closest power of two
  49590. * of the engine canvas size.
  49591. */
  49592. private _setMainTextureSize;
  49593. /**
  49594. * Creates the main texture for the effect layer.
  49595. */
  49596. protected _createMainTexture(): void;
  49597. /**
  49598. * Adds specific effects defines.
  49599. * @param defines The defines to add specifics to.
  49600. */
  49601. protected _addCustomEffectDefines(defines: string[]): void;
  49602. /**
  49603. * Checks for the readiness of the element composing the layer.
  49604. * @param subMesh the mesh to check for
  49605. * @param useInstances specify wether or not to use instances to render the mesh
  49606. * @param emissiveTexture the associated emissive texture used to generate the glow
  49607. * @return true if ready otherwise, false
  49608. */
  49609. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49610. /**
  49611. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49612. */
  49613. render(): void;
  49614. /**
  49615. * Determine if a given mesh will be used in the current effect.
  49616. * @param mesh mesh to test
  49617. * @returns true if the mesh will be used
  49618. */
  49619. hasMesh(mesh: AbstractMesh): boolean;
  49620. /**
  49621. * Returns true if the layer contains information to display, otherwise false.
  49622. * @returns true if the glow layer should be rendered
  49623. */
  49624. shouldRender(): boolean;
  49625. /**
  49626. * Returns true if the mesh should render, otherwise false.
  49627. * @param mesh The mesh to render
  49628. * @returns true if it should render otherwise false
  49629. */
  49630. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49631. /**
  49632. * Returns true if the mesh can be rendered, otherwise false.
  49633. * @param mesh The mesh to render
  49634. * @param material The material used on the mesh
  49635. * @returns true if it can be rendered otherwise false
  49636. */
  49637. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49638. /**
  49639. * Returns true if the mesh should render, otherwise false.
  49640. * @param mesh The mesh to render
  49641. * @returns true if it should render otherwise false
  49642. */
  49643. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49644. /**
  49645. * Renders the submesh passed in parameter to the generation map.
  49646. */
  49647. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49648. /**
  49649. * Rebuild the required buffers.
  49650. * @hidden Internal use only.
  49651. */
  49652. _rebuild(): void;
  49653. /**
  49654. * Dispose only the render target textures and post process.
  49655. */
  49656. private _disposeTextureAndPostProcesses;
  49657. /**
  49658. * Dispose the highlight layer and free resources.
  49659. */
  49660. dispose(): void;
  49661. /**
  49662. * Gets the class name of the effect layer
  49663. * @returns the string with the class name of the effect layer
  49664. */
  49665. getClassName(): string;
  49666. /**
  49667. * Creates an effect layer from parsed effect layer data
  49668. * @param parsedEffectLayer defines effect layer data
  49669. * @param scene defines the current scene
  49670. * @param rootUrl defines the root URL containing the effect layer information
  49671. * @returns a parsed effect Layer
  49672. */
  49673. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49674. }
  49675. }
  49676. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49677. import { Scene } from "babylonjs/scene";
  49678. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49679. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49680. import { AbstractScene } from "babylonjs/abstractScene";
  49681. module "babylonjs/abstractScene" {
  49682. interface AbstractScene {
  49683. /**
  49684. * The list of effect layers (highlights/glow) added to the scene
  49685. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49686. * @see http://doc.babylonjs.com/how_to/glow_layer
  49687. */
  49688. effectLayers: Array<EffectLayer>;
  49689. /**
  49690. * Removes the given effect layer from this scene.
  49691. * @param toRemove defines the effect layer to remove
  49692. * @returns the index of the removed effect layer
  49693. */
  49694. removeEffectLayer(toRemove: EffectLayer): number;
  49695. /**
  49696. * Adds the given effect layer to this scene
  49697. * @param newEffectLayer defines the effect layer to add
  49698. */
  49699. addEffectLayer(newEffectLayer: EffectLayer): void;
  49700. }
  49701. }
  49702. /**
  49703. * Defines the layer scene component responsible to manage any effect layers
  49704. * in a given scene.
  49705. */
  49706. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49707. /**
  49708. * The component name helpfull to identify the component in the list of scene components.
  49709. */
  49710. readonly name: string;
  49711. /**
  49712. * The scene the component belongs to.
  49713. */
  49714. scene: Scene;
  49715. private _engine;
  49716. private _renderEffects;
  49717. private _needStencil;
  49718. private _previousStencilState;
  49719. /**
  49720. * Creates a new instance of the component for the given scene
  49721. * @param scene Defines the scene to register the component in
  49722. */
  49723. constructor(scene: Scene);
  49724. /**
  49725. * Registers the component in a given scene
  49726. */
  49727. register(): void;
  49728. /**
  49729. * Rebuilds the elements related to this component in case of
  49730. * context lost for instance.
  49731. */
  49732. rebuild(): void;
  49733. /**
  49734. * Serializes the component data to the specified json object
  49735. * @param serializationObject The object to serialize to
  49736. */
  49737. serialize(serializationObject: any): void;
  49738. /**
  49739. * Adds all the elements from the container to the scene
  49740. * @param container the container holding the elements
  49741. */
  49742. addFromContainer(container: AbstractScene): void;
  49743. /**
  49744. * Removes all the elements in the container from the scene
  49745. * @param container contains the elements to remove
  49746. * @param dispose if the removed element should be disposed (default: false)
  49747. */
  49748. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49749. /**
  49750. * Disposes the component and the associated ressources.
  49751. */
  49752. dispose(): void;
  49753. private _isReadyForMesh;
  49754. private _renderMainTexture;
  49755. private _setStencil;
  49756. private _setStencilBack;
  49757. private _draw;
  49758. private _drawCamera;
  49759. private _drawRenderingGroup;
  49760. }
  49761. }
  49762. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49763. /** @hidden */
  49764. export var glowMapMergePixelShader: {
  49765. name: string;
  49766. shader: string;
  49767. };
  49768. }
  49769. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49770. /** @hidden */
  49771. export var glowMapMergeVertexShader: {
  49772. name: string;
  49773. shader: string;
  49774. };
  49775. }
  49776. declare module "babylonjs/Layers/glowLayer" {
  49777. import { Nullable } from "babylonjs/types";
  49778. import { Camera } from "babylonjs/Cameras/camera";
  49779. import { Scene } from "babylonjs/scene";
  49780. import { Color4 } from "babylonjs/Maths/math";
  49781. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49783. import { Mesh } from "babylonjs/Meshes/mesh";
  49784. import { Texture } from "babylonjs/Materials/Textures/texture";
  49785. import { Effect } from "babylonjs/Materials/effect";
  49786. import { Material } from "babylonjs/Materials/material";
  49787. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49788. import "babylonjs/Shaders/glowMapMerge.fragment";
  49789. import "babylonjs/Shaders/glowMapMerge.vertex";
  49790. import "babylonjs/Layers/effectLayerSceneComponent";
  49791. module "babylonjs/abstractScene" {
  49792. interface AbstractScene {
  49793. /**
  49794. * Return a the first highlight layer of the scene with a given name.
  49795. * @param name The name of the highlight layer to look for.
  49796. * @return The highlight layer if found otherwise null.
  49797. */
  49798. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49799. }
  49800. }
  49801. /**
  49802. * Glow layer options. This helps customizing the behaviour
  49803. * of the glow layer.
  49804. */
  49805. export interface IGlowLayerOptions {
  49806. /**
  49807. * Multiplication factor apply to the canvas size to compute the render target size
  49808. * used to generated the glowing objects (the smaller the faster).
  49809. */
  49810. mainTextureRatio: number;
  49811. /**
  49812. * Enforces a fixed size texture to ensure resize independant blur.
  49813. */
  49814. mainTextureFixedSize?: number;
  49815. /**
  49816. * How big is the kernel of the blur texture.
  49817. */
  49818. blurKernelSize: number;
  49819. /**
  49820. * The camera attached to the layer.
  49821. */
  49822. camera: Nullable<Camera>;
  49823. /**
  49824. * Enable MSAA by chosing the number of samples.
  49825. */
  49826. mainTextureSamples?: number;
  49827. /**
  49828. * The rendering group to draw the layer in.
  49829. */
  49830. renderingGroupId: number;
  49831. }
  49832. /**
  49833. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49834. *
  49835. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49836. * glowy meshes to your scene.
  49837. *
  49838. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49839. */
  49840. export class GlowLayer extends EffectLayer {
  49841. /**
  49842. * Effect Name of the layer.
  49843. */
  49844. static readonly EffectName: string;
  49845. /**
  49846. * The default blur kernel size used for the glow.
  49847. */
  49848. static DefaultBlurKernelSize: number;
  49849. /**
  49850. * The default texture size ratio used for the glow.
  49851. */
  49852. static DefaultTextureRatio: number;
  49853. /**
  49854. * Sets the kernel size of the blur.
  49855. */
  49856. /**
  49857. * Gets the kernel size of the blur.
  49858. */
  49859. blurKernelSize: number;
  49860. /**
  49861. * Sets the glow intensity.
  49862. */
  49863. /**
  49864. * Gets the glow intensity.
  49865. */
  49866. intensity: number;
  49867. private _options;
  49868. private _intensity;
  49869. private _horizontalBlurPostprocess1;
  49870. private _verticalBlurPostprocess1;
  49871. private _horizontalBlurPostprocess2;
  49872. private _verticalBlurPostprocess2;
  49873. private _blurTexture1;
  49874. private _blurTexture2;
  49875. private _postProcesses1;
  49876. private _postProcesses2;
  49877. private _includedOnlyMeshes;
  49878. private _excludedMeshes;
  49879. /**
  49880. * Callback used to let the user override the color selection on a per mesh basis
  49881. */
  49882. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49883. /**
  49884. * Callback used to let the user override the texture selection on a per mesh basis
  49885. */
  49886. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49887. /**
  49888. * Instantiates a new glow Layer and references it to the scene.
  49889. * @param name The name of the layer
  49890. * @param scene The scene to use the layer in
  49891. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49892. */
  49893. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49894. /**
  49895. * Get the effect name of the layer.
  49896. * @return The effect name
  49897. */
  49898. getEffectName(): string;
  49899. /**
  49900. * Create the merge effect. This is the shader use to blit the information back
  49901. * to the main canvas at the end of the scene rendering.
  49902. */
  49903. protected _createMergeEffect(): Effect;
  49904. /**
  49905. * Creates the render target textures and post processes used in the glow layer.
  49906. */
  49907. protected _createTextureAndPostProcesses(): void;
  49908. /**
  49909. * Checks for the readiness of the element composing the layer.
  49910. * @param subMesh the mesh to check for
  49911. * @param useInstances specify wether or not to use instances to render the mesh
  49912. * @param emissiveTexture the associated emissive texture used to generate the glow
  49913. * @return true if ready otherwise, false
  49914. */
  49915. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49916. /**
  49917. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49918. */
  49919. needStencil(): boolean;
  49920. /**
  49921. * Returns true if the mesh can be rendered, otherwise false.
  49922. * @param mesh The mesh to render
  49923. * @param material The material used on the mesh
  49924. * @returns true if it can be rendered otherwise false
  49925. */
  49926. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49927. /**
  49928. * Implementation specific of rendering the generating effect on the main canvas.
  49929. * @param effect The effect used to render through
  49930. */
  49931. protected _internalRender(effect: Effect): void;
  49932. /**
  49933. * Sets the required values for both the emissive texture and and the main color.
  49934. */
  49935. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49936. /**
  49937. * Returns true if the mesh should render, otherwise false.
  49938. * @param mesh The mesh to render
  49939. * @returns true if it should render otherwise false
  49940. */
  49941. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49942. /**
  49943. * Adds specific effects defines.
  49944. * @param defines The defines to add specifics to.
  49945. */
  49946. protected _addCustomEffectDefines(defines: string[]): void;
  49947. /**
  49948. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49949. * @param mesh The mesh to exclude from the glow layer
  49950. */
  49951. addExcludedMesh(mesh: Mesh): void;
  49952. /**
  49953. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49954. * @param mesh The mesh to remove
  49955. */
  49956. removeExcludedMesh(mesh: Mesh): void;
  49957. /**
  49958. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49959. * @param mesh The mesh to include in the glow layer
  49960. */
  49961. addIncludedOnlyMesh(mesh: Mesh): void;
  49962. /**
  49963. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49964. * @param mesh The mesh to remove
  49965. */
  49966. removeIncludedOnlyMesh(mesh: Mesh): void;
  49967. /**
  49968. * Determine if a given mesh will be used in the glow layer
  49969. * @param mesh The mesh to test
  49970. * @returns true if the mesh will be highlighted by the current glow layer
  49971. */
  49972. hasMesh(mesh: AbstractMesh): boolean;
  49973. /**
  49974. * Free any resources and references associated to a mesh.
  49975. * Internal use
  49976. * @param mesh The mesh to free.
  49977. * @hidden
  49978. */
  49979. _disposeMesh(mesh: Mesh): void;
  49980. /**
  49981. * Gets the class name of the effect layer
  49982. * @returns the string with the class name of the effect layer
  49983. */
  49984. getClassName(): string;
  49985. /**
  49986. * Serializes this glow layer
  49987. * @returns a serialized glow layer object
  49988. */
  49989. serialize(): any;
  49990. /**
  49991. * Creates a Glow Layer from parsed glow layer data
  49992. * @param parsedGlowLayer defines glow layer data
  49993. * @param scene defines the current scene
  49994. * @param rootUrl defines the root URL containing the glow layer information
  49995. * @returns a parsed Glow Layer
  49996. */
  49997. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49998. }
  49999. }
  50000. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50001. /** @hidden */
  50002. export var glowBlurPostProcessPixelShader: {
  50003. name: string;
  50004. shader: string;
  50005. };
  50006. }
  50007. declare module "babylonjs/Layers/highlightLayer" {
  50008. import { Observable } from "babylonjs/Misc/observable";
  50009. import { Nullable } from "babylonjs/types";
  50010. import { Camera } from "babylonjs/Cameras/camera";
  50011. import { Scene } from "babylonjs/scene";
  50012. import { Color3, Color4 } from "babylonjs/Maths/math";
  50013. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50015. import { Mesh } from "babylonjs/Meshes/mesh";
  50016. import { Effect } from "babylonjs/Materials/effect";
  50017. import { Material } from "babylonjs/Materials/material";
  50018. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50019. import "babylonjs/Shaders/glowMapMerge.fragment";
  50020. import "babylonjs/Shaders/glowMapMerge.vertex";
  50021. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50022. module "babylonjs/abstractScene" {
  50023. interface AbstractScene {
  50024. /**
  50025. * Return a the first highlight layer of the scene with a given name.
  50026. * @param name The name of the highlight layer to look for.
  50027. * @return The highlight layer if found otherwise null.
  50028. */
  50029. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50030. }
  50031. }
  50032. /**
  50033. * Highlight layer options. This helps customizing the behaviour
  50034. * of the highlight layer.
  50035. */
  50036. export interface IHighlightLayerOptions {
  50037. /**
  50038. * Multiplication factor apply to the canvas size to compute the render target size
  50039. * used to generated the glowing objects (the smaller the faster).
  50040. */
  50041. mainTextureRatio: number;
  50042. /**
  50043. * Enforces a fixed size texture to ensure resize independant blur.
  50044. */
  50045. mainTextureFixedSize?: number;
  50046. /**
  50047. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50048. * of the picture to blur (the smaller the faster).
  50049. */
  50050. blurTextureSizeRatio: number;
  50051. /**
  50052. * How big in texel of the blur texture is the vertical blur.
  50053. */
  50054. blurVerticalSize: number;
  50055. /**
  50056. * How big in texel of the blur texture is the horizontal blur.
  50057. */
  50058. blurHorizontalSize: number;
  50059. /**
  50060. * Alpha blending mode used to apply the blur. Default is combine.
  50061. */
  50062. alphaBlendingMode: number;
  50063. /**
  50064. * The camera attached to the layer.
  50065. */
  50066. camera: Nullable<Camera>;
  50067. /**
  50068. * Should we display highlight as a solid stroke?
  50069. */
  50070. isStroke?: boolean;
  50071. /**
  50072. * The rendering group to draw the layer in.
  50073. */
  50074. renderingGroupId: number;
  50075. }
  50076. /**
  50077. * The highlight layer Helps adding a glow effect around a mesh.
  50078. *
  50079. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50080. * glowy meshes to your scene.
  50081. *
  50082. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50083. */
  50084. export class HighlightLayer extends EffectLayer {
  50085. name: string;
  50086. /**
  50087. * Effect Name of the highlight layer.
  50088. */
  50089. static readonly EffectName: string;
  50090. /**
  50091. * The neutral color used during the preparation of the glow effect.
  50092. * This is black by default as the blend operation is a blend operation.
  50093. */
  50094. static NeutralColor: Color4;
  50095. /**
  50096. * Stencil value used for glowing meshes.
  50097. */
  50098. static GlowingMeshStencilReference: number;
  50099. /**
  50100. * Stencil value used for the other meshes in the scene.
  50101. */
  50102. static NormalMeshStencilReference: number;
  50103. /**
  50104. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50105. */
  50106. innerGlow: boolean;
  50107. /**
  50108. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50109. */
  50110. outerGlow: boolean;
  50111. /**
  50112. * Specifies the horizontal size of the blur.
  50113. */
  50114. /**
  50115. * Gets the horizontal size of the blur.
  50116. */
  50117. blurHorizontalSize: number;
  50118. /**
  50119. * Specifies the vertical size of the blur.
  50120. */
  50121. /**
  50122. * Gets the vertical size of the blur.
  50123. */
  50124. blurVerticalSize: number;
  50125. /**
  50126. * An event triggered when the highlight layer is being blurred.
  50127. */
  50128. onBeforeBlurObservable: Observable<HighlightLayer>;
  50129. /**
  50130. * An event triggered when the highlight layer has been blurred.
  50131. */
  50132. onAfterBlurObservable: Observable<HighlightLayer>;
  50133. private _instanceGlowingMeshStencilReference;
  50134. private _options;
  50135. private _downSamplePostprocess;
  50136. private _horizontalBlurPostprocess;
  50137. private _verticalBlurPostprocess;
  50138. private _blurTexture;
  50139. private _meshes;
  50140. private _excludedMeshes;
  50141. /**
  50142. * Instantiates a new highlight Layer and references it to the scene..
  50143. * @param name The name of the layer
  50144. * @param scene The scene to use the layer in
  50145. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50146. */
  50147. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50148. /**
  50149. * Get the effect name of the layer.
  50150. * @return The effect name
  50151. */
  50152. getEffectName(): string;
  50153. /**
  50154. * Create the merge effect. This is the shader use to blit the information back
  50155. * to the main canvas at the end of the scene rendering.
  50156. */
  50157. protected _createMergeEffect(): Effect;
  50158. /**
  50159. * Creates the render target textures and post processes used in the highlight layer.
  50160. */
  50161. protected _createTextureAndPostProcesses(): void;
  50162. /**
  50163. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50164. */
  50165. needStencil(): boolean;
  50166. /**
  50167. * Checks for the readiness of the element composing the layer.
  50168. * @param subMesh the mesh to check for
  50169. * @param useInstances specify wether or not to use instances to render the mesh
  50170. * @param emissiveTexture the associated emissive texture used to generate the glow
  50171. * @return true if ready otherwise, false
  50172. */
  50173. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50174. /**
  50175. * Implementation specific of rendering the generating effect on the main canvas.
  50176. * @param effect The effect used to render through
  50177. */
  50178. protected _internalRender(effect: Effect): void;
  50179. /**
  50180. * Returns true if the layer contains information to display, otherwise false.
  50181. */
  50182. shouldRender(): boolean;
  50183. /**
  50184. * Returns true if the mesh should render, otherwise false.
  50185. * @param mesh The mesh to render
  50186. * @returns true if it should render otherwise false
  50187. */
  50188. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50189. /**
  50190. * Sets the required values for both the emissive texture and and the main color.
  50191. */
  50192. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50193. /**
  50194. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50195. * @param mesh The mesh to exclude from the highlight layer
  50196. */
  50197. addExcludedMesh(mesh: Mesh): void;
  50198. /**
  50199. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50200. * @param mesh The mesh to highlight
  50201. */
  50202. removeExcludedMesh(mesh: Mesh): void;
  50203. /**
  50204. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50205. * @param mesh mesh to test
  50206. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50207. */
  50208. hasMesh(mesh: AbstractMesh): boolean;
  50209. /**
  50210. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50211. * @param mesh The mesh to highlight
  50212. * @param color The color of the highlight
  50213. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50214. */
  50215. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50216. /**
  50217. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50218. * @param mesh The mesh to highlight
  50219. */
  50220. removeMesh(mesh: Mesh): void;
  50221. /**
  50222. * Force the stencil to the normal expected value for none glowing parts
  50223. */
  50224. private _defaultStencilReference;
  50225. /**
  50226. * Free any resources and references associated to a mesh.
  50227. * Internal use
  50228. * @param mesh The mesh to free.
  50229. * @hidden
  50230. */
  50231. _disposeMesh(mesh: Mesh): void;
  50232. /**
  50233. * Dispose the highlight layer and free resources.
  50234. */
  50235. dispose(): void;
  50236. /**
  50237. * Gets the class name of the effect layer
  50238. * @returns the string with the class name of the effect layer
  50239. */
  50240. getClassName(): string;
  50241. /**
  50242. * Serializes this Highlight layer
  50243. * @returns a serialized Highlight layer object
  50244. */
  50245. serialize(): any;
  50246. /**
  50247. * Creates a Highlight layer from parsed Highlight layer data
  50248. * @param parsedHightlightLayer defines the Highlight layer data
  50249. * @param scene defines the current scene
  50250. * @param rootUrl defines the root URL containing the Highlight layer information
  50251. * @returns a parsed Highlight layer
  50252. */
  50253. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50254. }
  50255. }
  50256. declare module "babylonjs/Layers/layerSceneComponent" {
  50257. import { Scene } from "babylonjs/scene";
  50258. import { ISceneComponent } from "babylonjs/sceneComponent";
  50259. import { Layer } from "babylonjs/Layers/layer";
  50260. import { AbstractScene } from "babylonjs/abstractScene";
  50261. module "babylonjs/abstractScene" {
  50262. interface AbstractScene {
  50263. /**
  50264. * The list of layers (background and foreground) of the scene
  50265. */
  50266. layers: Array<Layer>;
  50267. }
  50268. }
  50269. /**
  50270. * Defines the layer scene component responsible to manage any layers
  50271. * in a given scene.
  50272. */
  50273. export class LayerSceneComponent implements ISceneComponent {
  50274. /**
  50275. * The component name helpfull to identify the component in the list of scene components.
  50276. */
  50277. readonly name: string;
  50278. /**
  50279. * The scene the component belongs to.
  50280. */
  50281. scene: Scene;
  50282. private _engine;
  50283. /**
  50284. * Creates a new instance of the component for the given scene
  50285. * @param scene Defines the scene to register the component in
  50286. */
  50287. constructor(scene: Scene);
  50288. /**
  50289. * Registers the component in a given scene
  50290. */
  50291. register(): void;
  50292. /**
  50293. * Rebuilds the elements related to this component in case of
  50294. * context lost for instance.
  50295. */
  50296. rebuild(): void;
  50297. /**
  50298. * Disposes the component and the associated ressources.
  50299. */
  50300. dispose(): void;
  50301. private _draw;
  50302. private _drawCameraPredicate;
  50303. private _drawCameraBackground;
  50304. private _drawCameraForeground;
  50305. private _drawRenderTargetPredicate;
  50306. private _drawRenderTargetBackground;
  50307. private _drawRenderTargetForeground;
  50308. /**
  50309. * Adds all the elements from the container to the scene
  50310. * @param container the container holding the elements
  50311. */
  50312. addFromContainer(container: AbstractScene): void;
  50313. /**
  50314. * Removes all the elements in the container from the scene
  50315. * @param container contains the elements to remove
  50316. * @param dispose if the removed element should be disposed (default: false)
  50317. */
  50318. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50319. }
  50320. }
  50321. declare module "babylonjs/Shaders/layer.fragment" {
  50322. /** @hidden */
  50323. export var layerPixelShader: {
  50324. name: string;
  50325. shader: string;
  50326. };
  50327. }
  50328. declare module "babylonjs/Shaders/layer.vertex" {
  50329. /** @hidden */
  50330. export var layerVertexShader: {
  50331. name: string;
  50332. shader: string;
  50333. };
  50334. }
  50335. declare module "babylonjs/Layers/layer" {
  50336. import { Observable } from "babylonjs/Misc/observable";
  50337. import { Nullable } from "babylonjs/types";
  50338. import { Scene } from "babylonjs/scene";
  50339. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50340. import { Texture } from "babylonjs/Materials/Textures/texture";
  50341. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50342. import "babylonjs/Shaders/layer.fragment";
  50343. import "babylonjs/Shaders/layer.vertex";
  50344. /**
  50345. * This represents a full screen 2d layer.
  50346. * This can be useful to display a picture in the background of your scene for instance.
  50347. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50348. */
  50349. export class Layer {
  50350. /**
  50351. * Define the name of the layer.
  50352. */
  50353. name: string;
  50354. /**
  50355. * Define the texture the layer should display.
  50356. */
  50357. texture: Nullable<Texture>;
  50358. /**
  50359. * Is the layer in background or foreground.
  50360. */
  50361. isBackground: boolean;
  50362. /**
  50363. * Define the color of the layer (instead of texture).
  50364. */
  50365. color: Color4;
  50366. /**
  50367. * Define the scale of the layer in order to zoom in out of the texture.
  50368. */
  50369. scale: Vector2;
  50370. /**
  50371. * Define an offset for the layer in order to shift the texture.
  50372. */
  50373. offset: Vector2;
  50374. /**
  50375. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50376. */
  50377. alphaBlendingMode: number;
  50378. /**
  50379. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50380. * Alpha test will not mix with the background color in case of transparency.
  50381. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50382. */
  50383. alphaTest: boolean;
  50384. /**
  50385. * Define a mask to restrict the layer to only some of the scene cameras.
  50386. */
  50387. layerMask: number;
  50388. /**
  50389. * Define the list of render target the layer is visible into.
  50390. */
  50391. renderTargetTextures: RenderTargetTexture[];
  50392. /**
  50393. * Define if the layer is only used in renderTarget or if it also
  50394. * renders in the main frame buffer of the canvas.
  50395. */
  50396. renderOnlyInRenderTargetTextures: boolean;
  50397. private _scene;
  50398. private _vertexBuffers;
  50399. private _indexBuffer;
  50400. private _effect;
  50401. private _alphaTestEffect;
  50402. /**
  50403. * An event triggered when the layer is disposed.
  50404. */
  50405. onDisposeObservable: Observable<Layer>;
  50406. private _onDisposeObserver;
  50407. /**
  50408. * Back compatibility with callback before the onDisposeObservable existed.
  50409. * The set callback will be triggered when the layer has been disposed.
  50410. */
  50411. onDispose: () => void;
  50412. /**
  50413. * An event triggered before rendering the scene
  50414. */
  50415. onBeforeRenderObservable: Observable<Layer>;
  50416. private _onBeforeRenderObserver;
  50417. /**
  50418. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50419. * The set callback will be triggered just before rendering the layer.
  50420. */
  50421. onBeforeRender: () => void;
  50422. /**
  50423. * An event triggered after rendering the scene
  50424. */
  50425. onAfterRenderObservable: Observable<Layer>;
  50426. private _onAfterRenderObserver;
  50427. /**
  50428. * Back compatibility with callback before the onAfterRenderObservable existed.
  50429. * The set callback will be triggered just after rendering the layer.
  50430. */
  50431. onAfterRender: () => void;
  50432. /**
  50433. * Instantiates a new layer.
  50434. * This represents a full screen 2d layer.
  50435. * This can be useful to display a picture in the background of your scene for instance.
  50436. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50437. * @param name Define the name of the layer in the scene
  50438. * @param imgUrl Define the url of the texture to display in the layer
  50439. * @param scene Define the scene the layer belongs to
  50440. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50441. * @param color Defines a color for the layer
  50442. */
  50443. constructor(
  50444. /**
  50445. * Define the name of the layer.
  50446. */
  50447. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50448. private _createIndexBuffer;
  50449. /** @hidden */
  50450. _rebuild(): void;
  50451. /**
  50452. * Renders the layer in the scene.
  50453. */
  50454. render(): void;
  50455. /**
  50456. * Disposes and releases the associated ressources.
  50457. */
  50458. dispose(): void;
  50459. }
  50460. }
  50461. declare module "babylonjs/Layers/index" {
  50462. export * from "babylonjs/Layers/effectLayer";
  50463. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50464. export * from "babylonjs/Layers/glowLayer";
  50465. export * from "babylonjs/Layers/highlightLayer";
  50466. export * from "babylonjs/Layers/layer";
  50467. export * from "babylonjs/Layers/layerSceneComponent";
  50468. }
  50469. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50470. /** @hidden */
  50471. export var lensFlarePixelShader: {
  50472. name: string;
  50473. shader: string;
  50474. };
  50475. }
  50476. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50477. /** @hidden */
  50478. export var lensFlareVertexShader: {
  50479. name: string;
  50480. shader: string;
  50481. };
  50482. }
  50483. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50484. import { Scene } from "babylonjs/scene";
  50485. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50487. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50488. import "babylonjs/Shaders/lensFlare.fragment";
  50489. import "babylonjs/Shaders/lensFlare.vertex";
  50490. /**
  50491. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50492. * It is usually composed of several `lensFlare`.
  50493. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50494. */
  50495. export class LensFlareSystem {
  50496. /**
  50497. * Define the name of the lens flare system
  50498. */
  50499. name: string;
  50500. /**
  50501. * List of lens flares used in this system.
  50502. */
  50503. lensFlares: LensFlare[];
  50504. /**
  50505. * Define a limit from the border the lens flare can be visible.
  50506. */
  50507. borderLimit: number;
  50508. /**
  50509. * Define a viewport border we do not want to see the lens flare in.
  50510. */
  50511. viewportBorder: number;
  50512. /**
  50513. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50514. */
  50515. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50516. /**
  50517. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50518. */
  50519. layerMask: number;
  50520. /**
  50521. * Define the id of the lens flare system in the scene.
  50522. * (equal to name by default)
  50523. */
  50524. id: string;
  50525. private _scene;
  50526. private _emitter;
  50527. private _vertexBuffers;
  50528. private _indexBuffer;
  50529. private _effect;
  50530. private _positionX;
  50531. private _positionY;
  50532. private _isEnabled;
  50533. /** @hidden */
  50534. static _SceneComponentInitialization: (scene: Scene) => void;
  50535. /**
  50536. * Instantiates a lens flare system.
  50537. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50538. * It is usually composed of several `lensFlare`.
  50539. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50540. * @param name Define the name of the lens flare system in the scene
  50541. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50542. * @param scene Define the scene the lens flare system belongs to
  50543. */
  50544. constructor(
  50545. /**
  50546. * Define the name of the lens flare system
  50547. */
  50548. name: string, emitter: any, scene: Scene);
  50549. /**
  50550. * Define if the lens flare system is enabled.
  50551. */
  50552. isEnabled: boolean;
  50553. /**
  50554. * Get the scene the effects belongs to.
  50555. * @returns the scene holding the lens flare system
  50556. */
  50557. getScene(): Scene;
  50558. /**
  50559. * Get the emitter of the lens flare system.
  50560. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50561. * @returns the emitter of the lens flare system
  50562. */
  50563. getEmitter(): any;
  50564. /**
  50565. * Set the emitter of the lens flare system.
  50566. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50567. * @param newEmitter Define the new emitter of the system
  50568. */
  50569. setEmitter(newEmitter: any): void;
  50570. /**
  50571. * Get the lens flare system emitter position.
  50572. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50573. * @returns the position
  50574. */
  50575. getEmitterPosition(): Vector3;
  50576. /**
  50577. * @hidden
  50578. */
  50579. computeEffectivePosition(globalViewport: Viewport): boolean;
  50580. /** @hidden */
  50581. _isVisible(): boolean;
  50582. /**
  50583. * @hidden
  50584. */
  50585. render(): boolean;
  50586. /**
  50587. * Dispose and release the lens flare with its associated resources.
  50588. */
  50589. dispose(): void;
  50590. /**
  50591. * Parse a lens flare system from a JSON repressentation
  50592. * @param parsedLensFlareSystem Define the JSON to parse
  50593. * @param scene Define the scene the parsed system should be instantiated in
  50594. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50595. * @returns the parsed system
  50596. */
  50597. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50598. /**
  50599. * Serialize the current Lens Flare System into a JSON representation.
  50600. * @returns the serialized JSON
  50601. */
  50602. serialize(): any;
  50603. }
  50604. }
  50605. declare module "babylonjs/LensFlares/lensFlare" {
  50606. import { Nullable } from "babylonjs/types";
  50607. import { Color3 } from "babylonjs/Maths/math";
  50608. import { Texture } from "babylonjs/Materials/Textures/texture";
  50609. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50610. /**
  50611. * This represents one of the lens effect in a `lensFlareSystem`.
  50612. * It controls one of the indiviual texture used in the effect.
  50613. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50614. */
  50615. export class LensFlare {
  50616. /**
  50617. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50618. */
  50619. size: number;
  50620. /**
  50621. * 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.
  50622. */
  50623. position: number;
  50624. /**
  50625. * Define the lens color.
  50626. */
  50627. color: Color3;
  50628. /**
  50629. * Define the lens texture.
  50630. */
  50631. texture: Nullable<Texture>;
  50632. /**
  50633. * Define the alpha mode to render this particular lens.
  50634. */
  50635. alphaMode: number;
  50636. private _system;
  50637. /**
  50638. * Creates a new Lens Flare.
  50639. * This represents one of the lens effect in a `lensFlareSystem`.
  50640. * It controls one of the indiviual texture used in the effect.
  50641. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50642. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50643. * @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.
  50644. * @param color Define the lens color
  50645. * @param imgUrl Define the lens texture url
  50646. * @param system Define the `lensFlareSystem` this flare is part of
  50647. * @returns The newly created Lens Flare
  50648. */
  50649. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50650. /**
  50651. * Instantiates a new Lens Flare.
  50652. * This represents one of the lens effect in a `lensFlareSystem`.
  50653. * It controls one of the indiviual texture used in the effect.
  50654. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50655. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50656. * @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.
  50657. * @param color Define the lens color
  50658. * @param imgUrl Define the lens texture url
  50659. * @param system Define the `lensFlareSystem` this flare is part of
  50660. */
  50661. constructor(
  50662. /**
  50663. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50664. */
  50665. size: number,
  50666. /**
  50667. * 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.
  50668. */
  50669. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50670. /**
  50671. * Dispose and release the lens flare with its associated resources.
  50672. */
  50673. dispose(): void;
  50674. }
  50675. }
  50676. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50677. import { Nullable } from "babylonjs/types";
  50678. import { Scene } from "babylonjs/scene";
  50679. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50680. import { AbstractScene } from "babylonjs/abstractScene";
  50681. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50682. module "babylonjs/abstractScene" {
  50683. interface AbstractScene {
  50684. /**
  50685. * The list of lens flare system added to the scene
  50686. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50687. */
  50688. lensFlareSystems: Array<LensFlareSystem>;
  50689. /**
  50690. * Removes the given lens flare system from this scene.
  50691. * @param toRemove The lens flare system to remove
  50692. * @returns The index of the removed lens flare system
  50693. */
  50694. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50695. /**
  50696. * Adds the given lens flare system to this scene
  50697. * @param newLensFlareSystem The lens flare system to add
  50698. */
  50699. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50700. /**
  50701. * Gets a lens flare system using its name
  50702. * @param name defines the name to look for
  50703. * @returns the lens flare system or null if not found
  50704. */
  50705. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50706. /**
  50707. * Gets a lens flare system using its id
  50708. * @param id defines the id to look for
  50709. * @returns the lens flare system or null if not found
  50710. */
  50711. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50712. }
  50713. }
  50714. /**
  50715. * Defines the lens flare scene component responsible to manage any lens flares
  50716. * in a given scene.
  50717. */
  50718. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50719. /**
  50720. * The component name helpfull to identify the component in the list of scene components.
  50721. */
  50722. readonly name: string;
  50723. /**
  50724. * The scene the component belongs to.
  50725. */
  50726. scene: Scene;
  50727. /**
  50728. * Creates a new instance of the component for the given scene
  50729. * @param scene Defines the scene to register the component in
  50730. */
  50731. constructor(scene: Scene);
  50732. /**
  50733. * Registers the component in a given scene
  50734. */
  50735. register(): void;
  50736. /**
  50737. * Rebuilds the elements related to this component in case of
  50738. * context lost for instance.
  50739. */
  50740. rebuild(): void;
  50741. /**
  50742. * Adds all the elements from the container to the scene
  50743. * @param container the container holding the elements
  50744. */
  50745. addFromContainer(container: AbstractScene): void;
  50746. /**
  50747. * Removes all the elements in the container from the scene
  50748. * @param container contains the elements to remove
  50749. * @param dispose if the removed element should be disposed (default: false)
  50750. */
  50751. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50752. /**
  50753. * Serializes the component data to the specified json object
  50754. * @param serializationObject The object to serialize to
  50755. */
  50756. serialize(serializationObject: any): void;
  50757. /**
  50758. * Disposes the component and the associated ressources.
  50759. */
  50760. dispose(): void;
  50761. private _draw;
  50762. }
  50763. }
  50764. declare module "babylonjs/LensFlares/index" {
  50765. export * from "babylonjs/LensFlares/lensFlare";
  50766. export * from "babylonjs/LensFlares/lensFlareSystem";
  50767. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50768. }
  50769. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50770. import { Scene } from "babylonjs/scene";
  50771. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50772. import { AbstractScene } from "babylonjs/abstractScene";
  50773. /**
  50774. * Defines the shadow generator component responsible to manage any shadow generators
  50775. * in a given scene.
  50776. */
  50777. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50778. /**
  50779. * The component name helpfull to identify the component in the list of scene components.
  50780. */
  50781. readonly name: string;
  50782. /**
  50783. * The scene the component belongs to.
  50784. */
  50785. scene: Scene;
  50786. /**
  50787. * Creates a new instance of the component for the given scene
  50788. * @param scene Defines the scene to register the component in
  50789. */
  50790. constructor(scene: Scene);
  50791. /**
  50792. * Registers the component in a given scene
  50793. */
  50794. register(): void;
  50795. /**
  50796. * Rebuilds the elements related to this component in case of
  50797. * context lost for instance.
  50798. */
  50799. rebuild(): void;
  50800. /**
  50801. * Serializes the component data to the specified json object
  50802. * @param serializationObject The object to serialize to
  50803. */
  50804. serialize(serializationObject: any): void;
  50805. /**
  50806. * Adds all the elements from the container to the scene
  50807. * @param container the container holding the elements
  50808. */
  50809. addFromContainer(container: AbstractScene): void;
  50810. /**
  50811. * Removes all the elements in the container from the scene
  50812. * @param container contains the elements to remove
  50813. * @param dispose if the removed element should be disposed (default: false)
  50814. */
  50815. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50816. /**
  50817. * Rebuilds the elements related to this component in case of
  50818. * context lost for instance.
  50819. */
  50820. dispose(): void;
  50821. private _gatherRenderTargets;
  50822. }
  50823. }
  50824. declare module "babylonjs/Lights/Shadows/index" {
  50825. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50826. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50827. }
  50828. declare module "babylonjs/Lights/pointLight" {
  50829. import { Scene } from "babylonjs/scene";
  50830. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50832. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50833. import { Effect } from "babylonjs/Materials/effect";
  50834. /**
  50835. * A point light is a light defined by an unique point in world space.
  50836. * The light is emitted in every direction from this point.
  50837. * A good example of a point light is a standard light bulb.
  50838. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50839. */
  50840. export class PointLight extends ShadowLight {
  50841. private _shadowAngle;
  50842. /**
  50843. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50844. * This specifies what angle the shadow will use to be created.
  50845. *
  50846. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50847. */
  50848. /**
  50849. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50850. * This specifies what angle the shadow will use to be created.
  50851. *
  50852. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50853. */
  50854. shadowAngle: number;
  50855. /**
  50856. * Gets the direction if it has been set.
  50857. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50858. */
  50859. /**
  50860. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50861. */
  50862. direction: Vector3;
  50863. /**
  50864. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50865. * A PointLight emits the light in every direction.
  50866. * It can cast shadows.
  50867. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50868. * ```javascript
  50869. * var pointLight = new PointLight("pl", camera.position, scene);
  50870. * ```
  50871. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50872. * @param name The light friendly name
  50873. * @param position The position of the point light in the scene
  50874. * @param scene The scene the lights belongs to
  50875. */
  50876. constructor(name: string, position: Vector3, scene: Scene);
  50877. /**
  50878. * Returns the string "PointLight"
  50879. * @returns the class name
  50880. */
  50881. getClassName(): string;
  50882. /**
  50883. * Returns the integer 0.
  50884. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50885. */
  50886. getTypeID(): number;
  50887. /**
  50888. * Specifies wether or not the shadowmap should be a cube texture.
  50889. * @returns true if the shadowmap needs to be a cube texture.
  50890. */
  50891. needCube(): boolean;
  50892. /**
  50893. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50894. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50895. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50896. */
  50897. getShadowDirection(faceIndex?: number): Vector3;
  50898. /**
  50899. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50900. * - fov = PI / 2
  50901. * - aspect ratio : 1.0
  50902. * - z-near and far equal to the active camera minZ and maxZ.
  50903. * Returns the PointLight.
  50904. */
  50905. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50906. protected _buildUniformLayout(): void;
  50907. /**
  50908. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50909. * @param effect The effect to update
  50910. * @param lightIndex The index of the light in the effect to update
  50911. * @returns The point light
  50912. */
  50913. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50914. /**
  50915. * Prepares the list of defines specific to the light type.
  50916. * @param defines the list of defines
  50917. * @param lightIndex defines the index of the light for the effect
  50918. */
  50919. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50920. }
  50921. }
  50922. declare module "babylonjs/Lights/index" {
  50923. export * from "babylonjs/Lights/light";
  50924. export * from "babylonjs/Lights/shadowLight";
  50925. export * from "babylonjs/Lights/Shadows/index";
  50926. export * from "babylonjs/Lights/directionalLight";
  50927. export * from "babylonjs/Lights/hemisphericLight";
  50928. export * from "babylonjs/Lights/pointLight";
  50929. export * from "babylonjs/Lights/spotLight";
  50930. }
  50931. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50932. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50933. /**
  50934. * Header information of HDR texture files.
  50935. */
  50936. export interface HDRInfo {
  50937. /**
  50938. * The height of the texture in pixels.
  50939. */
  50940. height: number;
  50941. /**
  50942. * The width of the texture in pixels.
  50943. */
  50944. width: number;
  50945. /**
  50946. * The index of the beginning of the data in the binary file.
  50947. */
  50948. dataPosition: number;
  50949. }
  50950. /**
  50951. * This groups tools to convert HDR texture to native colors array.
  50952. */
  50953. export class HDRTools {
  50954. private static Ldexp;
  50955. private static Rgbe2float;
  50956. private static readStringLine;
  50957. /**
  50958. * Reads header information from an RGBE texture stored in a native array.
  50959. * More information on this format are available here:
  50960. * https://en.wikipedia.org/wiki/RGBE_image_format
  50961. *
  50962. * @param uint8array The binary file stored in native array.
  50963. * @return The header information.
  50964. */
  50965. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50966. /**
  50967. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50968. * This RGBE texture needs to store the information as a panorama.
  50969. *
  50970. * More information on this format are available here:
  50971. * https://en.wikipedia.org/wiki/RGBE_image_format
  50972. *
  50973. * @param buffer The binary file stored in an array buffer.
  50974. * @param size The expected size of the extracted cubemap.
  50975. * @return The Cube Map information.
  50976. */
  50977. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50978. /**
  50979. * Returns the pixels data extracted from an RGBE texture.
  50980. * This pixels will be stored left to right up to down in the R G B order in one array.
  50981. *
  50982. * More information on this format are available here:
  50983. * https://en.wikipedia.org/wiki/RGBE_image_format
  50984. *
  50985. * @param uint8array The binary file stored in an array buffer.
  50986. * @param hdrInfo The header information of the file.
  50987. * @return The pixels data in RGB right to left up to down order.
  50988. */
  50989. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50990. private static RGBE_ReadPixels_RLE;
  50991. }
  50992. }
  50993. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50994. import { Nullable } from "babylonjs/types";
  50995. import { Scene } from "babylonjs/scene";
  50996. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50997. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50998. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50999. /**
  51000. * This represents a texture coming from an HDR input.
  51001. *
  51002. * The only supported format is currently panorama picture stored in RGBE format.
  51003. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51004. */
  51005. export class HDRCubeTexture extends BaseTexture {
  51006. private static _facesMapping;
  51007. private _generateHarmonics;
  51008. private _noMipmap;
  51009. private _textureMatrix;
  51010. private _size;
  51011. private _onLoad;
  51012. private _onError;
  51013. /**
  51014. * The texture URL.
  51015. */
  51016. url: string;
  51017. /**
  51018. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51019. */
  51020. coordinatesMode: number;
  51021. protected _isBlocking: boolean;
  51022. /**
  51023. * Sets wether or not the texture is blocking during loading.
  51024. */
  51025. /**
  51026. * Gets wether or not the texture is blocking during loading.
  51027. */
  51028. isBlocking: boolean;
  51029. protected _rotationY: number;
  51030. /**
  51031. * Sets texture matrix rotation angle around Y axis in radians.
  51032. */
  51033. /**
  51034. * Gets texture matrix rotation angle around Y axis radians.
  51035. */
  51036. rotationY: number;
  51037. /**
  51038. * Gets or sets the center of the bounding box associated with the cube texture
  51039. * It must define where the camera used to render the texture was set
  51040. */
  51041. boundingBoxPosition: Vector3;
  51042. private _boundingBoxSize;
  51043. /**
  51044. * Gets or sets the size of the bounding box associated with the cube texture
  51045. * When defined, the cubemap will switch to local mode
  51046. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51047. * @example https://www.babylonjs-playground.com/#RNASML
  51048. */
  51049. boundingBoxSize: Vector3;
  51050. /**
  51051. * Instantiates an HDRTexture from the following parameters.
  51052. *
  51053. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51054. * @param scene The scene the texture will be used in
  51055. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51056. * @param noMipmap Forces to not generate the mipmap if true
  51057. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51058. * @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)
  51059. * @param reserved Reserved flag for internal use.
  51060. */
  51061. 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>);
  51062. /**
  51063. * Get the current class name of the texture useful for serialization or dynamic coding.
  51064. * @returns "HDRCubeTexture"
  51065. */
  51066. getClassName(): string;
  51067. /**
  51068. * Occurs when the file is raw .hdr file.
  51069. */
  51070. private loadTexture;
  51071. clone(): HDRCubeTexture;
  51072. delayLoad(): void;
  51073. /**
  51074. * Get the texture reflection matrix used to rotate/transform the reflection.
  51075. * @returns the reflection matrix
  51076. */
  51077. getReflectionTextureMatrix(): Matrix;
  51078. /**
  51079. * Set the texture reflection matrix used to rotate/transform the reflection.
  51080. * @param value Define the reflection matrix to set
  51081. */
  51082. setReflectionTextureMatrix(value: Matrix): void;
  51083. /**
  51084. * Parses a JSON representation of an HDR Texture in order to create the texture
  51085. * @param parsedTexture Define the JSON representation
  51086. * @param scene Define the scene the texture should be created in
  51087. * @param rootUrl Define the root url in case we need to load relative dependencies
  51088. * @returns the newly created texture after parsing
  51089. */
  51090. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51091. serialize(): any;
  51092. }
  51093. }
  51094. declare module "babylonjs/Physics/physicsEngine" {
  51095. import { Nullable } from "babylonjs/types";
  51096. import { Vector3 } from "babylonjs/Maths/math";
  51097. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51098. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51099. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51100. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51101. /**
  51102. * Class used to control physics engine
  51103. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51104. */
  51105. export class PhysicsEngine implements IPhysicsEngine {
  51106. private _physicsPlugin;
  51107. /**
  51108. * Global value used to control the smallest number supported by the simulation
  51109. */
  51110. static Epsilon: number;
  51111. private _impostors;
  51112. private _joints;
  51113. /**
  51114. * Gets the gravity vector used by the simulation
  51115. */
  51116. gravity: Vector3;
  51117. /**
  51118. * Factory used to create the default physics plugin.
  51119. * @returns The default physics plugin
  51120. */
  51121. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51122. /**
  51123. * Creates a new Physics Engine
  51124. * @param gravity defines the gravity vector used by the simulation
  51125. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51126. */
  51127. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51128. /**
  51129. * Sets the gravity vector used by the simulation
  51130. * @param gravity defines the gravity vector to use
  51131. */
  51132. setGravity(gravity: Vector3): void;
  51133. /**
  51134. * Set the time step of the physics engine.
  51135. * Default is 1/60.
  51136. * To slow it down, enter 1/600 for example.
  51137. * To speed it up, 1/30
  51138. * @param newTimeStep defines the new timestep to apply to this world.
  51139. */
  51140. setTimeStep(newTimeStep?: number): void;
  51141. /**
  51142. * Get the time step of the physics engine.
  51143. * @returns the current time step
  51144. */
  51145. getTimeStep(): number;
  51146. /**
  51147. * Release all resources
  51148. */
  51149. dispose(): void;
  51150. /**
  51151. * Gets the name of the current physics plugin
  51152. * @returns the name of the plugin
  51153. */
  51154. getPhysicsPluginName(): string;
  51155. /**
  51156. * Adding a new impostor for the impostor tracking.
  51157. * This will be done by the impostor itself.
  51158. * @param impostor the impostor to add
  51159. */
  51160. addImpostor(impostor: PhysicsImpostor): void;
  51161. /**
  51162. * Remove an impostor from the engine.
  51163. * This impostor and its mesh will not longer be updated by the physics engine.
  51164. * @param impostor the impostor to remove
  51165. */
  51166. removeImpostor(impostor: PhysicsImpostor): void;
  51167. /**
  51168. * Add a joint to the physics engine
  51169. * @param mainImpostor defines the main impostor to which the joint is added.
  51170. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51171. * @param joint defines the joint that will connect both impostors.
  51172. */
  51173. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51174. /**
  51175. * Removes a joint from the simulation
  51176. * @param mainImpostor defines the impostor used with the joint
  51177. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51178. * @param joint defines the joint to remove
  51179. */
  51180. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51181. /**
  51182. * Called by the scene. No need to call it.
  51183. * @param delta defines the timespam between frames
  51184. */
  51185. _step(delta: number): void;
  51186. /**
  51187. * Gets the current plugin used to run the simulation
  51188. * @returns current plugin
  51189. */
  51190. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51191. /**
  51192. * Gets the list of physic impostors
  51193. * @returns an array of PhysicsImpostor
  51194. */
  51195. getImpostors(): Array<PhysicsImpostor>;
  51196. /**
  51197. * Gets the impostor for a physics enabled object
  51198. * @param object defines the object impersonated by the impostor
  51199. * @returns the PhysicsImpostor or null if not found
  51200. */
  51201. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51202. /**
  51203. * Gets the impostor for a physics body object
  51204. * @param body defines physics body used by the impostor
  51205. * @returns the PhysicsImpostor or null if not found
  51206. */
  51207. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51208. /**
  51209. * Does a raycast in the physics world
  51210. * @param from when should the ray start?
  51211. * @param to when should the ray end?
  51212. * @returns PhysicsRaycastResult
  51213. */
  51214. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51215. }
  51216. }
  51217. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51218. import { Nullable } from "babylonjs/types";
  51219. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51221. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51222. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51223. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51224. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51225. /** @hidden */
  51226. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51227. private _useDeltaForWorldStep;
  51228. world: any;
  51229. name: string;
  51230. private _physicsMaterials;
  51231. private _fixedTimeStep;
  51232. private _cannonRaycastResult;
  51233. private _raycastResult;
  51234. private _physicsBodysToRemoveAfterStep;
  51235. BJSCANNON: any;
  51236. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51237. setGravity(gravity: Vector3): void;
  51238. setTimeStep(timeStep: number): void;
  51239. getTimeStep(): number;
  51240. executeStep(delta: number): void;
  51241. private _removeMarkedPhysicsBodiesFromWorld;
  51242. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51243. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51244. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51245. private _processChildMeshes;
  51246. removePhysicsBody(impostor: PhysicsImpostor): void;
  51247. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51248. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51249. private _addMaterial;
  51250. private _checkWithEpsilon;
  51251. private _createShape;
  51252. private _createHeightmap;
  51253. private _minus90X;
  51254. private _plus90X;
  51255. private _tmpPosition;
  51256. private _tmpDeltaPosition;
  51257. private _tmpUnityRotation;
  51258. private _updatePhysicsBodyTransformation;
  51259. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51260. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51261. isSupported(): boolean;
  51262. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51263. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51264. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51265. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51266. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51267. getBodyMass(impostor: PhysicsImpostor): number;
  51268. getBodyFriction(impostor: PhysicsImpostor): number;
  51269. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51270. getBodyRestitution(impostor: PhysicsImpostor): number;
  51271. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51272. sleepBody(impostor: PhysicsImpostor): void;
  51273. wakeUpBody(impostor: PhysicsImpostor): void;
  51274. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51275. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51276. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51277. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51278. getRadius(impostor: PhysicsImpostor): number;
  51279. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51280. dispose(): void;
  51281. private _extendNamespace;
  51282. /**
  51283. * Does a raycast in the physics world
  51284. * @param from when should the ray start?
  51285. * @param to when should the ray end?
  51286. * @returns PhysicsRaycastResult
  51287. */
  51288. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51289. }
  51290. }
  51291. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51292. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51293. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51294. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51296. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51297. import { Nullable } from "babylonjs/types";
  51298. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51299. /** @hidden */
  51300. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51301. world: any;
  51302. name: string;
  51303. BJSOIMO: any;
  51304. private _raycastResult;
  51305. constructor(iterations?: number, oimoInjection?: any);
  51306. setGravity(gravity: Vector3): void;
  51307. setTimeStep(timeStep: number): void;
  51308. getTimeStep(): number;
  51309. private _tmpImpostorsArray;
  51310. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51311. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51312. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51313. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51314. private _tmpPositionVector;
  51315. removePhysicsBody(impostor: PhysicsImpostor): void;
  51316. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51317. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51318. isSupported(): boolean;
  51319. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51320. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51321. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51322. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51323. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51324. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51325. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51326. getBodyMass(impostor: PhysicsImpostor): number;
  51327. getBodyFriction(impostor: PhysicsImpostor): number;
  51328. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51329. getBodyRestitution(impostor: PhysicsImpostor): number;
  51330. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51331. sleepBody(impostor: PhysicsImpostor): void;
  51332. wakeUpBody(impostor: PhysicsImpostor): void;
  51333. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51334. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51335. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51336. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51337. getRadius(impostor: PhysicsImpostor): number;
  51338. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51339. dispose(): void;
  51340. /**
  51341. * Does a raycast in the physics world
  51342. * @param from when should the ray start?
  51343. * @param to when should the ray end?
  51344. * @returns PhysicsRaycastResult
  51345. */
  51346. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51347. }
  51348. }
  51349. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51350. import { Nullable } from "babylonjs/types";
  51351. import { Scene } from "babylonjs/scene";
  51352. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51353. import { Mesh } from "babylonjs/Meshes/mesh";
  51354. /**
  51355. * Class containing static functions to help procedurally build meshes
  51356. */
  51357. export class RibbonBuilder {
  51358. /**
  51359. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51360. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51361. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51362. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51363. * * 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
  51364. * * 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
  51365. * * 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
  51366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51367. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51368. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51369. * * 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
  51370. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51371. * * 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
  51372. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51374. * @param name defines the name of the mesh
  51375. * @param options defines the options used to create the mesh
  51376. * @param scene defines the hosting scene
  51377. * @returns the ribbon mesh
  51378. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51379. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51380. */
  51381. static CreateRibbon(name: string, options: {
  51382. pathArray: Vector3[][];
  51383. closeArray?: boolean;
  51384. closePath?: boolean;
  51385. offset?: number;
  51386. updatable?: boolean;
  51387. sideOrientation?: number;
  51388. frontUVs?: Vector4;
  51389. backUVs?: Vector4;
  51390. instance?: Mesh;
  51391. invertUV?: boolean;
  51392. uvs?: Vector2[];
  51393. colors?: Color4[];
  51394. }, scene?: Nullable<Scene>): Mesh;
  51395. }
  51396. }
  51397. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51398. import { Nullable } from "babylonjs/types";
  51399. import { Scene } from "babylonjs/scene";
  51400. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51401. import { Mesh } from "babylonjs/Meshes/mesh";
  51402. /**
  51403. * Class containing static functions to help procedurally build meshes
  51404. */
  51405. export class ShapeBuilder {
  51406. /**
  51407. * 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.
  51408. * * 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.
  51409. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51410. * * 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.
  51411. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51412. * * 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
  51413. * * 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
  51414. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51417. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51419. * @param name defines the name of the mesh
  51420. * @param options defines the options used to create the mesh
  51421. * @param scene defines the hosting scene
  51422. * @returns the extruded shape mesh
  51423. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51424. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51425. */
  51426. static ExtrudeShape(name: string, options: {
  51427. shape: Vector3[];
  51428. path: Vector3[];
  51429. scale?: number;
  51430. rotation?: number;
  51431. cap?: number;
  51432. updatable?: boolean;
  51433. sideOrientation?: number;
  51434. frontUVs?: Vector4;
  51435. backUVs?: Vector4;
  51436. instance?: Mesh;
  51437. invertUV?: boolean;
  51438. }, scene?: Nullable<Scene>): Mesh;
  51439. /**
  51440. * Creates an custom extruded shape mesh.
  51441. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51442. * * 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.
  51443. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51444. * * 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
  51445. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51446. * * 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
  51447. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51448. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51449. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51450. * * 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
  51451. * * 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
  51452. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51454. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51455. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51457. * @param name defines the name of the mesh
  51458. * @param options defines the options used to create the mesh
  51459. * @param scene defines the hosting scene
  51460. * @returns the custom extruded shape mesh
  51461. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51462. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51464. */
  51465. static ExtrudeShapeCustom(name: string, options: {
  51466. shape: Vector3[];
  51467. path: Vector3[];
  51468. scaleFunction?: any;
  51469. rotationFunction?: any;
  51470. ribbonCloseArray?: boolean;
  51471. ribbonClosePath?: boolean;
  51472. cap?: number;
  51473. updatable?: boolean;
  51474. sideOrientation?: number;
  51475. frontUVs?: Vector4;
  51476. backUVs?: Vector4;
  51477. instance?: Mesh;
  51478. invertUV?: boolean;
  51479. }, scene?: Nullable<Scene>): Mesh;
  51480. private static _ExtrudeShapeGeneric;
  51481. }
  51482. }
  51483. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51484. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51485. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51486. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51487. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51488. import { Nullable } from "babylonjs/types";
  51489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51490. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51491. /**
  51492. * AmmoJS Physics plugin
  51493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51494. * @see https://github.com/kripken/ammo.js/
  51495. */
  51496. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51497. private _useDeltaForWorldStep;
  51498. /**
  51499. * Reference to the Ammo library
  51500. */
  51501. bjsAMMO: any;
  51502. /**
  51503. * Created ammoJS world which physics bodies are added to
  51504. */
  51505. world: any;
  51506. /**
  51507. * Name of the plugin
  51508. */
  51509. name: string;
  51510. private _timeStep;
  51511. private _fixedTimeStep;
  51512. private _maxSteps;
  51513. private _tmpQuaternion;
  51514. private _tmpAmmoTransform;
  51515. private _tmpAmmoQuaternion;
  51516. private _tmpAmmoConcreteContactResultCallback;
  51517. private _collisionConfiguration;
  51518. private _dispatcher;
  51519. private _overlappingPairCache;
  51520. private _solver;
  51521. private _softBodySolver;
  51522. private _tmpAmmoVectorA;
  51523. private _tmpAmmoVectorB;
  51524. private _tmpAmmoVectorC;
  51525. private _tmpAmmoVectorD;
  51526. private _tmpContactCallbackResult;
  51527. private _tmpAmmoVectorRCA;
  51528. private _tmpAmmoVectorRCB;
  51529. private _raycastResult;
  51530. private static readonly DISABLE_COLLISION_FLAG;
  51531. private static readonly KINEMATIC_FLAG;
  51532. private static readonly DISABLE_DEACTIVATION_FLAG;
  51533. /**
  51534. * Initializes the ammoJS plugin
  51535. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51536. * @param ammoInjection can be used to inject your own ammo reference
  51537. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51538. */
  51539. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51540. /**
  51541. * Sets the gravity of the physics world (m/(s^2))
  51542. * @param gravity Gravity to set
  51543. */
  51544. setGravity(gravity: Vector3): void;
  51545. /**
  51546. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51547. * @param timeStep timestep to use in seconds
  51548. */
  51549. setTimeStep(timeStep: number): void;
  51550. /**
  51551. * 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)
  51552. * @param fixedTimeStep fixedTimeStep to use in seconds
  51553. */
  51554. setFixedTimeStep(fixedTimeStep: number): void;
  51555. /**
  51556. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51557. * @param maxSteps the maximum number of steps by the physics engine per frame
  51558. */
  51559. setMaxSteps(maxSteps: number): void;
  51560. /**
  51561. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51562. * @returns the current timestep in seconds
  51563. */
  51564. getTimeStep(): number;
  51565. private _isImpostorInContact;
  51566. private _isImpostorPairInContact;
  51567. private _stepSimulation;
  51568. /**
  51569. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51570. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51571. * After the step the babylon meshes are set to the position of the physics imposters
  51572. * @param delta amount of time to step forward
  51573. * @param impostors array of imposters to update before/after the step
  51574. */
  51575. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51576. /**
  51577. * Update babylon mesh to match physics world object
  51578. * @param impostor imposter to match
  51579. */
  51580. private _afterSoftStep;
  51581. /**
  51582. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51583. * @param impostor imposter to match
  51584. */
  51585. private _ropeStep;
  51586. /**
  51587. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51588. * @param impostor imposter to match
  51589. */
  51590. private _softbodyOrClothStep;
  51591. private _tmpVector;
  51592. private _tmpMatrix;
  51593. /**
  51594. * Applies an impulse on the imposter
  51595. * @param impostor imposter to apply impulse to
  51596. * @param force amount of force to be applied to the imposter
  51597. * @param contactPoint the location to apply the impulse on the imposter
  51598. */
  51599. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51600. /**
  51601. * Applies a force on the imposter
  51602. * @param impostor imposter to apply force
  51603. * @param force amount of force to be applied to the imposter
  51604. * @param contactPoint the location to apply the force on the imposter
  51605. */
  51606. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51607. /**
  51608. * Creates a physics body using the plugin
  51609. * @param impostor the imposter to create the physics body on
  51610. */
  51611. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51612. /**
  51613. * Removes the physics body from the imposter and disposes of the body's memory
  51614. * @param impostor imposter to remove the physics body from
  51615. */
  51616. removePhysicsBody(impostor: PhysicsImpostor): void;
  51617. /**
  51618. * Generates a joint
  51619. * @param impostorJoint the imposter joint to create the joint with
  51620. */
  51621. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51622. /**
  51623. * Removes a joint
  51624. * @param impostorJoint the imposter joint to remove the joint from
  51625. */
  51626. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51627. private _addMeshVerts;
  51628. /**
  51629. * Initialise the soft body vertices to match its object's (mesh) vertices
  51630. * Softbody vertices (nodes) are in world space and to match this
  51631. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51632. * @param impostor to create the softbody for
  51633. */
  51634. private _softVertexData;
  51635. /**
  51636. * Create an impostor's soft body
  51637. * @param impostor to create the softbody for
  51638. */
  51639. private _createSoftbody;
  51640. /**
  51641. * Create cloth for an impostor
  51642. * @param impostor to create the softbody for
  51643. */
  51644. private _createCloth;
  51645. /**
  51646. * Create rope for an impostor
  51647. * @param impostor to create the softbody for
  51648. */
  51649. private _createRope;
  51650. private _addHullVerts;
  51651. private _createShape;
  51652. /**
  51653. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51654. * @param impostor imposter containing the physics body and babylon object
  51655. */
  51656. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51657. /**
  51658. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51659. * @param impostor imposter containing the physics body and babylon object
  51660. * @param newPosition new position
  51661. * @param newRotation new rotation
  51662. */
  51663. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51664. /**
  51665. * If this plugin is supported
  51666. * @returns true if its supported
  51667. */
  51668. isSupported(): boolean;
  51669. /**
  51670. * Sets the linear velocity of the physics body
  51671. * @param impostor imposter to set the velocity on
  51672. * @param velocity velocity to set
  51673. */
  51674. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51675. /**
  51676. * Sets the angular velocity of the physics body
  51677. * @param impostor imposter to set the velocity on
  51678. * @param velocity velocity to set
  51679. */
  51680. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51681. /**
  51682. * gets the linear velocity
  51683. * @param impostor imposter to get linear velocity from
  51684. * @returns linear velocity
  51685. */
  51686. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51687. /**
  51688. * gets the angular velocity
  51689. * @param impostor imposter to get angular velocity from
  51690. * @returns angular velocity
  51691. */
  51692. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51693. /**
  51694. * Sets the mass of physics body
  51695. * @param impostor imposter to set the mass on
  51696. * @param mass mass to set
  51697. */
  51698. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51699. /**
  51700. * Gets the mass of the physics body
  51701. * @param impostor imposter to get the mass from
  51702. * @returns mass
  51703. */
  51704. getBodyMass(impostor: PhysicsImpostor): number;
  51705. /**
  51706. * Gets friction of the impostor
  51707. * @param impostor impostor to get friction from
  51708. * @returns friction value
  51709. */
  51710. getBodyFriction(impostor: PhysicsImpostor): number;
  51711. /**
  51712. * Sets friction of the impostor
  51713. * @param impostor impostor to set friction on
  51714. * @param friction friction value
  51715. */
  51716. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51717. /**
  51718. * Gets restitution of the impostor
  51719. * @param impostor impostor to get restitution from
  51720. * @returns restitution value
  51721. */
  51722. getBodyRestitution(impostor: PhysicsImpostor): number;
  51723. /**
  51724. * Sets resitution of the impostor
  51725. * @param impostor impostor to set resitution on
  51726. * @param restitution resitution value
  51727. */
  51728. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51729. /**
  51730. * Gets pressure inside the impostor
  51731. * @param impostor impostor to get pressure from
  51732. * @returns pressure value
  51733. */
  51734. getBodyPressure(impostor: PhysicsImpostor): number;
  51735. /**
  51736. * Sets pressure inside a soft body impostor
  51737. * Cloth and rope must remain 0 pressure
  51738. * @param impostor impostor to set pressure on
  51739. * @param pressure pressure value
  51740. */
  51741. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51742. /**
  51743. * Gets stiffness of the impostor
  51744. * @param impostor impostor to get stiffness from
  51745. * @returns pressure value
  51746. */
  51747. getBodyStiffness(impostor: PhysicsImpostor): number;
  51748. /**
  51749. * Sets stiffness of the impostor
  51750. * @param impostor impostor to set stiffness on
  51751. * @param stiffness stiffness value from 0 to 1
  51752. */
  51753. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51754. /**
  51755. * Gets velocityIterations of the impostor
  51756. * @param impostor impostor to get velocity iterations from
  51757. * @returns velocityIterations value
  51758. */
  51759. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51760. /**
  51761. * Sets velocityIterations of the impostor
  51762. * @param impostor impostor to set velocity iterations on
  51763. * @param velocityIterations velocityIterations value
  51764. */
  51765. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51766. /**
  51767. * Gets positionIterations of the impostor
  51768. * @param impostor impostor to get position iterations from
  51769. * @returns positionIterations value
  51770. */
  51771. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51772. /**
  51773. * Sets positionIterations of the impostor
  51774. * @param impostor impostor to set position on
  51775. * @param positionIterations positionIterations value
  51776. */
  51777. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51778. /**
  51779. * Append an anchor to a cloth object
  51780. * @param impostor is the cloth impostor to add anchor to
  51781. * @param otherImpostor is the rigid impostor to anchor to
  51782. * @param width ratio across width from 0 to 1
  51783. * @param height ratio up height from 0 to 1
  51784. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51785. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51786. */
  51787. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51788. /**
  51789. * Append an hook to a rope object
  51790. * @param impostor is the rope impostor to add hook to
  51791. * @param otherImpostor is the rigid impostor to hook to
  51792. * @param length ratio along the rope from 0 to 1
  51793. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51794. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51795. */
  51796. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51797. /**
  51798. * Sleeps the physics body and stops it from being active
  51799. * @param impostor impostor to sleep
  51800. */
  51801. sleepBody(impostor: PhysicsImpostor): void;
  51802. /**
  51803. * Activates the physics body
  51804. * @param impostor impostor to activate
  51805. */
  51806. wakeUpBody(impostor: PhysicsImpostor): void;
  51807. /**
  51808. * Updates the distance parameters of the joint
  51809. * @param joint joint to update
  51810. * @param maxDistance maximum distance of the joint
  51811. * @param minDistance minimum distance of the joint
  51812. */
  51813. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51814. /**
  51815. * Sets a motor on the joint
  51816. * @param joint joint to set motor on
  51817. * @param speed speed of the motor
  51818. * @param maxForce maximum force of the motor
  51819. * @param motorIndex index of the motor
  51820. */
  51821. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51822. /**
  51823. * Sets the motors limit
  51824. * @param joint joint to set limit on
  51825. * @param upperLimit upper limit
  51826. * @param lowerLimit lower limit
  51827. */
  51828. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51829. /**
  51830. * Syncs the position and rotation of a mesh with the impostor
  51831. * @param mesh mesh to sync
  51832. * @param impostor impostor to update the mesh with
  51833. */
  51834. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51835. /**
  51836. * Gets the radius of the impostor
  51837. * @param impostor impostor to get radius from
  51838. * @returns the radius
  51839. */
  51840. getRadius(impostor: PhysicsImpostor): number;
  51841. /**
  51842. * Gets the box size of the impostor
  51843. * @param impostor impostor to get box size from
  51844. * @param result the resulting box size
  51845. */
  51846. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51847. /**
  51848. * Disposes of the impostor
  51849. */
  51850. dispose(): void;
  51851. /**
  51852. * Does a raycast in the physics world
  51853. * @param from when should the ray start?
  51854. * @param to when should the ray end?
  51855. * @returns PhysicsRaycastResult
  51856. */
  51857. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51858. }
  51859. }
  51860. declare module "babylonjs/Probes/reflectionProbe" {
  51861. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51862. import { Vector3 } from "babylonjs/Maths/math";
  51863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51864. import { Nullable } from "babylonjs/types";
  51865. import { Scene } from "babylonjs/scene";
  51866. module "babylonjs/abstractScene" {
  51867. interface AbstractScene {
  51868. /**
  51869. * The list of reflection probes added to the scene
  51870. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51871. */
  51872. reflectionProbes: Array<ReflectionProbe>;
  51873. /**
  51874. * Removes the given reflection probe from this scene.
  51875. * @param toRemove The reflection probe to remove
  51876. * @returns The index of the removed reflection probe
  51877. */
  51878. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51879. /**
  51880. * Adds the given reflection probe to this scene.
  51881. * @param newReflectionProbe The reflection probe to add
  51882. */
  51883. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51884. }
  51885. }
  51886. /**
  51887. * Class used to generate realtime reflection / refraction cube textures
  51888. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51889. */
  51890. export class ReflectionProbe {
  51891. /** defines the name of the probe */
  51892. name: string;
  51893. private _scene;
  51894. private _renderTargetTexture;
  51895. private _projectionMatrix;
  51896. private _viewMatrix;
  51897. private _target;
  51898. private _add;
  51899. private _attachedMesh;
  51900. private _invertYAxis;
  51901. /** Gets or sets probe position (center of the cube map) */
  51902. position: Vector3;
  51903. /**
  51904. * Creates a new reflection probe
  51905. * @param name defines the name of the probe
  51906. * @param size defines the texture resolution (for each face)
  51907. * @param scene defines the hosting scene
  51908. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51909. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51910. */
  51911. constructor(
  51912. /** defines the name of the probe */
  51913. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51914. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51915. samples: number;
  51916. /** Gets or sets the refresh rate to use (on every frame by default) */
  51917. refreshRate: number;
  51918. /**
  51919. * Gets the hosting scene
  51920. * @returns a Scene
  51921. */
  51922. getScene(): Scene;
  51923. /** Gets the internal CubeTexture used to render to */
  51924. readonly cubeTexture: RenderTargetTexture;
  51925. /** Gets the list of meshes to render */
  51926. readonly renderList: Nullable<AbstractMesh[]>;
  51927. /**
  51928. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51929. * @param mesh defines the mesh to attach to
  51930. */
  51931. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51932. /**
  51933. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51934. * @param renderingGroupId The rendering group id corresponding to its index
  51935. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51936. */
  51937. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51938. /**
  51939. * Clean all associated resources
  51940. */
  51941. dispose(): void;
  51942. /**
  51943. * Converts the reflection probe information to a readable string for debug purpose.
  51944. * @param fullDetails Supports for multiple levels of logging within scene loading
  51945. * @returns the human readable reflection probe info
  51946. */
  51947. toString(fullDetails?: boolean): string;
  51948. /**
  51949. * Get the class name of the relfection probe.
  51950. * @returns "ReflectionProbe"
  51951. */
  51952. getClassName(): string;
  51953. /**
  51954. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51955. * @returns The JSON representation of the texture
  51956. */
  51957. serialize(): any;
  51958. /**
  51959. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51960. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51961. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51962. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51963. * @returns The parsed reflection probe if successful
  51964. */
  51965. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51966. }
  51967. }
  51968. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51969. /** @hidden */
  51970. export var _BabylonLoaderRegistered: boolean;
  51971. }
  51972. declare module "babylonjs/Loading/Plugins/index" {
  51973. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51974. }
  51975. declare module "babylonjs/Loading/index" {
  51976. export * from "babylonjs/Loading/loadingScreen";
  51977. export * from "babylonjs/Loading/Plugins/index";
  51978. export * from "babylonjs/Loading/sceneLoader";
  51979. export * from "babylonjs/Loading/sceneLoaderFlags";
  51980. }
  51981. declare module "babylonjs/Materials/Background/index" {
  51982. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51983. }
  51984. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51985. import { Scene } from "babylonjs/scene";
  51986. import { Color3 } from "babylonjs/Maths/math";
  51987. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51988. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51989. /**
  51990. * The Physically based simple base material of BJS.
  51991. *
  51992. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51993. * It is used as the base class for both the specGloss and metalRough conventions.
  51994. */
  51995. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51996. /**
  51997. * Number of Simultaneous lights allowed on the material.
  51998. */
  51999. maxSimultaneousLights: number;
  52000. /**
  52001. * If sets to true, disables all the lights affecting the material.
  52002. */
  52003. disableLighting: boolean;
  52004. /**
  52005. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52006. */
  52007. environmentTexture: BaseTexture;
  52008. /**
  52009. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52010. */
  52011. invertNormalMapX: boolean;
  52012. /**
  52013. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52014. */
  52015. invertNormalMapY: boolean;
  52016. /**
  52017. * Normal map used in the model.
  52018. */
  52019. normalTexture: BaseTexture;
  52020. /**
  52021. * Emissivie color used to self-illuminate the model.
  52022. */
  52023. emissiveColor: Color3;
  52024. /**
  52025. * Emissivie texture used to self-illuminate the model.
  52026. */
  52027. emissiveTexture: BaseTexture;
  52028. /**
  52029. * Occlusion Channel Strenght.
  52030. */
  52031. occlusionStrength: number;
  52032. /**
  52033. * Occlusion Texture of the material (adding extra occlusion effects).
  52034. */
  52035. occlusionTexture: BaseTexture;
  52036. /**
  52037. * Defines the alpha limits in alpha test mode.
  52038. */
  52039. alphaCutOff: number;
  52040. /**
  52041. * Gets the current double sided mode.
  52042. */
  52043. /**
  52044. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52045. */
  52046. doubleSided: boolean;
  52047. /**
  52048. * Stores the pre-calculated light information of a mesh in a texture.
  52049. */
  52050. lightmapTexture: BaseTexture;
  52051. /**
  52052. * If true, the light map contains occlusion information instead of lighting info.
  52053. */
  52054. useLightmapAsShadowmap: boolean;
  52055. /**
  52056. * Instantiates a new PBRMaterial instance.
  52057. *
  52058. * @param name The material name
  52059. * @param scene The scene the material will be use in.
  52060. */
  52061. constructor(name: string, scene: Scene);
  52062. getClassName(): string;
  52063. }
  52064. }
  52065. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52066. import { Scene } from "babylonjs/scene";
  52067. import { Color3 } from "babylonjs/Maths/math";
  52068. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52069. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52070. /**
  52071. * The PBR material of BJS following the metal roughness convention.
  52072. *
  52073. * This fits to the PBR convention in the GLTF definition:
  52074. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52075. */
  52076. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52077. /**
  52078. * The base color has two different interpretations depending on the value of metalness.
  52079. * When the material is a metal, the base color is the specific measured reflectance value
  52080. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52081. * of the material.
  52082. */
  52083. baseColor: Color3;
  52084. /**
  52085. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52086. * well as opacity information in the alpha channel.
  52087. */
  52088. baseTexture: BaseTexture;
  52089. /**
  52090. * Specifies the metallic scalar value of the material.
  52091. * Can also be used to scale the metalness values of the metallic texture.
  52092. */
  52093. metallic: number;
  52094. /**
  52095. * Specifies the roughness scalar value of the material.
  52096. * Can also be used to scale the roughness values of the metallic texture.
  52097. */
  52098. roughness: number;
  52099. /**
  52100. * Texture containing both the metallic value in the B channel and the
  52101. * roughness value in the G channel to keep better precision.
  52102. */
  52103. metallicRoughnessTexture: BaseTexture;
  52104. /**
  52105. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52106. *
  52107. * @param name The material name
  52108. * @param scene The scene the material will be use in.
  52109. */
  52110. constructor(name: string, scene: Scene);
  52111. /**
  52112. * Return the currrent class name of the material.
  52113. */
  52114. getClassName(): string;
  52115. /**
  52116. * Makes a duplicate of the current material.
  52117. * @param name - name to use for the new material.
  52118. */
  52119. clone(name: string): PBRMetallicRoughnessMaterial;
  52120. /**
  52121. * Serialize the material to a parsable JSON object.
  52122. */
  52123. serialize(): any;
  52124. /**
  52125. * Parses a JSON object correponding to the serialize function.
  52126. */
  52127. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52128. }
  52129. }
  52130. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52131. import { Scene } from "babylonjs/scene";
  52132. import { Color3 } from "babylonjs/Maths/math";
  52133. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52134. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52135. /**
  52136. * The PBR material of BJS following the specular glossiness convention.
  52137. *
  52138. * This fits to the PBR convention in the GLTF definition:
  52139. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52140. */
  52141. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52142. /**
  52143. * Specifies the diffuse color of the material.
  52144. */
  52145. diffuseColor: Color3;
  52146. /**
  52147. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52148. * channel.
  52149. */
  52150. diffuseTexture: BaseTexture;
  52151. /**
  52152. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52153. */
  52154. specularColor: Color3;
  52155. /**
  52156. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52157. */
  52158. glossiness: number;
  52159. /**
  52160. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52161. */
  52162. specularGlossinessTexture: BaseTexture;
  52163. /**
  52164. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52165. *
  52166. * @param name The material name
  52167. * @param scene The scene the material will be use in.
  52168. */
  52169. constructor(name: string, scene: Scene);
  52170. /**
  52171. * Return the currrent class name of the material.
  52172. */
  52173. getClassName(): string;
  52174. /**
  52175. * Makes a duplicate of the current material.
  52176. * @param name - name to use for the new material.
  52177. */
  52178. clone(name: string): PBRSpecularGlossinessMaterial;
  52179. /**
  52180. * Serialize the material to a parsable JSON object.
  52181. */
  52182. serialize(): any;
  52183. /**
  52184. * Parses a JSON object correponding to the serialize function.
  52185. */
  52186. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52187. }
  52188. }
  52189. declare module "babylonjs/Materials/PBR/index" {
  52190. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52191. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52192. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52193. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52194. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52195. }
  52196. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52197. import { Nullable } from "babylonjs/types";
  52198. import { Scene } from "babylonjs/scene";
  52199. import { Matrix } from "babylonjs/Maths/math";
  52200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52201. /**
  52202. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52203. * It can help converting any input color in a desired output one. This can then be used to create effects
  52204. * from sepia, black and white to sixties or futuristic rendering...
  52205. *
  52206. * The only supported format is currently 3dl.
  52207. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52208. */
  52209. export class ColorGradingTexture extends BaseTexture {
  52210. /**
  52211. * The current texture matrix. (will always be identity in color grading texture)
  52212. */
  52213. private _textureMatrix;
  52214. /**
  52215. * The texture URL.
  52216. */
  52217. url: string;
  52218. /**
  52219. * Empty line regex stored for GC.
  52220. */
  52221. private static _noneEmptyLineRegex;
  52222. private _engine;
  52223. /**
  52224. * Instantiates a ColorGradingTexture from the following parameters.
  52225. *
  52226. * @param url The location of the color gradind data (currently only supporting 3dl)
  52227. * @param scene The scene the texture will be used in
  52228. */
  52229. constructor(url: string, scene: Scene);
  52230. /**
  52231. * Returns the texture matrix used in most of the material.
  52232. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52233. */
  52234. getTextureMatrix(): Matrix;
  52235. /**
  52236. * Occurs when the file being loaded is a .3dl LUT file.
  52237. */
  52238. private load3dlTexture;
  52239. /**
  52240. * Starts the loading process of the texture.
  52241. */
  52242. private loadTexture;
  52243. /**
  52244. * Clones the color gradind texture.
  52245. */
  52246. clone(): ColorGradingTexture;
  52247. /**
  52248. * Called during delayed load for textures.
  52249. */
  52250. delayLoad(): void;
  52251. /**
  52252. * Parses a color grading texture serialized by Babylon.
  52253. * @param parsedTexture The texture information being parsedTexture
  52254. * @param scene The scene to load the texture in
  52255. * @param rootUrl The root url of the data assets to load
  52256. * @return A color gradind texture
  52257. */
  52258. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52259. /**
  52260. * Serializes the LUT texture to json format.
  52261. */
  52262. serialize(): any;
  52263. }
  52264. }
  52265. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52266. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52267. import { Scene } from "babylonjs/scene";
  52268. import { Nullable } from "babylonjs/types";
  52269. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52270. /**
  52271. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52272. */
  52273. export class EquiRectangularCubeTexture extends BaseTexture {
  52274. /** The six faces of the cube. */
  52275. private static _FacesMapping;
  52276. private _noMipmap;
  52277. private _onLoad;
  52278. private _onError;
  52279. /** The size of the cubemap. */
  52280. private _size;
  52281. /** The buffer of the image. */
  52282. private _buffer;
  52283. /** The width of the input image. */
  52284. private _width;
  52285. /** The height of the input image. */
  52286. private _height;
  52287. /** The URL to the image. */
  52288. url: string;
  52289. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52290. coordinatesMode: number;
  52291. /**
  52292. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52293. * @param url The location of the image
  52294. * @param scene The scene the texture will be used in
  52295. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52296. * @param noMipmap Forces to not generate the mipmap if true
  52297. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52298. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52299. * @param onLoad — defines a callback called when texture is loaded
  52300. * @param onError — defines a callback called if there is an error
  52301. */
  52302. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52303. /**
  52304. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52305. */
  52306. private loadImage;
  52307. /**
  52308. * Convert the image buffer into a cubemap and create a CubeTexture.
  52309. */
  52310. private loadTexture;
  52311. /**
  52312. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52313. * @param buffer The ArrayBuffer that should be converted.
  52314. * @returns The buffer as Float32Array.
  52315. */
  52316. private getFloat32ArrayFromArrayBuffer;
  52317. /**
  52318. * Get the current class name of the texture useful for serialization or dynamic coding.
  52319. * @returns "EquiRectangularCubeTexture"
  52320. */
  52321. getClassName(): string;
  52322. /**
  52323. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52324. * @returns A clone of the current EquiRectangularCubeTexture.
  52325. */
  52326. clone(): EquiRectangularCubeTexture;
  52327. }
  52328. }
  52329. declare module "babylonjs/Misc/tga" {
  52330. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52331. /**
  52332. * Based on jsTGALoader - Javascript loader for TGA file
  52333. * By Vincent Thibault
  52334. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52335. */
  52336. export class TGATools {
  52337. private static _TYPE_INDEXED;
  52338. private static _TYPE_RGB;
  52339. private static _TYPE_GREY;
  52340. private static _TYPE_RLE_INDEXED;
  52341. private static _TYPE_RLE_RGB;
  52342. private static _TYPE_RLE_GREY;
  52343. private static _ORIGIN_MASK;
  52344. private static _ORIGIN_SHIFT;
  52345. private static _ORIGIN_BL;
  52346. private static _ORIGIN_BR;
  52347. private static _ORIGIN_UL;
  52348. private static _ORIGIN_UR;
  52349. /**
  52350. * Gets the header of a TGA file
  52351. * @param data defines the TGA data
  52352. * @returns the header
  52353. */
  52354. static GetTGAHeader(data: Uint8Array): any;
  52355. /**
  52356. * Uploads TGA content to a Babylon Texture
  52357. * @hidden
  52358. */
  52359. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52360. /** @hidden */
  52361. 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;
  52362. /** @hidden */
  52363. 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;
  52364. /** @hidden */
  52365. 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;
  52366. /** @hidden */
  52367. 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;
  52368. /** @hidden */
  52369. 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;
  52370. /** @hidden */
  52371. 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;
  52372. }
  52373. }
  52374. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52375. import { Nullable } from "babylonjs/types";
  52376. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52377. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52378. /**
  52379. * Implementation of the TGA Texture Loader.
  52380. * @hidden
  52381. */
  52382. export class _TGATextureLoader implements IInternalTextureLoader {
  52383. /**
  52384. * Defines wether the loader supports cascade loading the different faces.
  52385. */
  52386. readonly supportCascades: boolean;
  52387. /**
  52388. * This returns if the loader support the current file information.
  52389. * @param extension defines the file extension of the file being loaded
  52390. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52391. * @param fallback defines the fallback internal texture if any
  52392. * @param isBase64 defines whether the texture is encoded as a base64
  52393. * @param isBuffer defines whether the texture data are stored as a buffer
  52394. * @returns true if the loader can load the specified file
  52395. */
  52396. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52397. /**
  52398. * Transform the url before loading if required.
  52399. * @param rootUrl the url of the texture
  52400. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52401. * @returns the transformed texture
  52402. */
  52403. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52404. /**
  52405. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52406. * @param rootUrl the url of the texture
  52407. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52408. * @returns the fallback texture
  52409. */
  52410. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52411. /**
  52412. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52413. * @param data contains the texture data
  52414. * @param texture defines the BabylonJS internal texture
  52415. * @param createPolynomials will be true if polynomials have been requested
  52416. * @param onLoad defines the callback to trigger once the texture is ready
  52417. * @param onError defines the callback to trigger in case of error
  52418. */
  52419. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52420. /**
  52421. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52422. * @param data contains the texture data
  52423. * @param texture defines the BabylonJS internal texture
  52424. * @param callback defines the method to call once ready to upload
  52425. */
  52426. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52427. }
  52428. }
  52429. declare module "babylonjs/Misc/basis" {
  52430. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52431. /**
  52432. * Info about the .basis files
  52433. */
  52434. class BasisFileInfo {
  52435. /**
  52436. * If the file has alpha
  52437. */
  52438. hasAlpha: boolean;
  52439. /**
  52440. * Info about each image of the basis file
  52441. */
  52442. images: Array<{
  52443. levels: Array<{
  52444. width: number;
  52445. height: number;
  52446. transcodedPixels: ArrayBufferView;
  52447. }>;
  52448. }>;
  52449. }
  52450. /**
  52451. * Result of transcoding a basis file
  52452. */
  52453. class TranscodeResult {
  52454. /**
  52455. * Info about the .basis file
  52456. */
  52457. fileInfo: BasisFileInfo;
  52458. /**
  52459. * Format to use when loading the file
  52460. */
  52461. format: number;
  52462. }
  52463. /**
  52464. * Configuration options for the Basis transcoder
  52465. */
  52466. export class BasisTranscodeConfiguration {
  52467. /**
  52468. * Supported compression formats used to determine the supported output format of the transcoder
  52469. */
  52470. supportedCompressionFormats?: {
  52471. /**
  52472. * etc1 compression format
  52473. */
  52474. etc1?: boolean;
  52475. /**
  52476. * s3tc compression format
  52477. */
  52478. s3tc?: boolean;
  52479. /**
  52480. * pvrtc compression format
  52481. */
  52482. pvrtc?: boolean;
  52483. /**
  52484. * etc2 compression format
  52485. */
  52486. etc2?: boolean;
  52487. };
  52488. /**
  52489. * If mipmap levels should be loaded for transcoded images (Default: true)
  52490. */
  52491. loadMipmapLevels?: boolean;
  52492. /**
  52493. * Index of a single image to load (Default: all images)
  52494. */
  52495. loadSingleImage?: number;
  52496. }
  52497. /**
  52498. * Used to load .Basis files
  52499. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52500. */
  52501. export class BasisTools {
  52502. private static _IgnoreSupportedFormats;
  52503. /**
  52504. * URL to use when loading the basis transcoder
  52505. */
  52506. static JSModuleURL: string;
  52507. /**
  52508. * URL to use when loading the wasm module for the transcoder
  52509. */
  52510. static WasmModuleURL: string;
  52511. /**
  52512. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52513. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52514. * @returns internal format corresponding to the Basis format
  52515. */
  52516. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52517. private static _WorkerPromise;
  52518. private static _Worker;
  52519. private static _actionId;
  52520. private static _CreateWorkerAsync;
  52521. /**
  52522. * Transcodes a loaded image file to compressed pixel data
  52523. * @param imageData image data to transcode
  52524. * @param config configuration options for the transcoding
  52525. * @returns a promise resulting in the transcoded image
  52526. */
  52527. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52528. /**
  52529. * Loads a texture from the transcode result
  52530. * @param texture texture load to
  52531. * @param transcodeResult the result of transcoding the basis file to load from
  52532. */
  52533. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52534. }
  52535. }
  52536. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  52537. import { Nullable } from "babylonjs/types";
  52538. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52539. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52540. /**
  52541. * Loader for .basis file format
  52542. */
  52543. export class _BasisTextureLoader implements IInternalTextureLoader {
  52544. /**
  52545. * Defines whether the loader supports cascade loading the different faces.
  52546. */
  52547. readonly supportCascades: boolean;
  52548. /**
  52549. * This returns if the loader support the current file information.
  52550. * @param extension defines the file extension of the file being loaded
  52551. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52552. * @param fallback defines the fallback internal texture if any
  52553. * @param isBase64 defines whether the texture is encoded as a base64
  52554. * @param isBuffer defines whether the texture data are stored as a buffer
  52555. * @returns true if the loader can load the specified file
  52556. */
  52557. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52558. /**
  52559. * Transform the url before loading if required.
  52560. * @param rootUrl the url of the texture
  52561. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52562. * @returns the transformed texture
  52563. */
  52564. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52565. /**
  52566. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52567. * @param rootUrl the url of the texture
  52568. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52569. * @returns the fallback texture
  52570. */
  52571. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52572. /**
  52573. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52574. * @param data contains the texture data
  52575. * @param texture defines the BabylonJS internal texture
  52576. * @param createPolynomials will be true if polynomials have been requested
  52577. * @param onLoad defines the callback to trigger once the texture is ready
  52578. * @param onError defines the callback to trigger in case of error
  52579. */
  52580. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52581. /**
  52582. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52583. * @param data contains the texture data
  52584. * @param texture defines the BabylonJS internal texture
  52585. * @param callback defines the method to call once ready to upload
  52586. */
  52587. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52588. }
  52589. }
  52590. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52591. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52592. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52593. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52594. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52595. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  52596. }
  52597. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52598. import { Scene } from "babylonjs/scene";
  52599. import { Texture } from "babylonjs/Materials/Textures/texture";
  52600. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52601. /**
  52602. * 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.
  52603. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52604. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52605. */
  52606. export class CustomProceduralTexture extends ProceduralTexture {
  52607. private _animate;
  52608. private _time;
  52609. private _config;
  52610. private _texturePath;
  52611. /**
  52612. * Instantiates a new Custom Procedural Texture.
  52613. * 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.
  52614. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52615. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52616. * @param name Define the name of the texture
  52617. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52618. * @param size Define the size of the texture to create
  52619. * @param scene Define the scene the texture belongs to
  52620. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52621. * @param generateMipMaps Define if the texture should creates mip maps or not
  52622. */
  52623. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52624. private _loadJson;
  52625. /**
  52626. * Is the texture ready to be used ? (rendered at least once)
  52627. * @returns true if ready, otherwise, false.
  52628. */
  52629. isReady(): boolean;
  52630. /**
  52631. * Render the texture to its associated render target.
  52632. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52633. */
  52634. render(useCameraPostProcess?: boolean): void;
  52635. /**
  52636. * Update the list of dependant textures samplers in the shader.
  52637. */
  52638. updateTextures(): void;
  52639. /**
  52640. * Update the uniform values of the procedural texture in the shader.
  52641. */
  52642. updateShaderUniforms(): void;
  52643. /**
  52644. * Define if the texture animates or not.
  52645. */
  52646. animate: boolean;
  52647. }
  52648. }
  52649. declare module "babylonjs/Shaders/noise.fragment" {
  52650. /** @hidden */
  52651. export var noisePixelShader: {
  52652. name: string;
  52653. shader: string;
  52654. };
  52655. }
  52656. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52657. import { Nullable } from "babylonjs/types";
  52658. import { Scene } from "babylonjs/scene";
  52659. import { Texture } from "babylonjs/Materials/Textures/texture";
  52660. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52661. import "babylonjs/Shaders/noise.fragment";
  52662. /**
  52663. * Class used to generate noise procedural textures
  52664. */
  52665. export class NoiseProceduralTexture extends ProceduralTexture {
  52666. private _time;
  52667. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52668. brightness: number;
  52669. /** Defines the number of octaves to process */
  52670. octaves: number;
  52671. /** Defines the level of persistence (0.8 by default) */
  52672. persistence: number;
  52673. /** Gets or sets animation speed factor (default is 1) */
  52674. animationSpeedFactor: number;
  52675. /**
  52676. * Creates a new NoiseProceduralTexture
  52677. * @param name defines the name fo the texture
  52678. * @param size defines the size of the texture (default is 256)
  52679. * @param scene defines the hosting scene
  52680. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52681. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52682. */
  52683. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52684. private _updateShaderUniforms;
  52685. protected _getDefines(): string;
  52686. /** Generate the current state of the procedural texture */
  52687. render(useCameraPostProcess?: boolean): void;
  52688. /**
  52689. * Serializes this noise procedural texture
  52690. * @returns a serialized noise procedural texture object
  52691. */
  52692. serialize(): any;
  52693. /**
  52694. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52695. * @param parsedTexture defines parsed texture data
  52696. * @param scene defines the current scene
  52697. * @param rootUrl defines the root URL containing noise procedural texture information
  52698. * @returns a parsed NoiseProceduralTexture
  52699. */
  52700. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52701. }
  52702. }
  52703. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52704. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52705. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52706. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52707. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52708. }
  52709. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52710. import { Nullable } from "babylonjs/types";
  52711. import { Scene } from "babylonjs/scene";
  52712. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52713. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52714. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52715. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52716. /**
  52717. * Raw cube texture where the raw buffers are passed in
  52718. */
  52719. export class RawCubeTexture extends CubeTexture {
  52720. /**
  52721. * Creates a cube texture where the raw buffers are passed in.
  52722. * @param scene defines the scene the texture is attached to
  52723. * @param data defines the array of data to use to create each face
  52724. * @param size defines the size of the textures
  52725. * @param format defines the format of the data
  52726. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52727. * @param generateMipMaps defines if the engine should generate the mip levels
  52728. * @param invertY defines if data must be stored with Y axis inverted
  52729. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52730. * @param compression defines the compression used (null by default)
  52731. */
  52732. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52733. /**
  52734. * Updates the raw cube texture.
  52735. * @param data defines the data to store
  52736. * @param format defines the data format
  52737. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52738. * @param invertY defines if data must be stored with Y axis inverted
  52739. * @param compression defines the compression used (null by default)
  52740. * @param level defines which level of the texture to update
  52741. */
  52742. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52743. /**
  52744. * Updates a raw cube texture with RGBD encoded data.
  52745. * @param data defines the array of data [mipmap][face] to use to create each face
  52746. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52747. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52748. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52749. * @returns a promsie that resolves when the operation is complete
  52750. */
  52751. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52752. /**
  52753. * Clones the raw cube texture.
  52754. * @return a new cube texture
  52755. */
  52756. clone(): CubeTexture;
  52757. /** @hidden */
  52758. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52759. }
  52760. }
  52761. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52762. import { Scene } from "babylonjs/scene";
  52763. import { Texture } from "babylonjs/Materials/Textures/texture";
  52764. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52765. /**
  52766. * Class used to store 3D textures containing user data
  52767. */
  52768. export class RawTexture3D extends Texture {
  52769. /** Gets or sets the texture format to use */
  52770. format: number;
  52771. private _engine;
  52772. /**
  52773. * Create a new RawTexture3D
  52774. * @param data defines the data of the texture
  52775. * @param width defines the width of the texture
  52776. * @param height defines the height of the texture
  52777. * @param depth defines the depth of the texture
  52778. * @param format defines the texture format to use
  52779. * @param scene defines the hosting scene
  52780. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52781. * @param invertY defines if texture must be stored with Y axis inverted
  52782. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52783. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52784. */
  52785. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52786. /** Gets or sets the texture format to use */
  52787. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52788. /**
  52789. * Update the texture with new data
  52790. * @param data defines the data to store in the texture
  52791. */
  52792. update(data: ArrayBufferView): void;
  52793. }
  52794. }
  52795. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52796. import { Scene } from "babylonjs/scene";
  52797. import { Plane } from "babylonjs/Maths/math";
  52798. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52799. /**
  52800. * Creates a refraction texture used by refraction channel of the standard material.
  52801. * It is like a mirror but to see through a material.
  52802. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52803. */
  52804. export class RefractionTexture extends RenderTargetTexture {
  52805. /**
  52806. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52807. * 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.
  52808. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52809. */
  52810. refractionPlane: Plane;
  52811. /**
  52812. * Define how deep under the surface we should see.
  52813. */
  52814. depth: number;
  52815. /**
  52816. * Creates a refraction texture used by refraction channel of the standard material.
  52817. * It is like a mirror but to see through a material.
  52818. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52819. * @param name Define the texture name
  52820. * @param size Define the size of the underlying texture
  52821. * @param scene Define the scene the refraction belongs to
  52822. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52823. */
  52824. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52825. /**
  52826. * Clone the refraction texture.
  52827. * @returns the cloned texture
  52828. */
  52829. clone(): RefractionTexture;
  52830. /**
  52831. * Serialize the texture to a JSON representation you could use in Parse later on
  52832. * @returns the serialized JSON representation
  52833. */
  52834. serialize(): any;
  52835. }
  52836. }
  52837. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52838. import { Nullable } from "babylonjs/types";
  52839. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52840. import { Matrix } from "babylonjs/Maths/math";
  52841. import { Engine } from "babylonjs/Engines/engine";
  52842. import { Scene } from "babylonjs/scene";
  52843. /**
  52844. * Defines the options related to the creation of an HtmlElementTexture
  52845. */
  52846. export interface IHtmlElementTextureOptions {
  52847. /**
  52848. * Defines wether mip maps should be created or not.
  52849. */
  52850. generateMipMaps?: boolean;
  52851. /**
  52852. * Defines the sampling mode of the texture.
  52853. */
  52854. samplingMode?: number;
  52855. /**
  52856. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52857. */
  52858. engine: Nullable<Engine>;
  52859. /**
  52860. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52861. */
  52862. scene: Nullable<Scene>;
  52863. }
  52864. /**
  52865. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52866. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52867. * is automatically managed.
  52868. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52869. * in your application.
  52870. *
  52871. * As the update is not automatic, you need to call them manually.
  52872. */
  52873. export class HtmlElementTexture extends BaseTexture {
  52874. /**
  52875. * The texture URL.
  52876. */
  52877. element: HTMLVideoElement | HTMLCanvasElement;
  52878. private static readonly DefaultOptions;
  52879. private _textureMatrix;
  52880. private _engine;
  52881. private _isVideo;
  52882. private _generateMipMaps;
  52883. private _samplingMode;
  52884. /**
  52885. * Instantiates a HtmlElementTexture from the following parameters.
  52886. *
  52887. * @param name Defines the name of the texture
  52888. * @param element Defines the video or canvas the texture is filled with
  52889. * @param options Defines the other none mandatory texture creation options
  52890. */
  52891. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52892. private _createInternalTexture;
  52893. /**
  52894. * Returns the texture matrix used in most of the material.
  52895. */
  52896. getTextureMatrix(): Matrix;
  52897. /**
  52898. * Updates the content of the texture.
  52899. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52900. */
  52901. update(invertY?: Nullable<boolean>): void;
  52902. }
  52903. }
  52904. declare module "babylonjs/Materials/Textures/index" {
  52905. export * from "babylonjs/Materials/Textures/baseTexture";
  52906. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  52907. export * from "babylonjs/Materials/Textures/cubeTexture";
  52908. export * from "babylonjs/Materials/Textures/dynamicTexture";
  52909. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  52910. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  52911. export * from "babylonjs/Materials/Textures/internalTexture";
  52912. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  52913. export * from "babylonjs/Materials/Textures/Loaders/index";
  52914. export * from "babylonjs/Materials/Textures/mirrorTexture";
  52915. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  52916. export * from "babylonjs/Materials/Textures/Procedurals/index";
  52917. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  52918. export * from "babylonjs/Materials/Textures/rawTexture";
  52919. export * from "babylonjs/Materials/Textures/rawTexture3D";
  52920. export * from "babylonjs/Materials/Textures/refractionTexture";
  52921. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  52922. export * from "babylonjs/Materials/Textures/texture";
  52923. export * from "babylonjs/Materials/Textures/videoTexture";
  52924. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  52925. }
  52926. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  52927. /**
  52928. * Enum used to define the target of a block
  52929. */
  52930. export enum NodeMaterialBlockTargets {
  52931. /** Vertex shader */
  52932. Vertex = 1,
  52933. /** Fragment shader */
  52934. Fragment = 2,
  52935. /** Vertex and Fragment */
  52936. VertexAndFragment = 3
  52937. }
  52938. }
  52939. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  52940. /**
  52941. * Defines the kind of connection point for node based material
  52942. */
  52943. export enum NodeMaterialBlockConnectionPointTypes {
  52944. /** Float */
  52945. Float = 1,
  52946. /** Int */
  52947. Int = 2,
  52948. /** Vector2 */
  52949. Vector2 = 4,
  52950. /** Vector3 */
  52951. Vector3 = 8,
  52952. /** Vector4 */
  52953. Vector4 = 16,
  52954. /** Color3 */
  52955. Color3 = 32,
  52956. /** Color4 */
  52957. Color4 = 64,
  52958. /** Matrix */
  52959. Matrix = 128,
  52960. /** Texture */
  52961. Texture = 256,
  52962. /** Texture3D */
  52963. Texture3D = 512,
  52964. /** Vector3 or Color3 */
  52965. Vector3OrColor3 = 40,
  52966. /** Vector3 or Vector4 */
  52967. Vector3OrVector4 = 24,
  52968. /** Vector4 or Color4 */
  52969. Vector4OrColor4 = 80,
  52970. /** Color3 or Color4 */
  52971. Color3OrColor4 = 96,
  52972. /** Vector3 or Color3 */
  52973. Vector3OrColor3OrVector4OrColor4 = 120,
  52974. /** Detect type based on connection */
  52975. AutoDetect = 1024,
  52976. /** Output type that will be defined by input type */
  52977. BasedOnInput = 2048,
  52978. /** Light */
  52979. Light = 4096
  52980. }
  52981. }
  52982. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  52983. /**
  52984. * Enum used to define well known values e.g. values automatically provided by the system
  52985. */
  52986. export enum NodeMaterialWellKnownValues {
  52987. /** World */
  52988. World = 1,
  52989. /** View */
  52990. View = 2,
  52991. /** Projection */
  52992. Projection = 3,
  52993. /** ViewProjection */
  52994. ViewProjection = 4,
  52995. /** WorldView */
  52996. WorldView = 5,
  52997. /** WorldViewProjection */
  52998. WorldViewProjection = 6,
  52999. /** CameraPosition */
  53000. CameraPosition = 7,
  53001. /** Will be filled by the block itself */
  53002. Automatic = 8
  53003. }
  53004. }
  53005. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  53006. /**
  53007. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53008. */
  53009. export enum NodeMaterialBlockConnectionPointMode {
  53010. /** Value is an uniform */
  53011. Uniform = 0,
  53012. /** Value is a mesh attribute */
  53013. Attribute = 1,
  53014. /** Value is a varying between vertex and fragment shaders */
  53015. Varying = 2,
  53016. /** Mode is undefined */
  53017. Undefined = 3
  53018. }
  53019. }
  53020. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  53021. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53022. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53023. /**
  53024. * Class used to store shared data between 2 NodeMaterialBuildState
  53025. */
  53026. export class NodeMaterialBuildStateSharedData {
  53027. /**
  53028. * Gets the list of emitted varyings
  53029. */
  53030. varyings: string[];
  53031. /**
  53032. * Gets the varying declaration string
  53033. */
  53034. varyingDeclaration: string;
  53035. /**
  53036. * Uniform connection points
  53037. */
  53038. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  53039. /**
  53040. * Bindable blocks (Blocks that need to set data to the effect)
  53041. */
  53042. bindableBlocks: NodeMaterialBlock[];
  53043. /**
  53044. * List of blocks that can provide a compilation fallback
  53045. */
  53046. blocksWithFallbacks: NodeMaterialBlock[];
  53047. /**
  53048. * List of blocks that can provide a define update
  53049. */
  53050. blocksWithDefines: NodeMaterialBlock[];
  53051. /**
  53052. * List of blocks that can provide a repeatable content
  53053. */
  53054. repeatableContentBlocks: NodeMaterialBlock[];
  53055. /**
  53056. * List of blocks that can block the isReady function for the material
  53057. */
  53058. blockingBlocks: NodeMaterialBlock[];
  53059. /**
  53060. * Build Id used to avoid multiple recompilations
  53061. */
  53062. buildId: number;
  53063. /** List of emitted variables */
  53064. variableNames: {
  53065. [key: string]: number;
  53066. };
  53067. /** List of emitted defines */
  53068. defineNames: {
  53069. [key: string]: number;
  53070. };
  53071. /** Should emit comments? */
  53072. emitComments: boolean;
  53073. /** Emit build activity */
  53074. verbose: boolean;
  53075. /**
  53076. * Gets the compilation hints emitted at compilation time
  53077. */
  53078. hints: {
  53079. needWorldViewMatrix: boolean;
  53080. needWorldViewProjectionMatrix: boolean;
  53081. needAlphaBlending: boolean;
  53082. needAlphaTesting: boolean;
  53083. };
  53084. /**
  53085. * List of compilation checks
  53086. */
  53087. checks: {
  53088. emitVertex: boolean;
  53089. emitFragment: boolean;
  53090. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53091. };
  53092. /** Creates a new shared data */
  53093. constructor();
  53094. /**
  53095. * Emits console errors and exceptions if there is a failing check
  53096. */
  53097. emitErrors(): void;
  53098. }
  53099. }
  53100. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  53101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53102. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53103. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53104. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  53105. import { Nullable } from "babylonjs/types";
  53106. /**
  53107. * Class used to store node based material build state
  53108. */
  53109. export class NodeMaterialBuildState {
  53110. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53111. supportUniformBuffers: boolean;
  53112. /**
  53113. * Gets the list of emitted attributes
  53114. */
  53115. attributes: string[];
  53116. /**
  53117. * Gets the list of emitted uniforms
  53118. */
  53119. uniforms: string[];
  53120. /**
  53121. * Gets the list of emitted uniform buffers
  53122. */
  53123. uniformBuffers: string[];
  53124. /**
  53125. * Gets the list of emitted samplers
  53126. */
  53127. samplers: string[];
  53128. /**
  53129. * Gets the list of emitted functions
  53130. */
  53131. functions: {
  53132. [key: string]: string;
  53133. };
  53134. /**
  53135. * Gets the target of the compilation state
  53136. */
  53137. target: NodeMaterialBlockTargets;
  53138. /**
  53139. * Gets the list of emitted counters
  53140. */
  53141. counters: {
  53142. [key: string]: number;
  53143. };
  53144. /**
  53145. * Shared data between multiple NodeMaterialBuildState instances
  53146. */
  53147. sharedData: NodeMaterialBuildStateSharedData;
  53148. /** @hidden */
  53149. _vertexState: NodeMaterialBuildState;
  53150. private _attributeDeclaration;
  53151. private _uniformDeclaration;
  53152. private _samplerDeclaration;
  53153. private _varyingTransfer;
  53154. private _repeatableContentAnchorIndex;
  53155. /** @hidden */
  53156. _builtCompilationString: string;
  53157. /**
  53158. * Gets the emitted compilation strings
  53159. */
  53160. compilationString: string;
  53161. /**
  53162. * Finalize the compilation strings
  53163. * @param state defines the current compilation state
  53164. */
  53165. finalize(state: NodeMaterialBuildState): void;
  53166. /** @hidden */
  53167. readonly _repeatableContentAnchor: string;
  53168. /** @hidden */
  53169. _getFreeVariableName(prefix: string): string;
  53170. /** @hidden */
  53171. _getFreeDefineName(prefix: string): string;
  53172. /** @hidden */
  53173. _excludeVariableName(name: string): void;
  53174. /** @hidden */
  53175. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53176. /** @hidden */
  53177. _emitFunction(name: string, code: string, comments: string): void;
  53178. /** @hidden */
  53179. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53180. replaceStrings?: {
  53181. search: RegExp;
  53182. replace: string;
  53183. }[];
  53184. }): string;
  53185. /** @hidden */
  53186. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53187. repeatKey?: string;
  53188. removeAttributes?: boolean;
  53189. removeUniforms?: boolean;
  53190. removeVaryings?: boolean;
  53191. removeIfDef?: boolean;
  53192. replaceStrings?: {
  53193. search: RegExp;
  53194. replace: string;
  53195. }[];
  53196. }, storeKey?: string): void;
  53197. /** @hidden */
  53198. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  53199. private _emitDefine;
  53200. /** @hidden */
  53201. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  53202. }
  53203. }
  53204. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53205. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53206. /**
  53207. * Root class for all node material optimizers
  53208. */
  53209. export class NodeMaterialOptimizer {
  53210. /**
  53211. * Function used to optimize a NodeMaterial graph
  53212. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53213. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53214. */
  53215. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53216. }
  53217. }
  53218. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  53219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53221. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53222. /**
  53223. * Block used to transform a vector4 with a matrix
  53224. */
  53225. export class Vector4TransformBlock extends NodeMaterialBlock {
  53226. /**
  53227. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53228. */
  53229. complementW: number;
  53230. /**
  53231. * Creates a new Vector4TransformBlock
  53232. * @param name defines the block name
  53233. */
  53234. constructor(name: string);
  53235. /**
  53236. * Gets the current class name
  53237. * @returns the class name
  53238. */
  53239. getClassName(): string;
  53240. /**
  53241. * Gets the vector input
  53242. */
  53243. readonly vector: NodeMaterialConnectionPoint;
  53244. /**
  53245. * Gets the output component
  53246. */
  53247. readonly output: NodeMaterialConnectionPoint;
  53248. /**
  53249. * Gets the matrix transform input
  53250. */
  53251. readonly transform: NodeMaterialConnectionPoint;
  53252. protected _buildBlock(state: NodeMaterialBuildState): this;
  53253. }
  53254. }
  53255. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53256. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53257. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53258. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53259. /**
  53260. * Block used to output the vertex position
  53261. */
  53262. export class VertexOutputBlock extends NodeMaterialBlock {
  53263. /**
  53264. * Creates a new VertexOutputBlock
  53265. * @param name defines the block name
  53266. */
  53267. constructor(name: string);
  53268. /**
  53269. * Gets the current class name
  53270. * @returns the class name
  53271. */
  53272. getClassName(): string;
  53273. /**
  53274. * Gets the vector input component
  53275. */
  53276. readonly vector: NodeMaterialConnectionPoint;
  53277. protected _buildBlock(state: NodeMaterialBuildState): this;
  53278. }
  53279. }
  53280. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53281. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53282. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53283. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53284. /**
  53285. * Block used to output the final color
  53286. */
  53287. export class FragmentOutputBlock extends NodeMaterialBlock {
  53288. /**
  53289. * Gets or sets a boolean indicating if this block will output an alpha value
  53290. */
  53291. alphaBlendingEnabled: boolean;
  53292. /**
  53293. * Create a new FragmentOutputBlock
  53294. * @param name defines the block name
  53295. */
  53296. constructor(name: string);
  53297. /**
  53298. * Gets the current class name
  53299. * @returns the class name
  53300. */
  53301. getClassName(): string;
  53302. /**
  53303. * Gets the color input component
  53304. */
  53305. readonly color: NodeMaterialConnectionPoint;
  53306. protected _buildBlock(state: NodeMaterialBuildState): this;
  53307. }
  53308. }
  53309. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53310. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53311. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53312. import { Scene } from "babylonjs/scene";
  53313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53314. import { Matrix } from "babylonjs/Maths/math";
  53315. import { Mesh } from "babylonjs/Meshes/mesh";
  53316. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53317. import { Observable } from "babylonjs/Misc/observable";
  53318. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53319. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53320. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53321. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53322. import { Nullable } from "babylonjs/types";
  53323. /**
  53324. * Interface used to configure the node material editor
  53325. */
  53326. export interface INodeMaterialEditorOptions {
  53327. /** Define the URl to load node editor script */
  53328. editorURL?: string;
  53329. }
  53330. /** @hidden */
  53331. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53332. /** BONES */
  53333. NUM_BONE_INFLUENCERS: number;
  53334. BonesPerMesh: number;
  53335. BONETEXTURE: boolean;
  53336. /** MORPH TARGETS */
  53337. MORPHTARGETS: boolean;
  53338. MORPHTARGETS_NORMAL: boolean;
  53339. MORPHTARGETS_TANGENT: boolean;
  53340. MORPHTARGETS_UV: boolean;
  53341. NUM_MORPH_INFLUENCERS: number;
  53342. /** IMAGE PROCESSING */
  53343. IMAGEPROCESSING: boolean;
  53344. VIGNETTE: boolean;
  53345. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53346. VIGNETTEBLENDMODEOPAQUE: boolean;
  53347. TONEMAPPING: boolean;
  53348. TONEMAPPING_ACES: boolean;
  53349. CONTRAST: boolean;
  53350. EXPOSURE: boolean;
  53351. COLORCURVES: boolean;
  53352. COLORGRADING: boolean;
  53353. COLORGRADING3D: boolean;
  53354. SAMPLER3DGREENDEPTH: boolean;
  53355. SAMPLER3DBGRMAP: boolean;
  53356. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53357. constructor();
  53358. setValue(name: string, value: boolean): void;
  53359. }
  53360. /**
  53361. * Class used to configure NodeMaterial
  53362. */
  53363. export interface INodeMaterialOptions {
  53364. /**
  53365. * Defines if blocks should emit comments
  53366. */
  53367. emitComments: boolean;
  53368. }
  53369. /**
  53370. * Class used to create a node based material built by assembling shader blocks
  53371. */
  53372. export class NodeMaterial extends PushMaterial {
  53373. private _options;
  53374. private _vertexCompilationState;
  53375. private _fragmentCompilationState;
  53376. private _sharedData;
  53377. private _buildId;
  53378. private _buildWasSuccessful;
  53379. private _cachedWorldViewMatrix;
  53380. private _cachedWorldViewProjectionMatrix;
  53381. private _textureConnectionPoints;
  53382. private _optimizers;
  53383. /** Define the URl to load node editor script */
  53384. static EditorURL: string;
  53385. private BJSNODEMATERIALEDITOR;
  53386. /** Get the inspector from bundle or global */
  53387. private _getGlobalNodeMaterialEditor;
  53388. /**
  53389. * Defines the maximum number of lights that can be used in the material
  53390. */
  53391. maxSimultaneousLights: number;
  53392. /**
  53393. * Observable raised when the material is built
  53394. */
  53395. onBuildObservable: Observable<NodeMaterial>;
  53396. /**
  53397. * Gets or sets the root nodes of the material vertex shader
  53398. */
  53399. _vertexOutputNodes: NodeMaterialBlock[];
  53400. /**
  53401. * Gets or sets the root nodes of the material fragment (pixel) shader
  53402. */
  53403. _fragmentOutputNodes: NodeMaterialBlock[];
  53404. /** Gets or sets options to control the node material overall behavior */
  53405. options: INodeMaterialOptions;
  53406. /**
  53407. * Default configuration related to image processing available in the standard Material.
  53408. */
  53409. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53410. /**
  53411. * Gets the image processing configuration used either in this material.
  53412. */
  53413. /**
  53414. * Sets the Default image processing configuration used either in the this material.
  53415. *
  53416. * If sets to null, the scene one is in use.
  53417. */
  53418. imageProcessingConfiguration: ImageProcessingConfiguration;
  53419. /**
  53420. * Create a new node based material
  53421. * @param name defines the material name
  53422. * @param scene defines the hosting scene
  53423. * @param options defines creation option
  53424. */
  53425. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53426. /**
  53427. * Gets the current class name of the material e.g. "NodeMaterial"
  53428. * @returns the class name
  53429. */
  53430. getClassName(): string;
  53431. /**
  53432. * Keep track of the image processing observer to allow dispose and replace.
  53433. */
  53434. private _imageProcessingObserver;
  53435. /**
  53436. * Attaches a new image processing configuration to the Standard Material.
  53437. * @param configuration
  53438. */
  53439. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53440. /**
  53441. * Adds a new optimizer to the list of optimizers
  53442. * @param optimizer defines the optimizers to add
  53443. * @returns the current material
  53444. */
  53445. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53446. /**
  53447. * Remove an optimizer from the list of optimizers
  53448. * @param optimizer defines the optimizers to remove
  53449. * @returns the current material
  53450. */
  53451. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53452. /**
  53453. * Add a new block to the list of output nodes
  53454. * @param node defines the node to add
  53455. * @returns the current material
  53456. */
  53457. addOutputNode(node: NodeMaterialBlock): this;
  53458. /**
  53459. * Remove a block from the list of root nodes
  53460. * @param node defines the node to remove
  53461. * @returns the current material
  53462. */
  53463. removeOutputNode(node: NodeMaterialBlock): this;
  53464. private _addVertexOutputNode;
  53465. private _removeVertexOutputNode;
  53466. private _addFragmentOutputNode;
  53467. private _removeFragmentOutputNode;
  53468. /**
  53469. * Specifies if the material will require alpha blending
  53470. * @returns a boolean specifying if alpha blending is needed
  53471. */
  53472. needAlphaBlending(): boolean;
  53473. /**
  53474. * Specifies if this material should be rendered in alpha test mode
  53475. * @returns a boolean specifying if an alpha test is needed.
  53476. */
  53477. needAlphaTesting(): boolean;
  53478. private _initializeBlock;
  53479. private _resetDualBlocks;
  53480. /**
  53481. * Build the material and generates the inner effect
  53482. * @param verbose defines if the build should log activity
  53483. */
  53484. build(verbose?: boolean): void;
  53485. /**
  53486. * Runs an otpimization phase to try to improve the shader code
  53487. */
  53488. optimize(): void;
  53489. private _prepareDefinesForAttributes;
  53490. /**
  53491. * Get if the submesh is ready to be used and all its information available.
  53492. * Child classes can use it to update shaders
  53493. * @param mesh defines the mesh to check
  53494. * @param subMesh defines which submesh to check
  53495. * @param useInstances specifies that instances should be used
  53496. * @returns a boolean indicating that the submesh is ready or not
  53497. */
  53498. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53499. /**
  53500. * Binds the world matrix to the material
  53501. * @param world defines the world transformation matrix
  53502. */
  53503. bindOnlyWorldMatrix(world: Matrix): void;
  53504. /**
  53505. * Binds the submesh to this material by preparing the effect and shader to draw
  53506. * @param world defines the world transformation matrix
  53507. * @param mesh defines the mesh containing the submesh
  53508. * @param subMesh defines the submesh to bind the material to
  53509. */
  53510. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53511. /**
  53512. * Gets the active textures from the material
  53513. * @returns an array of textures
  53514. */
  53515. getActiveTextures(): BaseTexture[];
  53516. /**
  53517. * Specifies if the material uses a texture
  53518. * @param texture defines the texture to check against the material
  53519. * @returns a boolean specifying if the material uses the texture
  53520. */
  53521. hasTexture(texture: BaseTexture): boolean;
  53522. /**
  53523. * Disposes the material
  53524. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53525. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53526. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53527. */
  53528. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53529. /** Creates the node editor window. */
  53530. private _createNodeEditor;
  53531. /**
  53532. * Launch the node material editor
  53533. * @param config Define the configuration of the editor
  53534. * @return a promise fulfilled when the node editor is visible
  53535. */
  53536. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53537. /**
  53538. * Clear the current material
  53539. */
  53540. clear(): void;
  53541. /**
  53542. * Clear the current material and set it to a default state
  53543. */
  53544. setToDefault(): void;
  53545. }
  53546. }
  53547. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53548. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53549. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53550. import { Nullable } from "babylonjs/types";
  53551. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53552. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53553. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53555. import { Mesh } from "babylonjs/Meshes/mesh";
  53556. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53557. /**
  53558. * Defines a block that can be used inside a node based material
  53559. */
  53560. export class NodeMaterialBlock {
  53561. private _buildId;
  53562. private _target;
  53563. private _isFinalMerger;
  53564. /** @hidden */
  53565. _inputs: NodeMaterialConnectionPoint[];
  53566. /** @hidden */
  53567. _outputs: NodeMaterialConnectionPoint[];
  53568. /**
  53569. * Gets or sets the name of the block
  53570. */
  53571. name: string;
  53572. /**
  53573. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53574. */
  53575. readonly isFinalMerger: boolean;
  53576. /**
  53577. * Gets or sets the build Id
  53578. */
  53579. buildId: number;
  53580. /**
  53581. * Gets or sets the target of the block
  53582. */
  53583. target: NodeMaterialBlockTargets;
  53584. /**
  53585. * Gets the list of input points
  53586. */
  53587. readonly inputs: NodeMaterialConnectionPoint[];
  53588. /** Gets the list of output points */
  53589. readonly outputs: NodeMaterialConnectionPoint[];
  53590. /**
  53591. * Find an input by its name
  53592. * @param name defines the name of the input to look for
  53593. * @returns the input or null if not found
  53594. */
  53595. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53596. /**
  53597. * Find an output by its name
  53598. * @param name defines the name of the outputto look for
  53599. * @returns the output or null if not found
  53600. */
  53601. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53602. /**
  53603. * Creates a new NodeMaterialBlock
  53604. * @param name defines the block name
  53605. * @param target defines the target of that block (Vertex by default)
  53606. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53607. */
  53608. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  53609. /**
  53610. * Initialize the block and prepare the context for build
  53611. * @param state defines the state that will be used for the build
  53612. */
  53613. initialize(state: NodeMaterialBuildState): void;
  53614. /**
  53615. * Bind data to effect. Will only be called for blocks with isBindable === true
  53616. * @param effect defines the effect to bind data to
  53617. * @param nodeMaterial defines the hosting NodeMaterial
  53618. * @param mesh defines the mesh that will be rendered
  53619. */
  53620. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53621. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53622. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53623. protected _writeFloat(value: number): string;
  53624. /**
  53625. * Gets the current class name e.g. "NodeMaterialBlock"
  53626. * @returns the class name
  53627. */
  53628. getClassName(): string;
  53629. /**
  53630. * Register a new input. Must be called inside a block constructor
  53631. * @param name defines the connection point name
  53632. * @param type defines the connection point type
  53633. * @param isOptional defines a boolean indicating that this input can be omitted
  53634. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53635. * @returns the current block
  53636. */
  53637. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53638. /**
  53639. * Register a new output. Must be called inside a block constructor
  53640. * @param name defines the connection point name
  53641. * @param type defines the connection point type
  53642. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53643. * @returns the current block
  53644. */
  53645. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53646. /**
  53647. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53648. * @param forOutput defines an optional connection point to check compatibility with
  53649. * @returns the first available input or null
  53650. */
  53651. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53652. /**
  53653. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53654. * @param forBlock defines an optional block to check compatibility with
  53655. * @returns the first available input or null
  53656. */
  53657. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53658. /**
  53659. * Connect current block with another block
  53660. * @param other defines the block to connect with
  53661. * @param options define the various options to help pick the right connections
  53662. * @returns the current block
  53663. */
  53664. connectTo(other: NodeMaterialBlock, options?: {
  53665. input?: string;
  53666. output?: string;
  53667. outputSwizzle?: string;
  53668. }): this | undefined;
  53669. protected _buildBlock(state: NodeMaterialBuildState): void;
  53670. /**
  53671. * Add potential fallbacks if shader compilation fails
  53672. * @param mesh defines the mesh to be rendered
  53673. * @param fallbacks defines the current prioritized list of fallbacks
  53674. */
  53675. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53676. /**
  53677. * Update defines for shader compilation
  53678. * @param mesh defines the mesh to be rendered
  53679. * @param nodeMaterial defines the node material requesting the update
  53680. * @param defines defines the material defines to update
  53681. * @param useInstances specifies that instances should be used
  53682. */
  53683. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53684. /**
  53685. * Lets the block try to connect some inputs automatically
  53686. */
  53687. autoConfigure(): void;
  53688. /**
  53689. * Function called when a block is declared as repeatable content generator
  53690. * @param vertexShaderState defines the current compilation state for the vertex shader
  53691. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53692. * @param mesh defines the mesh to be rendered
  53693. * @param defines defines the material defines to update
  53694. */
  53695. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53696. /**
  53697. * Checks if the block is ready
  53698. * @param mesh defines the mesh to be rendered
  53699. * @param nodeMaterial defines the node material requesting the update
  53700. * @param defines defines the material defines to update
  53701. * @param useInstances specifies that instances should be used
  53702. * @returns true if the block is ready
  53703. */
  53704. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53705. /**
  53706. * Compile the current node and generate the shader code
  53707. * @param state defines the current compilation state (uniforms, samplers, current string)
  53708. * @returns the current block
  53709. */
  53710. build(state: NodeMaterialBuildState): this | undefined;
  53711. }
  53712. }
  53713. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  53714. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53715. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53716. import { Nullable } from "babylonjs/types";
  53717. import { Effect } from "babylonjs/Materials/effect";
  53718. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53719. import { Scene } from "babylonjs/scene";
  53720. import { Matrix } from "babylonjs/Maths/math";
  53721. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53722. /**
  53723. * Defines a connection point for a block
  53724. */
  53725. export class NodeMaterialConnectionPoint {
  53726. /** @hidden */
  53727. _ownerBlock: NodeMaterialBlock;
  53728. /** @hidden */
  53729. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53730. private _associatedVariableName;
  53731. private _endpoints;
  53732. private _storedValue;
  53733. private _valueCallback;
  53734. private _mode;
  53735. /** @hidden */
  53736. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53737. /** @hidden */
  53738. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53739. /** @hidden */
  53740. _needToEmitVarying: boolean;
  53741. /** @hidden */
  53742. _forceUniformInVertexShaderOnly: boolean;
  53743. private _type;
  53744. /**
  53745. * Gets or sets the connection point type (default is float)
  53746. */
  53747. type: NodeMaterialBlockConnectionPointTypes;
  53748. /**
  53749. * Gets or sets the connection point name
  53750. */
  53751. name: string;
  53752. /**
  53753. * Gets or sets the swizzle to apply to this connection point when reading or writing
  53754. */
  53755. swizzle: string;
  53756. /**
  53757. * Gets or sets a boolean indicating that this connection point can be omitted
  53758. */
  53759. isOptional: boolean;
  53760. /**
  53761. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53762. */
  53763. define: string;
  53764. /** Gets or sets the target of that connection point */
  53765. target: NodeMaterialBlockTargets;
  53766. /**
  53767. * Gets or sets the value of that point.
  53768. * Please note that this value will be ignored if valueCallback is defined
  53769. */
  53770. value: any;
  53771. /**
  53772. * Gets or sets a callback used to get the value of that point.
  53773. * Please note that setting this value will force the connection point to ignore the value property
  53774. */
  53775. valueCallback: () => any;
  53776. /**
  53777. * Gets or sets the associated variable name in the shader
  53778. */
  53779. associatedVariableName: string;
  53780. /**
  53781. * Gets a boolean indicating that this connection point not defined yet
  53782. */
  53783. readonly isUndefined: boolean;
  53784. /**
  53785. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53786. * In this case the connection point name must be the name of the uniform to use.
  53787. * Can only be set on inputs
  53788. */
  53789. isUniform: boolean;
  53790. /**
  53791. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53792. * In this case the connection point name must be the name of the attribute to use
  53793. * Can only be set on inputs
  53794. */
  53795. isAttribute: boolean;
  53796. /**
  53797. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53798. * Can only be set on exit points
  53799. */
  53800. isVarying: boolean;
  53801. /** Get the other side of the connection (if any) */
  53802. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53803. /** Get the block that owns this connection point */
  53804. readonly ownerBlock: NodeMaterialBlock;
  53805. /** Get the block connected on the other side of this connection (if any) */
  53806. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53807. /** Get the block connected on the endpoints of this connection (if any) */
  53808. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53809. /**
  53810. * Creates a new connection point
  53811. * @param name defines the connection point name
  53812. * @param ownerBlock defines the block hosting this connection point
  53813. */
  53814. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53815. /**
  53816. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53817. * @returns the class name
  53818. */
  53819. getClassName(): string;
  53820. /**
  53821. * Set the source of this connection point to a vertex attribute
  53822. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53823. * @returns the current connection point
  53824. */
  53825. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  53826. /**
  53827. * Set the source of this connection point to a well known value
  53828. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53829. * @returns the current connection point
  53830. */
  53831. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  53832. /**
  53833. * Gets a boolean indicating that the current connection point is a well known value
  53834. */
  53835. readonly isWellKnownValue: boolean;
  53836. /**
  53837. * Gets or sets the current well known value or null if not defined as well know value
  53838. */
  53839. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53840. private _getTypeLength;
  53841. /**
  53842. * Connect this point to another connection point
  53843. * @param connectionPoint defines the other connection point
  53844. * @returns the current connection point
  53845. */
  53846. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53847. /**
  53848. * Disconnect this point from one of his endpoint
  53849. * @param endpoint defines the other connection point
  53850. * @returns the current connection point
  53851. */
  53852. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53853. /**
  53854. * When connection point is an uniform, this function will send its value to the effect
  53855. * @param effect defines the effect to transmit value to
  53856. * @param world defines the world matrix
  53857. * @param worldView defines the worldxview matrix
  53858. * @param worldViewProjection defines the worldxviewxprojection matrix
  53859. */
  53860. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53861. /**
  53862. * When connection point is an uniform, this function will send its value to the effect
  53863. * @param effect defines the effect to transmit value to
  53864. * @param scene defines the hosting scene
  53865. */
  53866. transmit(effect: Effect, scene: Scene): void;
  53867. }
  53868. }
  53869. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53870. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53871. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53873. import { Mesh } from "babylonjs/Meshes/mesh";
  53874. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53875. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53876. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53877. /**
  53878. * Block used to add support for vertex skinning (bones)
  53879. */
  53880. export class BonesBlock extends NodeMaterialBlock {
  53881. /**
  53882. * Creates a new BonesBlock
  53883. * @param name defines the block name
  53884. */
  53885. constructor(name: string);
  53886. /**
  53887. * Initialize the block and prepare the context for build
  53888. * @param state defines the state that will be used for the build
  53889. */
  53890. initialize(state: NodeMaterialBuildState): void;
  53891. /**
  53892. * Gets the current class name
  53893. * @returns the class name
  53894. */
  53895. getClassName(): string;
  53896. /**
  53897. * Gets the matrix indices input component
  53898. */
  53899. readonly matricesIndices: NodeMaterialConnectionPoint;
  53900. /**
  53901. * Gets the matrix weights input component
  53902. */
  53903. readonly matricesWeights: NodeMaterialConnectionPoint;
  53904. /**
  53905. * Gets the extra matrix indices input component
  53906. */
  53907. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53908. /**
  53909. * Gets the extra matrix weights input component
  53910. */
  53911. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53912. /**
  53913. * Gets the world input component
  53914. */
  53915. readonly world: NodeMaterialConnectionPoint;
  53916. /**
  53917. * Gets the output component
  53918. */
  53919. readonly output: NodeMaterialConnectionPoint;
  53920. autoConfigure(): void;
  53921. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53922. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53923. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53924. protected _buildBlock(state: NodeMaterialBuildState): this;
  53925. }
  53926. }
  53927. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  53928. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53929. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53930. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53932. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53933. /**
  53934. * Block used to add support for instances
  53935. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53936. */
  53937. export class InstancesBlock extends NodeMaterialBlock {
  53938. /**
  53939. * Creates a new InstancesBlock
  53940. * @param name defines the block name
  53941. */
  53942. constructor(name: string);
  53943. /**
  53944. * Gets the current class name
  53945. * @returns the class name
  53946. */
  53947. getClassName(): string;
  53948. /**
  53949. * Gets the first world row input component
  53950. */
  53951. readonly world0: NodeMaterialConnectionPoint;
  53952. /**
  53953. * Gets the second world row input component
  53954. */
  53955. readonly world1: NodeMaterialConnectionPoint;
  53956. /**
  53957. * Gets the third world row input component
  53958. */
  53959. readonly world2: NodeMaterialConnectionPoint;
  53960. /**
  53961. * Gets the forth world row input component
  53962. */
  53963. readonly world3: NodeMaterialConnectionPoint;
  53964. /**
  53965. * Gets the world input component
  53966. */
  53967. readonly world: NodeMaterialConnectionPoint;
  53968. /**
  53969. * Gets the output component
  53970. */
  53971. readonly output: NodeMaterialConnectionPoint;
  53972. autoConfigure(): void;
  53973. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53974. protected _buildBlock(state: NodeMaterialBuildState): this;
  53975. }
  53976. }
  53977. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  53978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53982. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53983. import { Effect } from "babylonjs/Materials/effect";
  53984. import { Mesh } from "babylonjs/Meshes/mesh";
  53985. /**
  53986. * Block used to add morph targets support to vertex shader
  53987. */
  53988. export class MorphTargetsBlock extends NodeMaterialBlock {
  53989. private _repeatableContentAnchor;
  53990. private _repeatebleContentGenerated;
  53991. /**
  53992. * Create a new MorphTargetsBlock
  53993. * @param name defines the block name
  53994. */
  53995. constructor(name: string);
  53996. /**
  53997. * Gets the current class name
  53998. * @returns the class name
  53999. */
  54000. getClassName(): string;
  54001. /**
  54002. * Gets the position input component
  54003. */
  54004. readonly position: NodeMaterialConnectionPoint;
  54005. /**
  54006. * Gets the normal input component
  54007. */
  54008. readonly normal: NodeMaterialConnectionPoint;
  54009. /**
  54010. * Gets the tangent input component
  54011. */
  54012. readonly tangent: NodeMaterialConnectionPoint;
  54013. /**
  54014. * Gets the tangent input component
  54015. */
  54016. readonly uv: NodeMaterialConnectionPoint;
  54017. /**
  54018. * Gets the position output component
  54019. */
  54020. readonly positionOutput: NodeMaterialConnectionPoint;
  54021. /**
  54022. * Gets the normal output component
  54023. */
  54024. readonly normalOutput: NodeMaterialConnectionPoint;
  54025. /**
  54026. * Gets the tangent output component
  54027. */
  54028. readonly tangentOutput: NodeMaterialConnectionPoint;
  54029. /**
  54030. * Gets the tangent output component
  54031. */
  54032. readonly uvOutput: NodeMaterialConnectionPoint;
  54033. initialize(state: NodeMaterialBuildState): void;
  54034. autoConfigure(): void;
  54035. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54036. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54037. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54038. protected _buildBlock(state: NodeMaterialBuildState): this;
  54039. }
  54040. }
  54041. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54042. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54043. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54044. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54045. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54046. }
  54047. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54048. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54049. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54050. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54051. /**
  54052. * Block used to add an alpha test in the fragment shader
  54053. */
  54054. export class AlphaTestBlock extends NodeMaterialBlock {
  54055. /**
  54056. * Gets or sets the alpha value where alpha testing happens
  54057. */
  54058. alphaCutOff: number;
  54059. /**
  54060. * Create a new AlphaTestBlock
  54061. * @param name defines the block name
  54062. */
  54063. constructor(name: string);
  54064. /**
  54065. * Gets the current class name
  54066. * @returns the class name
  54067. */
  54068. getClassName(): string;
  54069. /**
  54070. * Gets the color input component
  54071. */
  54072. readonly color: NodeMaterialConnectionPoint;
  54073. protected _buildBlock(state: NodeMaterialBuildState): this;
  54074. }
  54075. }
  54076. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  54077. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54078. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54079. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54080. /**
  54081. * Block used to create a Color4 out of 4 inputs (one for each component)
  54082. */
  54083. export class RGBAMergerBlock extends NodeMaterialBlock {
  54084. /**
  54085. * Create a new RGBAMergerBlock
  54086. * @param name defines the block name
  54087. */
  54088. constructor(name: string);
  54089. /**
  54090. * Gets the current class name
  54091. * @returns the class name
  54092. */
  54093. getClassName(): string;
  54094. /**
  54095. * Gets the R input component
  54096. */
  54097. readonly r: NodeMaterialConnectionPoint;
  54098. /**
  54099. * Gets the G input component
  54100. */
  54101. readonly g: NodeMaterialConnectionPoint;
  54102. /**
  54103. * Gets the B input component
  54104. */
  54105. readonly b: NodeMaterialConnectionPoint;
  54106. /**
  54107. * Gets the RGB input component
  54108. */
  54109. readonly rgb: NodeMaterialConnectionPoint;
  54110. /**
  54111. * Gets the R input component
  54112. */
  54113. readonly a: NodeMaterialConnectionPoint;
  54114. /**
  54115. * Gets the output component
  54116. */
  54117. readonly output: NodeMaterialConnectionPoint;
  54118. protected _buildBlock(state: NodeMaterialBuildState): this;
  54119. }
  54120. }
  54121. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  54122. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54123. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54124. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54125. /**
  54126. * Block used to create a Color3 out of 3 inputs (one for each component)
  54127. */
  54128. export class RGBMergerBlock extends NodeMaterialBlock {
  54129. /**
  54130. * Create a new RGBMergerBlock
  54131. * @param name defines the block name
  54132. */
  54133. constructor(name: string);
  54134. /**
  54135. * Gets the current class name
  54136. * @returns the class name
  54137. */
  54138. getClassName(): string;
  54139. /**
  54140. * Gets the R component input
  54141. */
  54142. readonly r: NodeMaterialConnectionPoint;
  54143. /**
  54144. * Gets the G component input
  54145. */
  54146. readonly g: NodeMaterialConnectionPoint;
  54147. /**
  54148. * Gets the B component input
  54149. */
  54150. readonly b: NodeMaterialConnectionPoint;
  54151. /**
  54152. * Gets the output component
  54153. */
  54154. readonly output: NodeMaterialConnectionPoint;
  54155. protected _buildBlock(state: NodeMaterialBuildState): this;
  54156. }
  54157. }
  54158. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  54159. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54160. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54161. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54162. /**
  54163. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  54164. */
  54165. export class RGBASplitterBlock extends NodeMaterialBlock {
  54166. /**
  54167. * Create a new RGBASplitterBlock
  54168. * @param name defines the block name
  54169. */
  54170. constructor(name: string);
  54171. /**
  54172. * Gets the current class name
  54173. * @returns the class name
  54174. */
  54175. getClassName(): string;
  54176. /**
  54177. * Gets the input component
  54178. */
  54179. readonly input: NodeMaterialConnectionPoint;
  54180. protected _buildBlock(state: NodeMaterialBuildState): this;
  54181. }
  54182. }
  54183. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  54184. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54185. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54187. /**
  54188. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  54189. */
  54190. export class RGBSplitterBlock extends NodeMaterialBlock {
  54191. /**
  54192. * Create a new RGBSplitterBlock
  54193. * @param name defines the block name
  54194. */
  54195. constructor(name: string);
  54196. /**
  54197. * Gets the current class name
  54198. * @returns the class name
  54199. */
  54200. getClassName(): string;
  54201. /**
  54202. * Gets the input component
  54203. */
  54204. readonly input: NodeMaterialConnectionPoint;
  54205. protected _buildBlock(state: NodeMaterialBuildState): this;
  54206. }
  54207. }
  54208. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  54209. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54210. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54211. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54213. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54214. /**
  54215. * Block used to read a texture from a sampler
  54216. */
  54217. export class TextureBlock extends NodeMaterialBlock {
  54218. private _defineName;
  54219. /**
  54220. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  54221. */
  54222. autoConnectTextureMatrix: boolean;
  54223. /**
  54224. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  54225. */
  54226. autoSelectUV: boolean;
  54227. /**
  54228. * Create a new TextureBlock
  54229. * @param name defines the block name
  54230. */
  54231. constructor(name: string);
  54232. /**
  54233. * Gets the current class name
  54234. * @returns the class name
  54235. */
  54236. getClassName(): string;
  54237. /**
  54238. * Gets the uv input component
  54239. */
  54240. readonly uv: NodeMaterialConnectionPoint;
  54241. /**
  54242. * Gets the texture information input component
  54243. */
  54244. readonly textureInfo: NodeMaterialConnectionPoint;
  54245. /**
  54246. * Gets the transformed uv input component
  54247. */
  54248. readonly transformedUV: NodeMaterialConnectionPoint;
  54249. /**
  54250. * Gets the texture input component
  54251. */
  54252. readonly texture: NodeMaterialConnectionPoint;
  54253. /**
  54254. * Gets the texture transform input component
  54255. */
  54256. readonly textureTransform: NodeMaterialConnectionPoint;
  54257. /**
  54258. * Gets the output component
  54259. */
  54260. readonly output: NodeMaterialConnectionPoint;
  54261. autoConfigure(): void;
  54262. initialize(state: NodeMaterialBuildState): void;
  54263. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54264. isReady(): boolean;
  54265. private _injectVertexCode;
  54266. protected _buildBlock(state: NodeMaterialBuildState): this;
  54267. }
  54268. }
  54269. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  54270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54271. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54272. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54274. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54275. import { Effect } from "babylonjs/Materials/effect";
  54276. import { Mesh } from "babylonjs/Meshes/mesh";
  54277. /**
  54278. * Block used to add image processing support to fragment shader
  54279. */
  54280. export class ImageProcessingBlock extends NodeMaterialBlock {
  54281. /**
  54282. * Create a new ImageProcessingBlock
  54283. * @param name defines the block name
  54284. */
  54285. constructor(name: string);
  54286. /**
  54287. * Gets the current class name
  54288. * @returns the class name
  54289. */
  54290. getClassName(): string;
  54291. /**
  54292. * Gets the color input component
  54293. */
  54294. readonly color: NodeMaterialConnectionPoint;
  54295. /**
  54296. * Gets the output component
  54297. */
  54298. readonly output: NodeMaterialConnectionPoint;
  54299. /**
  54300. * Initialize the block and prepare the context for build
  54301. * @param state defines the state that will be used for the build
  54302. */
  54303. initialize(state: NodeMaterialBuildState): void;
  54304. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54305. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54306. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54307. protected _buildBlock(state: NodeMaterialBuildState): this;
  54308. }
  54309. }
  54310. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  54311. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  54312. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  54313. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  54314. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  54315. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  54316. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  54317. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  54318. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  54319. }
  54320. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  54321. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54323. import { Mesh } from "babylonjs/Meshes/mesh";
  54324. import { Effect } from "babylonjs/Materials/effect";
  54325. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54327. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54328. /**
  54329. * Block used to add support for scene fog
  54330. */
  54331. export class FogBlock extends NodeMaterialBlock {
  54332. /**
  54333. * Create a new FogBlock
  54334. * @param name defines the block name
  54335. */
  54336. constructor(name: string);
  54337. /**
  54338. * Gets the current class name
  54339. * @returns the class name
  54340. */
  54341. getClassName(): string;
  54342. /**
  54343. * Gets the world position input component
  54344. */
  54345. readonly worldPosition: NodeMaterialConnectionPoint;
  54346. /**
  54347. * Gets the view input component
  54348. */
  54349. readonly view: NodeMaterialConnectionPoint;
  54350. /**
  54351. * Gets the color input component
  54352. */
  54353. readonly color: NodeMaterialConnectionPoint;
  54354. /**
  54355. * Gets the fog color input component
  54356. */
  54357. readonly fogColor: NodeMaterialConnectionPoint;
  54358. /**
  54359. * Gets the for parameter input component
  54360. */
  54361. readonly fogParameters: NodeMaterialConnectionPoint;
  54362. /**
  54363. * Gets the output component
  54364. */
  54365. readonly output: NodeMaterialConnectionPoint;
  54366. autoConfigure(): void;
  54367. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54368. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54369. protected _buildBlock(state: NodeMaterialBuildState): this;
  54370. }
  54371. }
  54372. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  54373. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54374. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54375. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54377. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54378. import { Effect } from "babylonjs/Materials/effect";
  54379. import { Mesh } from "babylonjs/Meshes/mesh";
  54380. /**
  54381. * Block used to add light in the fragment shader
  54382. */
  54383. export class LightBlock extends NodeMaterialBlock {
  54384. private _lightId;
  54385. /**
  54386. * Create a new LightBlock
  54387. * @param name defines the block name
  54388. */
  54389. constructor(name: string);
  54390. /**
  54391. * Gets the current class name
  54392. * @returns the class name
  54393. */
  54394. getClassName(): string;
  54395. /**
  54396. * Gets the world position input component
  54397. */
  54398. readonly worldPosition: NodeMaterialConnectionPoint;
  54399. /**
  54400. * Gets the world normal input component
  54401. */
  54402. readonly worldNormal: NodeMaterialConnectionPoint;
  54403. /**
  54404. * Gets the light input component
  54405. */
  54406. readonly light: NodeMaterialConnectionPoint;
  54407. /**
  54408. * Gets the camera (or eye) position component
  54409. */
  54410. readonly cameraPosition: NodeMaterialConnectionPoint;
  54411. /**
  54412. * Gets the diffuse output component
  54413. */
  54414. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54415. /**
  54416. * Gets the specular output component
  54417. */
  54418. readonly specularOutput: NodeMaterialConnectionPoint;
  54419. autoConfigure(): void;
  54420. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54421. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54422. private _injectVertexCode;
  54423. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54424. }
  54425. }
  54426. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  54427. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  54428. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  54429. }
  54430. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  54431. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54432. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54433. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54434. /**
  54435. * Block used to multiply 2 vector4
  54436. */
  54437. export class MultiplyBlock extends NodeMaterialBlock {
  54438. /**
  54439. * Creates a new MultiplyBlock
  54440. * @param name defines the block name
  54441. */
  54442. constructor(name: string);
  54443. /**
  54444. * Gets the current class name
  54445. * @returns the class name
  54446. */
  54447. getClassName(): string;
  54448. /**
  54449. * Gets the left operand input component
  54450. */
  54451. readonly left: NodeMaterialConnectionPoint;
  54452. /**
  54453. * Gets the right operand input component
  54454. */
  54455. readonly right: NodeMaterialConnectionPoint;
  54456. /**
  54457. * Gets the output component
  54458. */
  54459. readonly output: NodeMaterialConnectionPoint;
  54460. protected _buildBlock(state: NodeMaterialBuildState): this;
  54461. }
  54462. }
  54463. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  54464. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54465. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54466. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54467. /**
  54468. * Block used to add 2 vector4
  54469. */
  54470. export class AddBlock extends NodeMaterialBlock {
  54471. /**
  54472. * Creates a new AddBlock
  54473. * @param name defines the block name
  54474. */
  54475. constructor(name: string);
  54476. /**
  54477. * Gets the current class name
  54478. * @returns the class name
  54479. */
  54480. getClassName(): string;
  54481. /**
  54482. * Gets the left operand input component
  54483. */
  54484. readonly left: NodeMaterialConnectionPoint;
  54485. /**
  54486. * Gets the right operand input component
  54487. */
  54488. readonly right: NodeMaterialConnectionPoint;
  54489. /**
  54490. * Gets the output component
  54491. */
  54492. readonly output: NodeMaterialConnectionPoint;
  54493. protected _buildBlock(state: NodeMaterialBuildState): this;
  54494. }
  54495. }
  54496. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  54497. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54498. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54499. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54500. /**
  54501. * Block used to clamp a float
  54502. */
  54503. export class ClampBlock extends NodeMaterialBlock {
  54504. /** Gets or sets the minimum range */
  54505. minimum: number;
  54506. /** Gets or sets the maximum range */
  54507. maximum: number;
  54508. /**
  54509. * Creates a new ClampBlock
  54510. * @param name defines the block name
  54511. */
  54512. constructor(name: string);
  54513. /**
  54514. * Gets the current class name
  54515. * @returns the class name
  54516. */
  54517. getClassName(): string;
  54518. /**
  54519. * Gets the value input component
  54520. */
  54521. readonly value: NodeMaterialConnectionPoint;
  54522. /**
  54523. * Gets the output component
  54524. */
  54525. readonly output: NodeMaterialConnectionPoint;
  54526. protected _buildBlock(state: NodeMaterialBuildState): this;
  54527. }
  54528. }
  54529. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  54530. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54531. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54532. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54533. /**
  54534. * Block used to scale a value
  54535. */
  54536. export class ScaleBlock extends NodeMaterialBlock {
  54537. /**
  54538. * Creates a new ScaleBlock
  54539. * @param name defines the block name
  54540. */
  54541. constructor(name: string);
  54542. /**
  54543. * Gets the current class name
  54544. * @returns the class name
  54545. */
  54546. getClassName(): string;
  54547. /**
  54548. * Gets the value operand input component
  54549. */
  54550. readonly value: NodeMaterialConnectionPoint;
  54551. /**
  54552. * Gets the scale operand input component
  54553. */
  54554. readonly scale: NodeMaterialConnectionPoint;
  54555. /**
  54556. * Gets the output component
  54557. */
  54558. readonly output: NodeMaterialConnectionPoint;
  54559. protected _buildBlock(state: NodeMaterialBuildState): this;
  54560. }
  54561. }
  54562. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  54563. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54564. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54565. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54566. /**
  54567. * Block used to transform a vector2 with a matrix
  54568. */
  54569. export class Vector2TransformBlock extends NodeMaterialBlock {
  54570. /**
  54571. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54572. */
  54573. complementZ: number;
  54574. /**
  54575. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54576. */
  54577. complementW: number;
  54578. /**
  54579. * Creates a new Vector2TransformBlock
  54580. * @param name defines the block name
  54581. */
  54582. constructor(name: string);
  54583. /**
  54584. * Gets the vector input
  54585. */
  54586. readonly vector: NodeMaterialConnectionPoint;
  54587. /**
  54588. * Gets the matrix transform input
  54589. */
  54590. readonly transform: NodeMaterialConnectionPoint;
  54591. /**
  54592. * Gets the output component
  54593. */
  54594. readonly output: NodeMaterialConnectionPoint;
  54595. /**
  54596. * Gets the current class name
  54597. * @returns the class name
  54598. */
  54599. getClassName(): string;
  54600. protected _buildBlock(state: NodeMaterialBuildState): this;
  54601. }
  54602. }
  54603. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54604. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54605. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54606. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54607. /**
  54608. * Block used to transform a vector3 with a matrix
  54609. */
  54610. export class Vector3TransformBlock extends NodeMaterialBlock {
  54611. /**
  54612. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54613. */
  54614. complement: number;
  54615. /**
  54616. * Creates a new Vector3TransformBlock
  54617. * @param name defines the block name
  54618. */
  54619. constructor(name: string);
  54620. /**
  54621. * Gets the vector input
  54622. */
  54623. readonly vector: NodeMaterialConnectionPoint;
  54624. /**
  54625. * Gets the matrix transform input
  54626. */
  54627. readonly transform: NodeMaterialConnectionPoint;
  54628. /**
  54629. * Gets the output component
  54630. */
  54631. readonly output: NodeMaterialConnectionPoint;
  54632. /**
  54633. * Gets the current class name
  54634. * @returns the class name
  54635. */
  54636. getClassName(): string;
  54637. protected _buildBlock(state: NodeMaterialBuildState): this;
  54638. }
  54639. }
  54640. declare module "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock" {
  54641. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54642. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54643. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54644. /**
  54645. * Block used to multiply two matrices
  54646. */
  54647. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  54648. /**
  54649. * Creates a new MatrixMultiplicationBlock
  54650. * @param name defines the block name
  54651. */
  54652. constructor(name: string);
  54653. /**
  54654. * Gets the left operand
  54655. */
  54656. readonly left: NodeMaterialConnectionPoint;
  54657. /**
  54658. * Gets the right operand
  54659. */
  54660. readonly right: NodeMaterialConnectionPoint;
  54661. /**
  54662. * Gets the output component
  54663. */
  54664. readonly output: NodeMaterialConnectionPoint;
  54665. /**
  54666. * Gets the current class name
  54667. * @returns the class name
  54668. */
  54669. getClassName(): string;
  54670. protected _buildBlock(state: NodeMaterialBuildState): this;
  54671. }
  54672. }
  54673. declare module "babylonjs/Materials/Node/Blocks/index" {
  54674. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  54675. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  54676. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  54677. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  54678. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  54679. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  54680. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  54681. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  54682. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54683. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54684. export * from "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock";
  54685. }
  54686. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54687. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54688. }
  54689. declare module "babylonjs/Materials/Node/index" {
  54690. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54691. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54692. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54693. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54694. export * from "babylonjs/Materials/Node/nodeMaterial";
  54695. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54696. export * from "babylonjs/Materials/Node/Blocks/index";
  54697. export * from "babylonjs/Materials/Node/Optimizers/index";
  54698. }
  54699. declare module "babylonjs/Materials/index" {
  54700. export * from "babylonjs/Materials/Background/index";
  54701. export * from "babylonjs/Materials/colorCurves";
  54702. export * from "babylonjs/Materials/effect";
  54703. export * from "babylonjs/Materials/fresnelParameters";
  54704. export * from "babylonjs/Materials/imageProcessingConfiguration";
  54705. export * from "babylonjs/Materials/material";
  54706. export * from "babylonjs/Materials/materialDefines";
  54707. export * from "babylonjs/Materials/materialHelper";
  54708. export * from "babylonjs/Materials/multiMaterial";
  54709. export * from "babylonjs/Materials/PBR/index";
  54710. export * from "babylonjs/Materials/pushMaterial";
  54711. export * from "babylonjs/Materials/shaderMaterial";
  54712. export * from "babylonjs/Materials/standardMaterial";
  54713. export * from "babylonjs/Materials/Textures/index";
  54714. export * from "babylonjs/Materials/uniformBuffer";
  54715. export * from "babylonjs/Materials/materialFlags";
  54716. export * from "babylonjs/Materials/Node/index";
  54717. }
  54718. declare module "babylonjs/Maths/index" {
  54719. export * from "babylonjs/Maths/math.scalar";
  54720. export * from "babylonjs/Maths/math";
  54721. export * from "babylonjs/Maths/sphericalPolynomial";
  54722. }
  54723. declare module "babylonjs/Misc/workerPool" {
  54724. import { IDisposable } from "babylonjs/scene";
  54725. /**
  54726. * Helper class to push actions to a pool of workers.
  54727. */
  54728. export class WorkerPool implements IDisposable {
  54729. private _workerInfos;
  54730. private _pendingActions;
  54731. /**
  54732. * Constructor
  54733. * @param workers Array of workers to use for actions
  54734. */
  54735. constructor(workers: Array<Worker>);
  54736. /**
  54737. * Terminates all workers and clears any pending actions.
  54738. */
  54739. dispose(): void;
  54740. /**
  54741. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54742. * pended until a worker has completed its action.
  54743. * @param action The action to perform. Call onComplete when the action is complete.
  54744. */
  54745. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54746. private _execute;
  54747. }
  54748. }
  54749. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  54750. import { IDisposable } from "babylonjs/scene";
  54751. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54752. /**
  54753. * Configuration for Draco compression
  54754. */
  54755. export interface IDracoCompressionConfiguration {
  54756. /**
  54757. * Configuration for the decoder.
  54758. */
  54759. decoder: {
  54760. /**
  54761. * The url to the WebAssembly module.
  54762. */
  54763. wasmUrl?: string;
  54764. /**
  54765. * The url to the WebAssembly binary.
  54766. */
  54767. wasmBinaryUrl?: string;
  54768. /**
  54769. * The url to the fallback JavaScript module.
  54770. */
  54771. fallbackUrl?: string;
  54772. };
  54773. }
  54774. /**
  54775. * Draco compression (https://google.github.io/draco/)
  54776. *
  54777. * This class wraps the Draco module.
  54778. *
  54779. * **Encoder**
  54780. *
  54781. * The encoder is not currently implemented.
  54782. *
  54783. * **Decoder**
  54784. *
  54785. * 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.
  54786. *
  54787. * To update the configuration, use the following code:
  54788. * ```javascript
  54789. * DracoCompression.Configuration = {
  54790. * decoder: {
  54791. * wasmUrl: "<url to the WebAssembly library>",
  54792. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54793. * fallbackUrl: "<url to the fallback JavaScript library>",
  54794. * }
  54795. * };
  54796. * ```
  54797. *
  54798. * 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.
  54799. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54800. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54801. *
  54802. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54803. * ```javascript
  54804. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54805. * ```
  54806. *
  54807. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54808. */
  54809. export class DracoCompression implements IDisposable {
  54810. private _workerPoolPromise?;
  54811. private _decoderModulePromise?;
  54812. /**
  54813. * The configuration. Defaults to the following urls:
  54814. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54815. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54816. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54817. */
  54818. static Configuration: IDracoCompressionConfiguration;
  54819. /**
  54820. * Returns true if the decoder configuration is available.
  54821. */
  54822. static readonly DecoderAvailable: boolean;
  54823. /**
  54824. * Default number of workers to create when creating the draco compression object.
  54825. */
  54826. static DefaultNumWorkers: number;
  54827. private static GetDefaultNumWorkers;
  54828. private static _Default;
  54829. /**
  54830. * Default instance for the draco compression object.
  54831. */
  54832. static readonly Default: DracoCompression;
  54833. /**
  54834. * Constructor
  54835. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54836. */
  54837. constructor(numWorkers?: number);
  54838. /**
  54839. * Stop all async operations and release resources.
  54840. */
  54841. dispose(): void;
  54842. /**
  54843. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54844. * @returns a promise that resolves when ready
  54845. */
  54846. whenReadyAsync(): Promise<void>;
  54847. /**
  54848. * Decode Draco compressed mesh data to vertex data.
  54849. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54850. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54851. * @returns A promise that resolves with the decoded vertex data
  54852. */
  54853. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54854. [kind: string]: number;
  54855. }): Promise<VertexData>;
  54856. }
  54857. }
  54858. declare module "babylonjs/Meshes/Compression/index" {
  54859. export * from "babylonjs/Meshes/Compression/dracoCompression";
  54860. }
  54861. declare module "babylonjs/Meshes/csg" {
  54862. import { Nullable } from "babylonjs/types";
  54863. import { Scene } from "babylonjs/scene";
  54864. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  54865. import { Mesh } from "babylonjs/Meshes/mesh";
  54866. import { Material } from "babylonjs/Materials/material";
  54867. /**
  54868. * Class for building Constructive Solid Geometry
  54869. */
  54870. export class CSG {
  54871. private polygons;
  54872. /**
  54873. * The world matrix
  54874. */
  54875. matrix: Matrix;
  54876. /**
  54877. * Stores the position
  54878. */
  54879. position: Vector3;
  54880. /**
  54881. * Stores the rotation
  54882. */
  54883. rotation: Vector3;
  54884. /**
  54885. * Stores the rotation quaternion
  54886. */
  54887. rotationQuaternion: Nullable<Quaternion>;
  54888. /**
  54889. * Stores the scaling vector
  54890. */
  54891. scaling: Vector3;
  54892. /**
  54893. * Convert the Mesh to CSG
  54894. * @param mesh The Mesh to convert to CSG
  54895. * @returns A new CSG from the Mesh
  54896. */
  54897. static FromMesh(mesh: Mesh): CSG;
  54898. /**
  54899. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54900. * @param polygons Polygons used to construct a CSG solid
  54901. */
  54902. private static FromPolygons;
  54903. /**
  54904. * Clones, or makes a deep copy, of the CSG
  54905. * @returns A new CSG
  54906. */
  54907. clone(): CSG;
  54908. /**
  54909. * Unions this CSG with another CSG
  54910. * @param csg The CSG to union against this CSG
  54911. * @returns The unioned CSG
  54912. */
  54913. union(csg: CSG): CSG;
  54914. /**
  54915. * Unions this CSG with another CSG in place
  54916. * @param csg The CSG to union against this CSG
  54917. */
  54918. unionInPlace(csg: CSG): void;
  54919. /**
  54920. * Subtracts this CSG with another CSG
  54921. * @param csg The CSG to subtract against this CSG
  54922. * @returns A new CSG
  54923. */
  54924. subtract(csg: CSG): CSG;
  54925. /**
  54926. * Subtracts this CSG with another CSG in place
  54927. * @param csg The CSG to subtact against this CSG
  54928. */
  54929. subtractInPlace(csg: CSG): void;
  54930. /**
  54931. * Intersect this CSG with another CSG
  54932. * @param csg The CSG to intersect against this CSG
  54933. * @returns A new CSG
  54934. */
  54935. intersect(csg: CSG): CSG;
  54936. /**
  54937. * Intersects this CSG with another CSG in place
  54938. * @param csg The CSG to intersect against this CSG
  54939. */
  54940. intersectInPlace(csg: CSG): void;
  54941. /**
  54942. * Return a new CSG solid with solid and empty space switched. This solid is
  54943. * not modified.
  54944. * @returns A new CSG solid with solid and empty space switched
  54945. */
  54946. inverse(): CSG;
  54947. /**
  54948. * Inverses the CSG in place
  54949. */
  54950. inverseInPlace(): void;
  54951. /**
  54952. * This is used to keep meshes transformations so they can be restored
  54953. * when we build back a Babylon Mesh
  54954. * NB : All CSG operations are performed in world coordinates
  54955. * @param csg The CSG to copy the transform attributes from
  54956. * @returns This CSG
  54957. */
  54958. copyTransformAttributes(csg: CSG): CSG;
  54959. /**
  54960. * Build Raw mesh from CSG
  54961. * Coordinates here are in world space
  54962. * @param name The name of the mesh geometry
  54963. * @param scene The Scene
  54964. * @param keepSubMeshes Specifies if the submeshes should be kept
  54965. * @returns A new Mesh
  54966. */
  54967. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  54968. /**
  54969. * Build Mesh from CSG taking material and transforms into account
  54970. * @param name The name of the Mesh
  54971. * @param material The material of the Mesh
  54972. * @param scene The Scene
  54973. * @param keepSubMeshes Specifies if submeshes should be kept
  54974. * @returns The new Mesh
  54975. */
  54976. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  54977. }
  54978. }
  54979. declare module "babylonjs/Meshes/trailMesh" {
  54980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54981. import { Mesh } from "babylonjs/Meshes/mesh";
  54982. import { Scene } from "babylonjs/scene";
  54983. /**
  54984. * Class used to create a trail following a mesh
  54985. */
  54986. export class TrailMesh extends Mesh {
  54987. private _generator;
  54988. private _autoStart;
  54989. private _running;
  54990. private _diameter;
  54991. private _length;
  54992. private _sectionPolygonPointsCount;
  54993. private _sectionVectors;
  54994. private _sectionNormalVectors;
  54995. private _beforeRenderObserver;
  54996. /**
  54997. * @constructor
  54998. * @param name The value used by scene.getMeshByName() to do a lookup.
  54999. * @param generator The mesh to generate a trail.
  55000. * @param scene The scene to add this mesh to.
  55001. * @param diameter Diameter of trailing mesh. Default is 1.
  55002. * @param length Length of trailing mesh. Default is 60.
  55003. * @param autoStart Automatically start trailing mesh. Default true.
  55004. */
  55005. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55006. /**
  55007. * "TrailMesh"
  55008. * @returns "TrailMesh"
  55009. */
  55010. getClassName(): string;
  55011. private _createMesh;
  55012. /**
  55013. * Start trailing mesh.
  55014. */
  55015. start(): void;
  55016. /**
  55017. * Stop trailing mesh.
  55018. */
  55019. stop(): void;
  55020. /**
  55021. * Update trailing mesh geometry.
  55022. */
  55023. update(): void;
  55024. /**
  55025. * Returns a new TrailMesh object.
  55026. * @param name is a string, the name given to the new mesh
  55027. * @param newGenerator use new generator object for cloned trail mesh
  55028. * @returns a new mesh
  55029. */
  55030. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55031. /**
  55032. * Serializes this trail mesh
  55033. * @param serializationObject object to write serialization to
  55034. */
  55035. serialize(serializationObject: any): void;
  55036. /**
  55037. * Parses a serialized trail mesh
  55038. * @param parsedMesh the serialized mesh
  55039. * @param scene the scene to create the trail mesh in
  55040. * @returns the created trail mesh
  55041. */
  55042. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55043. }
  55044. }
  55045. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  55046. import { Nullable } from "babylonjs/types";
  55047. import { Scene } from "babylonjs/scene";
  55048. import { Vector4, Color4 } from "babylonjs/Maths/math";
  55049. import { Mesh } from "babylonjs/Meshes/mesh";
  55050. /**
  55051. * Class containing static functions to help procedurally build meshes
  55052. */
  55053. export class TiledBoxBuilder {
  55054. /**
  55055. * Creates a box mesh
  55056. * faceTiles sets the pattern, tile size and number of tiles for a face * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  55057. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55059. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55061. * @param name defines the name of the mesh
  55062. * @param options defines the options used to create the mesh
  55063. * @param scene defines the hosting scene
  55064. * @returns the box mesh
  55065. */
  55066. static CreateTiledBox(name: string, options: {
  55067. pattern?: number;
  55068. width?: number;
  55069. height?: number;
  55070. depth?: number;
  55071. tileSize?: number;
  55072. tileWidth?: number;
  55073. tileHeight?: number;
  55074. alignHorizontal?: number;
  55075. alignVertical?: number;
  55076. faceUV?: Vector4[];
  55077. faceColors?: Color4[];
  55078. sideOrientation?: number;
  55079. updatable?: boolean;
  55080. }, scene?: Nullable<Scene>): Mesh;
  55081. }
  55082. }
  55083. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  55084. import { Vector4 } from "babylonjs/Maths/math";
  55085. import { Mesh } from "babylonjs/Meshes/mesh";
  55086. /**
  55087. * Class containing static functions to help procedurally build meshes
  55088. */
  55089. export class TorusKnotBuilder {
  55090. /**
  55091. * Creates a torus knot mesh
  55092. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55093. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55094. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55095. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55099. * @param name defines the name of the mesh
  55100. * @param options defines the options used to create the mesh
  55101. * @param scene defines the hosting scene
  55102. * @returns the torus knot mesh
  55103. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55104. */
  55105. static CreateTorusKnot(name: string, options: {
  55106. radius?: number;
  55107. tube?: number;
  55108. radialSegments?: number;
  55109. tubularSegments?: number;
  55110. p?: number;
  55111. q?: number;
  55112. updatable?: boolean;
  55113. sideOrientation?: number;
  55114. frontUVs?: Vector4;
  55115. backUVs?: Vector4;
  55116. }, scene: any): Mesh;
  55117. }
  55118. }
  55119. declare module "babylonjs/Meshes/polygonMesh" {
  55120. import { Scene } from "babylonjs/scene";
  55121. import { Vector2, Path2 } from "babylonjs/Maths/math";
  55122. import { Mesh } from "babylonjs/Meshes/mesh";
  55123. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55124. /**
  55125. * Polygon
  55126. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55127. */
  55128. export class Polygon {
  55129. /**
  55130. * Creates a rectangle
  55131. * @param xmin bottom X coord
  55132. * @param ymin bottom Y coord
  55133. * @param xmax top X coord
  55134. * @param ymax top Y coord
  55135. * @returns points that make the resulting rectation
  55136. */
  55137. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55138. /**
  55139. * Creates a circle
  55140. * @param radius radius of circle
  55141. * @param cx scale in x
  55142. * @param cy scale in y
  55143. * @param numberOfSides number of sides that make up the circle
  55144. * @returns points that make the resulting circle
  55145. */
  55146. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55147. /**
  55148. * Creates a polygon from input string
  55149. * @param input Input polygon data
  55150. * @returns the parsed points
  55151. */
  55152. static Parse(input: string): Vector2[];
  55153. /**
  55154. * Starts building a polygon from x and y coordinates
  55155. * @param x x coordinate
  55156. * @param y y coordinate
  55157. * @returns the started path2
  55158. */
  55159. static StartingAt(x: number, y: number): Path2;
  55160. }
  55161. /**
  55162. * Builds a polygon
  55163. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55164. */
  55165. export class PolygonMeshBuilder {
  55166. private _points;
  55167. private _outlinepoints;
  55168. private _holes;
  55169. private _name;
  55170. private _scene;
  55171. private _epoints;
  55172. private _eholes;
  55173. private _addToepoint;
  55174. /**
  55175. * Babylon reference to the earcut plugin.
  55176. */
  55177. bjsEarcut: any;
  55178. /**
  55179. * Creates a PolygonMeshBuilder
  55180. * @param name name of the builder
  55181. * @param contours Path of the polygon
  55182. * @param scene scene to add to when creating the mesh
  55183. * @param earcutInjection can be used to inject your own earcut reference
  55184. */
  55185. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55186. /**
  55187. * Adds a whole within the polygon
  55188. * @param hole Array of points defining the hole
  55189. * @returns this
  55190. */
  55191. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55192. /**
  55193. * Creates the polygon
  55194. * @param updatable If the mesh should be updatable
  55195. * @param depth The depth of the mesh created
  55196. * @returns the created mesh
  55197. */
  55198. build(updatable?: boolean, depth?: number): Mesh;
  55199. /**
  55200. * Creates the polygon
  55201. * @param depth The depth of the mesh created
  55202. * @returns the created VertexData
  55203. */
  55204. buildVertexData(depth?: number): VertexData;
  55205. /**
  55206. * Adds a side to the polygon
  55207. * @param positions points that make the polygon
  55208. * @param normals normals of the polygon
  55209. * @param uvs uvs of the polygon
  55210. * @param indices indices of the polygon
  55211. * @param bounds bounds of the polygon
  55212. * @param points points of the polygon
  55213. * @param depth depth of the polygon
  55214. * @param flip flip of the polygon
  55215. */
  55216. private addSide;
  55217. }
  55218. }
  55219. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  55220. import { Scene } from "babylonjs/scene";
  55221. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  55222. import { Mesh } from "babylonjs/Meshes/mesh";
  55223. import { Nullable } from "babylonjs/types";
  55224. /**
  55225. * Class containing static functions to help procedurally build meshes
  55226. */
  55227. export class PolygonBuilder {
  55228. /**
  55229. * Creates a polygon mesh
  55230. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55231. * * 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
  55232. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55235. * * Remember you can only change the shape positions, not their number when updating a polygon
  55236. * @param name defines the name of the mesh
  55237. * @param options defines the options used to create the mesh
  55238. * @param scene defines the hosting scene
  55239. * @param earcutInjection can be used to inject your own earcut reference
  55240. * @returns the polygon mesh
  55241. */
  55242. static CreatePolygon(name: string, options: {
  55243. shape: Vector3[];
  55244. holes?: Vector3[][];
  55245. depth?: number;
  55246. faceUV?: Vector4[];
  55247. faceColors?: Color4[];
  55248. updatable?: boolean;
  55249. sideOrientation?: number;
  55250. frontUVs?: Vector4;
  55251. backUVs?: Vector4;
  55252. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55253. /**
  55254. * Creates an extruded polygon mesh, with depth in the Y direction.
  55255. * * 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)
  55256. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55257. * @param name defines the name of the mesh
  55258. * @param options defines the options used to create the mesh
  55259. * @param scene defines the hosting scene
  55260. * @param earcutInjection can be used to inject your own earcut reference
  55261. * @returns the polygon mesh
  55262. */
  55263. static ExtrudePolygon(name: string, options: {
  55264. shape: Vector3[];
  55265. holes?: Vector3[][];
  55266. depth?: number;
  55267. faceUV?: Vector4[];
  55268. faceColors?: Color4[];
  55269. updatable?: boolean;
  55270. sideOrientation?: number;
  55271. frontUVs?: Vector4;
  55272. backUVs?: Vector4;
  55273. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55274. }
  55275. }
  55276. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  55277. import { Scene } from "babylonjs/scene";
  55278. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55279. import { Mesh } from "babylonjs/Meshes/mesh";
  55280. import { Nullable } from "babylonjs/types";
  55281. /**
  55282. * Class containing static functions to help procedurally build meshes
  55283. */
  55284. export class LatheBuilder {
  55285. /**
  55286. * Creates lathe mesh.
  55287. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55288. * * 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
  55289. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55290. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55291. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55292. * * 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
  55293. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55294. * * 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
  55295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55297. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55299. * @param name defines the name of the mesh
  55300. * @param options defines the options used to create the mesh
  55301. * @param scene defines the hosting scene
  55302. * @returns the lathe mesh
  55303. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55304. */
  55305. static CreateLathe(name: string, options: {
  55306. shape: Vector3[];
  55307. radius?: number;
  55308. tessellation?: number;
  55309. clip?: number;
  55310. arc?: number;
  55311. closed?: boolean;
  55312. updatable?: boolean;
  55313. sideOrientation?: number;
  55314. frontUVs?: Vector4;
  55315. backUVs?: Vector4;
  55316. cap?: number;
  55317. invertUV?: boolean;
  55318. }, scene?: Nullable<Scene>): Mesh;
  55319. }
  55320. }
  55321. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  55322. import { Nullable } from "babylonjs/types";
  55323. import { Scene } from "babylonjs/scene";
  55324. import { Vector4 } from "babylonjs/Maths/math";
  55325. import { Mesh } from "babylonjs/Meshes/mesh";
  55326. /**
  55327. * Class containing static functions to help procedurally build meshes
  55328. */
  55329. export class TiledPlaneBuilder {
  55330. /**
  55331. * Creates a tiled plane mesh
  55332. * * The parameter `pattern` will, depending on value, do nothing or
  55333. * * * flip (reflect about central vertical) alternate tiles across and up
  55334. * * * flip every tile on alternate rows
  55335. * * * rotate (180 degs) alternate tiles across and up
  55336. * * * rotate every tile on alternate rows
  55337. * * * flip and rotate alternate tiles across and up
  55338. * * * flip and rotate every tile on alternate rows
  55339. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55340. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55342. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55343. * * 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)
  55344. * * 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)
  55345. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55346. * @param name defines the name of the mesh
  55347. * @param options defines the options used to create the mesh
  55348. * @param scene defines the hosting scene
  55349. * @returns the box mesh
  55350. */
  55351. static CreateTiledPlane(name: string, options: {
  55352. pattern?: number;
  55353. tileSize?: number;
  55354. tileWidth?: number;
  55355. tileHeight?: number;
  55356. size?: number;
  55357. width?: number;
  55358. height?: number;
  55359. alignHorizontal?: number;
  55360. alignVertical?: number;
  55361. sideOrientation?: number;
  55362. frontUVs?: Vector4;
  55363. backUVs?: Vector4;
  55364. updatable?: boolean;
  55365. }, scene?: Nullable<Scene>): Mesh;
  55366. }
  55367. }
  55368. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  55369. import { Nullable } from "babylonjs/types";
  55370. import { Scene } from "babylonjs/scene";
  55371. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55372. import { Mesh } from "babylonjs/Meshes/mesh";
  55373. /**
  55374. * Class containing static functions to help procedurally build meshes
  55375. */
  55376. export class TubeBuilder {
  55377. /**
  55378. * Creates a tube mesh.
  55379. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55380. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55381. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55382. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55383. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55384. * * 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)
  55385. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55386. * * 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
  55387. * * 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
  55388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55390. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55392. * @param name defines the name of the mesh
  55393. * @param options defines the options used to create the mesh
  55394. * @param scene defines the hosting scene
  55395. * @returns the tube mesh
  55396. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55397. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55398. */
  55399. static CreateTube(name: string, options: {
  55400. path: Vector3[];
  55401. radius?: number;
  55402. tessellation?: number;
  55403. radiusFunction?: {
  55404. (i: number, distance: number): number;
  55405. };
  55406. cap?: number;
  55407. arc?: number;
  55408. updatable?: boolean;
  55409. sideOrientation?: number;
  55410. frontUVs?: Vector4;
  55411. backUVs?: Vector4;
  55412. instance?: Mesh;
  55413. invertUV?: boolean;
  55414. }, scene?: Nullable<Scene>): Mesh;
  55415. }
  55416. }
  55417. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  55418. import { Scene } from "babylonjs/scene";
  55419. import { Vector4 } from "babylonjs/Maths/math";
  55420. import { Mesh } from "babylonjs/Meshes/mesh";
  55421. import { Nullable } from "babylonjs/types";
  55422. /**
  55423. * Class containing static functions to help procedurally build meshes
  55424. */
  55425. export class IcoSphereBuilder {
  55426. /**
  55427. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55428. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55429. * * 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`)
  55430. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55431. * * 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
  55432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55435. * @param name defines the name of the mesh
  55436. * @param options defines the options used to create the mesh
  55437. * @param scene defines the hosting scene
  55438. * @returns the icosahedron mesh
  55439. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55440. */
  55441. static CreateIcoSphere(name: string, options: {
  55442. radius?: number;
  55443. radiusX?: number;
  55444. radiusY?: number;
  55445. radiusZ?: number;
  55446. flat?: boolean;
  55447. subdivisions?: number;
  55448. sideOrientation?: number;
  55449. frontUVs?: Vector4;
  55450. backUVs?: Vector4;
  55451. updatable?: boolean;
  55452. }, scene?: Nullable<Scene>): Mesh;
  55453. }
  55454. }
  55455. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  55456. import { Vector3 } from "babylonjs/Maths/math";
  55457. import { Mesh } from "babylonjs/Meshes/mesh";
  55458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55459. /**
  55460. * Class containing static functions to help procedurally build meshes
  55461. */
  55462. export class DecalBuilder {
  55463. /**
  55464. * Creates a decal mesh.
  55465. * 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
  55466. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55467. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55468. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55469. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55470. * @param name defines the name of the mesh
  55471. * @param sourceMesh defines the mesh where the decal must be applied
  55472. * @param options defines the options used to create the mesh
  55473. * @param scene defines the hosting scene
  55474. * @returns the decal mesh
  55475. * @see https://doc.babylonjs.com/how_to/decals
  55476. */
  55477. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55478. position?: Vector3;
  55479. normal?: Vector3;
  55480. size?: Vector3;
  55481. angle?: number;
  55482. }): Mesh;
  55483. }
  55484. }
  55485. declare module "babylonjs/Meshes/meshBuilder" {
  55486. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  55487. import { Nullable } from "babylonjs/types";
  55488. import { Scene } from "babylonjs/scene";
  55489. import { Mesh } from "babylonjs/Meshes/mesh";
  55490. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  55491. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55493. /**
  55494. * Class containing static functions to help procedurally build meshes
  55495. */
  55496. export class MeshBuilder {
  55497. /**
  55498. * Creates a box mesh
  55499. * * The parameter `size` sets the size (float) of each box side (default 1)
  55500. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55501. * * 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)
  55502. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55506. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55507. * @param name defines the name of the mesh
  55508. * @param options defines the options used to create the mesh
  55509. * @param scene defines the hosting scene
  55510. * @returns the box mesh
  55511. */
  55512. static CreateBox(name: string, options: {
  55513. size?: number;
  55514. width?: number;
  55515. height?: number;
  55516. depth?: number;
  55517. faceUV?: Vector4[];
  55518. faceColors?: Color4[];
  55519. sideOrientation?: number;
  55520. frontUVs?: Vector4;
  55521. backUVs?: Vector4;
  55522. updatable?: boolean;
  55523. }, scene?: Nullable<Scene>): Mesh;
  55524. /**
  55525. * Creates a tiled box mesh
  55526. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55528. * @param name defines the name of the mesh
  55529. * @param options defines the options used to create the mesh
  55530. * @param scene defines the hosting scene
  55531. * @returns the tiled box mesh
  55532. */
  55533. static CreateTiledBox(name: string, options: {
  55534. pattern?: number;
  55535. size?: number;
  55536. width?: number;
  55537. height?: number;
  55538. depth: number;
  55539. tileSize?: number;
  55540. tileWidth?: number;
  55541. tileHeight?: number;
  55542. faceUV?: Vector4[];
  55543. faceColors?: Color4[];
  55544. alignHorizontal?: number;
  55545. alignVertical?: number;
  55546. sideOrientation?: number;
  55547. updatable?: boolean;
  55548. }, scene?: Nullable<Scene>): Mesh;
  55549. /**
  55550. * Creates a sphere mesh
  55551. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55552. * * 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`)
  55553. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55554. * * 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
  55555. * * 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)
  55556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55559. * @param name defines the name of the mesh
  55560. * @param options defines the options used to create the mesh
  55561. * @param scene defines the hosting scene
  55562. * @returns the sphere mesh
  55563. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55564. */
  55565. static CreateSphere(name: string, options: {
  55566. segments?: number;
  55567. diameter?: number;
  55568. diameterX?: number;
  55569. diameterY?: number;
  55570. diameterZ?: number;
  55571. arc?: number;
  55572. slice?: number;
  55573. sideOrientation?: number;
  55574. frontUVs?: Vector4;
  55575. backUVs?: Vector4;
  55576. updatable?: boolean;
  55577. }, scene?: Nullable<Scene>): Mesh;
  55578. /**
  55579. * Creates a plane polygonal mesh. By default, this is a disc
  55580. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55581. * * 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
  55582. * * 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
  55583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55584. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55586. * @param name defines the name of the mesh
  55587. * @param options defines the options used to create the mesh
  55588. * @param scene defines the hosting scene
  55589. * @returns the plane polygonal mesh
  55590. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55591. */
  55592. static CreateDisc(name: string, options: {
  55593. radius?: number;
  55594. tessellation?: number;
  55595. arc?: number;
  55596. updatable?: boolean;
  55597. sideOrientation?: number;
  55598. frontUVs?: Vector4;
  55599. backUVs?: Vector4;
  55600. }, scene?: Nullable<Scene>): Mesh;
  55601. /**
  55602. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55603. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55604. * * 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`)
  55605. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55606. * * 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
  55607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55608. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55610. * @param name defines the name of the mesh
  55611. * @param options defines the options used to create the mesh
  55612. * @param scene defines the hosting scene
  55613. * @returns the icosahedron mesh
  55614. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55615. */
  55616. static CreateIcoSphere(name: string, options: {
  55617. radius?: number;
  55618. radiusX?: number;
  55619. radiusY?: number;
  55620. radiusZ?: number;
  55621. flat?: boolean;
  55622. subdivisions?: number;
  55623. sideOrientation?: number;
  55624. frontUVs?: Vector4;
  55625. backUVs?: Vector4;
  55626. updatable?: boolean;
  55627. }, scene?: Nullable<Scene>): Mesh;
  55628. /**
  55629. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55630. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55631. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55632. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55633. * * 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
  55634. * * 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
  55635. * * 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
  55636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55637. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55638. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55639. * * 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
  55640. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55641. * * 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
  55642. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55644. * @param name defines the name of the mesh
  55645. * @param options defines the options used to create the mesh
  55646. * @param scene defines the hosting scene
  55647. * @returns the ribbon mesh
  55648. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55649. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55650. */
  55651. static CreateRibbon(name: string, options: {
  55652. pathArray: Vector3[][];
  55653. closeArray?: boolean;
  55654. closePath?: boolean;
  55655. offset?: number;
  55656. updatable?: boolean;
  55657. sideOrientation?: number;
  55658. frontUVs?: Vector4;
  55659. backUVs?: Vector4;
  55660. instance?: Mesh;
  55661. invertUV?: boolean;
  55662. uvs?: Vector2[];
  55663. colors?: Color4[];
  55664. }, scene?: Nullable<Scene>): Mesh;
  55665. /**
  55666. * Creates a cylinder or a cone mesh
  55667. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55668. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55669. * * 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.
  55670. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55671. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55672. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55673. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55674. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  55675. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55676. * * 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).
  55677. * * 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
  55678. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55679. * * 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
  55680. * * 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.
  55681. * * If `enclose` is false, a ring surface is one element.
  55682. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55683. * * 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
  55684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55687. * @param name defines the name of the mesh
  55688. * @param options defines the options used to create the mesh
  55689. * @param scene defines the hosting scene
  55690. * @returns the cylinder mesh
  55691. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55692. */
  55693. static CreateCylinder(name: string, options: {
  55694. height?: number;
  55695. diameterTop?: number;
  55696. diameterBottom?: number;
  55697. diameter?: number;
  55698. tessellation?: number;
  55699. subdivisions?: number;
  55700. arc?: number;
  55701. faceColors?: Color4[];
  55702. faceUV?: Vector4[];
  55703. updatable?: boolean;
  55704. hasRings?: boolean;
  55705. enclose?: boolean;
  55706. cap?: number;
  55707. sideOrientation?: number;
  55708. frontUVs?: Vector4;
  55709. backUVs?: Vector4;
  55710. }, scene?: Nullable<Scene>): Mesh;
  55711. /**
  55712. * Creates a torus mesh
  55713. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55714. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55715. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55719. * @param name defines the name of the mesh
  55720. * @param options defines the options used to create the mesh
  55721. * @param scene defines the hosting scene
  55722. * @returns the torus mesh
  55723. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55724. */
  55725. static CreateTorus(name: string, options: {
  55726. diameter?: number;
  55727. thickness?: number;
  55728. tessellation?: number;
  55729. updatable?: boolean;
  55730. sideOrientation?: number;
  55731. frontUVs?: Vector4;
  55732. backUVs?: Vector4;
  55733. }, scene?: Nullable<Scene>): Mesh;
  55734. /**
  55735. * Creates a torus knot mesh
  55736. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55737. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55738. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55739. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55743. * @param name defines the name of the mesh
  55744. * @param options defines the options used to create the mesh
  55745. * @param scene defines the hosting scene
  55746. * @returns the torus knot mesh
  55747. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55748. */
  55749. static CreateTorusKnot(name: string, options: {
  55750. radius?: number;
  55751. tube?: number;
  55752. radialSegments?: number;
  55753. tubularSegments?: number;
  55754. p?: number;
  55755. q?: number;
  55756. updatable?: boolean;
  55757. sideOrientation?: number;
  55758. frontUVs?: Vector4;
  55759. backUVs?: Vector4;
  55760. }, scene?: Nullable<Scene>): Mesh;
  55761. /**
  55762. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55763. * * 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
  55764. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55765. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55766. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55767. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55768. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55769. * * 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
  55770. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55772. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55773. * @param name defines the name of the new line system
  55774. * @param options defines the options used to create the line system
  55775. * @param scene defines the hosting scene
  55776. * @returns a new line system mesh
  55777. */
  55778. static CreateLineSystem(name: string, options: {
  55779. lines: Vector3[][];
  55780. updatable?: boolean;
  55781. instance?: Nullable<LinesMesh>;
  55782. colors?: Nullable<Color4[][]>;
  55783. useVertexAlpha?: boolean;
  55784. }, scene: Nullable<Scene>): LinesMesh;
  55785. /**
  55786. * Creates a line mesh
  55787. * 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
  55788. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55789. * * The parameter `points` is an array successive Vector3
  55790. * * 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
  55791. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55792. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55793. * * When updating an instance, remember that only point positions can change, not the number of points
  55794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55795. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55796. * @param name defines the name of the new line system
  55797. * @param options defines the options used to create the line system
  55798. * @param scene defines the hosting scene
  55799. * @returns a new line mesh
  55800. */
  55801. static CreateLines(name: string, options: {
  55802. points: Vector3[];
  55803. updatable?: boolean;
  55804. instance?: Nullable<LinesMesh>;
  55805. colors?: Color4[];
  55806. useVertexAlpha?: boolean;
  55807. }, scene?: Nullable<Scene>): LinesMesh;
  55808. /**
  55809. * Creates a dashed line mesh
  55810. * * 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
  55811. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55812. * * The parameter `points` is an array successive Vector3
  55813. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55814. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55815. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55816. * * 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
  55817. * * When updating an instance, remember that only point positions can change, not the number of points
  55818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55819. * @param name defines the name of the mesh
  55820. * @param options defines the options used to create the mesh
  55821. * @param scene defines the hosting scene
  55822. * @returns the dashed line mesh
  55823. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55824. */
  55825. static CreateDashedLines(name: string, options: {
  55826. points: Vector3[];
  55827. dashSize?: number;
  55828. gapSize?: number;
  55829. dashNb?: number;
  55830. updatable?: boolean;
  55831. instance?: LinesMesh;
  55832. }, scene?: Nullable<Scene>): LinesMesh;
  55833. /**
  55834. * 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.
  55835. * * 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.
  55836. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55837. * * 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.
  55838. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55839. * * 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
  55840. * * 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
  55841. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55843. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55844. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55846. * @param name defines the name of the mesh
  55847. * @param options defines the options used to create the mesh
  55848. * @param scene defines the hosting scene
  55849. * @returns the extruded shape mesh
  55850. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55851. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55852. */
  55853. static ExtrudeShape(name: string, options: {
  55854. shape: Vector3[];
  55855. path: Vector3[];
  55856. scale?: number;
  55857. rotation?: number;
  55858. cap?: number;
  55859. updatable?: boolean;
  55860. sideOrientation?: number;
  55861. frontUVs?: Vector4;
  55862. backUVs?: Vector4;
  55863. instance?: Mesh;
  55864. invertUV?: boolean;
  55865. }, scene?: Nullable<Scene>): Mesh;
  55866. /**
  55867. * Creates an custom extruded shape mesh.
  55868. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55869. * * 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.
  55870. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55871. * * 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
  55872. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55873. * * 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
  55874. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55875. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55876. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55877. * * 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
  55878. * * 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
  55879. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55881. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55882. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55884. * @param name defines the name of the mesh
  55885. * @param options defines the options used to create the mesh
  55886. * @param scene defines the hosting scene
  55887. * @returns the custom extruded shape mesh
  55888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55889. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55890. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55891. */
  55892. static ExtrudeShapeCustom(name: string, options: {
  55893. shape: Vector3[];
  55894. path: Vector3[];
  55895. scaleFunction?: any;
  55896. rotationFunction?: any;
  55897. ribbonCloseArray?: boolean;
  55898. ribbonClosePath?: boolean;
  55899. cap?: number;
  55900. updatable?: boolean;
  55901. sideOrientation?: number;
  55902. frontUVs?: Vector4;
  55903. backUVs?: Vector4;
  55904. instance?: Mesh;
  55905. invertUV?: boolean;
  55906. }, scene?: Nullable<Scene>): Mesh;
  55907. /**
  55908. * Creates lathe mesh.
  55909. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55910. * * 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
  55911. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55912. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55913. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55914. * * 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
  55915. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55916. * * 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
  55917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55919. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55921. * @param name defines the name of the mesh
  55922. * @param options defines the options used to create the mesh
  55923. * @param scene defines the hosting scene
  55924. * @returns the lathe mesh
  55925. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55926. */
  55927. static CreateLathe(name: string, options: {
  55928. shape: Vector3[];
  55929. radius?: number;
  55930. tessellation?: number;
  55931. clip?: number;
  55932. arc?: number;
  55933. closed?: boolean;
  55934. updatable?: boolean;
  55935. sideOrientation?: number;
  55936. frontUVs?: Vector4;
  55937. backUVs?: Vector4;
  55938. cap?: number;
  55939. invertUV?: boolean;
  55940. }, scene?: Nullable<Scene>): Mesh;
  55941. /**
  55942. * Creates a tiled plane mesh
  55943. * * You can set a limited pattern arrangement with the tiles
  55944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55947. * @param name defines the name of the mesh
  55948. * @param options defines the options used to create the mesh
  55949. * @param scene defines the hosting scene
  55950. * @returns the plane mesh
  55951. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55952. */
  55953. static CreateTiledPlane(name: string, options: {
  55954. pattern?: number;
  55955. tileSize?: number;
  55956. tileWidth?: number;
  55957. tileHeight?: number;
  55958. size?: number;
  55959. width?: number;
  55960. height?: number;
  55961. alignHorizontal?: number;
  55962. alignVertical?: number;
  55963. sideOrientation?: number;
  55964. frontUVs?: Vector4;
  55965. backUVs?: Vector4;
  55966. updatable?: boolean;
  55967. }, scene?: Nullable<Scene>): Mesh;
  55968. /**
  55969. * Creates a plane mesh
  55970. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55971. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55972. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55976. * @param name defines the name of the mesh
  55977. * @param options defines the options used to create the mesh
  55978. * @param scene defines the hosting scene
  55979. * @returns the plane mesh
  55980. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55981. */
  55982. static CreatePlane(name: string, options: {
  55983. size?: number;
  55984. width?: number;
  55985. height?: number;
  55986. sideOrientation?: number;
  55987. frontUVs?: Vector4;
  55988. backUVs?: Vector4;
  55989. updatable?: boolean;
  55990. sourcePlane?: Plane;
  55991. }, scene?: Nullable<Scene>): Mesh;
  55992. /**
  55993. * Creates a ground mesh
  55994. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55995. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55997. * @param name defines the name of the mesh
  55998. * @param options defines the options used to create the mesh
  55999. * @param scene defines the hosting scene
  56000. * @returns the ground mesh
  56001. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56002. */
  56003. static CreateGround(name: string, options: {
  56004. width?: number;
  56005. height?: number;
  56006. subdivisions?: number;
  56007. subdivisionsX?: number;
  56008. subdivisionsY?: number;
  56009. updatable?: boolean;
  56010. }, scene?: Nullable<Scene>): Mesh;
  56011. /**
  56012. * Creates a tiled ground mesh
  56013. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56014. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56015. * * 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
  56016. * * 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
  56017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56018. * @param name defines the name of the mesh
  56019. * @param options defines the options used to create the mesh
  56020. * @param scene defines the hosting scene
  56021. * @returns the tiled ground mesh
  56022. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56023. */
  56024. static CreateTiledGround(name: string, options: {
  56025. xmin: number;
  56026. zmin: number;
  56027. xmax: number;
  56028. zmax: number;
  56029. subdivisions?: {
  56030. w: number;
  56031. h: number;
  56032. };
  56033. precision?: {
  56034. w: number;
  56035. h: number;
  56036. };
  56037. updatable?: boolean;
  56038. }, scene?: Nullable<Scene>): Mesh;
  56039. /**
  56040. * Creates a ground mesh from a height map
  56041. * * The parameter `url` sets the URL of the height map image resource.
  56042. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56043. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56044. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56045. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56046. * * 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.
  56047. * * 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).
  56048. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56050. * @param name defines the name of the mesh
  56051. * @param url defines the url to the height map
  56052. * @param options defines the options used to create the mesh
  56053. * @param scene defines the hosting scene
  56054. * @returns the ground mesh
  56055. * @see https://doc.babylonjs.com/babylon101/height_map
  56056. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56057. */
  56058. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56059. width?: number;
  56060. height?: number;
  56061. subdivisions?: number;
  56062. minHeight?: number;
  56063. maxHeight?: number;
  56064. colorFilter?: Color3;
  56065. alphaFilter?: number;
  56066. updatable?: boolean;
  56067. onReady?: (mesh: GroundMesh) => void;
  56068. }, scene?: Nullable<Scene>): GroundMesh;
  56069. /**
  56070. * Creates a polygon mesh
  56071. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56072. * * 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
  56073. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56076. * * Remember you can only change the shape positions, not their number when updating a polygon
  56077. * @param name defines the name of the mesh
  56078. * @param options defines the options used to create the mesh
  56079. * @param scene defines the hosting scene
  56080. * @param earcutInjection can be used to inject your own earcut reference
  56081. * @returns the polygon mesh
  56082. */
  56083. static CreatePolygon(name: string, options: {
  56084. shape: Vector3[];
  56085. holes?: Vector3[][];
  56086. depth?: number;
  56087. faceUV?: Vector4[];
  56088. faceColors?: Color4[];
  56089. updatable?: boolean;
  56090. sideOrientation?: number;
  56091. frontUVs?: Vector4;
  56092. backUVs?: Vector4;
  56093. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56094. /**
  56095. * Creates an extruded polygon mesh, with depth in the Y direction.
  56096. * * 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)
  56097. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56098. * @param name defines the name of the mesh
  56099. * @param options defines the options used to create the mesh
  56100. * @param scene defines the hosting scene
  56101. * @param earcutInjection can be used to inject your own earcut reference
  56102. * @returns the polygon mesh
  56103. */
  56104. static ExtrudePolygon(name: string, options: {
  56105. shape: Vector3[];
  56106. holes?: Vector3[][];
  56107. depth?: number;
  56108. faceUV?: Vector4[];
  56109. faceColors?: Color4[];
  56110. updatable?: boolean;
  56111. sideOrientation?: number;
  56112. frontUVs?: Vector4;
  56113. backUVs?: Vector4;
  56114. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56115. /**
  56116. * Creates a tube mesh.
  56117. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56118. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56119. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56120. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56121. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56122. * * 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)
  56123. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56124. * * 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
  56125. * * 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
  56126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56127. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56128. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56130. * @param name defines the name of the mesh
  56131. * @param options defines the options used to create the mesh
  56132. * @param scene defines the hosting scene
  56133. * @returns the tube mesh
  56134. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56135. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56136. */
  56137. static CreateTube(name: string, options: {
  56138. path: Vector3[];
  56139. radius?: number;
  56140. tessellation?: number;
  56141. radiusFunction?: {
  56142. (i: number, distance: number): number;
  56143. };
  56144. cap?: number;
  56145. arc?: number;
  56146. updatable?: boolean;
  56147. sideOrientation?: number;
  56148. frontUVs?: Vector4;
  56149. backUVs?: Vector4;
  56150. instance?: Mesh;
  56151. invertUV?: boolean;
  56152. }, scene?: Nullable<Scene>): Mesh;
  56153. /**
  56154. * Creates a polyhedron mesh
  56155. * * 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
  56156. * * The parameter `size` (positive float, default 1) sets the polygon size
  56157. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56158. * * 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`
  56159. * * 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
  56160. * * 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)`)
  56161. * * 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
  56162. * * 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
  56163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56164. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56166. * @param name defines the name of the mesh
  56167. * @param options defines the options used to create the mesh
  56168. * @param scene defines the hosting scene
  56169. * @returns the polyhedron mesh
  56170. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56171. */
  56172. static CreatePolyhedron(name: string, options: {
  56173. type?: number;
  56174. size?: number;
  56175. sizeX?: number;
  56176. sizeY?: number;
  56177. sizeZ?: number;
  56178. custom?: any;
  56179. faceUV?: Vector4[];
  56180. faceColors?: Color4[];
  56181. flat?: boolean;
  56182. updatable?: boolean;
  56183. sideOrientation?: number;
  56184. frontUVs?: Vector4;
  56185. backUVs?: Vector4;
  56186. }, scene?: Nullable<Scene>): Mesh;
  56187. /**
  56188. * Creates a decal mesh.
  56189. * 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
  56190. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56191. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56192. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56193. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56194. * @param name defines the name of the mesh
  56195. * @param sourceMesh defines the mesh where the decal must be applied
  56196. * @param options defines the options used to create the mesh
  56197. * @param scene defines the hosting scene
  56198. * @returns the decal mesh
  56199. * @see https://doc.babylonjs.com/how_to/decals
  56200. */
  56201. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56202. position?: Vector3;
  56203. normal?: Vector3;
  56204. size?: Vector3;
  56205. angle?: number;
  56206. }): Mesh;
  56207. }
  56208. }
  56209. declare module "babylonjs/Meshes/meshSimplification" {
  56210. import { Mesh } from "babylonjs/Meshes/mesh";
  56211. /**
  56212. * A simplifier interface for future simplification implementations
  56213. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56214. */
  56215. export interface ISimplifier {
  56216. /**
  56217. * Simplification of a given mesh according to the given settings.
  56218. * Since this requires computation, it is assumed that the function runs async.
  56219. * @param settings The settings of the simplification, including quality and distance
  56220. * @param successCallback A callback that will be called after the mesh was simplified.
  56221. * @param errorCallback in case of an error, this callback will be called. optional.
  56222. */
  56223. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56224. }
  56225. /**
  56226. * Expected simplification settings.
  56227. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56228. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56229. */
  56230. export interface ISimplificationSettings {
  56231. /**
  56232. * Gets or sets the expected quality
  56233. */
  56234. quality: number;
  56235. /**
  56236. * Gets or sets the distance when this optimized version should be used
  56237. */
  56238. distance: number;
  56239. /**
  56240. * Gets an already optimized mesh
  56241. */
  56242. optimizeMesh?: boolean;
  56243. }
  56244. /**
  56245. * Class used to specify simplification options
  56246. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56247. */
  56248. export class SimplificationSettings implements ISimplificationSettings {
  56249. /** expected quality */
  56250. quality: number;
  56251. /** distance when this optimized version should be used */
  56252. distance: number;
  56253. /** already optimized mesh */
  56254. optimizeMesh?: boolean | undefined;
  56255. /**
  56256. * Creates a SimplificationSettings
  56257. * @param quality expected quality
  56258. * @param distance distance when this optimized version should be used
  56259. * @param optimizeMesh already optimized mesh
  56260. */
  56261. constructor(
  56262. /** expected quality */
  56263. quality: number,
  56264. /** distance when this optimized version should be used */
  56265. distance: number,
  56266. /** already optimized mesh */
  56267. optimizeMesh?: boolean | undefined);
  56268. }
  56269. /**
  56270. * Interface used to define a simplification task
  56271. */
  56272. export interface ISimplificationTask {
  56273. /**
  56274. * Array of settings
  56275. */
  56276. settings: Array<ISimplificationSettings>;
  56277. /**
  56278. * Simplification type
  56279. */
  56280. simplificationType: SimplificationType;
  56281. /**
  56282. * Mesh to simplify
  56283. */
  56284. mesh: Mesh;
  56285. /**
  56286. * Callback called on success
  56287. */
  56288. successCallback?: () => void;
  56289. /**
  56290. * Defines if parallel processing can be used
  56291. */
  56292. parallelProcessing: boolean;
  56293. }
  56294. /**
  56295. * Queue used to order the simplification tasks
  56296. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56297. */
  56298. export class SimplificationQueue {
  56299. private _simplificationArray;
  56300. /**
  56301. * Gets a boolean indicating that the process is still running
  56302. */
  56303. running: boolean;
  56304. /**
  56305. * Creates a new queue
  56306. */
  56307. constructor();
  56308. /**
  56309. * Adds a new simplification task
  56310. * @param task defines a task to add
  56311. */
  56312. addTask(task: ISimplificationTask): void;
  56313. /**
  56314. * Execute next task
  56315. */
  56316. executeNext(): void;
  56317. /**
  56318. * Execute a simplification task
  56319. * @param task defines the task to run
  56320. */
  56321. runSimplification(task: ISimplificationTask): void;
  56322. private getSimplifier;
  56323. }
  56324. /**
  56325. * The implemented types of simplification
  56326. * At the moment only Quadratic Error Decimation is implemented
  56327. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56328. */
  56329. export enum SimplificationType {
  56330. /** Quadratic error decimation */
  56331. QUADRATIC = 0
  56332. }
  56333. }
  56334. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  56335. import { Scene } from "babylonjs/scene";
  56336. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  56337. import { ISceneComponent } from "babylonjs/sceneComponent";
  56338. module "babylonjs/scene" {
  56339. interface Scene {
  56340. /** @hidden (Backing field) */
  56341. _simplificationQueue: SimplificationQueue;
  56342. /**
  56343. * Gets or sets the simplification queue attached to the scene
  56344. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56345. */
  56346. simplificationQueue: SimplificationQueue;
  56347. }
  56348. }
  56349. module "babylonjs/Meshes/mesh" {
  56350. interface Mesh {
  56351. /**
  56352. * Simplify the mesh according to the given array of settings.
  56353. * Function will return immediately and will simplify async
  56354. * @param settings a collection of simplification settings
  56355. * @param parallelProcessing should all levels calculate parallel or one after the other
  56356. * @param simplificationType the type of simplification to run
  56357. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56358. * @returns the current mesh
  56359. */
  56360. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56361. }
  56362. }
  56363. /**
  56364. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56365. * created in a scene
  56366. */
  56367. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56368. /**
  56369. * The component name helpfull to identify the component in the list of scene components.
  56370. */
  56371. readonly name: string;
  56372. /**
  56373. * The scene the component belongs to.
  56374. */
  56375. scene: Scene;
  56376. /**
  56377. * Creates a new instance of the component for the given scene
  56378. * @param scene Defines the scene to register the component in
  56379. */
  56380. constructor(scene: Scene);
  56381. /**
  56382. * Registers the component in a given scene
  56383. */
  56384. register(): void;
  56385. /**
  56386. * Rebuilds the elements related to this component in case of
  56387. * context lost for instance.
  56388. */
  56389. rebuild(): void;
  56390. /**
  56391. * Disposes the component and the associated ressources
  56392. */
  56393. dispose(): void;
  56394. private _beforeCameraUpdate;
  56395. }
  56396. }
  56397. declare module "babylonjs/Meshes/Builders/index" {
  56398. export * from "babylonjs/Meshes/Builders/boxBuilder";
  56399. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  56400. export * from "babylonjs/Meshes/Builders/discBuilder";
  56401. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  56402. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  56403. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  56404. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  56405. export * from "babylonjs/Meshes/Builders/torusBuilder";
  56406. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  56407. export * from "babylonjs/Meshes/Builders/linesBuilder";
  56408. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  56409. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  56410. export * from "babylonjs/Meshes/Builders/latheBuilder";
  56411. export * from "babylonjs/Meshes/Builders/planeBuilder";
  56412. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  56413. export * from "babylonjs/Meshes/Builders/groundBuilder";
  56414. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  56415. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  56416. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  56417. export * from "babylonjs/Meshes/Builders/decalBuilder";
  56418. }
  56419. declare module "babylonjs/Meshes/index" {
  56420. export * from "babylonjs/Meshes/abstractMesh";
  56421. export * from "babylonjs/Meshes/buffer";
  56422. export * from "babylonjs/Meshes/Compression/index";
  56423. export * from "babylonjs/Meshes/csg";
  56424. export * from "babylonjs/Meshes/geometry";
  56425. export * from "babylonjs/Meshes/groundMesh";
  56426. export * from "babylonjs/Meshes/trailMesh";
  56427. export * from "babylonjs/Meshes/instancedMesh";
  56428. export * from "babylonjs/Meshes/linesMesh";
  56429. export * from "babylonjs/Meshes/mesh";
  56430. export * from "babylonjs/Meshes/mesh.vertexData";
  56431. export * from "babylonjs/Meshes/meshBuilder";
  56432. export * from "babylonjs/Meshes/meshSimplification";
  56433. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  56434. export * from "babylonjs/Meshes/polygonMesh";
  56435. export * from "babylonjs/Meshes/subMesh";
  56436. export * from "babylonjs/Meshes/meshLODLevel";
  56437. export * from "babylonjs/Meshes/transformNode";
  56438. export * from "babylonjs/Meshes/Builders/index";
  56439. export * from "babylonjs/Meshes/dataBuffer";
  56440. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  56441. }
  56442. declare module "babylonjs/Morph/index" {
  56443. export * from "babylonjs/Morph/morphTarget";
  56444. export * from "babylonjs/Morph/morphTargetManager";
  56445. }
  56446. declare module "babylonjs/Offline/database" {
  56447. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  56448. /**
  56449. * Class used to enable access to IndexedDB
  56450. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56451. */
  56452. export class Database implements IOfflineProvider {
  56453. private _callbackManifestChecked;
  56454. private _currentSceneUrl;
  56455. private _db;
  56456. private _enableSceneOffline;
  56457. private _enableTexturesOffline;
  56458. private _manifestVersionFound;
  56459. private _mustUpdateRessources;
  56460. private _hasReachedQuota;
  56461. private _isSupported;
  56462. private _idbFactory;
  56463. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56464. private static IsUASupportingBlobStorage;
  56465. /**
  56466. * Gets a boolean indicating if Database storate is enabled (off by default)
  56467. */
  56468. static IDBStorageEnabled: boolean;
  56469. /**
  56470. * Gets a boolean indicating if scene must be saved in the database
  56471. */
  56472. readonly enableSceneOffline: boolean;
  56473. /**
  56474. * Gets a boolean indicating if textures must be saved in the database
  56475. */
  56476. readonly enableTexturesOffline: boolean;
  56477. /**
  56478. * Creates a new Database
  56479. * @param urlToScene defines the url to load the scene
  56480. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56481. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56482. */
  56483. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56484. private static _ParseURL;
  56485. private static _ReturnFullUrlLocation;
  56486. private _checkManifestFile;
  56487. /**
  56488. * Open the database and make it available
  56489. * @param successCallback defines the callback to call on success
  56490. * @param errorCallback defines the callback to call on error
  56491. */
  56492. open(successCallback: () => void, errorCallback: () => void): void;
  56493. /**
  56494. * Loads an image from the database
  56495. * @param url defines the url to load from
  56496. * @param image defines the target DOM image
  56497. */
  56498. loadImage(url: string, image: HTMLImageElement): void;
  56499. private _loadImageFromDBAsync;
  56500. private _saveImageIntoDBAsync;
  56501. private _checkVersionFromDB;
  56502. private _loadVersionFromDBAsync;
  56503. private _saveVersionIntoDBAsync;
  56504. /**
  56505. * Loads a file from database
  56506. * @param url defines the URL to load from
  56507. * @param sceneLoaded defines a callback to call on success
  56508. * @param progressCallBack defines a callback to call when progress changed
  56509. * @param errorCallback defines a callback to call on error
  56510. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56511. */
  56512. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56513. private _loadFileAsync;
  56514. private _saveFileAsync;
  56515. /**
  56516. * Validates if xhr data is correct
  56517. * @param xhr defines the request to validate
  56518. * @param dataType defines the expected data type
  56519. * @returns true if data is correct
  56520. */
  56521. private static _ValidateXHRData;
  56522. }
  56523. }
  56524. declare module "babylonjs/Offline/index" {
  56525. export * from "babylonjs/Offline/database";
  56526. export * from "babylonjs/Offline/IOfflineProvider";
  56527. }
  56528. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  56529. /** @hidden */
  56530. export var gpuUpdateParticlesPixelShader: {
  56531. name: string;
  56532. shader: string;
  56533. };
  56534. }
  56535. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  56536. /** @hidden */
  56537. export var gpuUpdateParticlesVertexShader: {
  56538. name: string;
  56539. shader: string;
  56540. };
  56541. }
  56542. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  56543. /** @hidden */
  56544. export var clipPlaneFragmentDeclaration2: {
  56545. name: string;
  56546. shader: string;
  56547. };
  56548. }
  56549. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  56550. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  56551. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56552. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56553. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56554. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56555. /** @hidden */
  56556. export var gpuRenderParticlesPixelShader: {
  56557. name: string;
  56558. shader: string;
  56559. };
  56560. }
  56561. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  56562. /** @hidden */
  56563. export var clipPlaneVertexDeclaration2: {
  56564. name: string;
  56565. shader: string;
  56566. };
  56567. }
  56568. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  56569. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  56570. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56571. /** @hidden */
  56572. export var gpuRenderParticlesVertexShader: {
  56573. name: string;
  56574. shader: string;
  56575. };
  56576. }
  56577. declare module "babylonjs/Particles/gpuParticleSystem" {
  56578. import { Nullable } from "babylonjs/types";
  56579. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  56580. import { Observable } from "babylonjs/Misc/observable";
  56581. import { Color4, Color3 } from "babylonjs/Maths/math";
  56582. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56583. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  56584. import { Scene, IDisposable } from "babylonjs/scene";
  56585. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  56586. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  56587. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  56588. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  56589. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  56590. /**
  56591. * This represents a GPU particle system in Babylon
  56592. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56593. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56594. */
  56595. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56596. /**
  56597. * The layer mask we are rendering the particles through.
  56598. */
  56599. layerMask: number;
  56600. private _capacity;
  56601. private _activeCount;
  56602. private _currentActiveCount;
  56603. private _accumulatedCount;
  56604. private _renderEffect;
  56605. private _updateEffect;
  56606. private _buffer0;
  56607. private _buffer1;
  56608. private _spriteBuffer;
  56609. private _updateVAO;
  56610. private _renderVAO;
  56611. private _targetIndex;
  56612. private _sourceBuffer;
  56613. private _targetBuffer;
  56614. private _engine;
  56615. private _currentRenderId;
  56616. private _started;
  56617. private _stopped;
  56618. private _timeDelta;
  56619. private _randomTexture;
  56620. private _randomTexture2;
  56621. private _attributesStrideSize;
  56622. private _updateEffectOptions;
  56623. private _randomTextureSize;
  56624. private _actualFrame;
  56625. private readonly _rawTextureWidth;
  56626. /**
  56627. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56628. */
  56629. static readonly IsSupported: boolean;
  56630. /**
  56631. * An event triggered when the system is disposed.
  56632. */
  56633. onDisposeObservable: Observable<GPUParticleSystem>;
  56634. /**
  56635. * Gets the maximum number of particles active at the same time.
  56636. * @returns The max number of active particles.
  56637. */
  56638. getCapacity(): number;
  56639. /**
  56640. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56641. * to override the particles.
  56642. */
  56643. forceDepthWrite: boolean;
  56644. /**
  56645. * Gets or set the number of active particles
  56646. */
  56647. activeParticleCount: number;
  56648. private _preWarmDone;
  56649. /**
  56650. * Is this system ready to be used/rendered
  56651. * @return true if the system is ready
  56652. */
  56653. isReady(): boolean;
  56654. /**
  56655. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56656. * @returns True if it has been started, otherwise false.
  56657. */
  56658. isStarted(): boolean;
  56659. /**
  56660. * Starts the particle system and begins to emit
  56661. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56662. */
  56663. start(delay?: number): void;
  56664. /**
  56665. * Stops the particle system.
  56666. */
  56667. stop(): void;
  56668. /**
  56669. * Remove all active particles
  56670. */
  56671. reset(): void;
  56672. /**
  56673. * Returns the string "GPUParticleSystem"
  56674. * @returns a string containing the class name
  56675. */
  56676. getClassName(): string;
  56677. private _colorGradientsTexture;
  56678. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56679. /**
  56680. * Adds a new color gradient
  56681. * @param gradient defines the gradient to use (between 0 and 1)
  56682. * @param color1 defines the color to affect to the specified gradient
  56683. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56684. * @returns the current particle system
  56685. */
  56686. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56687. /**
  56688. * Remove a specific color gradient
  56689. * @param gradient defines the gradient to remove
  56690. * @returns the current particle system
  56691. */
  56692. removeColorGradient(gradient: number): GPUParticleSystem;
  56693. private _angularSpeedGradientsTexture;
  56694. private _sizeGradientsTexture;
  56695. private _velocityGradientsTexture;
  56696. private _limitVelocityGradientsTexture;
  56697. private _dragGradientsTexture;
  56698. private _addFactorGradient;
  56699. /**
  56700. * Adds a new size gradient
  56701. * @param gradient defines the gradient to use (between 0 and 1)
  56702. * @param factor defines the size factor to affect to the specified gradient
  56703. * @returns the current particle system
  56704. */
  56705. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56706. /**
  56707. * Remove a specific size gradient
  56708. * @param gradient defines the gradient to remove
  56709. * @returns the current particle system
  56710. */
  56711. removeSizeGradient(gradient: number): GPUParticleSystem;
  56712. /**
  56713. * Adds a new angular speed gradient
  56714. * @param gradient defines the gradient to use (between 0 and 1)
  56715. * @param factor defines the angular speed to affect to the specified gradient
  56716. * @returns the current particle system
  56717. */
  56718. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56719. /**
  56720. * Remove a specific angular speed gradient
  56721. * @param gradient defines the gradient to remove
  56722. * @returns the current particle system
  56723. */
  56724. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56725. /**
  56726. * Adds a new velocity gradient
  56727. * @param gradient defines the gradient to use (between 0 and 1)
  56728. * @param factor defines the velocity to affect to the specified gradient
  56729. * @returns the current particle system
  56730. */
  56731. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56732. /**
  56733. * Remove a specific velocity gradient
  56734. * @param gradient defines the gradient to remove
  56735. * @returns the current particle system
  56736. */
  56737. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56738. /**
  56739. * Adds a new limit velocity gradient
  56740. * @param gradient defines the gradient to use (between 0 and 1)
  56741. * @param factor defines the limit velocity value to affect to the specified gradient
  56742. * @returns the current particle system
  56743. */
  56744. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56745. /**
  56746. * Remove a specific limit velocity gradient
  56747. * @param gradient defines the gradient to remove
  56748. * @returns the current particle system
  56749. */
  56750. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56751. /**
  56752. * Adds a new drag gradient
  56753. * @param gradient defines the gradient to use (between 0 and 1)
  56754. * @param factor defines the drag value to affect to the specified gradient
  56755. * @returns the current particle system
  56756. */
  56757. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56758. /**
  56759. * Remove a specific drag gradient
  56760. * @param gradient defines the gradient to remove
  56761. * @returns the current particle system
  56762. */
  56763. removeDragGradient(gradient: number): GPUParticleSystem;
  56764. /**
  56765. * Not supported by GPUParticleSystem
  56766. * @param gradient defines the gradient to use (between 0 and 1)
  56767. * @param factor defines the emit rate value to affect to the specified gradient
  56768. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56769. * @returns the current particle system
  56770. */
  56771. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56772. /**
  56773. * Not supported by GPUParticleSystem
  56774. * @param gradient defines the gradient to remove
  56775. * @returns the current particle system
  56776. */
  56777. removeEmitRateGradient(gradient: number): IParticleSystem;
  56778. /**
  56779. * Not supported by GPUParticleSystem
  56780. * @param gradient defines the gradient to use (between 0 and 1)
  56781. * @param factor defines the start size value to affect to the specified gradient
  56782. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56783. * @returns the current particle system
  56784. */
  56785. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56786. /**
  56787. * Not supported by GPUParticleSystem
  56788. * @param gradient defines the gradient to remove
  56789. * @returns the current particle system
  56790. */
  56791. removeStartSizeGradient(gradient: number): IParticleSystem;
  56792. /**
  56793. * Not supported by GPUParticleSystem
  56794. * @param gradient defines the gradient to use (between 0 and 1)
  56795. * @param min defines the color remap minimal range
  56796. * @param max defines the color remap maximal range
  56797. * @returns the current particle system
  56798. */
  56799. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56800. /**
  56801. * Not supported by GPUParticleSystem
  56802. * @param gradient defines the gradient to remove
  56803. * @returns the current particle system
  56804. */
  56805. removeColorRemapGradient(): IParticleSystem;
  56806. /**
  56807. * Not supported by GPUParticleSystem
  56808. * @param gradient defines the gradient to use (between 0 and 1)
  56809. * @param min defines the alpha remap minimal range
  56810. * @param max defines the alpha remap maximal range
  56811. * @returns the current particle system
  56812. */
  56813. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56814. /**
  56815. * Not supported by GPUParticleSystem
  56816. * @param gradient defines the gradient to remove
  56817. * @returns the current particle system
  56818. */
  56819. removeAlphaRemapGradient(): IParticleSystem;
  56820. /**
  56821. * Not supported by GPUParticleSystem
  56822. * @param gradient defines the gradient to use (between 0 and 1)
  56823. * @param color defines the color to affect to the specified gradient
  56824. * @returns the current particle system
  56825. */
  56826. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56827. /**
  56828. * Not supported by GPUParticleSystem
  56829. * @param gradient defines the gradient to remove
  56830. * @returns the current particle system
  56831. */
  56832. removeRampGradient(): IParticleSystem;
  56833. /**
  56834. * Not supported by GPUParticleSystem
  56835. * @returns the list of ramp gradients
  56836. */
  56837. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56838. /**
  56839. * Not supported by GPUParticleSystem
  56840. * Gets or sets a boolean indicating that ramp gradients must be used
  56841. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56842. */
  56843. useRampGradients: boolean;
  56844. /**
  56845. * Not supported by GPUParticleSystem
  56846. * @param gradient defines the gradient to use (between 0 and 1)
  56847. * @param factor defines the life time factor to affect to the specified gradient
  56848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56849. * @returns the current particle system
  56850. */
  56851. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56852. /**
  56853. * Not supported by GPUParticleSystem
  56854. * @param gradient defines the gradient to remove
  56855. * @returns the current particle system
  56856. */
  56857. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56858. /**
  56859. * Instantiates a GPU particle system.
  56860. * 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.
  56861. * @param name The name of the particle system
  56862. * @param options The options used to create the system
  56863. * @param scene The scene the particle system belongs to
  56864. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56865. */
  56866. constructor(name: string, options: Partial<{
  56867. capacity: number;
  56868. randomTextureSize: number;
  56869. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56870. protected _reset(): void;
  56871. private _createUpdateVAO;
  56872. private _createRenderVAO;
  56873. private _initialize;
  56874. /** @hidden */
  56875. _recreateUpdateEffect(): void;
  56876. /** @hidden */
  56877. _recreateRenderEffect(): void;
  56878. /**
  56879. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56880. * @param preWarm defines if we are in the pre-warmimg phase
  56881. */
  56882. animate(preWarm?: boolean): void;
  56883. private _createFactorGradientTexture;
  56884. private _createSizeGradientTexture;
  56885. private _createAngularSpeedGradientTexture;
  56886. private _createVelocityGradientTexture;
  56887. private _createLimitVelocityGradientTexture;
  56888. private _createDragGradientTexture;
  56889. private _createColorGradientTexture;
  56890. /**
  56891. * Renders the particle system in its current state
  56892. * @param preWarm defines if the system should only update the particles but not render them
  56893. * @returns the current number of particles
  56894. */
  56895. render(preWarm?: boolean): number;
  56896. /**
  56897. * Rebuilds the particle system
  56898. */
  56899. rebuild(): void;
  56900. private _releaseBuffers;
  56901. private _releaseVAOs;
  56902. /**
  56903. * Disposes the particle system and free the associated resources
  56904. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56905. */
  56906. dispose(disposeTexture?: boolean): void;
  56907. /**
  56908. * Clones the particle system.
  56909. * @param name The name of the cloned object
  56910. * @param newEmitter The new emitter to use
  56911. * @returns the cloned particle system
  56912. */
  56913. clone(name: string, newEmitter: any): GPUParticleSystem;
  56914. /**
  56915. * Serializes the particle system to a JSON object.
  56916. * @returns the JSON object
  56917. */
  56918. serialize(): any;
  56919. /**
  56920. * Parses a JSON object to create a GPU particle system.
  56921. * @param parsedParticleSystem The JSON object to parse
  56922. * @param scene The scene to create the particle system in
  56923. * @param rootUrl The root url to use to load external dependencies like texture
  56924. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56925. * @returns the parsed GPU particle system
  56926. */
  56927. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56928. }
  56929. }
  56930. declare module "babylonjs/Particles/particleSystemSet" {
  56931. import { Nullable } from "babylonjs/types";
  56932. import { Color3 } from "babylonjs/Maths/math";
  56933. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56935. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56936. import { Scene, IDisposable } from "babylonjs/scene";
  56937. /**
  56938. * Represents a set of particle systems working together to create a specific effect
  56939. */
  56940. export class ParticleSystemSet implements IDisposable {
  56941. private _emitterCreationOptions;
  56942. private _emitterNode;
  56943. /**
  56944. * Gets the particle system list
  56945. */
  56946. systems: IParticleSystem[];
  56947. /**
  56948. * Gets the emitter node used with this set
  56949. */
  56950. readonly emitterNode: Nullable<TransformNode>;
  56951. /**
  56952. * Creates a new emitter mesh as a sphere
  56953. * @param options defines the options used to create the sphere
  56954. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56955. * @param scene defines the hosting scene
  56956. */
  56957. setEmitterAsSphere(options: {
  56958. diameter: number;
  56959. segments: number;
  56960. color: Color3;
  56961. }, renderingGroupId: number, scene: Scene): void;
  56962. /**
  56963. * Starts all particle systems of the set
  56964. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56965. */
  56966. start(emitter?: AbstractMesh): void;
  56967. /**
  56968. * Release all associated resources
  56969. */
  56970. dispose(): void;
  56971. /**
  56972. * Serialize the set into a JSON compatible object
  56973. * @returns a JSON compatible representation of the set
  56974. */
  56975. serialize(): any;
  56976. /**
  56977. * Parse a new ParticleSystemSet from a serialized source
  56978. * @param data defines a JSON compatible representation of the set
  56979. * @param scene defines the hosting scene
  56980. * @param gpu defines if we want GPU particles or CPU particles
  56981. * @returns a new ParticleSystemSet
  56982. */
  56983. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56984. }
  56985. }
  56986. declare module "babylonjs/Particles/particleHelper" {
  56987. import { Nullable } from "babylonjs/types";
  56988. import { Scene } from "babylonjs/scene";
  56989. import { Vector3 } from "babylonjs/Maths/math";
  56990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56991. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56992. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  56993. /**
  56994. * This class is made for on one-liner static method to help creating particle system set.
  56995. */
  56996. export class ParticleHelper {
  56997. /**
  56998. * Gets or sets base Assets URL
  56999. */
  57000. static BaseAssetsUrl: string;
  57001. /**
  57002. * Create a default particle system that you can tweak
  57003. * @param emitter defines the emitter to use
  57004. * @param capacity defines the system capacity (default is 500 particles)
  57005. * @param scene defines the hosting scene
  57006. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57007. * @returns the new Particle system
  57008. */
  57009. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57010. /**
  57011. * This is the main static method (one-liner) of this helper to create different particle systems
  57012. * @param type This string represents the type to the particle system to create
  57013. * @param scene The scene where the particle system should live
  57014. * @param gpu If the system will use gpu
  57015. * @returns the ParticleSystemSet created
  57016. */
  57017. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57018. /**
  57019. * Static function used to export a particle system to a ParticleSystemSet variable.
  57020. * Please note that the emitter shape is not exported
  57021. * @param systems defines the particle systems to export
  57022. * @returns the created particle system set
  57023. */
  57024. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57025. }
  57026. }
  57027. declare module "babylonjs/Particles/particleSystemComponent" {
  57028. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57029. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  57030. import "babylonjs/Shaders/particles.vertex";
  57031. module "babylonjs/Engines/engine" {
  57032. interface Engine {
  57033. /**
  57034. * Create an effect to use with particle systems.
  57035. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57036. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57037. * @param uniformsNames defines a list of attribute names
  57038. * @param samplers defines an array of string used to represent textures
  57039. * @param defines defines the string containing the defines to use to compile the shaders
  57040. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57041. * @param onCompiled defines a function to call when the effect creation is successful
  57042. * @param onError defines a function to call when the effect creation has failed
  57043. * @returns the new Effect
  57044. */
  57045. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57046. }
  57047. }
  57048. module "babylonjs/Meshes/mesh" {
  57049. interface Mesh {
  57050. /**
  57051. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57052. * @returns an array of IParticleSystem
  57053. */
  57054. getEmittedParticleSystems(): IParticleSystem[];
  57055. /**
  57056. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57057. * @returns an array of IParticleSystem
  57058. */
  57059. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57060. }
  57061. }
  57062. /**
  57063. * @hidden
  57064. */
  57065. export var _IDoNeedToBeInTheBuild: number;
  57066. }
  57067. declare module "babylonjs/Particles/index" {
  57068. export * from "babylonjs/Particles/baseParticleSystem";
  57069. export * from "babylonjs/Particles/EmitterTypes/index";
  57070. export * from "babylonjs/Particles/gpuParticleSystem";
  57071. export * from "babylonjs/Particles/IParticleSystem";
  57072. export * from "babylonjs/Particles/particle";
  57073. export * from "babylonjs/Particles/particleHelper";
  57074. export * from "babylonjs/Particles/particleSystem";
  57075. export * from "babylonjs/Particles/particleSystemComponent";
  57076. export * from "babylonjs/Particles/particleSystemSet";
  57077. export * from "babylonjs/Particles/solidParticle";
  57078. export * from "babylonjs/Particles/solidParticleSystem";
  57079. export * from "babylonjs/Particles/subEmitter";
  57080. }
  57081. declare module "babylonjs/Physics/physicsEngineComponent" {
  57082. import { Nullable } from "babylonjs/types";
  57083. import { Observable, Observer } from "babylonjs/Misc/observable";
  57084. import { Vector3 } from "babylonjs/Maths/math";
  57085. import { Mesh } from "babylonjs/Meshes/mesh";
  57086. import { ISceneComponent } from "babylonjs/sceneComponent";
  57087. import { Scene } from "babylonjs/scene";
  57088. import { Node } from "babylonjs/node";
  57089. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57090. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57091. module "babylonjs/scene" {
  57092. interface Scene {
  57093. /** @hidden (Backing field) */
  57094. _physicsEngine: Nullable<IPhysicsEngine>;
  57095. /**
  57096. * Gets the current physics engine
  57097. * @returns a IPhysicsEngine or null if none attached
  57098. */
  57099. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57100. /**
  57101. * Enables physics to the current scene
  57102. * @param gravity defines the scene's gravity for the physics engine
  57103. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57104. * @return a boolean indicating if the physics engine was initialized
  57105. */
  57106. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57107. /**
  57108. * Disables and disposes the physics engine associated with the scene
  57109. */
  57110. disablePhysicsEngine(): void;
  57111. /**
  57112. * Gets a boolean indicating if there is an active physics engine
  57113. * @returns a boolean indicating if there is an active physics engine
  57114. */
  57115. isPhysicsEnabled(): boolean;
  57116. /**
  57117. * Deletes a physics compound impostor
  57118. * @param compound defines the compound to delete
  57119. */
  57120. deleteCompoundImpostor(compound: any): void;
  57121. /**
  57122. * An event triggered when physic simulation is about to be run
  57123. */
  57124. onBeforePhysicsObservable: Observable<Scene>;
  57125. /**
  57126. * An event triggered when physic simulation has been done
  57127. */
  57128. onAfterPhysicsObservable: Observable<Scene>;
  57129. }
  57130. }
  57131. module "babylonjs/Meshes/abstractMesh" {
  57132. interface AbstractMesh {
  57133. /** @hidden */
  57134. _physicsImpostor: Nullable<PhysicsImpostor>;
  57135. /**
  57136. * Gets or sets impostor used for physic simulation
  57137. * @see http://doc.babylonjs.com/features/physics_engine
  57138. */
  57139. physicsImpostor: Nullable<PhysicsImpostor>;
  57140. /**
  57141. * Gets the current physics impostor
  57142. * @see http://doc.babylonjs.com/features/physics_engine
  57143. * @returns a physics impostor or null
  57144. */
  57145. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57146. /** Apply a physic impulse to the mesh
  57147. * @param force defines the force to apply
  57148. * @param contactPoint defines where to apply the force
  57149. * @returns the current mesh
  57150. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57151. */
  57152. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57153. /**
  57154. * Creates a physic joint between two meshes
  57155. * @param otherMesh defines the other mesh to use
  57156. * @param pivot1 defines the pivot to use on this mesh
  57157. * @param pivot2 defines the pivot to use on the other mesh
  57158. * @param options defines additional options (can be plugin dependent)
  57159. * @returns the current mesh
  57160. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57161. */
  57162. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57163. /** @hidden */
  57164. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57165. }
  57166. }
  57167. /**
  57168. * Defines the physics engine scene component responsible to manage a physics engine
  57169. */
  57170. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57171. /**
  57172. * The component name helpful to identify the component in the list of scene components.
  57173. */
  57174. readonly name: string;
  57175. /**
  57176. * The scene the component belongs to.
  57177. */
  57178. scene: Scene;
  57179. /**
  57180. * Creates a new instance of the component for the given scene
  57181. * @param scene Defines the scene to register the component in
  57182. */
  57183. constructor(scene: Scene);
  57184. /**
  57185. * Registers the component in a given scene
  57186. */
  57187. register(): void;
  57188. /**
  57189. * Rebuilds the elements related to this component in case of
  57190. * context lost for instance.
  57191. */
  57192. rebuild(): void;
  57193. /**
  57194. * Disposes the component and the associated ressources
  57195. */
  57196. dispose(): void;
  57197. }
  57198. }
  57199. declare module "babylonjs/Physics/physicsHelper" {
  57200. import { Nullable } from "babylonjs/types";
  57201. import { Vector3 } from "babylonjs/Maths/math";
  57202. import { Mesh } from "babylonjs/Meshes/mesh";
  57203. import { Scene } from "babylonjs/scene";
  57204. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57205. /**
  57206. * A helper for physics simulations
  57207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57208. */
  57209. export class PhysicsHelper {
  57210. private _scene;
  57211. private _physicsEngine;
  57212. /**
  57213. * Initializes the Physics helper
  57214. * @param scene Babylon.js scene
  57215. */
  57216. constructor(scene: Scene);
  57217. /**
  57218. * Applies a radial explosion impulse
  57219. * @param origin the origin of the explosion
  57220. * @param radiusOrEventOptions the radius or the options of radial explosion
  57221. * @param strength the explosion strength
  57222. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57223. * @returns A physics radial explosion event, or null
  57224. */
  57225. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57226. /**
  57227. * Applies a radial explosion force
  57228. * @param origin the origin of the explosion
  57229. * @param radiusOrEventOptions the radius or the options of radial explosion
  57230. * @param strength the explosion strength
  57231. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57232. * @returns A physics radial explosion event, or null
  57233. */
  57234. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57235. /**
  57236. * Creates a gravitational field
  57237. * @param origin the origin of the explosion
  57238. * @param radiusOrEventOptions the radius or the options of radial explosion
  57239. * @param strength the explosion strength
  57240. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57241. * @returns A physics gravitational field event, or null
  57242. */
  57243. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57244. /**
  57245. * Creates a physics updraft event
  57246. * @param origin the origin of the updraft
  57247. * @param radiusOrEventOptions the radius or the options of the updraft
  57248. * @param strength the strength of the updraft
  57249. * @param height the height of the updraft
  57250. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57251. * @returns A physics updraft event, or null
  57252. */
  57253. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57254. /**
  57255. * Creates a physics vortex event
  57256. * @param origin the of the vortex
  57257. * @param radiusOrEventOptions the radius or the options of the vortex
  57258. * @param strength the strength of the vortex
  57259. * @param height the height of the vortex
  57260. * @returns a Physics vortex event, or null
  57261. * A physics vortex event or null
  57262. */
  57263. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57264. }
  57265. /**
  57266. * Represents a physics radial explosion event
  57267. */
  57268. class PhysicsRadialExplosionEvent {
  57269. private _scene;
  57270. private _options;
  57271. private _sphere;
  57272. private _dataFetched;
  57273. /**
  57274. * Initializes a radial explosioin event
  57275. * @param _scene BabylonJS scene
  57276. * @param _options The options for the vortex event
  57277. */
  57278. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57279. /**
  57280. * Returns the data related to the radial explosion event (sphere).
  57281. * @returns The radial explosion event data
  57282. */
  57283. getData(): PhysicsRadialExplosionEventData;
  57284. /**
  57285. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57286. * @param impostor A physics imposter
  57287. * @param origin the origin of the explosion
  57288. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57289. */
  57290. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57291. /**
  57292. * Triggers affecterd impostors callbacks
  57293. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57294. */
  57295. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57296. /**
  57297. * Disposes the sphere.
  57298. * @param force Specifies if the sphere should be disposed by force
  57299. */
  57300. dispose(force?: boolean): void;
  57301. /*** Helpers ***/
  57302. private _prepareSphere;
  57303. private _intersectsWithSphere;
  57304. }
  57305. /**
  57306. * Represents a gravitational field event
  57307. */
  57308. class PhysicsGravitationalFieldEvent {
  57309. private _physicsHelper;
  57310. private _scene;
  57311. private _origin;
  57312. private _options;
  57313. private _tickCallback;
  57314. private _sphere;
  57315. private _dataFetched;
  57316. /**
  57317. * Initializes the physics gravitational field event
  57318. * @param _physicsHelper A physics helper
  57319. * @param _scene BabylonJS scene
  57320. * @param _origin The origin position of the gravitational field event
  57321. * @param _options The options for the vortex event
  57322. */
  57323. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57324. /**
  57325. * Returns the data related to the gravitational field event (sphere).
  57326. * @returns A gravitational field event
  57327. */
  57328. getData(): PhysicsGravitationalFieldEventData;
  57329. /**
  57330. * Enables the gravitational field.
  57331. */
  57332. enable(): void;
  57333. /**
  57334. * Disables the gravitational field.
  57335. */
  57336. disable(): void;
  57337. /**
  57338. * Disposes the sphere.
  57339. * @param force The force to dispose from the gravitational field event
  57340. */
  57341. dispose(force?: boolean): void;
  57342. private _tick;
  57343. }
  57344. /**
  57345. * Represents a physics updraft event
  57346. */
  57347. class PhysicsUpdraftEvent {
  57348. private _scene;
  57349. private _origin;
  57350. private _options;
  57351. private _physicsEngine;
  57352. private _originTop;
  57353. private _originDirection;
  57354. private _tickCallback;
  57355. private _cylinder;
  57356. private _cylinderPosition;
  57357. private _dataFetched;
  57358. /**
  57359. * Initializes the physics updraft event
  57360. * @param _scene BabylonJS scene
  57361. * @param _origin The origin position of the updraft
  57362. * @param _options The options for the updraft event
  57363. */
  57364. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57365. /**
  57366. * Returns the data related to the updraft event (cylinder).
  57367. * @returns A physics updraft event
  57368. */
  57369. getData(): PhysicsUpdraftEventData;
  57370. /**
  57371. * Enables the updraft.
  57372. */
  57373. enable(): void;
  57374. /**
  57375. * Disables the updraft.
  57376. */
  57377. disable(): void;
  57378. /**
  57379. * Disposes the cylinder.
  57380. * @param force Specifies if the updraft should be disposed by force
  57381. */
  57382. dispose(force?: boolean): void;
  57383. private getImpostorHitData;
  57384. private _tick;
  57385. /*** Helpers ***/
  57386. private _prepareCylinder;
  57387. private _intersectsWithCylinder;
  57388. }
  57389. /**
  57390. * Represents a physics vortex event
  57391. */
  57392. class PhysicsVortexEvent {
  57393. private _scene;
  57394. private _origin;
  57395. private _options;
  57396. private _physicsEngine;
  57397. private _originTop;
  57398. private _tickCallback;
  57399. private _cylinder;
  57400. private _cylinderPosition;
  57401. private _dataFetched;
  57402. /**
  57403. * Initializes the physics vortex event
  57404. * @param _scene The BabylonJS scene
  57405. * @param _origin The origin position of the vortex
  57406. * @param _options The options for the vortex event
  57407. */
  57408. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57409. /**
  57410. * Returns the data related to the vortex event (cylinder).
  57411. * @returns The physics vortex event data
  57412. */
  57413. getData(): PhysicsVortexEventData;
  57414. /**
  57415. * Enables the vortex.
  57416. */
  57417. enable(): void;
  57418. /**
  57419. * Disables the cortex.
  57420. */
  57421. disable(): void;
  57422. /**
  57423. * Disposes the sphere.
  57424. * @param force
  57425. */
  57426. dispose(force?: boolean): void;
  57427. private getImpostorHitData;
  57428. private _tick;
  57429. /*** Helpers ***/
  57430. private _prepareCylinder;
  57431. private _intersectsWithCylinder;
  57432. }
  57433. /**
  57434. * Options fot the radial explosion event
  57435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57436. */
  57437. export class PhysicsRadialExplosionEventOptions {
  57438. /**
  57439. * The radius of the sphere for the radial explosion.
  57440. */
  57441. radius: number;
  57442. /**
  57443. * The strenth of the explosion.
  57444. */
  57445. strength: number;
  57446. /**
  57447. * The strenght of the force in correspondence to the distance of the affected object
  57448. */
  57449. falloff: PhysicsRadialImpulseFalloff;
  57450. /**
  57451. * Sphere options for the radial explosion.
  57452. */
  57453. sphere: {
  57454. segments: number;
  57455. diameter: number;
  57456. };
  57457. /**
  57458. * Sphere options for the radial explosion.
  57459. */
  57460. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57461. }
  57462. /**
  57463. * Options fot the updraft event
  57464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57465. */
  57466. export class PhysicsUpdraftEventOptions {
  57467. /**
  57468. * The radius of the cylinder for the vortex
  57469. */
  57470. radius: number;
  57471. /**
  57472. * The strenth of the updraft.
  57473. */
  57474. strength: number;
  57475. /**
  57476. * The height of the cylinder for the updraft.
  57477. */
  57478. height: number;
  57479. /**
  57480. * The mode for the the updraft.
  57481. */
  57482. updraftMode: PhysicsUpdraftMode;
  57483. }
  57484. /**
  57485. * Options fot the vortex event
  57486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57487. */
  57488. export class PhysicsVortexEventOptions {
  57489. /**
  57490. * The radius of the cylinder for the vortex
  57491. */
  57492. radius: number;
  57493. /**
  57494. * The strenth of the vortex.
  57495. */
  57496. strength: number;
  57497. /**
  57498. * The height of the cylinder for the vortex.
  57499. */
  57500. height: number;
  57501. /**
  57502. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57503. */
  57504. centripetalForceThreshold: number;
  57505. /**
  57506. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57507. */
  57508. centripetalForceMultiplier: number;
  57509. /**
  57510. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57511. */
  57512. centrifugalForceMultiplier: number;
  57513. /**
  57514. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57515. */
  57516. updraftForceMultiplier: number;
  57517. }
  57518. /**
  57519. * The strenght of the force in correspondence to the distance of the affected object
  57520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57521. */
  57522. export enum PhysicsRadialImpulseFalloff {
  57523. /** Defines that impulse is constant in strength across it's whole radius */
  57524. Constant = 0,
  57525. /** Defines that impulse gets weaker if it's further from the origin */
  57526. Linear = 1
  57527. }
  57528. /**
  57529. * The strength of the force in correspondence to the distance of the affected object
  57530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57531. */
  57532. export enum PhysicsUpdraftMode {
  57533. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57534. Center = 0,
  57535. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57536. Perpendicular = 1
  57537. }
  57538. /**
  57539. * Interface for a physics hit data
  57540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57541. */
  57542. export interface PhysicsHitData {
  57543. /**
  57544. * The force applied at the contact point
  57545. */
  57546. force: Vector3;
  57547. /**
  57548. * The contact point
  57549. */
  57550. contactPoint: Vector3;
  57551. /**
  57552. * The distance from the origin to the contact point
  57553. */
  57554. distanceFromOrigin: number;
  57555. }
  57556. /**
  57557. * Interface for radial explosion event data
  57558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57559. */
  57560. export interface PhysicsRadialExplosionEventData {
  57561. /**
  57562. * A sphere used for the radial explosion event
  57563. */
  57564. sphere: Mesh;
  57565. }
  57566. /**
  57567. * Interface for gravitational field event data
  57568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57569. */
  57570. export interface PhysicsGravitationalFieldEventData {
  57571. /**
  57572. * A sphere mesh used for the gravitational field event
  57573. */
  57574. sphere: Mesh;
  57575. }
  57576. /**
  57577. * Interface for updraft event data
  57578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57579. */
  57580. export interface PhysicsUpdraftEventData {
  57581. /**
  57582. * A cylinder used for the updraft event
  57583. */
  57584. cylinder: Mesh;
  57585. }
  57586. /**
  57587. * Interface for vortex event data
  57588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57589. */
  57590. export interface PhysicsVortexEventData {
  57591. /**
  57592. * A cylinder used for the vortex event
  57593. */
  57594. cylinder: Mesh;
  57595. }
  57596. /**
  57597. * Interface for an affected physics impostor
  57598. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57599. */
  57600. export interface PhysicsAffectedImpostorWithData {
  57601. /**
  57602. * The impostor affected by the effect
  57603. */
  57604. impostor: PhysicsImpostor;
  57605. /**
  57606. * The data about the hit/horce from the explosion
  57607. */
  57608. hitData: PhysicsHitData;
  57609. }
  57610. }
  57611. declare module "babylonjs/Physics/Plugins/index" {
  57612. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57613. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57614. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57615. }
  57616. declare module "babylonjs/Physics/index" {
  57617. export * from "babylonjs/Physics/IPhysicsEngine";
  57618. export * from "babylonjs/Physics/physicsEngine";
  57619. export * from "babylonjs/Physics/physicsEngineComponent";
  57620. export * from "babylonjs/Physics/physicsHelper";
  57621. export * from "babylonjs/Physics/physicsImpostor";
  57622. export * from "babylonjs/Physics/physicsJoint";
  57623. export * from "babylonjs/Physics/Plugins/index";
  57624. }
  57625. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57626. /** @hidden */
  57627. export var blackAndWhitePixelShader: {
  57628. name: string;
  57629. shader: string;
  57630. };
  57631. }
  57632. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57633. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57634. import { Camera } from "babylonjs/Cameras/camera";
  57635. import { Engine } from "babylonjs/Engines/engine";
  57636. import "babylonjs/Shaders/blackAndWhite.fragment";
  57637. /**
  57638. * Post process used to render in black and white
  57639. */
  57640. export class BlackAndWhitePostProcess extends PostProcess {
  57641. /**
  57642. * Linear about to convert he result to black and white (default: 1)
  57643. */
  57644. degree: number;
  57645. /**
  57646. * Creates a black and white post process
  57647. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57648. * @param name The name of the effect.
  57649. * @param options The required width/height ratio to downsize to before computing the render pass.
  57650. * @param camera The camera to apply the render pass to.
  57651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57652. * @param engine The engine which the post process will be applied. (default: current engine)
  57653. * @param reusable If the post process can be reused on the same frame. (default: false)
  57654. */
  57655. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57656. }
  57657. }
  57658. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  57659. import { Nullable } from "babylonjs/types";
  57660. import { Camera } from "babylonjs/Cameras/camera";
  57661. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57662. import { Engine } from "babylonjs/Engines/engine";
  57663. /**
  57664. * This represents a set of one or more post processes in Babylon.
  57665. * A post process can be used to apply a shader to a texture after it is rendered.
  57666. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57667. */
  57668. export class PostProcessRenderEffect {
  57669. private _postProcesses;
  57670. private _getPostProcesses;
  57671. private _singleInstance;
  57672. private _cameras;
  57673. private _indicesForCamera;
  57674. /**
  57675. * Name of the effect
  57676. * @hidden
  57677. */
  57678. _name: string;
  57679. /**
  57680. * Instantiates a post process render effect.
  57681. * A post process can be used to apply a shader to a texture after it is rendered.
  57682. * @param engine The engine the effect is tied to
  57683. * @param name The name of the effect
  57684. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57685. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57686. */
  57687. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57688. /**
  57689. * Checks if all the post processes in the effect are supported.
  57690. */
  57691. readonly isSupported: boolean;
  57692. /**
  57693. * Updates the current state of the effect
  57694. * @hidden
  57695. */
  57696. _update(): void;
  57697. /**
  57698. * Attaches the effect on cameras
  57699. * @param cameras The camera to attach to.
  57700. * @hidden
  57701. */
  57702. _attachCameras(cameras: Camera): void;
  57703. /**
  57704. * Attaches the effect on cameras
  57705. * @param cameras The camera to attach to.
  57706. * @hidden
  57707. */
  57708. _attachCameras(cameras: Camera[]): void;
  57709. /**
  57710. * Detaches the effect on cameras
  57711. * @param cameras The camera to detatch from.
  57712. * @hidden
  57713. */
  57714. _detachCameras(cameras: Camera): void;
  57715. /**
  57716. * Detatches the effect on cameras
  57717. * @param cameras The camera to detatch from.
  57718. * @hidden
  57719. */
  57720. _detachCameras(cameras: Camera[]): void;
  57721. /**
  57722. * Enables the effect on given cameras
  57723. * @param cameras The camera to enable.
  57724. * @hidden
  57725. */
  57726. _enable(cameras: Camera): void;
  57727. /**
  57728. * Enables the effect on given cameras
  57729. * @param cameras The camera to enable.
  57730. * @hidden
  57731. */
  57732. _enable(cameras: Nullable<Camera[]>): void;
  57733. /**
  57734. * Disables the effect on the given cameras
  57735. * @param cameras The camera to disable.
  57736. * @hidden
  57737. */
  57738. _disable(cameras: Camera): void;
  57739. /**
  57740. * Disables the effect on the given cameras
  57741. * @param cameras The camera to disable.
  57742. * @hidden
  57743. */
  57744. _disable(cameras: Nullable<Camera[]>): void;
  57745. /**
  57746. * Gets a list of the post processes contained in the effect.
  57747. * @param camera The camera to get the post processes on.
  57748. * @returns The list of the post processes in the effect.
  57749. */
  57750. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57751. }
  57752. }
  57753. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  57754. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57755. /** @hidden */
  57756. export var extractHighlightsPixelShader: {
  57757. name: string;
  57758. shader: string;
  57759. };
  57760. }
  57761. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  57762. import { Nullable } from "babylonjs/types";
  57763. import { Camera } from "babylonjs/Cameras/camera";
  57764. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57765. import { Engine } from "babylonjs/Engines/engine";
  57766. import "babylonjs/Shaders/extractHighlights.fragment";
  57767. /**
  57768. * 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.
  57769. */
  57770. export class ExtractHighlightsPostProcess extends PostProcess {
  57771. /**
  57772. * The luminance threshold, pixels below this value will be set to black.
  57773. */
  57774. threshold: number;
  57775. /** @hidden */
  57776. _exposure: number;
  57777. /**
  57778. * Post process which has the input texture to be used when performing highlight extraction
  57779. * @hidden
  57780. */
  57781. _inputPostProcess: Nullable<PostProcess>;
  57782. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57783. }
  57784. }
  57785. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  57786. /** @hidden */
  57787. export var bloomMergePixelShader: {
  57788. name: string;
  57789. shader: string;
  57790. };
  57791. }
  57792. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  57793. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57794. import { Nullable } from "babylonjs/types";
  57795. import { Engine } from "babylonjs/Engines/engine";
  57796. import { Camera } from "babylonjs/Cameras/camera";
  57797. import "babylonjs/Shaders/bloomMerge.fragment";
  57798. /**
  57799. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57800. */
  57801. export class BloomMergePostProcess extends PostProcess {
  57802. /** Weight of the bloom to be added to the original input. */
  57803. weight: number;
  57804. /**
  57805. * Creates a new instance of @see BloomMergePostProcess
  57806. * @param name The name of the effect.
  57807. * @param originalFromInput Post process which's input will be used for the merge.
  57808. * @param blurred Blurred highlights post process which's output will be used.
  57809. * @param weight Weight of the bloom to be added to the original input.
  57810. * @param options The required width/height ratio to downsize to before computing the render pass.
  57811. * @param camera The camera to apply the render pass to.
  57812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57813. * @param engine The engine which the post process will be applied. (default: current engine)
  57814. * @param reusable If the post process can be reused on the same frame. (default: false)
  57815. * @param textureType Type of textures used when performing the post process. (default: 0)
  57816. * @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)
  57817. */
  57818. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57819. /** Weight of the bloom to be added to the original input. */
  57820. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57821. }
  57822. }
  57823. declare module "babylonjs/PostProcesses/bloomEffect" {
  57824. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57825. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57826. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57827. import { Camera } from "babylonjs/Cameras/camera";
  57828. import { Scene } from "babylonjs/scene";
  57829. /**
  57830. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57831. */
  57832. export class BloomEffect extends PostProcessRenderEffect {
  57833. private bloomScale;
  57834. /**
  57835. * @hidden Internal
  57836. */
  57837. _effects: Array<PostProcess>;
  57838. /**
  57839. * @hidden Internal
  57840. */
  57841. _downscale: ExtractHighlightsPostProcess;
  57842. private _blurX;
  57843. private _blurY;
  57844. private _merge;
  57845. /**
  57846. * The luminance threshold to find bright areas of the image to bloom.
  57847. */
  57848. threshold: number;
  57849. /**
  57850. * The strength of the bloom.
  57851. */
  57852. weight: number;
  57853. /**
  57854. * Specifies the size of the bloom blur kernel, relative to the final output size
  57855. */
  57856. kernel: number;
  57857. /**
  57858. * Creates a new instance of @see BloomEffect
  57859. * @param scene The scene the effect belongs to.
  57860. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57861. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57862. * @param bloomWeight The the strength of bloom.
  57863. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57864. * @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)
  57865. */
  57866. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57867. /**
  57868. * Disposes each of the internal effects for a given camera.
  57869. * @param camera The camera to dispose the effect on.
  57870. */
  57871. disposeEffects(camera: Camera): void;
  57872. /**
  57873. * @hidden Internal
  57874. */
  57875. _updateEffects(): void;
  57876. /**
  57877. * Internal
  57878. * @returns if all the contained post processes are ready.
  57879. * @hidden
  57880. */
  57881. _isReady(): boolean;
  57882. }
  57883. }
  57884. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  57885. /** @hidden */
  57886. export var chromaticAberrationPixelShader: {
  57887. name: string;
  57888. shader: string;
  57889. };
  57890. }
  57891. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  57892. import { Vector2 } from "babylonjs/Maths/math";
  57893. import { Nullable } from "babylonjs/types";
  57894. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57895. import { Camera } from "babylonjs/Cameras/camera";
  57896. import { Engine } from "babylonjs/Engines/engine";
  57897. import "babylonjs/Shaders/chromaticAberration.fragment";
  57898. /**
  57899. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57900. */
  57901. export class ChromaticAberrationPostProcess extends PostProcess {
  57902. /**
  57903. * The amount of seperation of rgb channels (default: 30)
  57904. */
  57905. aberrationAmount: number;
  57906. /**
  57907. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57908. */
  57909. radialIntensity: number;
  57910. /**
  57911. * 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))
  57912. */
  57913. direction: Vector2;
  57914. /**
  57915. * 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))
  57916. */
  57917. centerPosition: Vector2;
  57918. /**
  57919. * Creates a new instance ChromaticAberrationPostProcess
  57920. * @param name The name of the effect.
  57921. * @param screenWidth The width of the screen to apply the effect on.
  57922. * @param screenHeight The height of the screen to apply the effect on.
  57923. * @param options The required width/height ratio to downsize to before computing the render pass.
  57924. * @param camera The camera to apply the render pass to.
  57925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57926. * @param engine The engine which the post process will be applied. (default: current engine)
  57927. * @param reusable If the post process can be reused on the same frame. (default: false)
  57928. * @param textureType Type of textures used when performing the post process. (default: 0)
  57929. * @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)
  57930. */
  57931. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57932. }
  57933. }
  57934. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  57935. /** @hidden */
  57936. export var circleOfConfusionPixelShader: {
  57937. name: string;
  57938. shader: string;
  57939. };
  57940. }
  57941. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  57942. import { Nullable } from "babylonjs/types";
  57943. import { Engine } from "babylonjs/Engines/engine";
  57944. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57945. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57946. import { Camera } from "babylonjs/Cameras/camera";
  57947. import "babylonjs/Shaders/circleOfConfusion.fragment";
  57948. /**
  57949. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57950. */
  57951. export class CircleOfConfusionPostProcess extends PostProcess {
  57952. /**
  57953. * 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.
  57954. */
  57955. lensSize: number;
  57956. /**
  57957. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57958. */
  57959. fStop: number;
  57960. /**
  57961. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57962. */
  57963. focusDistance: number;
  57964. /**
  57965. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57966. */
  57967. focalLength: number;
  57968. private _depthTexture;
  57969. /**
  57970. * Creates a new instance CircleOfConfusionPostProcess
  57971. * @param name The name of the effect.
  57972. * @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.
  57973. * @param options The required width/height ratio to downsize to before computing the render pass.
  57974. * @param camera The camera to apply the render pass to.
  57975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57976. * @param engine The engine which the post process will be applied. (default: current engine)
  57977. * @param reusable If the post process can be reused on the same frame. (default: false)
  57978. * @param textureType Type of textures used when performing the post process. (default: 0)
  57979. * @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)
  57980. */
  57981. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57982. /**
  57983. * 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.
  57984. */
  57985. depthTexture: RenderTargetTexture;
  57986. }
  57987. }
  57988. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  57989. /** @hidden */
  57990. export var colorCorrectionPixelShader: {
  57991. name: string;
  57992. shader: string;
  57993. };
  57994. }
  57995. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  57996. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57997. import { Engine } from "babylonjs/Engines/engine";
  57998. import { Camera } from "babylonjs/Cameras/camera";
  57999. import "babylonjs/Shaders/colorCorrection.fragment";
  58000. /**
  58001. *
  58002. * This post-process allows the modification of rendered colors by using
  58003. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58004. *
  58005. * The object needs to be provided an url to a texture containing the color
  58006. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58007. * Use an image editing software to tweak the LUT to match your needs.
  58008. *
  58009. * For an example of a color LUT, see here:
  58010. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58011. * For explanations on color grading, see here:
  58012. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58013. *
  58014. */
  58015. export class ColorCorrectionPostProcess extends PostProcess {
  58016. private _colorTableTexture;
  58017. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58018. }
  58019. }
  58020. declare module "babylonjs/Shaders/convolution.fragment" {
  58021. /** @hidden */
  58022. export var convolutionPixelShader: {
  58023. name: string;
  58024. shader: string;
  58025. };
  58026. }
  58027. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  58028. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58029. import { Nullable } from "babylonjs/types";
  58030. import { Camera } from "babylonjs/Cameras/camera";
  58031. import { Engine } from "babylonjs/Engines/engine";
  58032. import "babylonjs/Shaders/convolution.fragment";
  58033. /**
  58034. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58035. * input texture to perform effects such as edge detection or sharpening
  58036. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58037. */
  58038. export class ConvolutionPostProcess extends PostProcess {
  58039. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58040. kernel: number[];
  58041. /**
  58042. * Creates a new instance ConvolutionPostProcess
  58043. * @param name The name of the effect.
  58044. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58045. * @param options The required width/height ratio to downsize to before computing the render pass.
  58046. * @param camera The camera to apply the render pass to.
  58047. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58048. * @param engine The engine which the post process will be applied. (default: current engine)
  58049. * @param reusable If the post process can be reused on the same frame. (default: false)
  58050. * @param textureType Type of textures used when performing the post process. (default: 0)
  58051. */
  58052. constructor(name: string,
  58053. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58054. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58055. /**
  58056. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58057. */
  58058. static EdgeDetect0Kernel: number[];
  58059. /**
  58060. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58061. */
  58062. static EdgeDetect1Kernel: number[];
  58063. /**
  58064. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58065. */
  58066. static EdgeDetect2Kernel: number[];
  58067. /**
  58068. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58069. */
  58070. static SharpenKernel: number[];
  58071. /**
  58072. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58073. */
  58074. static EmbossKernel: number[];
  58075. /**
  58076. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58077. */
  58078. static GaussianKernel: number[];
  58079. }
  58080. }
  58081. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  58082. import { Nullable } from "babylonjs/types";
  58083. import { Vector2 } from "babylonjs/Maths/math";
  58084. import { Camera } from "babylonjs/Cameras/camera";
  58085. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58086. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  58087. import { Engine } from "babylonjs/Engines/engine";
  58088. import { Scene } from "babylonjs/scene";
  58089. /**
  58090. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58091. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58092. * based on samples that have a large difference in distance than the center pixel.
  58093. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58094. */
  58095. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58096. direction: Vector2;
  58097. /**
  58098. * Creates a new instance CircleOfConfusionPostProcess
  58099. * @param name The name of the effect.
  58100. * @param scene The scene the effect belongs to.
  58101. * @param direction The direction the blur should be applied.
  58102. * @param kernel The size of the kernel used to blur.
  58103. * @param options The required width/height ratio to downsize to before computing the render pass.
  58104. * @param camera The camera to apply the render pass to.
  58105. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58106. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58107. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58108. * @param engine The engine which the post process will be applied. (default: current engine)
  58109. * @param reusable If the post process can be reused on the same frame. (default: false)
  58110. * @param textureType Type of textures used when performing the post process. (default: 0)
  58111. * @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)
  58112. */
  58113. 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);
  58114. }
  58115. }
  58116. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  58117. /** @hidden */
  58118. export var depthOfFieldMergePixelShader: {
  58119. name: string;
  58120. shader: string;
  58121. };
  58122. }
  58123. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  58124. import { Nullable } from "babylonjs/types";
  58125. import { Camera } from "babylonjs/Cameras/camera";
  58126. import { Effect } from "babylonjs/Materials/effect";
  58127. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58128. import { Engine } from "babylonjs/Engines/engine";
  58129. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  58130. /**
  58131. * Options to be set when merging outputs from the default pipeline.
  58132. */
  58133. export class DepthOfFieldMergePostProcessOptions {
  58134. /**
  58135. * The original image to merge on top of
  58136. */
  58137. originalFromInput: PostProcess;
  58138. /**
  58139. * Parameters to perform the merge of the depth of field effect
  58140. */
  58141. depthOfField?: {
  58142. circleOfConfusion: PostProcess;
  58143. blurSteps: Array<PostProcess>;
  58144. };
  58145. /**
  58146. * Parameters to perform the merge of bloom effect
  58147. */
  58148. bloom?: {
  58149. blurred: PostProcess;
  58150. weight: number;
  58151. };
  58152. }
  58153. /**
  58154. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58155. */
  58156. export class DepthOfFieldMergePostProcess extends PostProcess {
  58157. private blurSteps;
  58158. /**
  58159. * Creates a new instance of DepthOfFieldMergePostProcess
  58160. * @param name The name of the effect.
  58161. * @param originalFromInput Post process which's input will be used for the merge.
  58162. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58163. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58164. * @param options The required width/height ratio to downsize to before computing the render pass.
  58165. * @param camera The camera to apply the render pass to.
  58166. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58167. * @param engine The engine which the post process will be applied. (default: current engine)
  58168. * @param reusable If the post process can be reused on the same frame. (default: false)
  58169. * @param textureType Type of textures used when performing the post process. (default: 0)
  58170. * @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)
  58171. */
  58172. 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);
  58173. /**
  58174. * Updates the effect with the current post process compile time values and recompiles the shader.
  58175. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58176. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58177. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58178. * @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
  58179. * @param onCompiled Called when the shader has been compiled.
  58180. * @param onError Called if there is an error when compiling a shader.
  58181. */
  58182. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58183. }
  58184. }
  58185. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  58186. import { Nullable } from "babylonjs/types";
  58187. import { Camera } from "babylonjs/Cameras/camera";
  58188. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58189. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58190. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58191. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  58192. import { Scene } from "babylonjs/scene";
  58193. /**
  58194. * Specifies the level of max blur that should be applied when using the depth of field effect
  58195. */
  58196. export enum DepthOfFieldEffectBlurLevel {
  58197. /**
  58198. * Subtle blur
  58199. */
  58200. Low = 0,
  58201. /**
  58202. * Medium blur
  58203. */
  58204. Medium = 1,
  58205. /**
  58206. * Large blur
  58207. */
  58208. High = 2
  58209. }
  58210. /**
  58211. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58212. */
  58213. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58214. private _circleOfConfusion;
  58215. /**
  58216. * @hidden Internal, blurs from high to low
  58217. */
  58218. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58219. private _depthOfFieldBlurY;
  58220. private _dofMerge;
  58221. /**
  58222. * @hidden Internal post processes in depth of field effect
  58223. */
  58224. _effects: Array<PostProcess>;
  58225. /**
  58226. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58227. */
  58228. focalLength: number;
  58229. /**
  58230. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58231. */
  58232. fStop: number;
  58233. /**
  58234. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58235. */
  58236. focusDistance: number;
  58237. /**
  58238. * 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.
  58239. */
  58240. lensSize: number;
  58241. /**
  58242. * Creates a new instance DepthOfFieldEffect
  58243. * @param scene The scene the effect belongs to.
  58244. * @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.
  58245. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58246. * @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)
  58247. */
  58248. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58249. /**
  58250. * Get the current class name of the current effet
  58251. * @returns "DepthOfFieldEffect"
  58252. */
  58253. getClassName(): string;
  58254. /**
  58255. * 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.
  58256. */
  58257. depthTexture: RenderTargetTexture;
  58258. /**
  58259. * Disposes each of the internal effects for a given camera.
  58260. * @param camera The camera to dispose the effect on.
  58261. */
  58262. disposeEffects(camera: Camera): void;
  58263. /**
  58264. * @hidden Internal
  58265. */
  58266. _updateEffects(): void;
  58267. /**
  58268. * Internal
  58269. * @returns if all the contained post processes are ready.
  58270. * @hidden
  58271. */
  58272. _isReady(): boolean;
  58273. }
  58274. }
  58275. declare module "babylonjs/Shaders/displayPass.fragment" {
  58276. /** @hidden */
  58277. export var displayPassPixelShader: {
  58278. name: string;
  58279. shader: string;
  58280. };
  58281. }
  58282. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  58283. import { Nullable } from "babylonjs/types";
  58284. import { Camera } from "babylonjs/Cameras/camera";
  58285. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58286. import { Engine } from "babylonjs/Engines/engine";
  58287. import "babylonjs/Shaders/displayPass.fragment";
  58288. /**
  58289. * DisplayPassPostProcess which produces an output the same as it's input
  58290. */
  58291. export class DisplayPassPostProcess extends PostProcess {
  58292. /**
  58293. * Creates the DisplayPassPostProcess
  58294. * @param name The name of the effect.
  58295. * @param options The required width/height ratio to downsize to before computing the render pass.
  58296. * @param camera The camera to apply the render pass to.
  58297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58298. * @param engine The engine which the post process will be applied. (default: current engine)
  58299. * @param reusable If the post process can be reused on the same frame. (default: false)
  58300. */
  58301. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58302. }
  58303. }
  58304. declare module "babylonjs/Shaders/filter.fragment" {
  58305. /** @hidden */
  58306. export var filterPixelShader: {
  58307. name: string;
  58308. shader: string;
  58309. };
  58310. }
  58311. declare module "babylonjs/PostProcesses/filterPostProcess" {
  58312. import { Nullable } from "babylonjs/types";
  58313. import { Matrix } from "babylonjs/Maths/math";
  58314. import { Camera } from "babylonjs/Cameras/camera";
  58315. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58316. import { Engine } from "babylonjs/Engines/engine";
  58317. import "babylonjs/Shaders/filter.fragment";
  58318. /**
  58319. * Applies a kernel filter to the image
  58320. */
  58321. export class FilterPostProcess extends PostProcess {
  58322. /** The matrix to be applied to the image */
  58323. kernelMatrix: Matrix;
  58324. /**
  58325. *
  58326. * @param name The name of the effect.
  58327. * @param kernelMatrix The matrix to be applied to the image
  58328. * @param options The required width/height ratio to downsize to before computing the render pass.
  58329. * @param camera The camera to apply the render pass to.
  58330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58331. * @param engine The engine which the post process will be applied. (default: current engine)
  58332. * @param reusable If the post process can be reused on the same frame. (default: false)
  58333. */
  58334. constructor(name: string,
  58335. /** The matrix to be applied to the image */
  58336. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58337. }
  58338. }
  58339. declare module "babylonjs/Shaders/fxaa.fragment" {
  58340. /** @hidden */
  58341. export var fxaaPixelShader: {
  58342. name: string;
  58343. shader: string;
  58344. };
  58345. }
  58346. declare module "babylonjs/Shaders/fxaa.vertex" {
  58347. /** @hidden */
  58348. export var fxaaVertexShader: {
  58349. name: string;
  58350. shader: string;
  58351. };
  58352. }
  58353. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  58354. import { Nullable } from "babylonjs/types";
  58355. import { Camera } from "babylonjs/Cameras/camera";
  58356. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58357. import { Engine } from "babylonjs/Engines/engine";
  58358. import "babylonjs/Shaders/fxaa.fragment";
  58359. import "babylonjs/Shaders/fxaa.vertex";
  58360. /**
  58361. * Fxaa post process
  58362. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58363. */
  58364. export class FxaaPostProcess extends PostProcess {
  58365. /** @hidden */
  58366. texelWidth: number;
  58367. /** @hidden */
  58368. texelHeight: number;
  58369. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58370. private _getDefines;
  58371. }
  58372. }
  58373. declare module "babylonjs/Shaders/grain.fragment" {
  58374. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58375. /** @hidden */
  58376. export var grainPixelShader: {
  58377. name: string;
  58378. shader: string;
  58379. };
  58380. }
  58381. declare module "babylonjs/PostProcesses/grainPostProcess" {
  58382. import { Nullable } from "babylonjs/types";
  58383. import { Camera } from "babylonjs/Cameras/camera";
  58384. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58385. import { Engine } from "babylonjs/Engines/engine";
  58386. import "babylonjs/Shaders/grain.fragment";
  58387. /**
  58388. * The GrainPostProcess adds noise to the image at mid luminance levels
  58389. */
  58390. export class GrainPostProcess extends PostProcess {
  58391. /**
  58392. * The intensity of the grain added (default: 30)
  58393. */
  58394. intensity: number;
  58395. /**
  58396. * If the grain should be randomized on every frame
  58397. */
  58398. animated: boolean;
  58399. /**
  58400. * Creates a new instance of @see GrainPostProcess
  58401. * @param name The name of the effect.
  58402. * @param options The required width/height ratio to downsize to before computing the render pass.
  58403. * @param camera The camera to apply the render pass to.
  58404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58405. * @param engine The engine which the post process will be applied. (default: current engine)
  58406. * @param reusable If the post process can be reused on the same frame. (default: false)
  58407. * @param textureType Type of textures used when performing the post process. (default: 0)
  58408. * @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)
  58409. */
  58410. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58411. }
  58412. }
  58413. declare module "babylonjs/Shaders/highlights.fragment" {
  58414. /** @hidden */
  58415. export var highlightsPixelShader: {
  58416. name: string;
  58417. shader: string;
  58418. };
  58419. }
  58420. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  58421. import { Nullable } from "babylonjs/types";
  58422. import { Camera } from "babylonjs/Cameras/camera";
  58423. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58424. import { Engine } from "babylonjs/Engines/engine";
  58425. import "babylonjs/Shaders/highlights.fragment";
  58426. /**
  58427. * Extracts highlights from the image
  58428. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58429. */
  58430. export class HighlightsPostProcess extends PostProcess {
  58431. /**
  58432. * Extracts highlights from the image
  58433. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58434. * @param name The name of the effect.
  58435. * @param options The required width/height ratio to downsize to before computing the render pass.
  58436. * @param camera The camera to apply the render pass to.
  58437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58438. * @param engine The engine which the post process will be applied. (default: current engine)
  58439. * @param reusable If the post process can be reused on the same frame. (default: false)
  58440. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58441. */
  58442. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58443. }
  58444. }
  58445. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  58446. /** @hidden */
  58447. export var mrtFragmentDeclaration: {
  58448. name: string;
  58449. shader: string;
  58450. };
  58451. }
  58452. declare module "babylonjs/Shaders/geometry.fragment" {
  58453. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  58454. /** @hidden */
  58455. export var geometryPixelShader: {
  58456. name: string;
  58457. shader: string;
  58458. };
  58459. }
  58460. declare module "babylonjs/Shaders/geometry.vertex" {
  58461. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58462. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58463. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58464. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58466. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58467. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58468. /** @hidden */
  58469. export var geometryVertexShader: {
  58470. name: string;
  58471. shader: string;
  58472. };
  58473. }
  58474. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  58475. import { Matrix } from "babylonjs/Maths/math";
  58476. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58477. import { Mesh } from "babylonjs/Meshes/mesh";
  58478. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  58479. import { Effect } from "babylonjs/Materials/effect";
  58480. import { Scene } from "babylonjs/scene";
  58481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58482. import "babylonjs/Shaders/geometry.fragment";
  58483. import "babylonjs/Shaders/geometry.vertex";
  58484. /** @hidden */
  58485. interface ISavedTransformationMatrix {
  58486. world: Matrix;
  58487. viewProjection: Matrix;
  58488. }
  58489. /**
  58490. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58491. */
  58492. export class GeometryBufferRenderer {
  58493. /**
  58494. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58495. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58496. */
  58497. static readonly POSITION_TEXTURE_TYPE: number;
  58498. /**
  58499. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58500. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58501. */
  58502. static readonly VELOCITY_TEXTURE_TYPE: number;
  58503. /**
  58504. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58505. * in order to compute objects velocities when enableVelocity is set to "true"
  58506. * @hidden
  58507. */
  58508. _previousTransformationMatrices: {
  58509. [index: number]: ISavedTransformationMatrix;
  58510. };
  58511. /**
  58512. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58513. * in order to compute objects velocities when enableVelocity is set to "true"
  58514. * @hidden
  58515. */
  58516. _previousBonesTransformationMatrices: {
  58517. [index: number]: Float32Array;
  58518. };
  58519. /**
  58520. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58521. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58522. */
  58523. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58524. private _scene;
  58525. private _multiRenderTarget;
  58526. private _ratio;
  58527. private _enablePosition;
  58528. private _enableVelocity;
  58529. private _positionIndex;
  58530. private _velocityIndex;
  58531. protected _effect: Effect;
  58532. protected _cachedDefines: string;
  58533. /**
  58534. * Set the render list (meshes to be rendered) used in the G buffer.
  58535. */
  58536. renderList: Mesh[];
  58537. /**
  58538. * Gets wether or not G buffer are supported by the running hardware.
  58539. * This requires draw buffer supports
  58540. */
  58541. readonly isSupported: boolean;
  58542. /**
  58543. * Returns the index of the given texture type in the G-Buffer textures array
  58544. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58545. * @returns the index of the given texture type in the G-Buffer textures array
  58546. */
  58547. getTextureIndex(textureType: number): number;
  58548. /**
  58549. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58550. */
  58551. /**
  58552. * Sets whether or not objects positions are enabled for the G buffer.
  58553. */
  58554. enablePosition: boolean;
  58555. /**
  58556. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58557. */
  58558. /**
  58559. * Sets wether or not objects velocities are enabled for the G buffer.
  58560. */
  58561. enableVelocity: boolean;
  58562. /**
  58563. * Gets the scene associated with the buffer.
  58564. */
  58565. readonly scene: Scene;
  58566. /**
  58567. * Gets the ratio used by the buffer during its creation.
  58568. * How big is the buffer related to the main canvas.
  58569. */
  58570. readonly ratio: number;
  58571. /** @hidden */
  58572. static _SceneComponentInitialization: (scene: Scene) => void;
  58573. /**
  58574. * Creates a new G Buffer for the scene
  58575. * @param scene The scene the buffer belongs to
  58576. * @param ratio How big is the buffer related to the main canvas.
  58577. */
  58578. constructor(scene: Scene, ratio?: number);
  58579. /**
  58580. * Checks wether everything is ready to render a submesh to the G buffer.
  58581. * @param subMesh the submesh to check readiness for
  58582. * @param useInstances is the mesh drawn using instance or not
  58583. * @returns true if ready otherwise false
  58584. */
  58585. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58586. /**
  58587. * Gets the current underlying G Buffer.
  58588. * @returns the buffer
  58589. */
  58590. getGBuffer(): MultiRenderTarget;
  58591. /**
  58592. * Gets the number of samples used to render the buffer (anti aliasing).
  58593. */
  58594. /**
  58595. * Sets the number of samples used to render the buffer (anti aliasing).
  58596. */
  58597. samples: number;
  58598. /**
  58599. * Disposes the renderer and frees up associated resources.
  58600. */
  58601. dispose(): void;
  58602. protected _createRenderTargets(): void;
  58603. private _copyBonesTransformationMatrices;
  58604. }
  58605. }
  58606. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  58607. import { Nullable } from "babylonjs/types";
  58608. import { Scene } from "babylonjs/scene";
  58609. import { ISceneComponent } from "babylonjs/sceneComponent";
  58610. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58611. module "babylonjs/scene" {
  58612. interface Scene {
  58613. /** @hidden (Backing field) */
  58614. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58615. /**
  58616. * Gets or Sets the current geometry buffer associated to the scene.
  58617. */
  58618. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58619. /**
  58620. * Enables a GeometryBufferRender and associates it with the scene
  58621. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58622. * @returns the GeometryBufferRenderer
  58623. */
  58624. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58625. /**
  58626. * Disables the GeometryBufferRender associated with the scene
  58627. */
  58628. disableGeometryBufferRenderer(): void;
  58629. }
  58630. }
  58631. /**
  58632. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58633. * in several rendering techniques.
  58634. */
  58635. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58636. /**
  58637. * The component name helpful to identify the component in the list of scene components.
  58638. */
  58639. readonly name: string;
  58640. /**
  58641. * The scene the component belongs to.
  58642. */
  58643. scene: Scene;
  58644. /**
  58645. * Creates a new instance of the component for the given scene
  58646. * @param scene Defines the scene to register the component in
  58647. */
  58648. constructor(scene: Scene);
  58649. /**
  58650. * Registers the component in a given scene
  58651. */
  58652. register(): void;
  58653. /**
  58654. * Rebuilds the elements related to this component in case of
  58655. * context lost for instance.
  58656. */
  58657. rebuild(): void;
  58658. /**
  58659. * Disposes the component and the associated ressources
  58660. */
  58661. dispose(): void;
  58662. private _gatherRenderTargets;
  58663. }
  58664. }
  58665. declare module "babylonjs/Shaders/motionBlur.fragment" {
  58666. /** @hidden */
  58667. export var motionBlurPixelShader: {
  58668. name: string;
  58669. shader: string;
  58670. };
  58671. }
  58672. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  58673. import { Nullable } from "babylonjs/types";
  58674. import { Camera } from "babylonjs/Cameras/camera";
  58675. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58676. import { Scene } from "babylonjs/scene";
  58677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58678. import "babylonjs/Animations/animatable";
  58679. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  58680. import "babylonjs/Shaders/motionBlur.fragment";
  58681. import { Engine } from "babylonjs/Engines/engine";
  58682. /**
  58683. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58684. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58685. * As an example, all you have to do is to create the post-process:
  58686. * var mb = new BABYLON.MotionBlurPostProcess(
  58687. * 'mb', // The name of the effect.
  58688. * scene, // The scene containing the objects to blur according to their velocity.
  58689. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58690. * camera // The camera to apply the render pass to.
  58691. * );
  58692. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58693. */
  58694. export class MotionBlurPostProcess extends PostProcess {
  58695. /**
  58696. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58697. */
  58698. motionStrength: number;
  58699. /**
  58700. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58701. */
  58702. /**
  58703. * Sets the number of iterations to be used for motion blur quality
  58704. */
  58705. motionBlurSamples: number;
  58706. private _motionBlurSamples;
  58707. private _geometryBufferRenderer;
  58708. /**
  58709. * Creates a new instance MotionBlurPostProcess
  58710. * @param name The name of the effect.
  58711. * @param scene The scene containing the objects to blur according to their velocity.
  58712. * @param options The required width/height ratio to downsize to before computing the render pass.
  58713. * @param camera The camera to apply the render pass to.
  58714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58715. * @param engine The engine which the post process will be applied. (default: current engine)
  58716. * @param reusable If the post process can be reused on the same frame. (default: false)
  58717. * @param textureType Type of textures used when performing the post process. (default: 0)
  58718. * @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)
  58719. */
  58720. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58721. /**
  58722. * Excludes the given skinned mesh from computing bones velocities.
  58723. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  58724. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58725. */
  58726. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58727. /**
  58728. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58729. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58730. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58731. */
  58732. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58733. /**
  58734. * Disposes the post process.
  58735. * @param camera The camera to dispose the post process on.
  58736. */
  58737. dispose(camera?: Camera): void;
  58738. }
  58739. }
  58740. declare module "babylonjs/Shaders/refraction.fragment" {
  58741. /** @hidden */
  58742. export var refractionPixelShader: {
  58743. name: string;
  58744. shader: string;
  58745. };
  58746. }
  58747. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  58748. import { Color3 } from "babylonjs/Maths/math";
  58749. import { Camera } from "babylonjs/Cameras/camera";
  58750. import { Texture } from "babylonjs/Materials/Textures/texture";
  58751. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58752. import { Engine } from "babylonjs/Engines/engine";
  58753. import "babylonjs/Shaders/refraction.fragment";
  58754. /**
  58755. * Post process which applies a refractin texture
  58756. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58757. */
  58758. export class RefractionPostProcess extends PostProcess {
  58759. /** the base color of the refraction (used to taint the rendering) */
  58760. color: Color3;
  58761. /** simulated refraction depth */
  58762. depth: number;
  58763. /** the coefficient of the base color (0 to remove base color tainting) */
  58764. colorLevel: number;
  58765. private _refTexture;
  58766. private _ownRefractionTexture;
  58767. /**
  58768. * Gets or sets the refraction texture
  58769. * Please note that you are responsible for disposing the texture if you set it manually
  58770. */
  58771. refractionTexture: Texture;
  58772. /**
  58773. * Initializes the RefractionPostProcess
  58774. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58775. * @param name The name of the effect.
  58776. * @param refractionTextureUrl Url of the refraction texture to use
  58777. * @param color the base color of the refraction (used to taint the rendering)
  58778. * @param depth simulated refraction depth
  58779. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58780. * @param camera The camera to apply the render pass to.
  58781. * @param options The required width/height ratio to downsize to before computing the render pass.
  58782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58783. * @param engine The engine which the post process will be applied. (default: current engine)
  58784. * @param reusable If the post process can be reused on the same frame. (default: false)
  58785. */
  58786. constructor(name: string, refractionTextureUrl: string,
  58787. /** the base color of the refraction (used to taint the rendering) */
  58788. color: Color3,
  58789. /** simulated refraction depth */
  58790. depth: number,
  58791. /** the coefficient of the base color (0 to remove base color tainting) */
  58792. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58793. /**
  58794. * Disposes of the post process
  58795. * @param camera Camera to dispose post process on
  58796. */
  58797. dispose(camera: Camera): void;
  58798. }
  58799. }
  58800. declare module "babylonjs/Shaders/sharpen.fragment" {
  58801. /** @hidden */
  58802. export var sharpenPixelShader: {
  58803. name: string;
  58804. shader: string;
  58805. };
  58806. }
  58807. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  58808. import { Nullable } from "babylonjs/types";
  58809. import { Camera } from "babylonjs/Cameras/camera";
  58810. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58811. import "babylonjs/Shaders/sharpen.fragment";
  58812. import { Engine } from "babylonjs/Engines/engine";
  58813. /**
  58814. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58815. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58816. */
  58817. export class SharpenPostProcess extends PostProcess {
  58818. /**
  58819. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58820. */
  58821. colorAmount: number;
  58822. /**
  58823. * How much sharpness should be applied (default: 0.3)
  58824. */
  58825. edgeAmount: number;
  58826. /**
  58827. * Creates a new instance ConvolutionPostProcess
  58828. * @param name The name of the effect.
  58829. * @param options The required width/height ratio to downsize to before computing the render pass.
  58830. * @param camera The camera to apply the render pass to.
  58831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58832. * @param engine The engine which the post process will be applied. (default: current engine)
  58833. * @param reusable If the post process can be reused on the same frame. (default: false)
  58834. * @param textureType Type of textures used when performing the post process. (default: 0)
  58835. * @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)
  58836. */
  58837. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58838. }
  58839. }
  58840. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  58841. import { Nullable } from "babylonjs/types";
  58842. import { Camera } from "babylonjs/Cameras/camera";
  58843. import { Engine } from "babylonjs/Engines/engine";
  58844. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58845. import { IInspectable } from "babylonjs/Misc/iInspectable";
  58846. /**
  58847. * PostProcessRenderPipeline
  58848. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58849. */
  58850. export class PostProcessRenderPipeline {
  58851. private engine;
  58852. private _renderEffects;
  58853. private _renderEffectsForIsolatedPass;
  58854. /**
  58855. * List of inspectable custom properties (used by the Inspector)
  58856. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58857. */
  58858. inspectableCustomProperties: IInspectable[];
  58859. /**
  58860. * @hidden
  58861. */
  58862. protected _cameras: Camera[];
  58863. /** @hidden */
  58864. _name: string;
  58865. /**
  58866. * Gets pipeline name
  58867. */
  58868. readonly name: string;
  58869. /**
  58870. * Initializes a PostProcessRenderPipeline
  58871. * @param engine engine to add the pipeline to
  58872. * @param name name of the pipeline
  58873. */
  58874. constructor(engine: Engine, name: string);
  58875. /**
  58876. * Gets the class name
  58877. * @returns "PostProcessRenderPipeline"
  58878. */
  58879. getClassName(): string;
  58880. /**
  58881. * If all the render effects in the pipeline are supported
  58882. */
  58883. readonly isSupported: boolean;
  58884. /**
  58885. * Adds an effect to the pipeline
  58886. * @param renderEffect the effect to add
  58887. */
  58888. addEffect(renderEffect: PostProcessRenderEffect): void;
  58889. /** @hidden */
  58890. _rebuild(): void;
  58891. /** @hidden */
  58892. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58893. /** @hidden */
  58894. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58895. /** @hidden */
  58896. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58897. /** @hidden */
  58898. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58899. /** @hidden */
  58900. _attachCameras(cameras: Camera, unique: boolean): void;
  58901. /** @hidden */
  58902. _attachCameras(cameras: Camera[], unique: boolean): void;
  58903. /** @hidden */
  58904. _detachCameras(cameras: Camera): void;
  58905. /** @hidden */
  58906. _detachCameras(cameras: Nullable<Camera[]>): void;
  58907. /** @hidden */
  58908. _update(): void;
  58909. /** @hidden */
  58910. _reset(): void;
  58911. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58912. /**
  58913. * Disposes of the pipeline
  58914. */
  58915. dispose(): void;
  58916. }
  58917. }
  58918. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  58919. import { Camera } from "babylonjs/Cameras/camera";
  58920. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58921. /**
  58922. * PostProcessRenderPipelineManager class
  58923. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58924. */
  58925. export class PostProcessRenderPipelineManager {
  58926. private _renderPipelines;
  58927. /**
  58928. * Initializes a PostProcessRenderPipelineManager
  58929. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58930. */
  58931. constructor();
  58932. /**
  58933. * Gets the list of supported render pipelines
  58934. */
  58935. readonly supportedPipelines: PostProcessRenderPipeline[];
  58936. /**
  58937. * Adds a pipeline to the manager
  58938. * @param renderPipeline The pipeline to add
  58939. */
  58940. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58941. /**
  58942. * Attaches a camera to the pipeline
  58943. * @param renderPipelineName The name of the pipeline to attach to
  58944. * @param cameras the camera to attach
  58945. * @param unique if the camera can be attached multiple times to the pipeline
  58946. */
  58947. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58948. /**
  58949. * Detaches a camera from the pipeline
  58950. * @param renderPipelineName The name of the pipeline to detach from
  58951. * @param cameras the camera to detach
  58952. */
  58953. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58954. /**
  58955. * Enables an effect by name on a pipeline
  58956. * @param renderPipelineName the name of the pipeline to enable the effect in
  58957. * @param renderEffectName the name of the effect to enable
  58958. * @param cameras the cameras that the effect should be enabled on
  58959. */
  58960. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58961. /**
  58962. * Disables an effect by name on a pipeline
  58963. * @param renderPipelineName the name of the pipeline to disable the effect in
  58964. * @param renderEffectName the name of the effect to disable
  58965. * @param cameras the cameras that the effect should be disabled on
  58966. */
  58967. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58968. /**
  58969. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58970. */
  58971. update(): void;
  58972. /** @hidden */
  58973. _rebuild(): void;
  58974. /**
  58975. * Disposes of the manager and pipelines
  58976. */
  58977. dispose(): void;
  58978. }
  58979. }
  58980. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  58981. import { ISceneComponent } from "babylonjs/sceneComponent";
  58982. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  58983. import { Scene } from "babylonjs/scene";
  58984. module "babylonjs/scene" {
  58985. interface Scene {
  58986. /** @hidden (Backing field) */
  58987. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58988. /**
  58989. * Gets the postprocess render pipeline manager
  58990. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58991. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58992. */
  58993. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58994. }
  58995. }
  58996. /**
  58997. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58998. */
  58999. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59000. /**
  59001. * The component name helpfull to identify the component in the list of scene components.
  59002. */
  59003. readonly name: string;
  59004. /**
  59005. * The scene the component belongs to.
  59006. */
  59007. scene: Scene;
  59008. /**
  59009. * Creates a new instance of the component for the given scene
  59010. * @param scene Defines the scene to register the component in
  59011. */
  59012. constructor(scene: Scene);
  59013. /**
  59014. * Registers the component in a given scene
  59015. */
  59016. register(): void;
  59017. /**
  59018. * Rebuilds the elements related to this component in case of
  59019. * context lost for instance.
  59020. */
  59021. rebuild(): void;
  59022. /**
  59023. * Disposes the component and the associated ressources
  59024. */
  59025. dispose(): void;
  59026. private _gatherRenderTargets;
  59027. }
  59028. }
  59029. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  59030. import { Nullable } from "babylonjs/types";
  59031. import { IAnimatable } from "babylonjs/Misc/tools";
  59032. import { Camera } from "babylonjs/Cameras/camera";
  59033. import { IDisposable } from "babylonjs/scene";
  59034. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  59035. import { Scene } from "babylonjs/scene";
  59036. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  59037. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59038. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59039. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  59040. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59041. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59042. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  59043. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59044. import { Animation } from "babylonjs/Animations/animation";
  59045. /**
  59046. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59047. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59048. */
  59049. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59050. private _scene;
  59051. private _camerasToBeAttached;
  59052. /**
  59053. * ID of the sharpen post process,
  59054. */
  59055. private readonly SharpenPostProcessId;
  59056. /**
  59057. * @ignore
  59058. * ID of the image processing post process;
  59059. */
  59060. readonly ImageProcessingPostProcessId: string;
  59061. /**
  59062. * @ignore
  59063. * ID of the Fast Approximate Anti-Aliasing post process;
  59064. */
  59065. readonly FxaaPostProcessId: string;
  59066. /**
  59067. * ID of the chromatic aberration post process,
  59068. */
  59069. private readonly ChromaticAberrationPostProcessId;
  59070. /**
  59071. * ID of the grain post process
  59072. */
  59073. private readonly GrainPostProcessId;
  59074. /**
  59075. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59076. */
  59077. sharpen: SharpenPostProcess;
  59078. private _sharpenEffect;
  59079. private bloom;
  59080. /**
  59081. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59082. */
  59083. depthOfField: DepthOfFieldEffect;
  59084. /**
  59085. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59086. */
  59087. fxaa: FxaaPostProcess;
  59088. /**
  59089. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59090. */
  59091. imageProcessing: ImageProcessingPostProcess;
  59092. /**
  59093. * Chromatic aberration post process which will shift rgb colors in the image
  59094. */
  59095. chromaticAberration: ChromaticAberrationPostProcess;
  59096. private _chromaticAberrationEffect;
  59097. /**
  59098. * Grain post process which add noise to the image
  59099. */
  59100. grain: GrainPostProcess;
  59101. private _grainEffect;
  59102. /**
  59103. * Glow post process which adds a glow to emissive areas of the image
  59104. */
  59105. private _glowLayer;
  59106. /**
  59107. * Animations which can be used to tweak settings over a period of time
  59108. */
  59109. animations: Animation[];
  59110. private _imageProcessingConfigurationObserver;
  59111. private _sharpenEnabled;
  59112. private _bloomEnabled;
  59113. private _depthOfFieldEnabled;
  59114. private _depthOfFieldBlurLevel;
  59115. private _fxaaEnabled;
  59116. private _imageProcessingEnabled;
  59117. private _defaultPipelineTextureType;
  59118. private _bloomScale;
  59119. private _chromaticAberrationEnabled;
  59120. private _grainEnabled;
  59121. private _buildAllowed;
  59122. /**
  59123. * Gets active scene
  59124. */
  59125. readonly scene: Scene;
  59126. /**
  59127. * Enable or disable the sharpen process from the pipeline
  59128. */
  59129. sharpenEnabled: boolean;
  59130. private _resizeObserver;
  59131. private _hardwareScaleLevel;
  59132. private _bloomKernel;
  59133. /**
  59134. * Specifies the size of the bloom blur kernel, relative to the final output size
  59135. */
  59136. bloomKernel: number;
  59137. /**
  59138. * Specifies the weight of the bloom in the final rendering
  59139. */
  59140. private _bloomWeight;
  59141. /**
  59142. * Specifies the luma threshold for the area that will be blurred by the bloom
  59143. */
  59144. private _bloomThreshold;
  59145. private _hdr;
  59146. /**
  59147. * The strength of the bloom.
  59148. */
  59149. bloomWeight: number;
  59150. /**
  59151. * The strength of the bloom.
  59152. */
  59153. bloomThreshold: number;
  59154. /**
  59155. * The scale of the bloom, lower value will provide better performance.
  59156. */
  59157. bloomScale: number;
  59158. /**
  59159. * Enable or disable the bloom from the pipeline
  59160. */
  59161. bloomEnabled: boolean;
  59162. private _rebuildBloom;
  59163. /**
  59164. * If the depth of field is enabled.
  59165. */
  59166. depthOfFieldEnabled: boolean;
  59167. /**
  59168. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59169. */
  59170. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59171. /**
  59172. * If the anti aliasing is enabled.
  59173. */
  59174. fxaaEnabled: boolean;
  59175. private _samples;
  59176. /**
  59177. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59178. */
  59179. samples: number;
  59180. /**
  59181. * If image processing is enabled.
  59182. */
  59183. imageProcessingEnabled: boolean;
  59184. /**
  59185. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59186. */
  59187. glowLayerEnabled: boolean;
  59188. /**
  59189. * Gets the glow layer (or null if not defined)
  59190. */
  59191. readonly glowLayer: Nullable<GlowLayer>;
  59192. /**
  59193. * Enable or disable the chromaticAberration process from the pipeline
  59194. */
  59195. chromaticAberrationEnabled: boolean;
  59196. /**
  59197. * Enable or disable the grain process from the pipeline
  59198. */
  59199. grainEnabled: boolean;
  59200. /**
  59201. * @constructor
  59202. * @param name - The rendering pipeline name (default: "")
  59203. * @param hdr - If high dynamic range textures should be used (default: true)
  59204. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59205. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59206. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59207. */
  59208. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59209. /**
  59210. * Get the class name
  59211. * @returns "DefaultRenderingPipeline"
  59212. */
  59213. getClassName(): string;
  59214. /**
  59215. * Force the compilation of the entire pipeline.
  59216. */
  59217. prepare(): void;
  59218. private _hasCleared;
  59219. private _prevPostProcess;
  59220. private _prevPrevPostProcess;
  59221. private _setAutoClearAndTextureSharing;
  59222. private _depthOfFieldSceneObserver;
  59223. private _buildPipeline;
  59224. private _disposePostProcesses;
  59225. /**
  59226. * Adds a camera to the pipeline
  59227. * @param camera the camera to be added
  59228. */
  59229. addCamera(camera: Camera): void;
  59230. /**
  59231. * Removes a camera from the pipeline
  59232. * @param camera the camera to remove
  59233. */
  59234. removeCamera(camera: Camera): void;
  59235. /**
  59236. * Dispose of the pipeline and stop all post processes
  59237. */
  59238. dispose(): void;
  59239. /**
  59240. * Serialize the rendering pipeline (Used when exporting)
  59241. * @returns the serialized object
  59242. */
  59243. serialize(): any;
  59244. /**
  59245. * Parse the serialized pipeline
  59246. * @param source Source pipeline.
  59247. * @param scene The scene to load the pipeline to.
  59248. * @param rootUrl The URL of the serialized pipeline.
  59249. * @returns An instantiated pipeline from the serialized object.
  59250. */
  59251. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59252. }
  59253. }
  59254. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  59255. /** @hidden */
  59256. export var lensHighlightsPixelShader: {
  59257. name: string;
  59258. shader: string;
  59259. };
  59260. }
  59261. declare module "babylonjs/Shaders/depthOfField.fragment" {
  59262. /** @hidden */
  59263. export var depthOfFieldPixelShader: {
  59264. name: string;
  59265. shader: string;
  59266. };
  59267. }
  59268. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  59269. import { Camera } from "babylonjs/Cameras/camera";
  59270. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59271. import { Scene } from "babylonjs/scene";
  59272. import "babylonjs/Shaders/chromaticAberration.fragment";
  59273. import "babylonjs/Shaders/lensHighlights.fragment";
  59274. import "babylonjs/Shaders/depthOfField.fragment";
  59275. /**
  59276. * BABYLON.JS Chromatic Aberration GLSL Shader
  59277. * Author: Olivier Guyot
  59278. * Separates very slightly R, G and B colors on the edges of the screen
  59279. * Inspired by Francois Tarlier & Martins Upitis
  59280. */
  59281. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59282. /**
  59283. * @ignore
  59284. * The chromatic aberration PostProcess id in the pipeline
  59285. */
  59286. LensChromaticAberrationEffect: string;
  59287. /**
  59288. * @ignore
  59289. * The highlights enhancing PostProcess id in the pipeline
  59290. */
  59291. HighlightsEnhancingEffect: string;
  59292. /**
  59293. * @ignore
  59294. * The depth-of-field PostProcess id in the pipeline
  59295. */
  59296. LensDepthOfFieldEffect: string;
  59297. private _scene;
  59298. private _depthTexture;
  59299. private _grainTexture;
  59300. private _chromaticAberrationPostProcess;
  59301. private _highlightsPostProcess;
  59302. private _depthOfFieldPostProcess;
  59303. private _edgeBlur;
  59304. private _grainAmount;
  59305. private _chromaticAberration;
  59306. private _distortion;
  59307. private _highlightsGain;
  59308. private _highlightsThreshold;
  59309. private _dofDistance;
  59310. private _dofAperture;
  59311. private _dofDarken;
  59312. private _dofPentagon;
  59313. private _blurNoise;
  59314. /**
  59315. * @constructor
  59316. *
  59317. * Effect parameters are as follow:
  59318. * {
  59319. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59320. * edge_blur: number; // from 0 to x (1 for realism)
  59321. * distortion: number; // from 0 to x (1 for realism)
  59322. * grain_amount: number; // from 0 to 1
  59323. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59324. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59325. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59326. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59327. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59328. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59329. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59330. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59331. * }
  59332. * Note: if an effect parameter is unset, effect is disabled
  59333. *
  59334. * @param name The rendering pipeline name
  59335. * @param parameters - An object containing all parameters (see above)
  59336. * @param scene The scene linked to this pipeline
  59337. * @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)
  59338. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59339. */
  59340. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59341. /**
  59342. * Get the class name
  59343. * @returns "LensRenderingPipeline"
  59344. */
  59345. getClassName(): string;
  59346. /**
  59347. * Gets associated scene
  59348. */
  59349. readonly scene: Scene;
  59350. /**
  59351. * Gets or sets the edge blur
  59352. */
  59353. edgeBlur: number;
  59354. /**
  59355. * Gets or sets the grain amount
  59356. */
  59357. grainAmount: number;
  59358. /**
  59359. * Gets or sets the chromatic aberration amount
  59360. */
  59361. chromaticAberration: number;
  59362. /**
  59363. * Gets or sets the depth of field aperture
  59364. */
  59365. dofAperture: number;
  59366. /**
  59367. * Gets or sets the edge distortion
  59368. */
  59369. edgeDistortion: number;
  59370. /**
  59371. * Gets or sets the depth of field distortion
  59372. */
  59373. dofDistortion: number;
  59374. /**
  59375. * Gets or sets the darken out of focus amount
  59376. */
  59377. darkenOutOfFocus: number;
  59378. /**
  59379. * Gets or sets a boolean indicating if blur noise is enabled
  59380. */
  59381. blurNoise: boolean;
  59382. /**
  59383. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59384. */
  59385. pentagonBokeh: boolean;
  59386. /**
  59387. * Gets or sets the highlight grain amount
  59388. */
  59389. highlightsGain: number;
  59390. /**
  59391. * Gets or sets the highlight threshold
  59392. */
  59393. highlightsThreshold: number;
  59394. /**
  59395. * Sets the amount of blur at the edges
  59396. * @param amount blur amount
  59397. */
  59398. setEdgeBlur(amount: number): void;
  59399. /**
  59400. * Sets edge blur to 0
  59401. */
  59402. disableEdgeBlur(): void;
  59403. /**
  59404. * Sets the amout of grain
  59405. * @param amount Amount of grain
  59406. */
  59407. setGrainAmount(amount: number): void;
  59408. /**
  59409. * Set grain amount to 0
  59410. */
  59411. disableGrain(): void;
  59412. /**
  59413. * Sets the chromatic aberration amount
  59414. * @param amount amount of chromatic aberration
  59415. */
  59416. setChromaticAberration(amount: number): void;
  59417. /**
  59418. * Sets chromatic aberration amount to 0
  59419. */
  59420. disableChromaticAberration(): void;
  59421. /**
  59422. * Sets the EdgeDistortion amount
  59423. * @param amount amount of EdgeDistortion
  59424. */
  59425. setEdgeDistortion(amount: number): void;
  59426. /**
  59427. * Sets edge distortion to 0
  59428. */
  59429. disableEdgeDistortion(): void;
  59430. /**
  59431. * Sets the FocusDistance amount
  59432. * @param amount amount of FocusDistance
  59433. */
  59434. setFocusDistance(amount: number): void;
  59435. /**
  59436. * Disables depth of field
  59437. */
  59438. disableDepthOfField(): void;
  59439. /**
  59440. * Sets the Aperture amount
  59441. * @param amount amount of Aperture
  59442. */
  59443. setAperture(amount: number): void;
  59444. /**
  59445. * Sets the DarkenOutOfFocus amount
  59446. * @param amount amount of DarkenOutOfFocus
  59447. */
  59448. setDarkenOutOfFocus(amount: number): void;
  59449. private _pentagonBokehIsEnabled;
  59450. /**
  59451. * Creates a pentagon bokeh effect
  59452. */
  59453. enablePentagonBokeh(): void;
  59454. /**
  59455. * Disables the pentagon bokeh effect
  59456. */
  59457. disablePentagonBokeh(): void;
  59458. /**
  59459. * Enables noise blur
  59460. */
  59461. enableNoiseBlur(): void;
  59462. /**
  59463. * Disables noise blur
  59464. */
  59465. disableNoiseBlur(): void;
  59466. /**
  59467. * Sets the HighlightsGain amount
  59468. * @param amount amount of HighlightsGain
  59469. */
  59470. setHighlightsGain(amount: number): void;
  59471. /**
  59472. * Sets the HighlightsThreshold amount
  59473. * @param amount amount of HighlightsThreshold
  59474. */
  59475. setHighlightsThreshold(amount: number): void;
  59476. /**
  59477. * Disables highlights
  59478. */
  59479. disableHighlights(): void;
  59480. /**
  59481. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59482. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59483. */
  59484. dispose(disableDepthRender?: boolean): void;
  59485. private _createChromaticAberrationPostProcess;
  59486. private _createHighlightsPostProcess;
  59487. private _createDepthOfFieldPostProcess;
  59488. private _createGrainTexture;
  59489. }
  59490. }
  59491. declare module "babylonjs/Shaders/ssao2.fragment" {
  59492. /** @hidden */
  59493. export var ssao2PixelShader: {
  59494. name: string;
  59495. shader: string;
  59496. };
  59497. }
  59498. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  59499. /** @hidden */
  59500. export var ssaoCombinePixelShader: {
  59501. name: string;
  59502. shader: string;
  59503. };
  59504. }
  59505. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  59506. import { Camera } from "babylonjs/Cameras/camera";
  59507. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59508. import { Scene } from "babylonjs/scene";
  59509. import "babylonjs/Shaders/ssao2.fragment";
  59510. import "babylonjs/Shaders/ssaoCombine.fragment";
  59511. /**
  59512. * Render pipeline to produce ssao effect
  59513. */
  59514. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59515. /**
  59516. * @ignore
  59517. * The PassPostProcess id in the pipeline that contains the original scene color
  59518. */
  59519. SSAOOriginalSceneColorEffect: string;
  59520. /**
  59521. * @ignore
  59522. * The SSAO PostProcess id in the pipeline
  59523. */
  59524. SSAORenderEffect: string;
  59525. /**
  59526. * @ignore
  59527. * The horizontal blur PostProcess id in the pipeline
  59528. */
  59529. SSAOBlurHRenderEffect: string;
  59530. /**
  59531. * @ignore
  59532. * The vertical blur PostProcess id in the pipeline
  59533. */
  59534. SSAOBlurVRenderEffect: string;
  59535. /**
  59536. * @ignore
  59537. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59538. */
  59539. SSAOCombineRenderEffect: string;
  59540. /**
  59541. * The output strength of the SSAO post-process. Default value is 1.0.
  59542. */
  59543. totalStrength: number;
  59544. /**
  59545. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59546. */
  59547. maxZ: number;
  59548. /**
  59549. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59550. */
  59551. minZAspect: number;
  59552. private _samples;
  59553. /**
  59554. * Number of samples used for the SSAO calculations. Default value is 8
  59555. */
  59556. samples: number;
  59557. private _textureSamples;
  59558. /**
  59559. * Number of samples to use for antialiasing
  59560. */
  59561. textureSamples: number;
  59562. /**
  59563. * Ratio object used for SSAO ratio and blur ratio
  59564. */
  59565. private _ratio;
  59566. /**
  59567. * Dynamically generated sphere sampler.
  59568. */
  59569. private _sampleSphere;
  59570. /**
  59571. * Blur filter offsets
  59572. */
  59573. private _samplerOffsets;
  59574. private _expensiveBlur;
  59575. /**
  59576. * If bilateral blur should be used
  59577. */
  59578. expensiveBlur: boolean;
  59579. /**
  59580. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59581. */
  59582. radius: number;
  59583. /**
  59584. * The base color of the SSAO post-process
  59585. * The final result is "base + ssao" between [0, 1]
  59586. */
  59587. base: number;
  59588. /**
  59589. * Support test.
  59590. */
  59591. static readonly IsSupported: boolean;
  59592. private _scene;
  59593. private _depthTexture;
  59594. private _normalTexture;
  59595. private _randomTexture;
  59596. private _originalColorPostProcess;
  59597. private _ssaoPostProcess;
  59598. private _blurHPostProcess;
  59599. private _blurVPostProcess;
  59600. private _ssaoCombinePostProcess;
  59601. private _firstUpdate;
  59602. /**
  59603. * Gets active scene
  59604. */
  59605. readonly scene: Scene;
  59606. /**
  59607. * @constructor
  59608. * @param name The rendering pipeline name
  59609. * @param scene The scene linked to this pipeline
  59610. * @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 }
  59611. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59612. */
  59613. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59614. /**
  59615. * Get the class name
  59616. * @returns "SSAO2RenderingPipeline"
  59617. */
  59618. getClassName(): string;
  59619. /**
  59620. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59621. */
  59622. dispose(disableGeometryBufferRenderer?: boolean): void;
  59623. private _createBlurPostProcess;
  59624. /** @hidden */
  59625. _rebuild(): void;
  59626. private _bits;
  59627. private _radicalInverse_VdC;
  59628. private _hammersley;
  59629. private _hemisphereSample_uniform;
  59630. private _generateHemisphere;
  59631. private _createSSAOPostProcess;
  59632. private _createSSAOCombinePostProcess;
  59633. private _createRandomTexture;
  59634. /**
  59635. * Serialize the rendering pipeline (Used when exporting)
  59636. * @returns the serialized object
  59637. */
  59638. serialize(): any;
  59639. /**
  59640. * Parse the serialized pipeline
  59641. * @param source Source pipeline.
  59642. * @param scene The scene to load the pipeline to.
  59643. * @param rootUrl The URL of the serialized pipeline.
  59644. * @returns An instantiated pipeline from the serialized object.
  59645. */
  59646. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59647. }
  59648. }
  59649. declare module "babylonjs/Shaders/ssao.fragment" {
  59650. /** @hidden */
  59651. export var ssaoPixelShader: {
  59652. name: string;
  59653. shader: string;
  59654. };
  59655. }
  59656. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  59657. import { Camera } from "babylonjs/Cameras/camera";
  59658. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59659. import { Scene } from "babylonjs/scene";
  59660. import "babylonjs/Shaders/ssao.fragment";
  59661. import "babylonjs/Shaders/ssaoCombine.fragment";
  59662. /**
  59663. * Render pipeline to produce ssao effect
  59664. */
  59665. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59666. /**
  59667. * @ignore
  59668. * The PassPostProcess id in the pipeline that contains the original scene color
  59669. */
  59670. SSAOOriginalSceneColorEffect: string;
  59671. /**
  59672. * @ignore
  59673. * The SSAO PostProcess id in the pipeline
  59674. */
  59675. SSAORenderEffect: string;
  59676. /**
  59677. * @ignore
  59678. * The horizontal blur PostProcess id in the pipeline
  59679. */
  59680. SSAOBlurHRenderEffect: string;
  59681. /**
  59682. * @ignore
  59683. * The vertical blur PostProcess id in the pipeline
  59684. */
  59685. SSAOBlurVRenderEffect: string;
  59686. /**
  59687. * @ignore
  59688. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59689. */
  59690. SSAOCombineRenderEffect: string;
  59691. /**
  59692. * The output strength of the SSAO post-process. Default value is 1.0.
  59693. */
  59694. totalStrength: number;
  59695. /**
  59696. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59697. */
  59698. radius: number;
  59699. /**
  59700. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59701. * Must not be equal to fallOff and superior to fallOff.
  59702. * Default value is 0.0075
  59703. */
  59704. area: number;
  59705. /**
  59706. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59707. * Must not be equal to area and inferior to area.
  59708. * Default value is 0.000001
  59709. */
  59710. fallOff: number;
  59711. /**
  59712. * The base color of the SSAO post-process
  59713. * The final result is "base + ssao" between [0, 1]
  59714. */
  59715. base: number;
  59716. private _scene;
  59717. private _depthTexture;
  59718. private _randomTexture;
  59719. private _originalColorPostProcess;
  59720. private _ssaoPostProcess;
  59721. private _blurHPostProcess;
  59722. private _blurVPostProcess;
  59723. private _ssaoCombinePostProcess;
  59724. private _firstUpdate;
  59725. /**
  59726. * Gets active scene
  59727. */
  59728. readonly scene: Scene;
  59729. /**
  59730. * @constructor
  59731. * @param name - The rendering pipeline name
  59732. * @param scene - The scene linked to this pipeline
  59733. * @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 }
  59734. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59735. */
  59736. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59737. /**
  59738. * Get the class name
  59739. * @returns "SSAORenderingPipeline"
  59740. */
  59741. getClassName(): string;
  59742. /**
  59743. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59744. */
  59745. dispose(disableDepthRender?: boolean): void;
  59746. private _createBlurPostProcess;
  59747. /** @hidden */
  59748. _rebuild(): void;
  59749. private _createSSAOPostProcess;
  59750. private _createSSAOCombinePostProcess;
  59751. private _createRandomTexture;
  59752. }
  59753. }
  59754. declare module "babylonjs/Shaders/standard.fragment" {
  59755. /** @hidden */
  59756. export var standardPixelShader: {
  59757. name: string;
  59758. shader: string;
  59759. };
  59760. }
  59761. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  59762. import { Nullable } from "babylonjs/types";
  59763. import { IAnimatable } from "babylonjs/Misc/tools";
  59764. import { Camera } from "babylonjs/Cameras/camera";
  59765. import { Texture } from "babylonjs/Materials/Textures/texture";
  59766. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59767. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59768. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59769. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59770. import { IDisposable } from "babylonjs/scene";
  59771. import { SpotLight } from "babylonjs/Lights/spotLight";
  59772. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  59773. import { Scene } from "babylonjs/scene";
  59774. import { Animation } from "babylonjs/Animations/animation";
  59775. import "babylonjs/Shaders/standard.fragment";
  59776. /**
  59777. * Standard rendering pipeline
  59778. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59779. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59780. */
  59781. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59782. /**
  59783. * Public members
  59784. */
  59785. /**
  59786. * Post-process which contains the original scene color before the pipeline applies all the effects
  59787. */
  59788. originalPostProcess: Nullable<PostProcess>;
  59789. /**
  59790. * Post-process used to down scale an image x4
  59791. */
  59792. downSampleX4PostProcess: Nullable<PostProcess>;
  59793. /**
  59794. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59795. */
  59796. brightPassPostProcess: Nullable<PostProcess>;
  59797. /**
  59798. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59799. */
  59800. blurHPostProcesses: PostProcess[];
  59801. /**
  59802. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59803. */
  59804. blurVPostProcesses: PostProcess[];
  59805. /**
  59806. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59807. */
  59808. textureAdderPostProcess: Nullable<PostProcess>;
  59809. /**
  59810. * Post-process used to create volumetric lighting effect
  59811. */
  59812. volumetricLightPostProcess: Nullable<PostProcess>;
  59813. /**
  59814. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59815. */
  59816. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59817. /**
  59818. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59819. */
  59820. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59821. /**
  59822. * Post-process used to merge the volumetric light effect and the real scene color
  59823. */
  59824. volumetricLightMergePostProces: Nullable<PostProcess>;
  59825. /**
  59826. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59827. */
  59828. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59829. /**
  59830. * Base post-process used to calculate the average luminance of the final image for HDR
  59831. */
  59832. luminancePostProcess: Nullable<PostProcess>;
  59833. /**
  59834. * Post-processes used to create down sample post-processes in order to get
  59835. * the average luminance of the final image for HDR
  59836. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59837. */
  59838. luminanceDownSamplePostProcesses: PostProcess[];
  59839. /**
  59840. * Post-process used to create a HDR effect (light adaptation)
  59841. */
  59842. hdrPostProcess: Nullable<PostProcess>;
  59843. /**
  59844. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59845. */
  59846. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59847. /**
  59848. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59849. */
  59850. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59851. /**
  59852. * Post-process used to merge the final HDR post-process and the real scene color
  59853. */
  59854. hdrFinalPostProcess: Nullable<PostProcess>;
  59855. /**
  59856. * Post-process used to create a lens flare effect
  59857. */
  59858. lensFlarePostProcess: Nullable<PostProcess>;
  59859. /**
  59860. * Post-process that merges the result of the lens flare post-process and the real scene color
  59861. */
  59862. lensFlareComposePostProcess: Nullable<PostProcess>;
  59863. /**
  59864. * Post-process used to create a motion blur effect
  59865. */
  59866. motionBlurPostProcess: Nullable<PostProcess>;
  59867. /**
  59868. * Post-process used to create a depth of field effect
  59869. */
  59870. depthOfFieldPostProcess: Nullable<PostProcess>;
  59871. /**
  59872. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59873. */
  59874. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59875. /**
  59876. * Represents the brightness threshold in order to configure the illuminated surfaces
  59877. */
  59878. brightThreshold: number;
  59879. /**
  59880. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59881. */
  59882. blurWidth: number;
  59883. /**
  59884. * Sets if the blur for highlighted surfaces must be only horizontal
  59885. */
  59886. horizontalBlur: boolean;
  59887. /**
  59888. * Gets the overall exposure used by the pipeline
  59889. */
  59890. /**
  59891. * Sets the overall exposure used by the pipeline
  59892. */
  59893. exposure: number;
  59894. /**
  59895. * Texture used typically to simulate "dirty" on camera lens
  59896. */
  59897. lensTexture: Nullable<Texture>;
  59898. /**
  59899. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59900. */
  59901. volumetricLightCoefficient: number;
  59902. /**
  59903. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59904. */
  59905. volumetricLightPower: number;
  59906. /**
  59907. * Used the set the blur intensity to smooth the volumetric lights
  59908. */
  59909. volumetricLightBlurScale: number;
  59910. /**
  59911. * Light (spot or directional) used to generate the volumetric lights rays
  59912. * The source light must have a shadow generate so the pipeline can get its
  59913. * depth map
  59914. */
  59915. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59916. /**
  59917. * For eye adaptation, represents the minimum luminance the eye can see
  59918. */
  59919. hdrMinimumLuminance: number;
  59920. /**
  59921. * For eye adaptation, represents the decrease luminance speed
  59922. */
  59923. hdrDecreaseRate: number;
  59924. /**
  59925. * For eye adaptation, represents the increase luminance speed
  59926. */
  59927. hdrIncreaseRate: number;
  59928. /**
  59929. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59930. */
  59931. /**
  59932. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59933. */
  59934. hdrAutoExposure: boolean;
  59935. /**
  59936. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59937. */
  59938. lensColorTexture: Nullable<Texture>;
  59939. /**
  59940. * The overall strengh for the lens flare effect
  59941. */
  59942. lensFlareStrength: number;
  59943. /**
  59944. * Dispersion coefficient for lens flare ghosts
  59945. */
  59946. lensFlareGhostDispersal: number;
  59947. /**
  59948. * Main lens flare halo width
  59949. */
  59950. lensFlareHaloWidth: number;
  59951. /**
  59952. * Based on the lens distortion effect, defines how much the lens flare result
  59953. * is distorted
  59954. */
  59955. lensFlareDistortionStrength: number;
  59956. /**
  59957. * Lens star texture must be used to simulate rays on the flares and is available
  59958. * in the documentation
  59959. */
  59960. lensStarTexture: Nullable<Texture>;
  59961. /**
  59962. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59963. * flare effect by taking account of the dirt texture
  59964. */
  59965. lensFlareDirtTexture: Nullable<Texture>;
  59966. /**
  59967. * Represents the focal length for the depth of field effect
  59968. */
  59969. depthOfFieldDistance: number;
  59970. /**
  59971. * Represents the blur intensity for the blurred part of the depth of field effect
  59972. */
  59973. depthOfFieldBlurWidth: number;
  59974. /**
  59975. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59976. */
  59977. /**
  59978. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59979. */
  59980. motionStrength: number;
  59981. /**
  59982. * Gets wether or not the motion blur post-process is object based or screen based.
  59983. */
  59984. /**
  59985. * Sets wether or not the motion blur post-process should be object based or screen based
  59986. */
  59987. objectBasedMotionBlur: boolean;
  59988. /**
  59989. * List of animations for the pipeline (IAnimatable implementation)
  59990. */
  59991. animations: Animation[];
  59992. /**
  59993. * Private members
  59994. */
  59995. private _scene;
  59996. private _currentDepthOfFieldSource;
  59997. private _basePostProcess;
  59998. private _fixedExposure;
  59999. private _currentExposure;
  60000. private _hdrAutoExposure;
  60001. private _hdrCurrentLuminance;
  60002. private _motionStrength;
  60003. private _isObjectBasedMotionBlur;
  60004. private _floatTextureType;
  60005. private _ratio;
  60006. private _bloomEnabled;
  60007. private _depthOfFieldEnabled;
  60008. private _vlsEnabled;
  60009. private _lensFlareEnabled;
  60010. private _hdrEnabled;
  60011. private _motionBlurEnabled;
  60012. private _fxaaEnabled;
  60013. private _motionBlurSamples;
  60014. private _volumetricLightStepsCount;
  60015. private _samples;
  60016. /**
  60017. * @ignore
  60018. * Specifies if the bloom pipeline is enabled
  60019. */
  60020. BloomEnabled: boolean;
  60021. /**
  60022. * @ignore
  60023. * Specifies if the depth of field pipeline is enabed
  60024. */
  60025. DepthOfFieldEnabled: boolean;
  60026. /**
  60027. * @ignore
  60028. * Specifies if the lens flare pipeline is enabed
  60029. */
  60030. LensFlareEnabled: boolean;
  60031. /**
  60032. * @ignore
  60033. * Specifies if the HDR pipeline is enabled
  60034. */
  60035. HDREnabled: boolean;
  60036. /**
  60037. * @ignore
  60038. * Specifies if the volumetric lights scattering effect is enabled
  60039. */
  60040. VLSEnabled: boolean;
  60041. /**
  60042. * @ignore
  60043. * Specifies if the motion blur effect is enabled
  60044. */
  60045. MotionBlurEnabled: boolean;
  60046. /**
  60047. * Specifies if anti-aliasing is enabled
  60048. */
  60049. fxaaEnabled: boolean;
  60050. /**
  60051. * Specifies the number of steps used to calculate the volumetric lights
  60052. * Typically in interval [50, 200]
  60053. */
  60054. volumetricLightStepsCount: number;
  60055. /**
  60056. * Specifies the number of samples used for the motion blur effect
  60057. * Typically in interval [16, 64]
  60058. */
  60059. motionBlurSamples: number;
  60060. /**
  60061. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60062. */
  60063. samples: number;
  60064. /**
  60065. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60066. * @constructor
  60067. * @param name The rendering pipeline name
  60068. * @param scene The scene linked to this pipeline
  60069. * @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)
  60070. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60071. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60072. */
  60073. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60074. private _buildPipeline;
  60075. private _createDownSampleX4PostProcess;
  60076. private _createBrightPassPostProcess;
  60077. private _createBlurPostProcesses;
  60078. private _createTextureAdderPostProcess;
  60079. private _createVolumetricLightPostProcess;
  60080. private _createLuminancePostProcesses;
  60081. private _createHdrPostProcess;
  60082. private _createLensFlarePostProcess;
  60083. private _createDepthOfFieldPostProcess;
  60084. private _createMotionBlurPostProcess;
  60085. private _getDepthTexture;
  60086. private _disposePostProcesses;
  60087. /**
  60088. * Dispose of the pipeline and stop all post processes
  60089. */
  60090. dispose(): void;
  60091. /**
  60092. * Serialize the rendering pipeline (Used when exporting)
  60093. * @returns the serialized object
  60094. */
  60095. serialize(): any;
  60096. /**
  60097. * Parse the serialized pipeline
  60098. * @param source Source pipeline.
  60099. * @param scene The scene to load the pipeline to.
  60100. * @param rootUrl The URL of the serialized pipeline.
  60101. * @returns An instantiated pipeline from the serialized object.
  60102. */
  60103. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60104. /**
  60105. * Luminance steps
  60106. */
  60107. static LuminanceSteps: number;
  60108. }
  60109. }
  60110. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  60111. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  60112. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  60113. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  60114. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  60115. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  60116. }
  60117. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  60118. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  60119. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60120. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60121. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60122. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60123. }
  60124. declare module "babylonjs/Shaders/tonemap.fragment" {
  60125. /** @hidden */
  60126. export var tonemapPixelShader: {
  60127. name: string;
  60128. shader: string;
  60129. };
  60130. }
  60131. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  60132. import { Camera } from "babylonjs/Cameras/camera";
  60133. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60134. import "babylonjs/Shaders/tonemap.fragment";
  60135. import { Engine } from "babylonjs/Engines/engine";
  60136. /** Defines operator used for tonemapping */
  60137. export enum TonemappingOperator {
  60138. /** Hable */
  60139. Hable = 0,
  60140. /** Reinhard */
  60141. Reinhard = 1,
  60142. /** HejiDawson */
  60143. HejiDawson = 2,
  60144. /** Photographic */
  60145. Photographic = 3
  60146. }
  60147. /**
  60148. * Defines a post process to apply tone mapping
  60149. */
  60150. export class TonemapPostProcess extends PostProcess {
  60151. private _operator;
  60152. /** Defines the required exposure adjustement */
  60153. exposureAdjustment: number;
  60154. /**
  60155. * Creates a new TonemapPostProcess
  60156. * @param name defines the name of the postprocess
  60157. * @param _operator defines the operator to use
  60158. * @param exposureAdjustment defines the required exposure adjustement
  60159. * @param camera defines the camera to use (can be null)
  60160. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60161. * @param engine defines the hosting engine (can be ignore if camera is set)
  60162. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60163. */
  60164. constructor(name: string, _operator: TonemappingOperator,
  60165. /** Defines the required exposure adjustement */
  60166. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60167. }
  60168. }
  60169. declare module "babylonjs/Shaders/depth.vertex" {
  60170. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60171. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60172. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60173. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60174. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60175. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60176. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60177. /** @hidden */
  60178. export var depthVertexShader: {
  60179. name: string;
  60180. shader: string;
  60181. };
  60182. }
  60183. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  60184. /** @hidden */
  60185. export var volumetricLightScatteringPixelShader: {
  60186. name: string;
  60187. shader: string;
  60188. };
  60189. }
  60190. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  60191. /** @hidden */
  60192. export var volumetricLightScatteringPassPixelShader: {
  60193. name: string;
  60194. shader: string;
  60195. };
  60196. }
  60197. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  60198. import { Vector3 } from "babylonjs/Maths/math";
  60199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60200. import { Mesh } from "babylonjs/Meshes/mesh";
  60201. import { Camera } from "babylonjs/Cameras/camera";
  60202. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60203. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60204. import { Scene } from "babylonjs/scene";
  60205. import "babylonjs/Meshes/Builders/planeBuilder";
  60206. import "babylonjs/Shaders/depth.vertex";
  60207. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  60208. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  60209. import { Engine } from "babylonjs/Engines/engine";
  60210. /**
  60211. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60212. */
  60213. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60214. private _volumetricLightScatteringPass;
  60215. private _volumetricLightScatteringRTT;
  60216. private _viewPort;
  60217. private _screenCoordinates;
  60218. private _cachedDefines;
  60219. /**
  60220. * If not undefined, the mesh position is computed from the attached node position
  60221. */
  60222. attachedNode: {
  60223. position: Vector3;
  60224. };
  60225. /**
  60226. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60227. */
  60228. customMeshPosition: Vector3;
  60229. /**
  60230. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60231. */
  60232. useCustomMeshPosition: boolean;
  60233. /**
  60234. * If the post-process should inverse the light scattering direction
  60235. */
  60236. invert: boolean;
  60237. /**
  60238. * The internal mesh used by the post-process
  60239. */
  60240. mesh: Mesh;
  60241. /**
  60242. * @hidden
  60243. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60244. */
  60245. useDiffuseColor: boolean;
  60246. /**
  60247. * Array containing the excluded meshes not rendered in the internal pass
  60248. */
  60249. excludedMeshes: AbstractMesh[];
  60250. /**
  60251. * Controls the overall intensity of the post-process
  60252. */
  60253. exposure: number;
  60254. /**
  60255. * Dissipates each sample's contribution in range [0, 1]
  60256. */
  60257. decay: number;
  60258. /**
  60259. * Controls the overall intensity of each sample
  60260. */
  60261. weight: number;
  60262. /**
  60263. * Controls the density of each sample
  60264. */
  60265. density: number;
  60266. /**
  60267. * @constructor
  60268. * @param name The post-process name
  60269. * @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)
  60270. * @param camera The camera that the post-process will be attached to
  60271. * @param mesh The mesh used to create the light scattering
  60272. * @param samples The post-process quality, default 100
  60273. * @param samplingModeThe post-process filtering mode
  60274. * @param engine The babylon engine
  60275. * @param reusable If the post-process is reusable
  60276. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60277. */
  60278. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60279. /**
  60280. * Returns the string "VolumetricLightScatteringPostProcess"
  60281. * @returns "VolumetricLightScatteringPostProcess"
  60282. */
  60283. getClassName(): string;
  60284. private _isReady;
  60285. /**
  60286. * Sets the new light position for light scattering effect
  60287. * @param position The new custom light position
  60288. */
  60289. setCustomMeshPosition(position: Vector3): void;
  60290. /**
  60291. * Returns the light position for light scattering effect
  60292. * @return Vector3 The custom light position
  60293. */
  60294. getCustomMeshPosition(): Vector3;
  60295. /**
  60296. * Disposes the internal assets and detaches the post-process from the camera
  60297. */
  60298. dispose(camera: Camera): void;
  60299. /**
  60300. * Returns the render target texture used by the post-process
  60301. * @return the render target texture used by the post-process
  60302. */
  60303. getPass(): RenderTargetTexture;
  60304. private _meshExcluded;
  60305. private _createPass;
  60306. private _updateMeshScreenCoordinates;
  60307. /**
  60308. * Creates a default mesh for the Volumeric Light Scattering post-process
  60309. * @param name The mesh name
  60310. * @param scene The scene where to create the mesh
  60311. * @return the default mesh
  60312. */
  60313. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60314. }
  60315. }
  60316. declare module "babylonjs/PostProcesses/index" {
  60317. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  60318. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  60319. export * from "babylonjs/PostProcesses/bloomEffect";
  60320. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  60321. export * from "babylonjs/PostProcesses/blurPostProcess";
  60322. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60323. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  60324. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  60325. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  60326. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60327. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  60328. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  60329. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  60330. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60331. export * from "babylonjs/PostProcesses/filterPostProcess";
  60332. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  60333. export * from "babylonjs/PostProcesses/grainPostProcess";
  60334. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  60335. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60336. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  60337. export * from "babylonjs/PostProcesses/passPostProcess";
  60338. export * from "babylonjs/PostProcesses/postProcess";
  60339. export * from "babylonjs/PostProcesses/postProcessManager";
  60340. export * from "babylonjs/PostProcesses/refractionPostProcess";
  60341. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  60342. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  60343. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  60344. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  60345. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  60346. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  60347. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  60348. }
  60349. declare module "babylonjs/Probes/index" {
  60350. export * from "babylonjs/Probes/reflectionProbe";
  60351. }
  60352. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  60353. import { Scene } from "babylonjs/scene";
  60354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60355. import { Color3 } from "babylonjs/Maths/math";
  60356. import { SmartArray } from "babylonjs/Misc/smartArray";
  60357. import { ISceneComponent } from "babylonjs/sceneComponent";
  60358. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  60359. import "babylonjs/Meshes/Builders/boxBuilder";
  60360. import "babylonjs/Shaders/color.fragment";
  60361. import "babylonjs/Shaders/color.vertex";
  60362. module "babylonjs/scene" {
  60363. interface Scene {
  60364. /** @hidden (Backing field) */
  60365. _boundingBoxRenderer: BoundingBoxRenderer;
  60366. /** @hidden (Backing field) */
  60367. _forceShowBoundingBoxes: boolean;
  60368. /**
  60369. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60370. */
  60371. forceShowBoundingBoxes: boolean;
  60372. /**
  60373. * Gets the bounding box renderer associated with the scene
  60374. * @returns a BoundingBoxRenderer
  60375. */
  60376. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60377. }
  60378. }
  60379. module "babylonjs/Meshes/abstractMesh" {
  60380. interface AbstractMesh {
  60381. /** @hidden (Backing field) */
  60382. _showBoundingBox: boolean;
  60383. /**
  60384. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60385. */
  60386. showBoundingBox: boolean;
  60387. }
  60388. }
  60389. /**
  60390. * Component responsible of rendering the bounding box of the meshes in a scene.
  60391. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60392. */
  60393. export class BoundingBoxRenderer implements ISceneComponent {
  60394. /**
  60395. * The component name helpfull to identify the component in the list of scene components.
  60396. */
  60397. readonly name: string;
  60398. /**
  60399. * The scene the component belongs to.
  60400. */
  60401. scene: Scene;
  60402. /**
  60403. * Color of the bounding box lines placed in front of an object
  60404. */
  60405. frontColor: Color3;
  60406. /**
  60407. * Color of the bounding box lines placed behind an object
  60408. */
  60409. backColor: Color3;
  60410. /**
  60411. * Defines if the renderer should show the back lines or not
  60412. */
  60413. showBackLines: boolean;
  60414. /**
  60415. * @hidden
  60416. */
  60417. renderList: SmartArray<BoundingBox>;
  60418. private _colorShader;
  60419. private _vertexBuffers;
  60420. private _indexBuffer;
  60421. private _fillIndexBuffer;
  60422. private _fillIndexData;
  60423. /**
  60424. * Instantiates a new bounding box renderer in a scene.
  60425. * @param scene the scene the renderer renders in
  60426. */
  60427. constructor(scene: Scene);
  60428. /**
  60429. * Registers the component in a given scene
  60430. */
  60431. register(): void;
  60432. private _evaluateSubMesh;
  60433. private _activeMesh;
  60434. private _prepareRessources;
  60435. private _createIndexBuffer;
  60436. /**
  60437. * Rebuilds the elements related to this component in case of
  60438. * context lost for instance.
  60439. */
  60440. rebuild(): void;
  60441. /**
  60442. * @hidden
  60443. */
  60444. reset(): void;
  60445. /**
  60446. * Render the bounding boxes of a specific rendering group
  60447. * @param renderingGroupId defines the rendering group to render
  60448. */
  60449. render(renderingGroupId: number): void;
  60450. /**
  60451. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60452. * @param mesh Define the mesh to render the occlusion bounding box for
  60453. */
  60454. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60455. /**
  60456. * Dispose and release the resources attached to this renderer.
  60457. */
  60458. dispose(): void;
  60459. }
  60460. }
  60461. declare module "babylonjs/Shaders/depth.fragment" {
  60462. /** @hidden */
  60463. export var depthPixelShader: {
  60464. name: string;
  60465. shader: string;
  60466. };
  60467. }
  60468. declare module "babylonjs/Rendering/depthRenderer" {
  60469. import { Nullable } from "babylonjs/types";
  60470. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60471. import { Scene } from "babylonjs/scene";
  60472. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60473. import { Camera } from "babylonjs/Cameras/camera";
  60474. import "babylonjs/Shaders/depth.fragment";
  60475. import "babylonjs/Shaders/depth.vertex";
  60476. /**
  60477. * This represents a depth renderer in Babylon.
  60478. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60479. */
  60480. export class DepthRenderer {
  60481. private _scene;
  60482. private _depthMap;
  60483. private _effect;
  60484. private _cachedDefines;
  60485. private _camera;
  60486. /**
  60487. * Specifiess that the depth renderer will only be used within
  60488. * the camera it is created for.
  60489. * This can help forcing its rendering during the camera processing.
  60490. */
  60491. useOnlyInActiveCamera: boolean;
  60492. /** @hidden */
  60493. static _SceneComponentInitialization: (scene: Scene) => void;
  60494. /**
  60495. * Instantiates a depth renderer
  60496. * @param scene The scene the renderer belongs to
  60497. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60498. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60499. */
  60500. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  60501. /**
  60502. * Creates the depth rendering effect and checks if the effect is ready.
  60503. * @param subMesh The submesh to be used to render the depth map of
  60504. * @param useInstances If multiple world instances should be used
  60505. * @returns if the depth renderer is ready to render the depth map
  60506. */
  60507. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60508. /**
  60509. * Gets the texture which the depth map will be written to.
  60510. * @returns The depth map texture
  60511. */
  60512. getDepthMap(): RenderTargetTexture;
  60513. /**
  60514. * Disposes of the depth renderer.
  60515. */
  60516. dispose(): void;
  60517. }
  60518. }
  60519. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  60520. import { Nullable } from "babylonjs/types";
  60521. import { Scene } from "babylonjs/scene";
  60522. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60523. import { Camera } from "babylonjs/Cameras/camera";
  60524. import { ISceneComponent } from "babylonjs/sceneComponent";
  60525. module "babylonjs/scene" {
  60526. interface Scene {
  60527. /** @hidden (Backing field) */
  60528. _depthRenderer: {
  60529. [id: string]: DepthRenderer;
  60530. };
  60531. /**
  60532. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60533. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60534. * @returns the created depth renderer
  60535. */
  60536. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  60537. /**
  60538. * Disables a depth renderer for a given camera
  60539. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60540. */
  60541. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60542. }
  60543. }
  60544. /**
  60545. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60546. * in several rendering techniques.
  60547. */
  60548. export class DepthRendererSceneComponent implements ISceneComponent {
  60549. /**
  60550. * The component name helpfull to identify the component in the list of scene components.
  60551. */
  60552. readonly name: string;
  60553. /**
  60554. * The scene the component belongs to.
  60555. */
  60556. scene: Scene;
  60557. /**
  60558. * Creates a new instance of the component for the given scene
  60559. * @param scene Defines the scene to register the component in
  60560. */
  60561. constructor(scene: Scene);
  60562. /**
  60563. * Registers the component in a given scene
  60564. */
  60565. register(): void;
  60566. /**
  60567. * Rebuilds the elements related to this component in case of
  60568. * context lost for instance.
  60569. */
  60570. rebuild(): void;
  60571. /**
  60572. * Disposes the component and the associated ressources
  60573. */
  60574. dispose(): void;
  60575. private _gatherRenderTargets;
  60576. private _gatherActiveCameraRenderTargets;
  60577. }
  60578. }
  60579. declare module "babylonjs/Shaders/outline.fragment" {
  60580. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60581. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  60582. /** @hidden */
  60583. export var outlinePixelShader: {
  60584. name: string;
  60585. shader: string;
  60586. };
  60587. }
  60588. declare module "babylonjs/Shaders/outline.vertex" {
  60589. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60590. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60591. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60592. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60593. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60594. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60595. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60596. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60597. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  60598. /** @hidden */
  60599. export var outlineVertexShader: {
  60600. name: string;
  60601. shader: string;
  60602. };
  60603. }
  60604. declare module "babylonjs/Rendering/outlineRenderer" {
  60605. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60606. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  60607. import { Scene } from "babylonjs/scene";
  60608. import { ISceneComponent } from "babylonjs/sceneComponent";
  60609. import "babylonjs/Shaders/outline.fragment";
  60610. import "babylonjs/Shaders/outline.vertex";
  60611. module "babylonjs/scene" {
  60612. interface Scene {
  60613. /** @hidden */
  60614. _outlineRenderer: OutlineRenderer;
  60615. /**
  60616. * Gets the outline renderer associated with the scene
  60617. * @returns a OutlineRenderer
  60618. */
  60619. getOutlineRenderer(): OutlineRenderer;
  60620. }
  60621. }
  60622. module "babylonjs/Meshes/abstractMesh" {
  60623. interface AbstractMesh {
  60624. /** @hidden (Backing field) */
  60625. _renderOutline: boolean;
  60626. /**
  60627. * Gets or sets a boolean indicating if the outline must be rendered as well
  60628. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60629. */
  60630. renderOutline: boolean;
  60631. /** @hidden (Backing field) */
  60632. _renderOverlay: boolean;
  60633. /**
  60634. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60635. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60636. */
  60637. renderOverlay: boolean;
  60638. }
  60639. }
  60640. /**
  60641. * This class is responsible to draw bothe outline/overlay of meshes.
  60642. * It should not be used directly but through the available method on mesh.
  60643. */
  60644. export class OutlineRenderer implements ISceneComponent {
  60645. /**
  60646. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60647. */
  60648. private static _StencilReference;
  60649. /**
  60650. * The name of the component. Each component must have a unique name.
  60651. */
  60652. name: string;
  60653. /**
  60654. * The scene the component belongs to.
  60655. */
  60656. scene: Scene;
  60657. /**
  60658. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60659. */
  60660. zOffset: number;
  60661. private _engine;
  60662. private _effect;
  60663. private _cachedDefines;
  60664. private _savedDepthWrite;
  60665. /**
  60666. * Instantiates a new outline renderer. (There could be only one per scene).
  60667. * @param scene Defines the scene it belongs to
  60668. */
  60669. constructor(scene: Scene);
  60670. /**
  60671. * Register the component to one instance of a scene.
  60672. */
  60673. register(): void;
  60674. /**
  60675. * Rebuilds the elements related to this component in case of
  60676. * context lost for instance.
  60677. */
  60678. rebuild(): void;
  60679. /**
  60680. * Disposes the component and the associated ressources.
  60681. */
  60682. dispose(): void;
  60683. /**
  60684. * Renders the outline in the canvas.
  60685. * @param subMesh Defines the sumesh to render
  60686. * @param batch Defines the batch of meshes in case of instances
  60687. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60688. */
  60689. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60690. /**
  60691. * Returns whether or not the outline renderer is ready for a given submesh.
  60692. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60693. * @param subMesh Defines the submesh to check readyness for
  60694. * @param useInstances Defines wheter wee are trying to render instances or not
  60695. * @returns true if ready otherwise false
  60696. */
  60697. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60698. private _beforeRenderingMesh;
  60699. private _afterRenderingMesh;
  60700. }
  60701. }
  60702. declare module "babylonjs/Rendering/index" {
  60703. export * from "babylonjs/Rendering/boundingBoxRenderer";
  60704. export * from "babylonjs/Rendering/depthRenderer";
  60705. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  60706. export * from "babylonjs/Rendering/edgesRenderer";
  60707. export * from "babylonjs/Rendering/geometryBufferRenderer";
  60708. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60709. export * from "babylonjs/Rendering/outlineRenderer";
  60710. export * from "babylonjs/Rendering/renderingGroup";
  60711. export * from "babylonjs/Rendering/renderingManager";
  60712. export * from "babylonjs/Rendering/utilityLayerRenderer";
  60713. }
  60714. declare module "babylonjs/Sprites/index" {
  60715. export * from "babylonjs/Sprites/sprite";
  60716. export * from "babylonjs/Sprites/spriteManager";
  60717. export * from "babylonjs/Sprites/spriteSceneComponent";
  60718. }
  60719. declare module "babylonjs/Misc/assetsManager" {
  60720. import { Scene } from "babylonjs/scene";
  60721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60722. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60723. import { Skeleton } from "babylonjs/Bones/skeleton";
  60724. import { Observable } from "babylonjs/Misc/observable";
  60725. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60726. import { Texture } from "babylonjs/Materials/Textures/texture";
  60727. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  60728. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  60729. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60730. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  60731. /**
  60732. * Defines the list of states available for a task inside a AssetsManager
  60733. */
  60734. export enum AssetTaskState {
  60735. /**
  60736. * Initialization
  60737. */
  60738. INIT = 0,
  60739. /**
  60740. * Running
  60741. */
  60742. RUNNING = 1,
  60743. /**
  60744. * Done
  60745. */
  60746. DONE = 2,
  60747. /**
  60748. * Error
  60749. */
  60750. ERROR = 3
  60751. }
  60752. /**
  60753. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60754. */
  60755. export abstract class AbstractAssetTask {
  60756. /**
  60757. * Task name
  60758. */ name: string;
  60759. /**
  60760. * Callback called when the task is successful
  60761. */
  60762. onSuccess: (task: any) => void;
  60763. /**
  60764. * Callback called when the task is not successful
  60765. */
  60766. onError: (task: any, message?: string, exception?: any) => void;
  60767. /**
  60768. * Creates a new AssetsManager
  60769. * @param name defines the name of the task
  60770. */
  60771. constructor(
  60772. /**
  60773. * Task name
  60774. */ name: string);
  60775. private _isCompleted;
  60776. private _taskState;
  60777. private _errorObject;
  60778. /**
  60779. * Get if the task is completed
  60780. */
  60781. readonly isCompleted: boolean;
  60782. /**
  60783. * Gets the current state of the task
  60784. */
  60785. readonly taskState: AssetTaskState;
  60786. /**
  60787. * Gets the current error object (if task is in error)
  60788. */
  60789. readonly errorObject: {
  60790. message?: string;
  60791. exception?: any;
  60792. };
  60793. /**
  60794. * Internal only
  60795. * @hidden
  60796. */
  60797. _setErrorObject(message?: string, exception?: any): void;
  60798. /**
  60799. * Execute the current task
  60800. * @param scene defines the scene where you want your assets to be loaded
  60801. * @param onSuccess is a callback called when the task is successfully executed
  60802. * @param onError is a callback called if an error occurs
  60803. */
  60804. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60805. /**
  60806. * Execute the current task
  60807. * @param scene defines the scene where you want your assets to be loaded
  60808. * @param onSuccess is a callback called when the task is successfully executed
  60809. * @param onError is a callback called if an error occurs
  60810. */
  60811. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60812. /**
  60813. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60814. * This can be used with failed tasks that have the reason for failure fixed.
  60815. */
  60816. reset(): void;
  60817. private onErrorCallback;
  60818. private onDoneCallback;
  60819. }
  60820. /**
  60821. * Define the interface used by progress events raised during assets loading
  60822. */
  60823. export interface IAssetsProgressEvent {
  60824. /**
  60825. * Defines the number of remaining tasks to process
  60826. */
  60827. remainingCount: number;
  60828. /**
  60829. * Defines the total number of tasks
  60830. */
  60831. totalCount: number;
  60832. /**
  60833. * Defines the task that was just processed
  60834. */
  60835. task: AbstractAssetTask;
  60836. }
  60837. /**
  60838. * Class used to share progress information about assets loading
  60839. */
  60840. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60841. /**
  60842. * Defines the number of remaining tasks to process
  60843. */
  60844. remainingCount: number;
  60845. /**
  60846. * Defines the total number of tasks
  60847. */
  60848. totalCount: number;
  60849. /**
  60850. * Defines the task that was just processed
  60851. */
  60852. task: AbstractAssetTask;
  60853. /**
  60854. * Creates a AssetsProgressEvent
  60855. * @param remainingCount defines the number of remaining tasks to process
  60856. * @param totalCount defines the total number of tasks
  60857. * @param task defines the task that was just processed
  60858. */
  60859. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60860. }
  60861. /**
  60862. * Define a task used by AssetsManager to load meshes
  60863. */
  60864. export class MeshAssetTask extends AbstractAssetTask {
  60865. /**
  60866. * Defines the name of the task
  60867. */
  60868. name: string;
  60869. /**
  60870. * Defines the list of mesh's names you want to load
  60871. */
  60872. meshesNames: any;
  60873. /**
  60874. * Defines the root url to use as a base to load your meshes and associated resources
  60875. */
  60876. rootUrl: string;
  60877. /**
  60878. * Defines the filename of the scene to load from
  60879. */
  60880. sceneFilename: string;
  60881. /**
  60882. * Gets the list of loaded meshes
  60883. */
  60884. loadedMeshes: Array<AbstractMesh>;
  60885. /**
  60886. * Gets the list of loaded particle systems
  60887. */
  60888. loadedParticleSystems: Array<IParticleSystem>;
  60889. /**
  60890. * Gets the list of loaded skeletons
  60891. */
  60892. loadedSkeletons: Array<Skeleton>;
  60893. /**
  60894. * Gets the list of loaded animation groups
  60895. */
  60896. loadedAnimationGroups: Array<AnimationGroup>;
  60897. /**
  60898. * Callback called when the task is successful
  60899. */
  60900. onSuccess: (task: MeshAssetTask) => void;
  60901. /**
  60902. * Callback called when the task is successful
  60903. */
  60904. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60905. /**
  60906. * Creates a new MeshAssetTask
  60907. * @param name defines the name of the task
  60908. * @param meshesNames defines the list of mesh's names you want to load
  60909. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60910. * @param sceneFilename defines the filename of the scene to load from
  60911. */
  60912. constructor(
  60913. /**
  60914. * Defines the name of the task
  60915. */
  60916. name: string,
  60917. /**
  60918. * Defines the list of mesh's names you want to load
  60919. */
  60920. meshesNames: any,
  60921. /**
  60922. * Defines the root url to use as a base to load your meshes and associated resources
  60923. */
  60924. rootUrl: string,
  60925. /**
  60926. * Defines the filename of the scene to load from
  60927. */
  60928. sceneFilename: string);
  60929. /**
  60930. * Execute the current task
  60931. * @param scene defines the scene where you want your assets to be loaded
  60932. * @param onSuccess is a callback called when the task is successfully executed
  60933. * @param onError is a callback called if an error occurs
  60934. */
  60935. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60936. }
  60937. /**
  60938. * Define a task used by AssetsManager to load text content
  60939. */
  60940. export class TextFileAssetTask extends AbstractAssetTask {
  60941. /**
  60942. * Defines the name of the task
  60943. */
  60944. name: string;
  60945. /**
  60946. * Defines the location of the file to load
  60947. */
  60948. url: string;
  60949. /**
  60950. * Gets the loaded text string
  60951. */
  60952. text: string;
  60953. /**
  60954. * Callback called when the task is successful
  60955. */
  60956. onSuccess: (task: TextFileAssetTask) => void;
  60957. /**
  60958. * Callback called when the task is successful
  60959. */
  60960. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60961. /**
  60962. * Creates a new TextFileAssetTask object
  60963. * @param name defines the name of the task
  60964. * @param url defines the location of the file to load
  60965. */
  60966. constructor(
  60967. /**
  60968. * Defines the name of the task
  60969. */
  60970. name: string,
  60971. /**
  60972. * Defines the location of the file to load
  60973. */
  60974. url: string);
  60975. /**
  60976. * Execute the current task
  60977. * @param scene defines the scene where you want your assets to be loaded
  60978. * @param onSuccess is a callback called when the task is successfully executed
  60979. * @param onError is a callback called if an error occurs
  60980. */
  60981. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60982. }
  60983. /**
  60984. * Define a task used by AssetsManager to load binary data
  60985. */
  60986. export class BinaryFileAssetTask extends AbstractAssetTask {
  60987. /**
  60988. * Defines the name of the task
  60989. */
  60990. name: string;
  60991. /**
  60992. * Defines the location of the file to load
  60993. */
  60994. url: string;
  60995. /**
  60996. * Gets the lodaded data (as an array buffer)
  60997. */
  60998. data: ArrayBuffer;
  60999. /**
  61000. * Callback called when the task is successful
  61001. */
  61002. onSuccess: (task: BinaryFileAssetTask) => void;
  61003. /**
  61004. * Callback called when the task is successful
  61005. */
  61006. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61007. /**
  61008. * Creates a new BinaryFileAssetTask object
  61009. * @param name defines the name of the new task
  61010. * @param url defines the location of the file to load
  61011. */
  61012. constructor(
  61013. /**
  61014. * Defines the name of the task
  61015. */
  61016. name: string,
  61017. /**
  61018. * Defines the location of the file to load
  61019. */
  61020. url: string);
  61021. /**
  61022. * Execute the current task
  61023. * @param scene defines the scene where you want your assets to be loaded
  61024. * @param onSuccess is a callback called when the task is successfully executed
  61025. * @param onError is a callback called if an error occurs
  61026. */
  61027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61028. }
  61029. /**
  61030. * Define a task used by AssetsManager to load images
  61031. */
  61032. export class ImageAssetTask extends AbstractAssetTask {
  61033. /**
  61034. * Defines the name of the task
  61035. */
  61036. name: string;
  61037. /**
  61038. * Defines the location of the image to load
  61039. */
  61040. url: string;
  61041. /**
  61042. * Gets the loaded images
  61043. */
  61044. image: HTMLImageElement;
  61045. /**
  61046. * Callback called when the task is successful
  61047. */
  61048. onSuccess: (task: ImageAssetTask) => void;
  61049. /**
  61050. * Callback called when the task is successful
  61051. */
  61052. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61053. /**
  61054. * Creates a new ImageAssetTask
  61055. * @param name defines the name of the task
  61056. * @param url defines the location of the image to load
  61057. */
  61058. constructor(
  61059. /**
  61060. * Defines the name of the task
  61061. */
  61062. name: string,
  61063. /**
  61064. * Defines the location of the image to load
  61065. */
  61066. url: string);
  61067. /**
  61068. * Execute the current task
  61069. * @param scene defines the scene where you want your assets to be loaded
  61070. * @param onSuccess is a callback called when the task is successfully executed
  61071. * @param onError is a callback called if an error occurs
  61072. */
  61073. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61074. }
  61075. /**
  61076. * Defines the interface used by texture loading tasks
  61077. */
  61078. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61079. /**
  61080. * Gets the loaded texture
  61081. */
  61082. texture: TEX;
  61083. }
  61084. /**
  61085. * Define a task used by AssetsManager to load 2D textures
  61086. */
  61087. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61088. /**
  61089. * Defines the name of the task
  61090. */
  61091. name: string;
  61092. /**
  61093. * Defines the location of the file to load
  61094. */
  61095. url: string;
  61096. /**
  61097. * Defines if mipmap should not be generated (default is false)
  61098. */
  61099. noMipmap?: boolean | undefined;
  61100. /**
  61101. * Defines if texture must be inverted on Y axis (default is false)
  61102. */
  61103. invertY?: boolean | undefined;
  61104. /**
  61105. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61106. */
  61107. samplingMode: number;
  61108. /**
  61109. * Gets the loaded texture
  61110. */
  61111. texture: Texture;
  61112. /**
  61113. * Callback called when the task is successful
  61114. */
  61115. onSuccess: (task: TextureAssetTask) => void;
  61116. /**
  61117. * Callback called when the task is successful
  61118. */
  61119. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61120. /**
  61121. * Creates a new TextureAssetTask object
  61122. * @param name defines the name of the task
  61123. * @param url defines the location of the file to load
  61124. * @param noMipmap defines if mipmap should not be generated (default is false)
  61125. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61126. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61127. */
  61128. constructor(
  61129. /**
  61130. * Defines the name of the task
  61131. */
  61132. name: string,
  61133. /**
  61134. * Defines the location of the file to load
  61135. */
  61136. url: string,
  61137. /**
  61138. * Defines if mipmap should not be generated (default is false)
  61139. */
  61140. noMipmap?: boolean | undefined,
  61141. /**
  61142. * Defines if texture must be inverted on Y axis (default is false)
  61143. */
  61144. invertY?: boolean | undefined,
  61145. /**
  61146. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61147. */
  61148. samplingMode?: number);
  61149. /**
  61150. * Execute the current task
  61151. * @param scene defines the scene where you want your assets to be loaded
  61152. * @param onSuccess is a callback called when the task is successfully executed
  61153. * @param onError is a callback called if an error occurs
  61154. */
  61155. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61156. }
  61157. /**
  61158. * Define a task used by AssetsManager to load cube textures
  61159. */
  61160. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61161. /**
  61162. * Defines the name of the task
  61163. */
  61164. name: string;
  61165. /**
  61166. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61167. */
  61168. url: string;
  61169. /**
  61170. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61171. */
  61172. extensions?: string[] | undefined;
  61173. /**
  61174. * Defines if mipmaps should not be generated (default is false)
  61175. */
  61176. noMipmap?: boolean | undefined;
  61177. /**
  61178. * Defines the explicit list of files (undefined by default)
  61179. */
  61180. files?: string[] | undefined;
  61181. /**
  61182. * Gets the loaded texture
  61183. */
  61184. texture: CubeTexture;
  61185. /**
  61186. * Callback called when the task is successful
  61187. */
  61188. onSuccess: (task: CubeTextureAssetTask) => void;
  61189. /**
  61190. * Callback called when the task is successful
  61191. */
  61192. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61193. /**
  61194. * Creates a new CubeTextureAssetTask
  61195. * @param name defines the name of the task
  61196. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61197. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61198. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61199. * @param files defines the explicit list of files (undefined by default)
  61200. */
  61201. constructor(
  61202. /**
  61203. * Defines the name of the task
  61204. */
  61205. name: string,
  61206. /**
  61207. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61208. */
  61209. url: string,
  61210. /**
  61211. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61212. */
  61213. extensions?: string[] | undefined,
  61214. /**
  61215. * Defines if mipmaps should not be generated (default is false)
  61216. */
  61217. noMipmap?: boolean | undefined,
  61218. /**
  61219. * Defines the explicit list of files (undefined by default)
  61220. */
  61221. files?: string[] | undefined);
  61222. /**
  61223. * Execute the current task
  61224. * @param scene defines the scene where you want your assets to be loaded
  61225. * @param onSuccess is a callback called when the task is successfully executed
  61226. * @param onError is a callback called if an error occurs
  61227. */
  61228. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61229. }
  61230. /**
  61231. * Define a task used by AssetsManager to load HDR cube textures
  61232. */
  61233. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61234. /**
  61235. * Defines the name of the task
  61236. */
  61237. name: string;
  61238. /**
  61239. * Defines the location of the file to load
  61240. */
  61241. url: string;
  61242. /**
  61243. * Defines the desired size (the more it increases the longer the generation will be)
  61244. */
  61245. size: number;
  61246. /**
  61247. * Defines if mipmaps should not be generated (default is false)
  61248. */
  61249. noMipmap: boolean;
  61250. /**
  61251. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61252. */
  61253. generateHarmonics: boolean;
  61254. /**
  61255. * 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)
  61256. */
  61257. gammaSpace: boolean;
  61258. /**
  61259. * Internal Use Only
  61260. */
  61261. reserved: boolean;
  61262. /**
  61263. * Gets the loaded texture
  61264. */
  61265. texture: HDRCubeTexture;
  61266. /**
  61267. * Callback called when the task is successful
  61268. */
  61269. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61270. /**
  61271. * Callback called when the task is successful
  61272. */
  61273. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61274. /**
  61275. * Creates a new HDRCubeTextureAssetTask object
  61276. * @param name defines the name of the task
  61277. * @param url defines the location of the file to load
  61278. * @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.
  61279. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61280. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61281. * @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)
  61282. * @param reserved Internal use only
  61283. */
  61284. constructor(
  61285. /**
  61286. * Defines the name of the task
  61287. */
  61288. name: string,
  61289. /**
  61290. * Defines the location of the file to load
  61291. */
  61292. url: string,
  61293. /**
  61294. * Defines the desired size (the more it increases the longer the generation will be)
  61295. */
  61296. size: number,
  61297. /**
  61298. * Defines if mipmaps should not be generated (default is false)
  61299. */
  61300. noMipmap?: boolean,
  61301. /**
  61302. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61303. */
  61304. generateHarmonics?: boolean,
  61305. /**
  61306. * 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)
  61307. */
  61308. gammaSpace?: boolean,
  61309. /**
  61310. * Internal Use Only
  61311. */
  61312. reserved?: boolean);
  61313. /**
  61314. * Execute the current task
  61315. * @param scene defines the scene where you want your assets to be loaded
  61316. * @param onSuccess is a callback called when the task is successfully executed
  61317. * @param onError is a callback called if an error occurs
  61318. */
  61319. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61320. }
  61321. /**
  61322. * Define a task used by AssetsManager to load Equirectangular cube textures
  61323. */
  61324. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61325. /**
  61326. * Defines the name of the task
  61327. */
  61328. name: string;
  61329. /**
  61330. * Defines the location of the file to load
  61331. */
  61332. url: string;
  61333. /**
  61334. * Defines the desired size (the more it increases the longer the generation will be)
  61335. */
  61336. size: number;
  61337. /**
  61338. * Defines if mipmaps should not be generated (default is false)
  61339. */
  61340. noMipmap: boolean;
  61341. /**
  61342. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61343. * but the standard material would require them in Gamma space) (default is true)
  61344. */
  61345. gammaSpace: boolean;
  61346. /**
  61347. * Gets the loaded texture
  61348. */
  61349. texture: EquiRectangularCubeTexture;
  61350. /**
  61351. * Callback called when the task is successful
  61352. */
  61353. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61354. /**
  61355. * Callback called when the task is successful
  61356. */
  61357. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61358. /**
  61359. * Creates a new EquiRectangularCubeTextureAssetTask object
  61360. * @param name defines the name of the task
  61361. * @param url defines the location of the file to load
  61362. * @param size defines the desired size (the more it increases the longer the generation will be)
  61363. * If the size is omitted this implies you are using a preprocessed cubemap.
  61364. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61365. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61366. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61367. * (default is true)
  61368. */
  61369. constructor(
  61370. /**
  61371. * Defines the name of the task
  61372. */
  61373. name: string,
  61374. /**
  61375. * Defines the location of the file to load
  61376. */
  61377. url: string,
  61378. /**
  61379. * Defines the desired size (the more it increases the longer the generation will be)
  61380. */
  61381. size: number,
  61382. /**
  61383. * Defines if mipmaps should not be generated (default is false)
  61384. */
  61385. noMipmap?: boolean,
  61386. /**
  61387. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61388. * but the standard material would require them in Gamma space) (default is true)
  61389. */
  61390. gammaSpace?: boolean);
  61391. /**
  61392. * Execute the current task
  61393. * @param scene defines the scene where you want your assets to be loaded
  61394. * @param onSuccess is a callback called when the task is successfully executed
  61395. * @param onError is a callback called if an error occurs
  61396. */
  61397. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61398. }
  61399. /**
  61400. * This class can be used to easily import assets into a scene
  61401. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61402. */
  61403. export class AssetsManager {
  61404. private _scene;
  61405. private _isLoading;
  61406. protected _tasks: AbstractAssetTask[];
  61407. protected _waitingTasksCount: number;
  61408. protected _totalTasksCount: number;
  61409. /**
  61410. * Callback called when all tasks are processed
  61411. */
  61412. onFinish: (tasks: AbstractAssetTask[]) => void;
  61413. /**
  61414. * Callback called when a task is successful
  61415. */
  61416. onTaskSuccess: (task: AbstractAssetTask) => void;
  61417. /**
  61418. * Callback called when a task had an error
  61419. */
  61420. onTaskError: (task: AbstractAssetTask) => void;
  61421. /**
  61422. * Callback called when a task is done (whatever the result is)
  61423. */
  61424. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61425. /**
  61426. * Observable called when all tasks are processed
  61427. */
  61428. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61429. /**
  61430. * Observable called when a task had an error
  61431. */
  61432. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61433. /**
  61434. * Observable called when all tasks were executed
  61435. */
  61436. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61437. /**
  61438. * Observable called when a task is done (whatever the result is)
  61439. */
  61440. onProgressObservable: Observable<IAssetsProgressEvent>;
  61441. /**
  61442. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61443. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61444. */
  61445. useDefaultLoadingScreen: boolean;
  61446. /**
  61447. * Creates a new AssetsManager
  61448. * @param scene defines the scene to work on
  61449. */
  61450. constructor(scene: Scene);
  61451. /**
  61452. * Add a MeshAssetTask to the list of active tasks
  61453. * @param taskName defines the name of the new task
  61454. * @param meshesNames defines the name of meshes to load
  61455. * @param rootUrl defines the root url to use to locate files
  61456. * @param sceneFilename defines the filename of the scene file
  61457. * @returns a new MeshAssetTask object
  61458. */
  61459. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61460. /**
  61461. * Add a TextFileAssetTask to the list of active tasks
  61462. * @param taskName defines the name of the new task
  61463. * @param url defines the url of the file to load
  61464. * @returns a new TextFileAssetTask object
  61465. */
  61466. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61467. /**
  61468. * Add a BinaryFileAssetTask to the list of active tasks
  61469. * @param taskName defines the name of the new task
  61470. * @param url defines the url of the file to load
  61471. * @returns a new BinaryFileAssetTask object
  61472. */
  61473. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61474. /**
  61475. * Add a ImageAssetTask to the list of active tasks
  61476. * @param taskName defines the name of the new task
  61477. * @param url defines the url of the file to load
  61478. * @returns a new ImageAssetTask object
  61479. */
  61480. addImageTask(taskName: string, url: string): ImageAssetTask;
  61481. /**
  61482. * Add a TextureAssetTask to the list of active tasks
  61483. * @param taskName defines the name of the new task
  61484. * @param url defines the url of the file to load
  61485. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61486. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61487. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61488. * @returns a new TextureAssetTask object
  61489. */
  61490. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61491. /**
  61492. * Add a CubeTextureAssetTask to the list of active tasks
  61493. * @param taskName defines the name of the new task
  61494. * @param url defines the url of the file to load
  61495. * @param extensions defines the extension to use to load the cube map (can be null)
  61496. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61497. * @param files defines the list of files to load (can be null)
  61498. * @returns a new CubeTextureAssetTask object
  61499. */
  61500. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61501. /**
  61502. *
  61503. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61504. * @param taskName defines the name of the new task
  61505. * @param url defines the url of the file to load
  61506. * @param size defines the size you want for the cubemap (can be null)
  61507. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61508. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61509. * @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)
  61510. * @param reserved Internal use only
  61511. * @returns a new HDRCubeTextureAssetTask object
  61512. */
  61513. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61514. /**
  61515. *
  61516. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61517. * @param taskName defines the name of the new task
  61518. * @param url defines the url of the file to load
  61519. * @param size defines the size you want for the cubemap (can be null)
  61520. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61521. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61522. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61523. * @returns a new EquiRectangularCubeTextureAssetTask object
  61524. */
  61525. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61526. /**
  61527. * Remove a task from the assets manager.
  61528. * @param task the task to remove
  61529. */
  61530. removeTask(task: AbstractAssetTask): void;
  61531. private _decreaseWaitingTasksCount;
  61532. private _runTask;
  61533. /**
  61534. * Reset the AssetsManager and remove all tasks
  61535. * @return the current instance of the AssetsManager
  61536. */
  61537. reset(): AssetsManager;
  61538. /**
  61539. * Start the loading process
  61540. * @return the current instance of the AssetsManager
  61541. */
  61542. load(): AssetsManager;
  61543. /**
  61544. * Start the loading process as an async operation
  61545. * @return a promise returning the list of failed tasks
  61546. */
  61547. loadAsync(): Promise<void>;
  61548. }
  61549. }
  61550. declare module "babylonjs/Misc/deferred" {
  61551. /**
  61552. * Wrapper class for promise with external resolve and reject.
  61553. */
  61554. export class Deferred<T> {
  61555. /**
  61556. * The promise associated with this deferred object.
  61557. */
  61558. readonly promise: Promise<T>;
  61559. private _resolve;
  61560. private _reject;
  61561. /**
  61562. * The resolve method of the promise associated with this deferred object.
  61563. */
  61564. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61565. /**
  61566. * The reject method of the promise associated with this deferred object.
  61567. */
  61568. readonly reject: (reason?: any) => void;
  61569. /**
  61570. * Constructor for this deferred object.
  61571. */
  61572. constructor();
  61573. }
  61574. }
  61575. declare module "babylonjs/Misc/meshExploder" {
  61576. import { Mesh } from "babylonjs/Meshes/mesh";
  61577. /**
  61578. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61579. */
  61580. export class MeshExploder {
  61581. private _centerMesh;
  61582. private _meshes;
  61583. private _meshesOrigins;
  61584. private _toCenterVectors;
  61585. private _scaledDirection;
  61586. private _newPosition;
  61587. private _centerPosition;
  61588. /**
  61589. * Explodes meshes from a center mesh.
  61590. * @param meshes The meshes to explode.
  61591. * @param centerMesh The mesh to be center of explosion.
  61592. */
  61593. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61594. private _setCenterMesh;
  61595. /**
  61596. * Get class name
  61597. * @returns "MeshExploder"
  61598. */
  61599. getClassName(): string;
  61600. /**
  61601. * "Exploded meshes"
  61602. * @returns Array of meshes with the centerMesh at index 0.
  61603. */
  61604. getMeshes(): Array<Mesh>;
  61605. /**
  61606. * Explodes meshes giving a specific direction
  61607. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61608. */
  61609. explode(direction?: number): void;
  61610. }
  61611. }
  61612. declare module "babylonjs/Misc/filesInput" {
  61613. import { Engine } from "babylonjs/Engines/engine";
  61614. import { Scene } from "babylonjs/scene";
  61615. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61616. /**
  61617. * Class used to help managing file picking and drag'n'drop
  61618. */
  61619. export class FilesInput {
  61620. /**
  61621. * List of files ready to be loaded
  61622. */
  61623. static readonly FilesToLoad: {
  61624. [key: string]: File;
  61625. };
  61626. /**
  61627. * Callback called when a file is processed
  61628. */
  61629. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61630. private _engine;
  61631. private _currentScene;
  61632. private _sceneLoadedCallback;
  61633. private _progressCallback;
  61634. private _additionalRenderLoopLogicCallback;
  61635. private _textureLoadingCallback;
  61636. private _startingProcessingFilesCallback;
  61637. private _onReloadCallback;
  61638. private _errorCallback;
  61639. private _elementToMonitor;
  61640. private _sceneFileToLoad;
  61641. private _filesToLoad;
  61642. /**
  61643. * Creates a new FilesInput
  61644. * @param engine defines the rendering engine
  61645. * @param scene defines the hosting scene
  61646. * @param sceneLoadedCallback callback called when scene is loaded
  61647. * @param progressCallback callback called to track progress
  61648. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61649. * @param textureLoadingCallback callback called when a texture is loading
  61650. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61651. * @param onReloadCallback callback called when a reload is requested
  61652. * @param errorCallback callback call if an error occurs
  61653. */
  61654. 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);
  61655. private _dragEnterHandler;
  61656. private _dragOverHandler;
  61657. private _dropHandler;
  61658. /**
  61659. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61660. * @param elementToMonitor defines the DOM element to track
  61661. */
  61662. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61663. /**
  61664. * Release all associated resources
  61665. */
  61666. dispose(): void;
  61667. private renderFunction;
  61668. private drag;
  61669. private drop;
  61670. private _traverseFolder;
  61671. private _processFiles;
  61672. /**
  61673. * Load files from a drop event
  61674. * @param event defines the drop event to use as source
  61675. */
  61676. loadFiles(event: any): void;
  61677. private _processReload;
  61678. /**
  61679. * Reload the current scene from the loaded files
  61680. */
  61681. reload(): void;
  61682. }
  61683. }
  61684. declare module "babylonjs/Misc/HighDynamicRange/index" {
  61685. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  61686. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  61687. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61688. }
  61689. declare module "babylonjs/Misc/sceneOptimizer" {
  61690. import { Scene, IDisposable } from "babylonjs/scene";
  61691. import { Observable } from "babylonjs/Misc/observable";
  61692. /**
  61693. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61694. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61695. */
  61696. export class SceneOptimization {
  61697. /**
  61698. * Defines the priority of this optimization (0 by default which means first in the list)
  61699. */
  61700. priority: number;
  61701. /**
  61702. * Gets a string describing the action executed by the current optimization
  61703. * @returns description string
  61704. */
  61705. getDescription(): string;
  61706. /**
  61707. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61708. * @param scene defines the current scene where to apply this optimization
  61709. * @param optimizer defines the current optimizer
  61710. * @returns true if everything that can be done was applied
  61711. */
  61712. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61713. /**
  61714. * Creates the SceneOptimization object
  61715. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61716. * @param desc defines the description associated with the optimization
  61717. */
  61718. constructor(
  61719. /**
  61720. * Defines the priority of this optimization (0 by default which means first in the list)
  61721. */
  61722. priority?: number);
  61723. }
  61724. /**
  61725. * Defines an optimization used to reduce the size of render target textures
  61726. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61727. */
  61728. export class TextureOptimization extends SceneOptimization {
  61729. /**
  61730. * Defines the priority of this optimization (0 by default which means first in the list)
  61731. */
  61732. priority: number;
  61733. /**
  61734. * 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
  61735. */
  61736. maximumSize: number;
  61737. /**
  61738. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61739. */
  61740. step: number;
  61741. /**
  61742. * Gets a string describing the action executed by the current optimization
  61743. * @returns description string
  61744. */
  61745. getDescription(): string;
  61746. /**
  61747. * Creates the TextureOptimization object
  61748. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61749. * @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
  61750. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61751. */
  61752. constructor(
  61753. /**
  61754. * Defines the priority of this optimization (0 by default which means first in the list)
  61755. */
  61756. priority?: number,
  61757. /**
  61758. * 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
  61759. */
  61760. maximumSize?: number,
  61761. /**
  61762. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61763. */
  61764. step?: number);
  61765. /**
  61766. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61767. * @param scene defines the current scene where to apply this optimization
  61768. * @param optimizer defines the current optimizer
  61769. * @returns true if everything that can be done was applied
  61770. */
  61771. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61772. }
  61773. /**
  61774. * Defines an optimization used to increase or decrease the rendering resolution
  61775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61776. */
  61777. export class HardwareScalingOptimization extends SceneOptimization {
  61778. /**
  61779. * Defines the priority of this optimization (0 by default which means first in the list)
  61780. */
  61781. priority: number;
  61782. /**
  61783. * Defines the maximum scale to use (2 by default)
  61784. */
  61785. maximumScale: number;
  61786. /**
  61787. * Defines the step to use between two passes (0.5 by default)
  61788. */
  61789. step: number;
  61790. private _currentScale;
  61791. private _directionOffset;
  61792. /**
  61793. * Gets a string describing the action executed by the current optimization
  61794. * @return description string
  61795. */
  61796. getDescription(): string;
  61797. /**
  61798. * Creates the HardwareScalingOptimization object
  61799. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61800. * @param maximumScale defines the maximum scale to use (2 by default)
  61801. * @param step defines the step to use between two passes (0.5 by default)
  61802. */
  61803. constructor(
  61804. /**
  61805. * Defines the priority of this optimization (0 by default which means first in the list)
  61806. */
  61807. priority?: number,
  61808. /**
  61809. * Defines the maximum scale to use (2 by default)
  61810. */
  61811. maximumScale?: number,
  61812. /**
  61813. * Defines the step to use between two passes (0.5 by default)
  61814. */
  61815. step?: number);
  61816. /**
  61817. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61818. * @param scene defines the current scene where to apply this optimization
  61819. * @param optimizer defines the current optimizer
  61820. * @returns true if everything that can be done was applied
  61821. */
  61822. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61823. }
  61824. /**
  61825. * Defines an optimization used to remove shadows
  61826. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61827. */
  61828. export class ShadowsOptimization extends SceneOptimization {
  61829. /**
  61830. * Gets a string describing the action executed by the current optimization
  61831. * @return description string
  61832. */
  61833. getDescription(): string;
  61834. /**
  61835. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61836. * @param scene defines the current scene where to apply this optimization
  61837. * @param optimizer defines the current optimizer
  61838. * @returns true if everything that can be done was applied
  61839. */
  61840. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61841. }
  61842. /**
  61843. * Defines an optimization used to turn post-processes off
  61844. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61845. */
  61846. export class PostProcessesOptimization extends SceneOptimization {
  61847. /**
  61848. * Gets a string describing the action executed by the current optimization
  61849. * @return description string
  61850. */
  61851. getDescription(): string;
  61852. /**
  61853. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61854. * @param scene defines the current scene where to apply this optimization
  61855. * @param optimizer defines the current optimizer
  61856. * @returns true if everything that can be done was applied
  61857. */
  61858. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61859. }
  61860. /**
  61861. * Defines an optimization used to turn lens flares off
  61862. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61863. */
  61864. export class LensFlaresOptimization extends SceneOptimization {
  61865. /**
  61866. * Gets a string describing the action executed by the current optimization
  61867. * @return description string
  61868. */
  61869. getDescription(): string;
  61870. /**
  61871. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61872. * @param scene defines the current scene where to apply this optimization
  61873. * @param optimizer defines the current optimizer
  61874. * @returns true if everything that can be done was applied
  61875. */
  61876. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61877. }
  61878. /**
  61879. * Defines an optimization based on user defined callback.
  61880. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61881. */
  61882. export class CustomOptimization extends SceneOptimization {
  61883. /**
  61884. * Callback called to apply the custom optimization.
  61885. */
  61886. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61887. /**
  61888. * Callback called to get custom description
  61889. */
  61890. onGetDescription: () => string;
  61891. /**
  61892. * Gets a string describing the action executed by the current optimization
  61893. * @returns description string
  61894. */
  61895. getDescription(): string;
  61896. /**
  61897. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61898. * @param scene defines the current scene where to apply this optimization
  61899. * @param optimizer defines the current optimizer
  61900. * @returns true if everything that can be done was applied
  61901. */
  61902. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61903. }
  61904. /**
  61905. * Defines an optimization used to turn particles off
  61906. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61907. */
  61908. export class ParticlesOptimization extends SceneOptimization {
  61909. /**
  61910. * Gets a string describing the action executed by the current optimization
  61911. * @return description string
  61912. */
  61913. getDescription(): string;
  61914. /**
  61915. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61916. * @param scene defines the current scene where to apply this optimization
  61917. * @param optimizer defines the current optimizer
  61918. * @returns true if everything that can be done was applied
  61919. */
  61920. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61921. }
  61922. /**
  61923. * Defines an optimization used to turn render targets off
  61924. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61925. */
  61926. export class RenderTargetsOptimization extends SceneOptimization {
  61927. /**
  61928. * Gets a string describing the action executed by the current optimization
  61929. * @return description string
  61930. */
  61931. getDescription(): string;
  61932. /**
  61933. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61934. * @param scene defines the current scene where to apply this optimization
  61935. * @param optimizer defines the current optimizer
  61936. * @returns true if everything that can be done was applied
  61937. */
  61938. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61939. }
  61940. /**
  61941. * Defines an optimization used to merge meshes with compatible materials
  61942. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61943. */
  61944. export class MergeMeshesOptimization extends SceneOptimization {
  61945. private static _UpdateSelectionTree;
  61946. /**
  61947. * Gets or sets a boolean which defines if optimization octree has to be updated
  61948. */
  61949. /**
  61950. * Gets or sets a boolean which defines if optimization octree has to be updated
  61951. */
  61952. static UpdateSelectionTree: boolean;
  61953. /**
  61954. * Gets a string describing the action executed by the current optimization
  61955. * @return description string
  61956. */
  61957. getDescription(): string;
  61958. private _canBeMerged;
  61959. /**
  61960. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61961. * @param scene defines the current scene where to apply this optimization
  61962. * @param optimizer defines the current optimizer
  61963. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61964. * @returns true if everything that can be done was applied
  61965. */
  61966. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61967. }
  61968. /**
  61969. * Defines a list of options used by SceneOptimizer
  61970. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61971. */
  61972. export class SceneOptimizerOptions {
  61973. /**
  61974. * Defines the target frame rate to reach (60 by default)
  61975. */
  61976. targetFrameRate: number;
  61977. /**
  61978. * Defines the interval between two checkes (2000ms by default)
  61979. */
  61980. trackerDuration: number;
  61981. /**
  61982. * Gets the list of optimizations to apply
  61983. */
  61984. optimizations: SceneOptimization[];
  61985. /**
  61986. * Creates a new list of options used by SceneOptimizer
  61987. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61988. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61989. */
  61990. constructor(
  61991. /**
  61992. * Defines the target frame rate to reach (60 by default)
  61993. */
  61994. targetFrameRate?: number,
  61995. /**
  61996. * Defines the interval between two checkes (2000ms by default)
  61997. */
  61998. trackerDuration?: number);
  61999. /**
  62000. * Add a new optimization
  62001. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62002. * @returns the current SceneOptimizerOptions
  62003. */
  62004. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62005. /**
  62006. * Add a new custom optimization
  62007. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62008. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62009. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62010. * @returns the current SceneOptimizerOptions
  62011. */
  62012. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62013. /**
  62014. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62015. * @param targetFrameRate defines the target frame rate (60 by default)
  62016. * @returns a SceneOptimizerOptions object
  62017. */
  62018. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62019. /**
  62020. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62021. * @param targetFrameRate defines the target frame rate (60 by default)
  62022. * @returns a SceneOptimizerOptions object
  62023. */
  62024. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62025. /**
  62026. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62027. * @param targetFrameRate defines the target frame rate (60 by default)
  62028. * @returns a SceneOptimizerOptions object
  62029. */
  62030. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62031. }
  62032. /**
  62033. * Class used to run optimizations in order to reach a target frame rate
  62034. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62035. */
  62036. export class SceneOptimizer implements IDisposable {
  62037. private _isRunning;
  62038. private _options;
  62039. private _scene;
  62040. private _currentPriorityLevel;
  62041. private _targetFrameRate;
  62042. private _trackerDuration;
  62043. private _currentFrameRate;
  62044. private _sceneDisposeObserver;
  62045. private _improvementMode;
  62046. /**
  62047. * Defines an observable called when the optimizer reaches the target frame rate
  62048. */
  62049. onSuccessObservable: Observable<SceneOptimizer>;
  62050. /**
  62051. * Defines an observable called when the optimizer enables an optimization
  62052. */
  62053. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62054. /**
  62055. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62056. */
  62057. onFailureObservable: Observable<SceneOptimizer>;
  62058. /**
  62059. * Gets a boolean indicating if the optimizer is in improvement mode
  62060. */
  62061. readonly isInImprovementMode: boolean;
  62062. /**
  62063. * Gets the current priority level (0 at start)
  62064. */
  62065. readonly currentPriorityLevel: number;
  62066. /**
  62067. * Gets the current frame rate checked by the SceneOptimizer
  62068. */
  62069. readonly currentFrameRate: number;
  62070. /**
  62071. * Gets or sets the current target frame rate (60 by default)
  62072. */
  62073. /**
  62074. * Gets or sets the current target frame rate (60 by default)
  62075. */
  62076. targetFrameRate: number;
  62077. /**
  62078. * Gets or sets the current interval between two checks (every 2000ms by default)
  62079. */
  62080. /**
  62081. * Gets or sets the current interval between two checks (every 2000ms by default)
  62082. */
  62083. trackerDuration: number;
  62084. /**
  62085. * Gets the list of active optimizations
  62086. */
  62087. readonly optimizations: SceneOptimization[];
  62088. /**
  62089. * Creates a new SceneOptimizer
  62090. * @param scene defines the scene to work on
  62091. * @param options defines the options to use with the SceneOptimizer
  62092. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62093. * @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)
  62094. */
  62095. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62096. /**
  62097. * Stops the current optimizer
  62098. */
  62099. stop(): void;
  62100. /**
  62101. * Reset the optimizer to initial step (current priority level = 0)
  62102. */
  62103. reset(): void;
  62104. /**
  62105. * Start the optimizer. By default it will try to reach a specific framerate
  62106. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62107. */
  62108. start(): void;
  62109. private _checkCurrentState;
  62110. /**
  62111. * Release all resources
  62112. */
  62113. dispose(): void;
  62114. /**
  62115. * Helper function to create a SceneOptimizer with one single line of code
  62116. * @param scene defines the scene to work on
  62117. * @param options defines the options to use with the SceneOptimizer
  62118. * @param onSuccess defines a callback to call on success
  62119. * @param onFailure defines a callback to call on failure
  62120. * @returns the new SceneOptimizer object
  62121. */
  62122. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62123. }
  62124. }
  62125. declare module "babylonjs/Misc/sceneSerializer" {
  62126. import { Scene } from "babylonjs/scene";
  62127. /**
  62128. * Class used to serialize a scene into a string
  62129. */
  62130. export class SceneSerializer {
  62131. /**
  62132. * Clear cache used by a previous serialization
  62133. */
  62134. static ClearCache(): void;
  62135. /**
  62136. * Serialize a scene into a JSON compatible object
  62137. * @param scene defines the scene to serialize
  62138. * @returns a JSON compatible object
  62139. */
  62140. static Serialize(scene: Scene): any;
  62141. /**
  62142. * Serialize a mesh into a JSON compatible object
  62143. * @param toSerialize defines the mesh to serialize
  62144. * @param withParents defines if parents must be serialized as well
  62145. * @param withChildren defines if children must be serialized as well
  62146. * @returns a JSON compatible object
  62147. */
  62148. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62149. }
  62150. }
  62151. declare module "babylonjs/Misc/textureTools" {
  62152. import { Texture } from "babylonjs/Materials/Textures/texture";
  62153. /**
  62154. * Class used to host texture specific utilities
  62155. */
  62156. export class TextureTools {
  62157. /**
  62158. * Uses the GPU to create a copy texture rescaled at a given size
  62159. * @param texture Texture to copy from
  62160. * @param width defines the desired width
  62161. * @param height defines the desired height
  62162. * @param useBilinearMode defines if bilinear mode has to be used
  62163. * @return the generated texture
  62164. */
  62165. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62166. }
  62167. }
  62168. declare module "babylonjs/Misc/videoRecorder" {
  62169. import { Nullable } from "babylonjs/types";
  62170. import { Engine } from "babylonjs/Engines/engine";
  62171. /**
  62172. * This represents the different options available for the video capture.
  62173. */
  62174. export interface VideoRecorderOptions {
  62175. /** Defines the mime type of the video. */
  62176. mimeType: string;
  62177. /** Defines the FPS the video should be recorded at. */
  62178. fps: number;
  62179. /** Defines the chunk size for the recording data. */
  62180. recordChunckSize: number;
  62181. /** The audio tracks to attach to the recording. */
  62182. audioTracks?: MediaStreamTrack[];
  62183. }
  62184. /**
  62185. * This can help with recording videos from BabylonJS.
  62186. * This is based on the available WebRTC functionalities of the browser.
  62187. *
  62188. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62189. */
  62190. export class VideoRecorder {
  62191. private static readonly _defaultOptions;
  62192. /**
  62193. * Returns whether or not the VideoRecorder is available in your browser.
  62194. * @param engine Defines the Babylon Engine.
  62195. * @returns true if supported otherwise false.
  62196. */
  62197. static IsSupported(engine: Engine): boolean;
  62198. private readonly _options;
  62199. private _canvas;
  62200. private _mediaRecorder;
  62201. private _recordedChunks;
  62202. private _fileName;
  62203. private _resolve;
  62204. private _reject;
  62205. /**
  62206. * True when a recording is already in progress.
  62207. */
  62208. readonly isRecording: boolean;
  62209. /**
  62210. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62211. * @param engine Defines the BabylonJS Engine you wish to record.
  62212. * @param options Defines options that can be used to customize the capture.
  62213. */
  62214. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62215. /**
  62216. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62217. */
  62218. stopRecording(): void;
  62219. /**
  62220. * Starts recording the canvas for a max duration specified in parameters.
  62221. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62222. * If null no automatic download will start and you can rely on the promise to get the data back.
  62223. * @param maxDuration Defines the maximum recording time in seconds.
  62224. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62225. * @return A promise callback at the end of the recording with the video data in Blob.
  62226. */
  62227. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62228. /**
  62229. * Releases internal resources used during the recording.
  62230. */
  62231. dispose(): void;
  62232. private _handleDataAvailable;
  62233. private _handleError;
  62234. private _handleStop;
  62235. }
  62236. }
  62237. declare module "babylonjs/Misc/screenshotTools" {
  62238. import { Camera } from "babylonjs/Cameras/camera";
  62239. import { Engine } from "babylonjs/Engines/engine";
  62240. /**
  62241. * Class containing a set of static utilities functions for screenshots
  62242. */
  62243. export class ScreenshotTools {
  62244. /**
  62245. * Captures a screenshot of the current rendering
  62246. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62247. * @param engine defines the rendering engine
  62248. * @param camera defines the source camera
  62249. * @param size This parameter can be set to a single number or to an object with the
  62250. * following (optional) properties: precision, width, height. If a single number is passed,
  62251. * it will be used for both width and height. If an object is passed, the screenshot size
  62252. * will be derived from the parameters. The precision property is a multiplier allowing
  62253. * rendering at a higher or lower resolution
  62254. * @param successCallback defines the callback receives a single parameter which contains the
  62255. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62256. * src parameter of an <img> to display it
  62257. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62258. * Check your browser for supported MIME types
  62259. */
  62260. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  62261. /**
  62262. * Generates an image screenshot from the specified camera.
  62263. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62264. * @param engine The engine to use for rendering
  62265. * @param camera The camera to use for rendering
  62266. * @param size This parameter can be set to a single number or to an object with the
  62267. * following (optional) properties: precision, width, height. If a single number is passed,
  62268. * it will be used for both width and height. If an object is passed, the screenshot size
  62269. * will be derived from the parameters. The precision property is a multiplier allowing
  62270. * rendering at a higher or lower resolution
  62271. * @param successCallback The callback receives a single parameter which contains the
  62272. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62273. * src parameter of an <img> to display it
  62274. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62275. * Check your browser for supported MIME types
  62276. * @param samples Texture samples (default: 1)
  62277. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62278. * @param fileName A name for for the downloaded file.
  62279. */
  62280. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62281. }
  62282. }
  62283. declare module "babylonjs/Misc/index" {
  62284. export * from "babylonjs/Misc/andOrNotEvaluator";
  62285. export * from "babylonjs/Misc/assetsManager";
  62286. export * from "babylonjs/Misc/dds";
  62287. export * from "babylonjs/Misc/decorators";
  62288. export * from "babylonjs/Misc/deferred";
  62289. export * from "babylonjs/Misc/environmentTextureTools";
  62290. export * from "babylonjs/Misc/meshExploder";
  62291. export * from "babylonjs/Misc/filesInput";
  62292. export * from "babylonjs/Misc/HighDynamicRange/index";
  62293. export * from "babylonjs/Misc/khronosTextureContainer";
  62294. export * from "babylonjs/Misc/observable";
  62295. export * from "babylonjs/Misc/performanceMonitor";
  62296. export * from "babylonjs/Misc/promise";
  62297. export * from "babylonjs/Misc/sceneOptimizer";
  62298. export * from "babylonjs/Misc/sceneSerializer";
  62299. export * from "babylonjs/Misc/smartArray";
  62300. export * from "babylonjs/Misc/stringDictionary";
  62301. export * from "babylonjs/Misc/tags";
  62302. export * from "babylonjs/Misc/textureTools";
  62303. export * from "babylonjs/Misc/tga";
  62304. export * from "babylonjs/Misc/tools";
  62305. export * from "babylonjs/Misc/videoRecorder";
  62306. export * from "babylonjs/Misc/virtualJoystick";
  62307. export * from "babylonjs/Misc/workerPool";
  62308. export * from "babylonjs/Misc/logger";
  62309. export * from "babylonjs/Misc/typeStore";
  62310. export * from "babylonjs/Misc/filesInputStore";
  62311. export * from "babylonjs/Misc/deepCopier";
  62312. export * from "babylonjs/Misc/pivotTools";
  62313. export * from "babylonjs/Misc/precisionDate";
  62314. export * from "babylonjs/Misc/screenshotTools";
  62315. export * from "babylonjs/Misc/typeStore";
  62316. export * from "babylonjs/Misc/webRequest";
  62317. export * from "babylonjs/Misc/iInspectable";
  62318. export * from "babylonjs/Misc/brdfTextureTools";
  62319. }
  62320. declare module "babylonjs/index" {
  62321. export * from "babylonjs/abstractScene";
  62322. export * from "babylonjs/Actions/index";
  62323. export * from "babylonjs/Animations/index";
  62324. export * from "babylonjs/assetContainer";
  62325. export * from "babylonjs/Audio/index";
  62326. export * from "babylonjs/Behaviors/index";
  62327. export * from "babylonjs/Bones/index";
  62328. export * from "babylonjs/Cameras/index";
  62329. export * from "babylonjs/Collisions/index";
  62330. export * from "babylonjs/Culling/index";
  62331. export * from "babylonjs/Debug/index";
  62332. export * from "babylonjs/Engines/index";
  62333. export * from "babylonjs/Events/index";
  62334. export * from "babylonjs/Gamepads/index";
  62335. export * from "babylonjs/Gizmos/index";
  62336. export * from "babylonjs/Helpers/index";
  62337. export * from "babylonjs/Instrumentation/index";
  62338. export * from "babylonjs/Layers/index";
  62339. export * from "babylonjs/LensFlares/index";
  62340. export * from "babylonjs/Lights/index";
  62341. export * from "babylonjs/Loading/index";
  62342. export * from "babylonjs/Materials/index";
  62343. export * from "babylonjs/Maths/index";
  62344. export * from "babylonjs/Meshes/index";
  62345. export * from "babylonjs/Morph/index";
  62346. export * from "babylonjs/node";
  62347. export * from "babylonjs/Offline/index";
  62348. export * from "babylonjs/Particles/index";
  62349. export * from "babylonjs/Physics/index";
  62350. export * from "babylonjs/PostProcesses/index";
  62351. export * from "babylonjs/Probes/index";
  62352. export * from "babylonjs/Rendering/index";
  62353. export * from "babylonjs/scene";
  62354. export * from "babylonjs/sceneComponent";
  62355. export * from "babylonjs/Sprites/index";
  62356. export * from "babylonjs/States/index";
  62357. export * from "babylonjs/Misc/index";
  62358. export * from "babylonjs/types";
  62359. }
  62360. declare module "babylonjs/Animations/pathCursor" {
  62361. import { Path2, Vector3 } from "babylonjs/Maths/math";
  62362. /**
  62363. * A cursor which tracks a point on a path
  62364. */
  62365. export class PathCursor {
  62366. private path;
  62367. /**
  62368. * Stores path cursor callbacks for when an onchange event is triggered
  62369. */
  62370. private _onchange;
  62371. /**
  62372. * The value of the path cursor
  62373. */
  62374. value: number;
  62375. /**
  62376. * The animation array of the path cursor
  62377. */
  62378. animations: Animation[];
  62379. /**
  62380. * Initializes the path cursor
  62381. * @param path The path to track
  62382. */
  62383. constructor(path: Path2);
  62384. /**
  62385. * Gets the cursor point on the path
  62386. * @returns A point on the path cursor at the cursor location
  62387. */
  62388. getPoint(): Vector3;
  62389. /**
  62390. * Moves the cursor ahead by the step amount
  62391. * @param step The amount to move the cursor forward
  62392. * @returns This path cursor
  62393. */
  62394. moveAhead(step?: number): PathCursor;
  62395. /**
  62396. * Moves the cursor behind by the step amount
  62397. * @param step The amount to move the cursor back
  62398. * @returns This path cursor
  62399. */
  62400. moveBack(step?: number): PathCursor;
  62401. /**
  62402. * Moves the cursor by the step amount
  62403. * If the step amount is greater than one, an exception is thrown
  62404. * @param step The amount to move the cursor
  62405. * @returns This path cursor
  62406. */
  62407. move(step: number): PathCursor;
  62408. /**
  62409. * Ensures that the value is limited between zero and one
  62410. * @returns This path cursor
  62411. */
  62412. private ensureLimits;
  62413. /**
  62414. * Runs onchange callbacks on change (used by the animation engine)
  62415. * @returns This path cursor
  62416. */
  62417. private raiseOnChange;
  62418. /**
  62419. * Executes a function on change
  62420. * @param f A path cursor onchange callback
  62421. * @returns This path cursor
  62422. */
  62423. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62424. }
  62425. }
  62426. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  62427. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  62428. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  62429. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  62430. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  62431. }
  62432. declare module "babylonjs/Engines/Processors/Expressions/index" {
  62433. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  62434. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  62435. }
  62436. declare module "babylonjs/Engines/Processors/index" {
  62437. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  62438. export * from "babylonjs/Engines/Processors/Expressions/index";
  62439. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  62440. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  62441. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  62442. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  62443. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  62444. export * from "babylonjs/Engines/Processors/shaderProcessor";
  62445. }
  62446. declare module "babylonjs/Legacy/legacy" {
  62447. import * as Babylon from "babylonjs/index";
  62448. export * from "babylonjs/index";
  62449. }
  62450. declare module "babylonjs/Shaders/blur.fragment" {
  62451. /** @hidden */
  62452. export var blurPixelShader: {
  62453. name: string;
  62454. shader: string;
  62455. };
  62456. }
  62457. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  62458. /** @hidden */
  62459. export var pointCloudVertexDeclaration: {
  62460. name: string;
  62461. shader: string;
  62462. };
  62463. }
  62464. // Mixins
  62465. interface Window {
  62466. mozIndexedDB: IDBFactory;
  62467. webkitIndexedDB: IDBFactory;
  62468. msIndexedDB: IDBFactory;
  62469. webkitURL: typeof URL;
  62470. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62471. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62472. WebGLRenderingContext: WebGLRenderingContext;
  62473. MSGesture: MSGesture;
  62474. CANNON: any;
  62475. AudioContext: AudioContext;
  62476. webkitAudioContext: AudioContext;
  62477. PointerEvent: any;
  62478. Math: Math;
  62479. Uint8Array: Uint8ArrayConstructor;
  62480. Float32Array: Float32ArrayConstructor;
  62481. mozURL: typeof URL;
  62482. msURL: typeof URL;
  62483. VRFrameData: any; // WebVR, from specs 1.1
  62484. DracoDecoderModule: any;
  62485. setImmediate(handler: (...args: any[]) => void): number;
  62486. }
  62487. interface HTMLCanvasElement {
  62488. requestPointerLock(): void;
  62489. msRequestPointerLock?(): void;
  62490. mozRequestPointerLock?(): void;
  62491. webkitRequestPointerLock?(): void;
  62492. /** Track wether a record is in progress */
  62493. isRecording: boolean;
  62494. /** Capture Stream method defined by some browsers */
  62495. captureStream(fps?: number): MediaStream;
  62496. }
  62497. interface CanvasRenderingContext2D {
  62498. msImageSmoothingEnabled: boolean;
  62499. }
  62500. interface MouseEvent {
  62501. mozMovementX: number;
  62502. mozMovementY: number;
  62503. webkitMovementX: number;
  62504. webkitMovementY: number;
  62505. msMovementX: number;
  62506. msMovementY: number;
  62507. }
  62508. interface Navigator {
  62509. mozGetVRDevices: (any: any) => any;
  62510. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62511. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62512. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62513. webkitGetGamepads(): Gamepad[];
  62514. msGetGamepads(): Gamepad[];
  62515. webkitGamepads(): Gamepad[];
  62516. }
  62517. interface HTMLVideoElement {
  62518. mozSrcObject: any;
  62519. }
  62520. interface Math {
  62521. fround(x: number): number;
  62522. imul(a: number, b: number): number;
  62523. }
  62524. interface WebGLRenderingContext {
  62525. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62526. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62527. vertexAttribDivisor(index: number, divisor: number): void;
  62528. createVertexArray(): any;
  62529. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62530. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62531. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62532. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62533. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62534. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62535. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62536. // Queries
  62537. createQuery(): WebGLQuery;
  62538. deleteQuery(query: WebGLQuery): void;
  62539. beginQuery(target: number, query: WebGLQuery): void;
  62540. endQuery(target: number): void;
  62541. getQueryParameter(query: WebGLQuery, pname: number): any;
  62542. getQuery(target: number, pname: number): any;
  62543. MAX_SAMPLES: number;
  62544. RGBA8: number;
  62545. READ_FRAMEBUFFER: number;
  62546. DRAW_FRAMEBUFFER: number;
  62547. UNIFORM_BUFFER: number;
  62548. HALF_FLOAT_OES: number;
  62549. RGBA16F: number;
  62550. RGBA32F: number;
  62551. R32F: number;
  62552. RG32F: number;
  62553. RGB32F: number;
  62554. R16F: number;
  62555. RG16F: number;
  62556. RGB16F: number;
  62557. RED: number;
  62558. RG: number;
  62559. R8: number;
  62560. RG8: number;
  62561. UNSIGNED_INT_24_8: number;
  62562. DEPTH24_STENCIL8: number;
  62563. /* Multiple Render Targets */
  62564. drawBuffers(buffers: number[]): void;
  62565. readBuffer(src: number): void;
  62566. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62567. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62568. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62569. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62570. // Occlusion Query
  62571. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62572. ANY_SAMPLES_PASSED: number;
  62573. QUERY_RESULT_AVAILABLE: number;
  62574. QUERY_RESULT: number;
  62575. }
  62576. interface WebGLProgram {
  62577. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62578. }
  62579. interface EXT_disjoint_timer_query {
  62580. QUERY_COUNTER_BITS_EXT: number;
  62581. TIME_ELAPSED_EXT: number;
  62582. TIMESTAMP_EXT: number;
  62583. GPU_DISJOINT_EXT: number;
  62584. QUERY_RESULT_EXT: number;
  62585. QUERY_RESULT_AVAILABLE_EXT: number;
  62586. queryCounterEXT(query: WebGLQuery, target: number): void;
  62587. createQueryEXT(): WebGLQuery;
  62588. beginQueryEXT(target: number, query: WebGLQuery): void;
  62589. endQueryEXT(target: number): void;
  62590. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62591. deleteQueryEXT(query: WebGLQuery): void;
  62592. }
  62593. interface WebGLUniformLocation {
  62594. _currentState: any;
  62595. }
  62596. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62597. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62598. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62599. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62600. interface WebGLRenderingContext {
  62601. readonly RASTERIZER_DISCARD: number;
  62602. readonly DEPTH_COMPONENT24: number;
  62603. readonly TEXTURE_3D: number;
  62604. readonly TEXTURE_2D_ARRAY: number;
  62605. readonly TEXTURE_COMPARE_FUNC: number;
  62606. readonly TEXTURE_COMPARE_MODE: number;
  62607. readonly COMPARE_REF_TO_TEXTURE: number;
  62608. readonly TEXTURE_WRAP_R: number;
  62609. readonly HALF_FLOAT: number;
  62610. readonly RGB8: number;
  62611. readonly RED_INTEGER: number;
  62612. readonly RG_INTEGER: number;
  62613. readonly RGB_INTEGER: number;
  62614. readonly RGBA_INTEGER: number;
  62615. readonly R8_SNORM: number;
  62616. readonly RG8_SNORM: number;
  62617. readonly RGB8_SNORM: number;
  62618. readonly RGBA8_SNORM: number;
  62619. readonly R8I: number;
  62620. readonly RG8I: number;
  62621. readonly RGB8I: number;
  62622. readonly RGBA8I: number;
  62623. readonly R8UI: number;
  62624. readonly RG8UI: number;
  62625. readonly RGB8UI: number;
  62626. readonly RGBA8UI: number;
  62627. readonly R16I: number;
  62628. readonly RG16I: number;
  62629. readonly RGB16I: number;
  62630. readonly RGBA16I: number;
  62631. readonly R16UI: number;
  62632. readonly RG16UI: number;
  62633. readonly RGB16UI: number;
  62634. readonly RGBA16UI: number;
  62635. readonly R32I: number;
  62636. readonly RG32I: number;
  62637. readonly RGB32I: number;
  62638. readonly RGBA32I: number;
  62639. readonly R32UI: number;
  62640. readonly RG32UI: number;
  62641. readonly RGB32UI: number;
  62642. readonly RGBA32UI: number;
  62643. readonly RGB10_A2UI: number;
  62644. readonly R11F_G11F_B10F: number;
  62645. readonly RGB9_E5: number;
  62646. readonly RGB10_A2: number;
  62647. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62648. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62649. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62650. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62651. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62652. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62653. 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;
  62654. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62655. readonly TRANSFORM_FEEDBACK: number;
  62656. readonly INTERLEAVED_ATTRIBS: number;
  62657. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62658. createTransformFeedback(): WebGLTransformFeedback;
  62659. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62660. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62661. beginTransformFeedback(primitiveMode: number): void;
  62662. endTransformFeedback(): void;
  62663. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62664. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62665. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62666. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62667. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62668. }
  62669. interface ImageBitmap {
  62670. readonly width: number;
  62671. readonly height: number;
  62672. close(): void;
  62673. }
  62674. interface WebGLQuery extends WebGLObject {
  62675. }
  62676. declare var WebGLQuery: {
  62677. prototype: WebGLQuery;
  62678. new(): WebGLQuery;
  62679. };
  62680. interface WebGLSampler extends WebGLObject {
  62681. }
  62682. declare var WebGLSampler: {
  62683. prototype: WebGLSampler;
  62684. new(): WebGLSampler;
  62685. };
  62686. interface WebGLSync extends WebGLObject {
  62687. }
  62688. declare var WebGLSync: {
  62689. prototype: WebGLSync;
  62690. new(): WebGLSync;
  62691. };
  62692. interface WebGLTransformFeedback extends WebGLObject {
  62693. }
  62694. declare var WebGLTransformFeedback: {
  62695. prototype: WebGLTransformFeedback;
  62696. new(): WebGLTransformFeedback;
  62697. };
  62698. interface WebGLVertexArrayObject extends WebGLObject {
  62699. }
  62700. declare var WebGLVertexArrayObject: {
  62701. prototype: WebGLVertexArrayObject;
  62702. new(): WebGLVertexArrayObject;
  62703. };
  62704. // Type definitions for WebVR API
  62705. // Project: https://w3c.github.io/webvr/
  62706. // Definitions by: six a <https://github.com/lostfictions>
  62707. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62708. interface VRDisplay extends EventTarget {
  62709. /**
  62710. * Dictionary of capabilities describing the VRDisplay.
  62711. */
  62712. readonly capabilities: VRDisplayCapabilities;
  62713. /**
  62714. * z-depth defining the far plane of the eye view frustum
  62715. * enables mapping of values in the render target depth
  62716. * attachment to scene coordinates. Initially set to 10000.0.
  62717. */
  62718. depthFar: number;
  62719. /**
  62720. * z-depth defining the near plane of the eye view frustum
  62721. * enables mapping of values in the render target depth
  62722. * attachment to scene coordinates. Initially set to 0.01.
  62723. */
  62724. depthNear: number;
  62725. /**
  62726. * An identifier for this distinct VRDisplay. Used as an
  62727. * association point in the Gamepad API.
  62728. */
  62729. readonly displayId: number;
  62730. /**
  62731. * A display name, a user-readable name identifying it.
  62732. */
  62733. readonly displayName: string;
  62734. readonly isConnected: boolean;
  62735. readonly isPresenting: boolean;
  62736. /**
  62737. * If this VRDisplay supports room-scale experiences, the optional
  62738. * stage attribute contains details on the room-scale parameters.
  62739. */
  62740. readonly stageParameters: VRStageParameters | null;
  62741. /**
  62742. * Passing the value returned by `requestAnimationFrame` to
  62743. * `cancelAnimationFrame` will unregister the callback.
  62744. * @param handle Define the hanle of the request to cancel
  62745. */
  62746. cancelAnimationFrame(handle: number): void;
  62747. /**
  62748. * Stops presenting to the VRDisplay.
  62749. * @returns a promise to know when it stopped
  62750. */
  62751. exitPresent(): Promise<void>;
  62752. /**
  62753. * Return the current VREyeParameters for the given eye.
  62754. * @param whichEye Define the eye we want the parameter for
  62755. * @returns the eye parameters
  62756. */
  62757. getEyeParameters(whichEye: string): VREyeParameters;
  62758. /**
  62759. * Populates the passed VRFrameData with the information required to render
  62760. * the current frame.
  62761. * @param frameData Define the data structure to populate
  62762. * @returns true if ok otherwise false
  62763. */
  62764. getFrameData(frameData: VRFrameData): boolean;
  62765. /**
  62766. * Get the layers currently being presented.
  62767. * @returns the list of VR layers
  62768. */
  62769. getLayers(): VRLayer[];
  62770. /**
  62771. * Return a VRPose containing the future predicted pose of the VRDisplay
  62772. * when the current frame will be presented. The value returned will not
  62773. * change until JavaScript has returned control to the browser.
  62774. *
  62775. * The VRPose will contain the position, orientation, velocity,
  62776. * and acceleration of each of these properties.
  62777. * @returns the pose object
  62778. */
  62779. getPose(): VRPose;
  62780. /**
  62781. * Return the current instantaneous pose of the VRDisplay, with no
  62782. * prediction applied.
  62783. * @returns the current instantaneous pose
  62784. */
  62785. getImmediatePose(): VRPose;
  62786. /**
  62787. * The callback passed to `requestAnimationFrame` will be called
  62788. * any time a new frame should be rendered. When the VRDisplay is
  62789. * presenting the callback will be called at the native refresh
  62790. * rate of the HMD. When not presenting this function acts
  62791. * identically to how window.requestAnimationFrame acts. Content should
  62792. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62793. * asynchronously from other displays and at differing refresh rates.
  62794. * @param callback Define the eaction to run next frame
  62795. * @returns the request handle it
  62796. */
  62797. requestAnimationFrame(callback: FrameRequestCallback): number;
  62798. /**
  62799. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62800. * Repeat calls while already presenting will update the VRLayers being displayed.
  62801. * @param layers Define the list of layer to present
  62802. * @returns a promise to know when the request has been fulfilled
  62803. */
  62804. requestPresent(layers: VRLayer[]): Promise<void>;
  62805. /**
  62806. * Reset the pose for this display, treating its current position and
  62807. * orientation as the "origin/zero" values. VRPose.position,
  62808. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62809. * updated when calling resetPose(). This should be called in only
  62810. * sitting-space experiences.
  62811. */
  62812. resetPose(): void;
  62813. /**
  62814. * The VRLayer provided to the VRDisplay will be captured and presented
  62815. * in the HMD. Calling this function has the same effect on the source
  62816. * canvas as any other operation that uses its source image, and canvases
  62817. * created without preserveDrawingBuffer set to true will be cleared.
  62818. * @param pose Define the pose to submit
  62819. */
  62820. submitFrame(pose?: VRPose): void;
  62821. }
  62822. declare var VRDisplay: {
  62823. prototype: VRDisplay;
  62824. new(): VRDisplay;
  62825. };
  62826. interface VRLayer {
  62827. leftBounds?: number[] | Float32Array | null;
  62828. rightBounds?: number[] | Float32Array | null;
  62829. source?: HTMLCanvasElement | null;
  62830. }
  62831. interface VRDisplayCapabilities {
  62832. readonly canPresent: boolean;
  62833. readonly hasExternalDisplay: boolean;
  62834. readonly hasOrientation: boolean;
  62835. readonly hasPosition: boolean;
  62836. readonly maxLayers: number;
  62837. }
  62838. interface VREyeParameters {
  62839. /** @deprecated */
  62840. readonly fieldOfView: VRFieldOfView;
  62841. readonly offset: Float32Array;
  62842. readonly renderHeight: number;
  62843. readonly renderWidth: number;
  62844. }
  62845. interface VRFieldOfView {
  62846. readonly downDegrees: number;
  62847. readonly leftDegrees: number;
  62848. readonly rightDegrees: number;
  62849. readonly upDegrees: number;
  62850. }
  62851. interface VRFrameData {
  62852. readonly leftProjectionMatrix: Float32Array;
  62853. readonly leftViewMatrix: Float32Array;
  62854. readonly pose: VRPose;
  62855. readonly rightProjectionMatrix: Float32Array;
  62856. readonly rightViewMatrix: Float32Array;
  62857. readonly timestamp: number;
  62858. }
  62859. interface VRPose {
  62860. readonly angularAcceleration: Float32Array | null;
  62861. readonly angularVelocity: Float32Array | null;
  62862. readonly linearAcceleration: Float32Array | null;
  62863. readonly linearVelocity: Float32Array | null;
  62864. readonly orientation: Float32Array | null;
  62865. readonly position: Float32Array | null;
  62866. readonly timestamp: number;
  62867. }
  62868. interface VRStageParameters {
  62869. sittingToStandingTransform?: Float32Array;
  62870. sizeX?: number;
  62871. sizeY?: number;
  62872. }
  62873. interface Navigator {
  62874. getVRDisplays(): Promise<VRDisplay[]>;
  62875. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62876. }
  62877. interface Window {
  62878. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62879. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62880. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62881. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62882. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62883. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62884. }
  62885. interface Gamepad {
  62886. readonly displayId: number;
  62887. }
  62888. interface XRDevice {
  62889. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  62890. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  62891. }
  62892. interface XRSession {
  62893. getInputSources(): Array<any>;
  62894. baseLayer: XRWebGLLayer;
  62895. requestFrameOfReference(type: string): Promise<void>;
  62896. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  62897. end(): Promise<void>;
  62898. requestAnimationFrame: Function;
  62899. addEventListener: Function;
  62900. }
  62901. interface XRSessionCreationOptions {
  62902. outputContext?: WebGLRenderingContext | null;
  62903. immersive?: boolean;
  62904. environmentIntegration?: boolean;
  62905. }
  62906. interface XRLayer {
  62907. getViewport: Function;
  62908. framebufferWidth: number;
  62909. framebufferHeight: number;
  62910. }
  62911. interface XRView {
  62912. projectionMatrix: Float32Array;
  62913. }
  62914. interface XRFrame {
  62915. getDevicePose: Function;
  62916. getInputPose: Function;
  62917. views: Array<XRView>;
  62918. baseLayer: XRLayer;
  62919. }
  62920. interface XRFrameOfReference {
  62921. }
  62922. interface XRWebGLLayer extends XRLayer {
  62923. framebuffer: WebGLFramebuffer;
  62924. }
  62925. declare var XRWebGLLayer: {
  62926. prototype: XRWebGLLayer;
  62927. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  62928. };
  62929. declare module "babylonjs" {
  62930. export * from "babylonjs/Legacy/legacy";
  62931. }
  62932. declare module BABYLON {
  62933. /** Alias type for value that can be null */
  62934. export type Nullable<T> = T | null;
  62935. /**
  62936. * Alias type for number that are floats
  62937. * @ignorenaming
  62938. */
  62939. export type float = number;
  62940. /**
  62941. * Alias type for number that are doubles.
  62942. * @ignorenaming
  62943. */
  62944. export type double = number;
  62945. /**
  62946. * Alias type for number that are integer
  62947. * @ignorenaming
  62948. */
  62949. export type int = number;
  62950. /** Alias type for number array or Float32Array */
  62951. export type FloatArray = number[] | Float32Array;
  62952. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62953. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62954. /**
  62955. * Alias for types that can be used by a Buffer or VertexBuffer.
  62956. */
  62957. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62958. /**
  62959. * Alias type for primitive types
  62960. * @ignorenaming
  62961. */
  62962. type Primitive = undefined | null | boolean | string | number | Function;
  62963. /**
  62964. * Type modifier to make all the properties of an object Readonly
  62965. */
  62966. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62967. /**
  62968. * Type modifier to make all the properties of an object Readonly recursively
  62969. */
  62970. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62971. /** @hidden */
  62972. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62973. }
  62974. /** @hidden */
  62975. /** @hidden */
  62976. type DeepImmutableObject<T> = {
  62977. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62978. };
  62979. }
  62980. declare module BABYLON {
  62981. /**
  62982. * Class containing a set of static utilities functions for arrays.
  62983. */
  62984. export class ArrayTools {
  62985. /**
  62986. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62987. * @param size the number of element to construct and put in the array
  62988. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62989. * @returns a new array filled with new objects
  62990. */
  62991. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62992. }
  62993. }
  62994. declare module BABYLON {
  62995. /**
  62996. * Scalar computation library
  62997. */
  62998. export class Scalar {
  62999. /**
  63000. * Two pi constants convenient for computation.
  63001. */
  63002. static TwoPi: number;
  63003. /**
  63004. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  63005. * @param a number
  63006. * @param b number
  63007. * @param epsilon (default = 1.401298E-45)
  63008. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  63009. */
  63010. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  63011. /**
  63012. * Returns a string : the upper case translation of the number i to hexadecimal.
  63013. * @param i number
  63014. * @returns the upper case translation of the number i to hexadecimal.
  63015. */
  63016. static ToHex(i: number): string;
  63017. /**
  63018. * Returns -1 if value is negative and +1 is value is positive.
  63019. * @param value the value
  63020. * @returns the value itself if it's equal to zero.
  63021. */
  63022. static Sign(value: number): number;
  63023. /**
  63024. * Returns the value itself if it's between min and max.
  63025. * Returns min if the value is lower than min.
  63026. * Returns max if the value is greater than max.
  63027. * @param value the value to clmap
  63028. * @param min the min value to clamp to (default: 0)
  63029. * @param max the max value to clamp to (default: 1)
  63030. * @returns the clamped value
  63031. */
  63032. static Clamp(value: number, min?: number, max?: number): number;
  63033. /**
  63034. * the log2 of value.
  63035. * @param value the value to compute log2 of
  63036. * @returns the log2 of value.
  63037. */
  63038. static Log2(value: number): number;
  63039. /**
  63040. * Loops the value, so that it is never larger than length and never smaller than 0.
  63041. *
  63042. * This is similar to the modulo operator but it works with floating point numbers.
  63043. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  63044. * With t = 5 and length = 2.5, the result would be 0.0.
  63045. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  63046. * @param value the value
  63047. * @param length the length
  63048. * @returns the looped value
  63049. */
  63050. static Repeat(value: number, length: number): number;
  63051. /**
  63052. * Normalize the value between 0.0 and 1.0 using min and max values
  63053. * @param value value to normalize
  63054. * @param min max to normalize between
  63055. * @param max min to normalize between
  63056. * @returns the normalized value
  63057. */
  63058. static Normalize(value: number, min: number, max: number): number;
  63059. /**
  63060. * Denormalize the value from 0.0 and 1.0 using min and max values
  63061. * @param normalized value to denormalize
  63062. * @param min max to denormalize between
  63063. * @param max min to denormalize between
  63064. * @returns the denormalized value
  63065. */
  63066. static Denormalize(normalized: number, min: number, max: number): number;
  63067. /**
  63068. * Calculates the shortest difference between two given angles given in degrees.
  63069. * @param current current angle in degrees
  63070. * @param target target angle in degrees
  63071. * @returns the delta
  63072. */
  63073. static DeltaAngle(current: number, target: number): number;
  63074. /**
  63075. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  63076. * @param tx value
  63077. * @param length length
  63078. * @returns The returned value will move back and forth between 0 and length
  63079. */
  63080. static PingPong(tx: number, length: number): number;
  63081. /**
  63082. * Interpolates between min and max with smoothing at the limits.
  63083. *
  63084. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  63085. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  63086. * @param from from
  63087. * @param to to
  63088. * @param tx value
  63089. * @returns the smooth stepped value
  63090. */
  63091. static SmoothStep(from: number, to: number, tx: number): number;
  63092. /**
  63093. * Moves a value current towards target.
  63094. *
  63095. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  63096. * Negative values of maxDelta pushes the value away from target.
  63097. * @param current current value
  63098. * @param target target value
  63099. * @param maxDelta max distance to move
  63100. * @returns resulting value
  63101. */
  63102. static MoveTowards(current: number, target: number, maxDelta: number): number;
  63103. /**
  63104. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  63105. *
  63106. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  63107. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  63108. * @param current current value
  63109. * @param target target value
  63110. * @param maxDelta max distance to move
  63111. * @returns resulting angle
  63112. */
  63113. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  63114. /**
  63115. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  63116. * @param start start value
  63117. * @param end target value
  63118. * @param amount amount to lerp between
  63119. * @returns the lerped value
  63120. */
  63121. static Lerp(start: number, end: number, amount: number): number;
  63122. /**
  63123. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  63124. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  63125. * @param start start value
  63126. * @param end target value
  63127. * @param amount amount to lerp between
  63128. * @returns the lerped value
  63129. */
  63130. static LerpAngle(start: number, end: number, amount: number): number;
  63131. /**
  63132. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  63133. * @param a start value
  63134. * @param b target value
  63135. * @param value value between a and b
  63136. * @returns the inverseLerp value
  63137. */
  63138. static InverseLerp(a: number, b: number, value: number): number;
  63139. /**
  63140. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  63141. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  63142. * @param value1 spline value
  63143. * @param tangent1 spline value
  63144. * @param value2 spline value
  63145. * @param tangent2 spline value
  63146. * @param amount input value
  63147. * @returns hermite result
  63148. */
  63149. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  63150. /**
  63151. * Returns a random float number between and min and max values
  63152. * @param min min value of random
  63153. * @param max max value of random
  63154. * @returns random value
  63155. */
  63156. static RandomRange(min: number, max: number): number;
  63157. /**
  63158. * This function returns percentage of a number in a given range.
  63159. *
  63160. * RangeToPercent(40,20,60) will return 0.5 (50%)
  63161. * RangeToPercent(34,0,100) will return 0.34 (34%)
  63162. * @param number to convert to percentage
  63163. * @param min min range
  63164. * @param max max range
  63165. * @returns the percentage
  63166. */
  63167. static RangeToPercent(number: number, min: number, max: number): number;
  63168. /**
  63169. * This function returns number that corresponds to the percentage in a given range.
  63170. *
  63171. * PercentToRange(0.34,0,100) will return 34.
  63172. * @param percent to convert to number
  63173. * @param min min range
  63174. * @param max max range
  63175. * @returns the number
  63176. */
  63177. static PercentToRange(percent: number, min: number, max: number): number;
  63178. /**
  63179. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  63180. * @param angle The angle to normalize in radian.
  63181. * @return The converted angle.
  63182. */
  63183. static NormalizeRadians(angle: number): number;
  63184. }
  63185. }
  63186. declare module BABYLON {
  63187. /**
  63188. * Constant used to convert a value to gamma space
  63189. * @ignorenaming
  63190. */
  63191. export const ToGammaSpace: number;
  63192. /**
  63193. * Constant used to convert a value to linear space
  63194. * @ignorenaming
  63195. */
  63196. export const ToLinearSpace = 2.2;
  63197. /**
  63198. * Constant used to define the minimal number value in Babylon.js
  63199. * @ignorenaming
  63200. */
  63201. let Epsilon: number;
  63202. /**
  63203. * Class used to hold a RBG color
  63204. */
  63205. export class Color3 {
  63206. /**
  63207. * Defines the red component (between 0 and 1, default is 0)
  63208. */
  63209. r: number;
  63210. /**
  63211. * Defines the green component (between 0 and 1, default is 0)
  63212. */
  63213. g: number;
  63214. /**
  63215. * Defines the blue component (between 0 and 1, default is 0)
  63216. */
  63217. b: number;
  63218. /**
  63219. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  63220. * @param r defines the red component (between 0 and 1, default is 0)
  63221. * @param g defines the green component (between 0 and 1, default is 0)
  63222. * @param b defines the blue component (between 0 and 1, default is 0)
  63223. */
  63224. constructor(
  63225. /**
  63226. * Defines the red component (between 0 and 1, default is 0)
  63227. */
  63228. r?: number,
  63229. /**
  63230. * Defines the green component (between 0 and 1, default is 0)
  63231. */
  63232. g?: number,
  63233. /**
  63234. * Defines the blue component (between 0 and 1, default is 0)
  63235. */
  63236. b?: number);
  63237. /**
  63238. * Creates a string with the Color3 current values
  63239. * @returns the string representation of the Color3 object
  63240. */
  63241. toString(): string;
  63242. /**
  63243. * Returns the string "Color3"
  63244. * @returns "Color3"
  63245. */
  63246. getClassName(): string;
  63247. /**
  63248. * Compute the Color3 hash code
  63249. * @returns an unique number that can be used to hash Color3 objects
  63250. */
  63251. getHashCode(): number;
  63252. /**
  63253. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  63254. * @param array defines the array where to store the r,g,b components
  63255. * @param index defines an optional index in the target array to define where to start storing values
  63256. * @returns the current Color3 object
  63257. */
  63258. toArray(array: FloatArray, index?: number): Color3;
  63259. /**
  63260. * Returns a new Color4 object from the current Color3 and the given alpha
  63261. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  63262. * @returns a new Color4 object
  63263. */
  63264. toColor4(alpha?: number): Color4;
  63265. /**
  63266. * Returns a new array populated with 3 numeric elements : red, green and blue values
  63267. * @returns the new array
  63268. */
  63269. asArray(): number[];
  63270. /**
  63271. * Returns the luminance value
  63272. * @returns a float value
  63273. */
  63274. toLuminance(): number;
  63275. /**
  63276. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  63277. * @param otherColor defines the second operand
  63278. * @returns the new Color3 object
  63279. */
  63280. multiply(otherColor: DeepImmutable<Color3>): Color3;
  63281. /**
  63282. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  63283. * @param otherColor defines the second operand
  63284. * @param result defines the Color3 object where to store the result
  63285. * @returns the current Color3
  63286. */
  63287. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63288. /**
  63289. * Determines equality between Color3 objects
  63290. * @param otherColor defines the second operand
  63291. * @returns true if the rgb values are equal to the given ones
  63292. */
  63293. equals(otherColor: DeepImmutable<Color3>): boolean;
  63294. /**
  63295. * Determines equality between the current Color3 object and a set of r,b,g values
  63296. * @param r defines the red component to check
  63297. * @param g defines the green component to check
  63298. * @param b defines the blue component to check
  63299. * @returns true if the rgb values are equal to the given ones
  63300. */
  63301. equalsFloats(r: number, g: number, b: number): boolean;
  63302. /**
  63303. * Multiplies in place each rgb value by scale
  63304. * @param scale defines the scaling factor
  63305. * @returns the updated Color3
  63306. */
  63307. scale(scale: number): Color3;
  63308. /**
  63309. * Multiplies the rgb values by scale and stores the result into "result"
  63310. * @param scale defines the scaling factor
  63311. * @param result defines the Color3 object where to store the result
  63312. * @returns the unmodified current Color3
  63313. */
  63314. scaleToRef(scale: number, result: Color3): Color3;
  63315. /**
  63316. * Scale the current Color3 values by a factor and add the result to a given Color3
  63317. * @param scale defines the scale factor
  63318. * @param result defines color to store the result into
  63319. * @returns the unmodified current Color3
  63320. */
  63321. scaleAndAddToRef(scale: number, result: Color3): Color3;
  63322. /**
  63323. * Clamps the rgb values by the min and max values and stores the result into "result"
  63324. * @param min defines minimum clamping value (default is 0)
  63325. * @param max defines maximum clamping value (default is 1)
  63326. * @param result defines color to store the result into
  63327. * @returns the original Color3
  63328. */
  63329. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  63330. /**
  63331. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  63332. * @param otherColor defines the second operand
  63333. * @returns the new Color3
  63334. */
  63335. add(otherColor: DeepImmutable<Color3>): Color3;
  63336. /**
  63337. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  63338. * @param otherColor defines the second operand
  63339. * @param result defines Color3 object to store the result into
  63340. * @returns the unmodified current Color3
  63341. */
  63342. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63343. /**
  63344. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  63345. * @param otherColor defines the second operand
  63346. * @returns the new Color3
  63347. */
  63348. subtract(otherColor: DeepImmutable<Color3>): Color3;
  63349. /**
  63350. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  63351. * @param otherColor defines the second operand
  63352. * @param result defines Color3 object to store the result into
  63353. * @returns the unmodified current Color3
  63354. */
  63355. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63356. /**
  63357. * Copy the current object
  63358. * @returns a new Color3 copied the current one
  63359. */
  63360. clone(): Color3;
  63361. /**
  63362. * Copies the rgb values from the source in the current Color3
  63363. * @param source defines the source Color3 object
  63364. * @returns the updated Color3 object
  63365. */
  63366. copyFrom(source: DeepImmutable<Color3>): Color3;
  63367. /**
  63368. * Updates the Color3 rgb values from the given floats
  63369. * @param r defines the red component to read from
  63370. * @param g defines the green component to read from
  63371. * @param b defines the blue component to read from
  63372. * @returns the current Color3 object
  63373. */
  63374. copyFromFloats(r: number, g: number, b: number): Color3;
  63375. /**
  63376. * Updates the Color3 rgb values from the given floats
  63377. * @param r defines the red component to read from
  63378. * @param g defines the green component to read from
  63379. * @param b defines the blue component to read from
  63380. * @returns the current Color3 object
  63381. */
  63382. set(r: number, g: number, b: number): Color3;
  63383. /**
  63384. * Compute the Color3 hexadecimal code as a string
  63385. * @returns a string containing the hexadecimal representation of the Color3 object
  63386. */
  63387. toHexString(): string;
  63388. /**
  63389. * Computes a new Color3 converted from the current one to linear space
  63390. * @returns a new Color3 object
  63391. */
  63392. toLinearSpace(): Color3;
  63393. /**
  63394. * Converts current color in rgb space to HSV values
  63395. * @returns a new color3 representing the HSV values
  63396. */
  63397. toHSV(): Color3;
  63398. /**
  63399. * Converts current color in rgb space to HSV values
  63400. * @param result defines the Color3 where to store the HSV values
  63401. */
  63402. toHSVToRef(result: Color3): void;
  63403. /**
  63404. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  63405. * @param convertedColor defines the Color3 object where to store the linear space version
  63406. * @returns the unmodified Color3
  63407. */
  63408. toLinearSpaceToRef(convertedColor: Color3): Color3;
  63409. /**
  63410. * Computes a new Color3 converted from the current one to gamma space
  63411. * @returns a new Color3 object
  63412. */
  63413. toGammaSpace(): Color3;
  63414. /**
  63415. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  63416. * @param convertedColor defines the Color3 object where to store the gamma space version
  63417. * @returns the unmodified Color3
  63418. */
  63419. toGammaSpaceToRef(convertedColor: Color3): Color3;
  63420. private static _BlackReadOnly;
  63421. /**
  63422. * Convert Hue, saturation and value to a Color3 (RGB)
  63423. * @param hue defines the hue
  63424. * @param saturation defines the saturation
  63425. * @param value defines the value
  63426. * @param result defines the Color3 where to store the RGB values
  63427. */
  63428. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  63429. /**
  63430. * Creates a new Color3 from the string containing valid hexadecimal values
  63431. * @param hex defines a string containing valid hexadecimal values
  63432. * @returns a new Color3 object
  63433. */
  63434. static FromHexString(hex: string): Color3;
  63435. /**
  63436. * Creates a new Color3 from the starting index of the given array
  63437. * @param array defines the source array
  63438. * @param offset defines an offset in the source array
  63439. * @returns a new Color3 object
  63440. */
  63441. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  63442. /**
  63443. * Creates a new Color3 from integer values (< 256)
  63444. * @param r defines the red component to read from (value between 0 and 255)
  63445. * @param g defines the green component to read from (value between 0 and 255)
  63446. * @param b defines the blue component to read from (value between 0 and 255)
  63447. * @returns a new Color3 object
  63448. */
  63449. static FromInts(r: number, g: number, b: number): Color3;
  63450. /**
  63451. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63452. * @param start defines the start Color3 value
  63453. * @param end defines the end Color3 value
  63454. * @param amount defines the gradient value between start and end
  63455. * @returns a new Color3 object
  63456. */
  63457. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  63458. /**
  63459. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63460. * @param left defines the start value
  63461. * @param right defines the end value
  63462. * @param amount defines the gradient factor
  63463. * @param result defines the Color3 object where to store the result
  63464. */
  63465. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  63466. /**
  63467. * Returns a Color3 value containing a red color
  63468. * @returns a new Color3 object
  63469. */
  63470. static Red(): Color3;
  63471. /**
  63472. * Returns a Color3 value containing a green color
  63473. * @returns a new Color3 object
  63474. */
  63475. static Green(): Color3;
  63476. /**
  63477. * Returns a Color3 value containing a blue color
  63478. * @returns a new Color3 object
  63479. */
  63480. static Blue(): Color3;
  63481. /**
  63482. * Returns a Color3 value containing a black color
  63483. * @returns a new Color3 object
  63484. */
  63485. static Black(): Color3;
  63486. /**
  63487. * Gets a Color3 value containing a black color that must not be updated
  63488. */
  63489. static readonly BlackReadOnly: DeepImmutable<Color3>;
  63490. /**
  63491. * Returns a Color3 value containing a white color
  63492. * @returns a new Color3 object
  63493. */
  63494. static White(): Color3;
  63495. /**
  63496. * Returns a Color3 value containing a purple color
  63497. * @returns a new Color3 object
  63498. */
  63499. static Purple(): Color3;
  63500. /**
  63501. * Returns a Color3 value containing a magenta color
  63502. * @returns a new Color3 object
  63503. */
  63504. static Magenta(): Color3;
  63505. /**
  63506. * Returns a Color3 value containing a yellow color
  63507. * @returns a new Color3 object
  63508. */
  63509. static Yellow(): Color3;
  63510. /**
  63511. * Returns a Color3 value containing a gray color
  63512. * @returns a new Color3 object
  63513. */
  63514. static Gray(): Color3;
  63515. /**
  63516. * Returns a Color3 value containing a teal color
  63517. * @returns a new Color3 object
  63518. */
  63519. static Teal(): Color3;
  63520. /**
  63521. * Returns a Color3 value containing a random color
  63522. * @returns a new Color3 object
  63523. */
  63524. static Random(): Color3;
  63525. }
  63526. /**
  63527. * Class used to hold a RBGA color
  63528. */
  63529. export class Color4 {
  63530. /**
  63531. * Defines the red component (between 0 and 1, default is 0)
  63532. */
  63533. r: number;
  63534. /**
  63535. * Defines the green component (between 0 and 1, default is 0)
  63536. */
  63537. g: number;
  63538. /**
  63539. * Defines the blue component (between 0 and 1, default is 0)
  63540. */
  63541. b: number;
  63542. /**
  63543. * Defines the alpha component (between 0 and 1, default is 1)
  63544. */
  63545. a: number;
  63546. /**
  63547. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  63548. * @param r defines the red component (between 0 and 1, default is 0)
  63549. * @param g defines the green component (between 0 and 1, default is 0)
  63550. * @param b defines the blue component (between 0 and 1, default is 0)
  63551. * @param a defines the alpha component (between 0 and 1, default is 1)
  63552. */
  63553. constructor(
  63554. /**
  63555. * Defines the red component (between 0 and 1, default is 0)
  63556. */
  63557. r?: number,
  63558. /**
  63559. * Defines the green component (between 0 and 1, default is 0)
  63560. */
  63561. g?: number,
  63562. /**
  63563. * Defines the blue component (between 0 and 1, default is 0)
  63564. */
  63565. b?: number,
  63566. /**
  63567. * Defines the alpha component (between 0 and 1, default is 1)
  63568. */
  63569. a?: number);
  63570. /**
  63571. * Adds in place the given Color4 values to the current Color4 object
  63572. * @param right defines the second operand
  63573. * @returns the current updated Color4 object
  63574. */
  63575. addInPlace(right: DeepImmutable<Color4>): Color4;
  63576. /**
  63577. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  63578. * @returns the new array
  63579. */
  63580. asArray(): number[];
  63581. /**
  63582. * Stores from the starting index in the given array the Color4 successive values
  63583. * @param array defines the array where to store the r,g,b components
  63584. * @param index defines an optional index in the target array to define where to start storing values
  63585. * @returns the current Color4 object
  63586. */
  63587. toArray(array: number[], index?: number): Color4;
  63588. /**
  63589. * Determines equality between Color4 objects
  63590. * @param otherColor defines the second operand
  63591. * @returns true if the rgba values are equal to the given ones
  63592. */
  63593. equals(otherColor: DeepImmutable<Color4>): boolean;
  63594. /**
  63595. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  63596. * @param right defines the second operand
  63597. * @returns a new Color4 object
  63598. */
  63599. add(right: DeepImmutable<Color4>): Color4;
  63600. /**
  63601. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63602. * @param right defines the second operand
  63603. * @returns a new Color4 object
  63604. */
  63605. subtract(right: DeepImmutable<Color4>): Color4;
  63606. /**
  63607. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63608. * @param right defines the second operand
  63609. * @param result defines the Color4 object where to store the result
  63610. * @returns the current Color4 object
  63611. */
  63612. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63613. /**
  63614. * Creates a new Color4 with the current Color4 values multiplied by scale
  63615. * @param scale defines the scaling factor to apply
  63616. * @returns a new Color4 object
  63617. */
  63618. scale(scale: number): Color4;
  63619. /**
  63620. * Multiplies the current Color4 values by scale and stores the result in "result"
  63621. * @param scale defines the scaling factor to apply
  63622. * @param result defines the Color4 object where to store the result
  63623. * @returns the current unmodified Color4
  63624. */
  63625. scaleToRef(scale: number, result: Color4): Color4;
  63626. /**
  63627. * Scale the current Color4 values by a factor and add the result to a given Color4
  63628. * @param scale defines the scale factor
  63629. * @param result defines the Color4 object where to store the result
  63630. * @returns the unmodified current Color4
  63631. */
  63632. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63633. /**
  63634. * Clamps the rgb values by the min and max values and stores the result into "result"
  63635. * @param min defines minimum clamping value (default is 0)
  63636. * @param max defines maximum clamping value (default is 1)
  63637. * @param result defines color to store the result into.
  63638. * @returns the cuurent Color4
  63639. */
  63640. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63641. /**
  63642. * Multipy an Color4 value by another and return a new Color4 object
  63643. * @param color defines the Color4 value to multiply by
  63644. * @returns a new Color4 object
  63645. */
  63646. multiply(color: Color4): Color4;
  63647. /**
  63648. * Multipy a Color4 value by another and push the result in a reference value
  63649. * @param color defines the Color4 value to multiply by
  63650. * @param result defines the Color4 to fill the result in
  63651. * @returns the result Color4
  63652. */
  63653. multiplyToRef(color: Color4, result: Color4): Color4;
  63654. /**
  63655. * Creates a string with the Color4 current values
  63656. * @returns the string representation of the Color4 object
  63657. */
  63658. toString(): string;
  63659. /**
  63660. * Returns the string "Color4"
  63661. * @returns "Color4"
  63662. */
  63663. getClassName(): string;
  63664. /**
  63665. * Compute the Color4 hash code
  63666. * @returns an unique number that can be used to hash Color4 objects
  63667. */
  63668. getHashCode(): number;
  63669. /**
  63670. * Creates a new Color4 copied from the current one
  63671. * @returns a new Color4 object
  63672. */
  63673. clone(): Color4;
  63674. /**
  63675. * Copies the given Color4 values into the current one
  63676. * @param source defines the source Color4 object
  63677. * @returns the current updated Color4 object
  63678. */
  63679. copyFrom(source: Color4): Color4;
  63680. /**
  63681. * Copies the given float values into the current one
  63682. * @param r defines the red component to read from
  63683. * @param g defines the green component to read from
  63684. * @param b defines the blue component to read from
  63685. * @param a defines the alpha component to read from
  63686. * @returns the current updated Color4 object
  63687. */
  63688. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63689. /**
  63690. * Copies the given float values into the current one
  63691. * @param r defines the red component to read from
  63692. * @param g defines the green component to read from
  63693. * @param b defines the blue component to read from
  63694. * @param a defines the alpha component to read from
  63695. * @returns the current updated Color4 object
  63696. */
  63697. set(r: number, g: number, b: number, a: number): Color4;
  63698. /**
  63699. * Compute the Color4 hexadecimal code as a string
  63700. * @returns a string containing the hexadecimal representation of the Color4 object
  63701. */
  63702. toHexString(): string;
  63703. /**
  63704. * Computes a new Color4 converted from the current one to linear space
  63705. * @returns a new Color4 object
  63706. */
  63707. toLinearSpace(): Color4;
  63708. /**
  63709. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63710. * @param convertedColor defines the Color4 object where to store the linear space version
  63711. * @returns the unmodified Color4
  63712. */
  63713. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63714. /**
  63715. * Computes a new Color4 converted from the current one to gamma space
  63716. * @returns a new Color4 object
  63717. */
  63718. toGammaSpace(): Color4;
  63719. /**
  63720. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63721. * @param convertedColor defines the Color4 object where to store the gamma space version
  63722. * @returns the unmodified Color4
  63723. */
  63724. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63725. /**
  63726. * Creates a new Color4 from the string containing valid hexadecimal values
  63727. * @param hex defines a string containing valid hexadecimal values
  63728. * @returns a new Color4 object
  63729. */
  63730. static FromHexString(hex: string): Color4;
  63731. /**
  63732. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63733. * @param left defines the start value
  63734. * @param right defines the end value
  63735. * @param amount defines the gradient factor
  63736. * @returns a new Color4 object
  63737. */
  63738. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63739. /**
  63740. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63741. * @param left defines the start value
  63742. * @param right defines the end value
  63743. * @param amount defines the gradient factor
  63744. * @param result defines the Color4 object where to store data
  63745. */
  63746. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63747. /**
  63748. * Creates a new Color4 from a Color3 and an alpha value
  63749. * @param color3 defines the source Color3 to read from
  63750. * @param alpha defines the alpha component (1.0 by default)
  63751. * @returns a new Color4 object
  63752. */
  63753. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63754. /**
  63755. * Creates a new Color4 from the starting index element of the given array
  63756. * @param array defines the source array to read from
  63757. * @param offset defines the offset in the source array
  63758. * @returns a new Color4 object
  63759. */
  63760. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63761. /**
  63762. * Creates a new Color3 from integer values (< 256)
  63763. * @param r defines the red component to read from (value between 0 and 255)
  63764. * @param g defines the green component to read from (value between 0 and 255)
  63765. * @param b defines the blue component to read from (value between 0 and 255)
  63766. * @param a defines the alpha component to read from (value between 0 and 255)
  63767. * @returns a new Color3 object
  63768. */
  63769. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63770. /**
  63771. * Check the content of a given array and convert it to an array containing RGBA data
  63772. * If the original array was already containing count * 4 values then it is returned directly
  63773. * @param colors defines the array to check
  63774. * @param count defines the number of RGBA data to expect
  63775. * @returns an array containing count * 4 values (RGBA)
  63776. */
  63777. static CheckColors4(colors: number[], count: number): number[];
  63778. }
  63779. /**
  63780. * Class representing a vector containing 2 coordinates
  63781. */
  63782. export class Vector2 {
  63783. /** defines the first coordinate */
  63784. x: number;
  63785. /** defines the second coordinate */
  63786. y: number;
  63787. /**
  63788. * Creates a new Vector2 from the given x and y coordinates
  63789. * @param x defines the first coordinate
  63790. * @param y defines the second coordinate
  63791. */
  63792. constructor(
  63793. /** defines the first coordinate */
  63794. x?: number,
  63795. /** defines the second coordinate */
  63796. y?: number);
  63797. /**
  63798. * Gets a string with the Vector2 coordinates
  63799. * @returns a string with the Vector2 coordinates
  63800. */
  63801. toString(): string;
  63802. /**
  63803. * Gets class name
  63804. * @returns the string "Vector2"
  63805. */
  63806. getClassName(): string;
  63807. /**
  63808. * Gets current vector hash code
  63809. * @returns the Vector2 hash code as a number
  63810. */
  63811. getHashCode(): number;
  63812. /**
  63813. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63814. * @param array defines the source array
  63815. * @param index defines the offset in source array
  63816. * @returns the current Vector2
  63817. */
  63818. toArray(array: FloatArray, index?: number): Vector2;
  63819. /**
  63820. * Copy the current vector to an array
  63821. * @returns a new array with 2 elements: the Vector2 coordinates.
  63822. */
  63823. asArray(): number[];
  63824. /**
  63825. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63826. * @param source defines the source Vector2
  63827. * @returns the current updated Vector2
  63828. */
  63829. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63830. /**
  63831. * Sets the Vector2 coordinates with the given floats
  63832. * @param x defines the first coordinate
  63833. * @param y defines the second coordinate
  63834. * @returns the current updated Vector2
  63835. */
  63836. copyFromFloats(x: number, y: number): Vector2;
  63837. /**
  63838. * Sets the Vector2 coordinates with the given floats
  63839. * @param x defines the first coordinate
  63840. * @param y defines the second coordinate
  63841. * @returns the current updated Vector2
  63842. */
  63843. set(x: number, y: number): Vector2;
  63844. /**
  63845. * Add another vector with the current one
  63846. * @param otherVector defines the other vector
  63847. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63848. */
  63849. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63850. /**
  63851. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63852. * @param otherVector defines the other vector
  63853. * @param result defines the target vector
  63854. * @returns the unmodified current Vector2
  63855. */
  63856. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63857. /**
  63858. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63859. * @param otherVector defines the other vector
  63860. * @returns the current updated Vector2
  63861. */
  63862. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63863. /**
  63864. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63865. * @param otherVector defines the other vector
  63866. * @returns a new Vector2
  63867. */
  63868. addVector3(otherVector: Vector3): Vector2;
  63869. /**
  63870. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63871. * @param otherVector defines the other vector
  63872. * @returns a new Vector2
  63873. */
  63874. subtract(otherVector: Vector2): Vector2;
  63875. /**
  63876. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63877. * @param otherVector defines the other vector
  63878. * @param result defines the target vector
  63879. * @returns the unmodified current Vector2
  63880. */
  63881. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63882. /**
  63883. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63884. * @param otherVector defines the other vector
  63885. * @returns the current updated Vector2
  63886. */
  63887. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63888. /**
  63889. * Multiplies in place the current Vector2 coordinates by the given ones
  63890. * @param otherVector defines the other vector
  63891. * @returns the current updated Vector2
  63892. */
  63893. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63894. /**
  63895. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63896. * @param otherVector defines the other vector
  63897. * @returns a new Vector2
  63898. */
  63899. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63900. /**
  63901. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63902. * @param otherVector defines the other vector
  63903. * @param result defines the target vector
  63904. * @returns the unmodified current Vector2
  63905. */
  63906. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63907. /**
  63908. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63909. * @param x defines the first coordinate
  63910. * @param y defines the second coordinate
  63911. * @returns a new Vector2
  63912. */
  63913. multiplyByFloats(x: number, y: number): Vector2;
  63914. /**
  63915. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63916. * @param otherVector defines the other vector
  63917. * @returns a new Vector2
  63918. */
  63919. divide(otherVector: Vector2): Vector2;
  63920. /**
  63921. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63922. * @param otherVector defines the other vector
  63923. * @param result defines the target vector
  63924. * @returns the unmodified current Vector2
  63925. */
  63926. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63927. /**
  63928. * Divides the current Vector2 coordinates by the given ones
  63929. * @param otherVector defines the other vector
  63930. * @returns the current updated Vector2
  63931. */
  63932. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63933. /**
  63934. * Gets a new Vector2 with current Vector2 negated coordinates
  63935. * @returns a new Vector2
  63936. */
  63937. negate(): Vector2;
  63938. /**
  63939. * Multiply the Vector2 coordinates by scale
  63940. * @param scale defines the scaling factor
  63941. * @returns the current updated Vector2
  63942. */
  63943. scaleInPlace(scale: number): Vector2;
  63944. /**
  63945. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63946. * @param scale defines the scaling factor
  63947. * @returns a new Vector2
  63948. */
  63949. scale(scale: number): Vector2;
  63950. /**
  63951. * Scale the current Vector2 values by a factor to a given Vector2
  63952. * @param scale defines the scale factor
  63953. * @param result defines the Vector2 object where to store the result
  63954. * @returns the unmodified current Vector2
  63955. */
  63956. scaleToRef(scale: number, result: Vector2): Vector2;
  63957. /**
  63958. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63959. * @param scale defines the scale factor
  63960. * @param result defines the Vector2 object where to store the result
  63961. * @returns the unmodified current Vector2
  63962. */
  63963. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63964. /**
  63965. * Gets a boolean if two vectors are equals
  63966. * @param otherVector defines the other vector
  63967. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63968. */
  63969. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63970. /**
  63971. * Gets a boolean if two vectors are equals (using an epsilon value)
  63972. * @param otherVector defines the other vector
  63973. * @param epsilon defines the minimal distance to consider equality
  63974. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63975. */
  63976. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63977. /**
  63978. * Gets a new Vector2 from current Vector2 floored values
  63979. * @returns a new Vector2
  63980. */
  63981. floor(): Vector2;
  63982. /**
  63983. * Gets a new Vector2 from current Vector2 floored values
  63984. * @returns a new Vector2
  63985. */
  63986. fract(): Vector2;
  63987. /**
  63988. * Gets the length of the vector
  63989. * @returns the vector length (float)
  63990. */
  63991. length(): number;
  63992. /**
  63993. * Gets the vector squared length
  63994. * @returns the vector squared length (float)
  63995. */
  63996. lengthSquared(): number;
  63997. /**
  63998. * Normalize the vector
  63999. * @returns the current updated Vector2
  64000. */
  64001. normalize(): Vector2;
  64002. /**
  64003. * Gets a new Vector2 copied from the Vector2
  64004. * @returns a new Vector2
  64005. */
  64006. clone(): Vector2;
  64007. /**
  64008. * Gets a new Vector2(0, 0)
  64009. * @returns a new Vector2
  64010. */
  64011. static Zero(): Vector2;
  64012. /**
  64013. * Gets a new Vector2(1, 1)
  64014. * @returns a new Vector2
  64015. */
  64016. static One(): Vector2;
  64017. /**
  64018. * Gets a new Vector2 set from the given index element of the given array
  64019. * @param array defines the data source
  64020. * @param offset defines the offset in the data source
  64021. * @returns a new Vector2
  64022. */
  64023. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  64024. /**
  64025. * Sets "result" from the given index element of the given array
  64026. * @param array defines the data source
  64027. * @param offset defines the offset in the data source
  64028. * @param result defines the target vector
  64029. */
  64030. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  64031. /**
  64032. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  64033. * @param value1 defines 1st point of control
  64034. * @param value2 defines 2nd point of control
  64035. * @param value3 defines 3rd point of control
  64036. * @param value4 defines 4th point of control
  64037. * @param amount defines the interpolation factor
  64038. * @returns a new Vector2
  64039. */
  64040. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  64041. /**
  64042. * 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".
  64043. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  64044. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  64045. * @param value defines the value to clamp
  64046. * @param min defines the lower limit
  64047. * @param max defines the upper limit
  64048. * @returns a new Vector2
  64049. */
  64050. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  64051. /**
  64052. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  64053. * @param value1 defines the 1st control point
  64054. * @param tangent1 defines the outgoing tangent
  64055. * @param value2 defines the 2nd control point
  64056. * @param tangent2 defines the incoming tangent
  64057. * @param amount defines the interpolation factor
  64058. * @returns a new Vector2
  64059. */
  64060. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  64061. /**
  64062. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  64063. * @param start defines the start vector
  64064. * @param end defines the end vector
  64065. * @param amount defines the interpolation factor
  64066. * @returns a new Vector2
  64067. */
  64068. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  64069. /**
  64070. * Gets the dot product of the vector "left" and the vector "right"
  64071. * @param left defines first vector
  64072. * @param right defines second vector
  64073. * @returns the dot product (float)
  64074. */
  64075. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  64076. /**
  64077. * Returns a new Vector2 equal to the normalized given vector
  64078. * @param vector defines the vector to normalize
  64079. * @returns a new Vector2
  64080. */
  64081. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  64082. /**
  64083. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  64084. * @param left defines 1st vector
  64085. * @param right defines 2nd vector
  64086. * @returns a new Vector2
  64087. */
  64088. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  64089. /**
  64090. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  64091. * @param left defines 1st vector
  64092. * @param right defines 2nd vector
  64093. * @returns a new Vector2
  64094. */
  64095. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  64096. /**
  64097. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  64098. * @param vector defines the vector to transform
  64099. * @param transformation defines the matrix to apply
  64100. * @returns a new Vector2
  64101. */
  64102. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  64103. /**
  64104. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  64105. * @param vector defines the vector to transform
  64106. * @param transformation defines the matrix to apply
  64107. * @param result defines the target vector
  64108. */
  64109. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  64110. /**
  64111. * Determines if a given vector is included in a triangle
  64112. * @param p defines the vector to test
  64113. * @param p0 defines 1st triangle point
  64114. * @param p1 defines 2nd triangle point
  64115. * @param p2 defines 3rd triangle point
  64116. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  64117. */
  64118. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  64119. /**
  64120. * Gets the distance between the vectors "value1" and "value2"
  64121. * @param value1 defines first vector
  64122. * @param value2 defines second vector
  64123. * @returns the distance between vectors
  64124. */
  64125. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  64126. /**
  64127. * Returns the squared distance between the vectors "value1" and "value2"
  64128. * @param value1 defines first vector
  64129. * @param value2 defines second vector
  64130. * @returns the squared distance between vectors
  64131. */
  64132. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  64133. /**
  64134. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  64135. * @param value1 defines first vector
  64136. * @param value2 defines second vector
  64137. * @returns a new Vector2
  64138. */
  64139. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  64140. /**
  64141. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  64142. * @param p defines the middle point
  64143. * @param segA defines one point of the segment
  64144. * @param segB defines the other point of the segment
  64145. * @returns the shortest distance
  64146. */
  64147. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  64148. }
  64149. /**
  64150. * Classed used to store (x,y,z) vector representation
  64151. * A Vector3 is the main object used in 3D geometry
  64152. * It can represent etiher the coordinates of a point the space, either a direction
  64153. * Reminder: js uses a left handed forward facing system
  64154. */
  64155. export class Vector3 {
  64156. /**
  64157. * Defines the first coordinates (on X axis)
  64158. */
  64159. x: number;
  64160. /**
  64161. * Defines the second coordinates (on Y axis)
  64162. */
  64163. y: number;
  64164. /**
  64165. * Defines the third coordinates (on Z axis)
  64166. */
  64167. z: number;
  64168. private static _UpReadOnly;
  64169. private static _ZeroReadOnly;
  64170. /**
  64171. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  64172. * @param x defines the first coordinates (on X axis)
  64173. * @param y defines the second coordinates (on Y axis)
  64174. * @param z defines the third coordinates (on Z axis)
  64175. */
  64176. constructor(
  64177. /**
  64178. * Defines the first coordinates (on X axis)
  64179. */
  64180. x?: number,
  64181. /**
  64182. * Defines the second coordinates (on Y axis)
  64183. */
  64184. y?: number,
  64185. /**
  64186. * Defines the third coordinates (on Z axis)
  64187. */
  64188. z?: number);
  64189. /**
  64190. * Creates a string representation of the Vector3
  64191. * @returns a string with the Vector3 coordinates.
  64192. */
  64193. toString(): string;
  64194. /**
  64195. * Gets the class name
  64196. * @returns the string "Vector3"
  64197. */
  64198. getClassName(): string;
  64199. /**
  64200. * Creates the Vector3 hash code
  64201. * @returns a number which tends to be unique between Vector3 instances
  64202. */
  64203. getHashCode(): number;
  64204. /**
  64205. * Creates an array containing three elements : the coordinates of the Vector3
  64206. * @returns a new array of numbers
  64207. */
  64208. asArray(): number[];
  64209. /**
  64210. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  64211. * @param array defines the destination array
  64212. * @param index defines the offset in the destination array
  64213. * @returns the current Vector3
  64214. */
  64215. toArray(array: FloatArray, index?: number): Vector3;
  64216. /**
  64217. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  64218. * @returns a new Quaternion object, computed from the Vector3 coordinates
  64219. */
  64220. toQuaternion(): Quaternion;
  64221. /**
  64222. * Adds the given vector to the current Vector3
  64223. * @param otherVector defines the second operand
  64224. * @returns the current updated Vector3
  64225. */
  64226. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64227. /**
  64228. * Adds the given coordinates to the current Vector3
  64229. * @param x defines the x coordinate of the operand
  64230. * @param y defines the y coordinate of the operand
  64231. * @param z defines the z coordinate of the operand
  64232. * @returns the current updated Vector3
  64233. */
  64234. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64235. /**
  64236. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  64237. * @param otherVector defines the second operand
  64238. * @returns the resulting Vector3
  64239. */
  64240. add(otherVector: DeepImmutable<Vector3>): Vector3;
  64241. /**
  64242. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  64243. * @param otherVector defines the second operand
  64244. * @param result defines the Vector3 object where to store the result
  64245. * @returns the current Vector3
  64246. */
  64247. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64248. /**
  64249. * Subtract the given vector from the current Vector3
  64250. * @param otherVector defines the second operand
  64251. * @returns the current updated Vector3
  64252. */
  64253. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64254. /**
  64255. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  64256. * @param otherVector defines the second operand
  64257. * @returns the resulting Vector3
  64258. */
  64259. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  64260. /**
  64261. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  64262. * @param otherVector defines the second operand
  64263. * @param result defines the Vector3 object where to store the result
  64264. * @returns the current Vector3
  64265. */
  64266. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64267. /**
  64268. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  64269. * @param x defines the x coordinate of the operand
  64270. * @param y defines the y coordinate of the operand
  64271. * @param z defines the z coordinate of the operand
  64272. * @returns the resulting Vector3
  64273. */
  64274. subtractFromFloats(x: number, y: number, z: number): Vector3;
  64275. /**
  64276. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  64277. * @param x defines the x coordinate of the operand
  64278. * @param y defines the y coordinate of the operand
  64279. * @param z defines the z coordinate of the operand
  64280. * @param result defines the Vector3 object where to store the result
  64281. * @returns the current Vector3
  64282. */
  64283. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  64284. /**
  64285. * Gets a new Vector3 set with the current Vector3 negated coordinates
  64286. * @returns a new Vector3
  64287. */
  64288. negate(): Vector3;
  64289. /**
  64290. * Multiplies the Vector3 coordinates by the float "scale"
  64291. * @param scale defines the multiplier factor
  64292. * @returns the current updated Vector3
  64293. */
  64294. scaleInPlace(scale: number): Vector3;
  64295. /**
  64296. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  64297. * @param scale defines the multiplier factor
  64298. * @returns a new Vector3
  64299. */
  64300. scale(scale: number): Vector3;
  64301. /**
  64302. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  64303. * @param scale defines the multiplier factor
  64304. * @param result defines the Vector3 object where to store the result
  64305. * @returns the current Vector3
  64306. */
  64307. scaleToRef(scale: number, result: Vector3): Vector3;
  64308. /**
  64309. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  64310. * @param scale defines the scale factor
  64311. * @param result defines the Vector3 object where to store the result
  64312. * @returns the unmodified current Vector3
  64313. */
  64314. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  64315. /**
  64316. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  64317. * @param otherVector defines the second operand
  64318. * @returns true if both vectors are equals
  64319. */
  64320. equals(otherVector: DeepImmutable<Vector3>): boolean;
  64321. /**
  64322. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  64323. * @param otherVector defines the second operand
  64324. * @param epsilon defines the minimal distance to define values as equals
  64325. * @returns true if both vectors are distant less than epsilon
  64326. */
  64327. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  64328. /**
  64329. * Returns true if the current Vector3 coordinates equals the given floats
  64330. * @param x defines the x coordinate of the operand
  64331. * @param y defines the y coordinate of the operand
  64332. * @param z defines the z coordinate of the operand
  64333. * @returns true if both vectors are equals
  64334. */
  64335. equalsToFloats(x: number, y: number, z: number): boolean;
  64336. /**
  64337. * Multiplies the current Vector3 coordinates by the given ones
  64338. * @param otherVector defines the second operand
  64339. * @returns the current updated Vector3
  64340. */
  64341. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64342. /**
  64343. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  64344. * @param otherVector defines the second operand
  64345. * @returns the new Vector3
  64346. */
  64347. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  64348. /**
  64349. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  64350. * @param otherVector defines the second operand
  64351. * @param result defines the Vector3 object where to store the result
  64352. * @returns the current Vector3
  64353. */
  64354. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64355. /**
  64356. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  64357. * @param x defines the x coordinate of the operand
  64358. * @param y defines the y coordinate of the operand
  64359. * @param z defines the z coordinate of the operand
  64360. * @returns the new Vector3
  64361. */
  64362. multiplyByFloats(x: number, y: number, z: number): Vector3;
  64363. /**
  64364. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  64365. * @param otherVector defines the second operand
  64366. * @returns the new Vector3
  64367. */
  64368. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  64369. /**
  64370. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  64371. * @param otherVector defines the second operand
  64372. * @param result defines the Vector3 object where to store the result
  64373. * @returns the current Vector3
  64374. */
  64375. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64376. /**
  64377. * Divides the current Vector3 coordinates by the given ones.
  64378. * @param otherVector defines the second operand
  64379. * @returns the current updated Vector3
  64380. */
  64381. divideInPlace(otherVector: Vector3): Vector3;
  64382. /**
  64383. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  64384. * @param other defines the second operand
  64385. * @returns the current updated Vector3
  64386. */
  64387. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64388. /**
  64389. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  64390. * @param other defines the second operand
  64391. * @returns the current updated Vector3
  64392. */
  64393. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64394. /**
  64395. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  64396. * @param x defines the x coordinate of the operand
  64397. * @param y defines the y coordinate of the operand
  64398. * @param z defines the z coordinate of the operand
  64399. * @returns the current updated Vector3
  64400. */
  64401. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64402. /**
  64403. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  64404. * @param x defines the x coordinate of the operand
  64405. * @param y defines the y coordinate of the operand
  64406. * @param z defines the z coordinate of the operand
  64407. * @returns the current updated Vector3
  64408. */
  64409. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64410. /**
  64411. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  64412. * Check if is non uniform within a certain amount of decimal places to account for this
  64413. * @param epsilon the amount the values can differ
  64414. * @returns if the the vector is non uniform to a certain number of decimal places
  64415. */
  64416. isNonUniformWithinEpsilon(epsilon: number): boolean;
  64417. /**
  64418. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  64419. */
  64420. readonly isNonUniform: boolean;
  64421. /**
  64422. * Gets a new Vector3 from current Vector3 floored values
  64423. * @returns a new Vector3
  64424. */
  64425. floor(): Vector3;
  64426. /**
  64427. * Gets a new Vector3 from current Vector3 floored values
  64428. * @returns a new Vector3
  64429. */
  64430. fract(): Vector3;
  64431. /**
  64432. * Gets the length of the Vector3
  64433. * @returns the length of the Vector3
  64434. */
  64435. length(): number;
  64436. /**
  64437. * Gets the squared length of the Vector3
  64438. * @returns squared length of the Vector3
  64439. */
  64440. lengthSquared(): number;
  64441. /**
  64442. * Normalize the current Vector3.
  64443. * Please note that this is an in place operation.
  64444. * @returns the current updated Vector3
  64445. */
  64446. normalize(): Vector3;
  64447. /**
  64448. * Reorders the x y z properties of the vector in place
  64449. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  64450. * @returns the current updated vector
  64451. */
  64452. reorderInPlace(order: string): this;
  64453. /**
  64454. * Rotates the vector around 0,0,0 by a quaternion
  64455. * @param quaternion the rotation quaternion
  64456. * @param result vector to store the result
  64457. * @returns the resulting vector
  64458. */
  64459. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  64460. /**
  64461. * Rotates a vector around a given point
  64462. * @param quaternion the rotation quaternion
  64463. * @param point the point to rotate around
  64464. * @param result vector to store the result
  64465. * @returns the resulting vector
  64466. */
  64467. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  64468. /**
  64469. * Normalize the current Vector3 with the given input length.
  64470. * Please note that this is an in place operation.
  64471. * @param len the length of the vector
  64472. * @returns the current updated Vector3
  64473. */
  64474. normalizeFromLength(len: number): Vector3;
  64475. /**
  64476. * Normalize the current Vector3 to a new vector
  64477. * @returns the new Vector3
  64478. */
  64479. normalizeToNew(): Vector3;
  64480. /**
  64481. * Normalize the current Vector3 to the reference
  64482. * @param reference define the Vector3 to update
  64483. * @returns the updated Vector3
  64484. */
  64485. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  64486. /**
  64487. * Creates a new Vector3 copied from the current Vector3
  64488. * @returns the new Vector3
  64489. */
  64490. clone(): Vector3;
  64491. /**
  64492. * Copies the given vector coordinates to the current Vector3 ones
  64493. * @param source defines the source Vector3
  64494. * @returns the current updated Vector3
  64495. */
  64496. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  64497. /**
  64498. * Copies the given floats to the current Vector3 coordinates
  64499. * @param x defines the x coordinate of the operand
  64500. * @param y defines the y coordinate of the operand
  64501. * @param z defines the z coordinate of the operand
  64502. * @returns the current updated Vector3
  64503. */
  64504. copyFromFloats(x: number, y: number, z: number): Vector3;
  64505. /**
  64506. * Copies the given floats to the current Vector3 coordinates
  64507. * @param x defines the x coordinate of the operand
  64508. * @param y defines the y coordinate of the operand
  64509. * @param z defines the z coordinate of the operand
  64510. * @returns the current updated Vector3
  64511. */
  64512. set(x: number, y: number, z: number): Vector3;
  64513. /**
  64514. * Copies the given float to the current Vector3 coordinates
  64515. * @param v defines the x, y and z coordinates of the operand
  64516. * @returns the current updated Vector3
  64517. */
  64518. setAll(v: number): Vector3;
  64519. /**
  64520. * Get the clip factor between two vectors
  64521. * @param vector0 defines the first operand
  64522. * @param vector1 defines the second operand
  64523. * @param axis defines the axis to use
  64524. * @param size defines the size along the axis
  64525. * @returns the clip factor
  64526. */
  64527. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  64528. /**
  64529. * Get angle between two vectors
  64530. * @param vector0 angle between vector0 and vector1
  64531. * @param vector1 angle between vector0 and vector1
  64532. * @param normal direction of the normal
  64533. * @return the angle between vector0 and vector1
  64534. */
  64535. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  64536. /**
  64537. * Returns a new Vector3 set from the index "offset" of the given array
  64538. * @param array defines the source array
  64539. * @param offset defines the offset in the source array
  64540. * @returns the new Vector3
  64541. */
  64542. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  64543. /**
  64544. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  64545. * This function is deprecated. Use FromArray instead
  64546. * @param array defines the source array
  64547. * @param offset defines the offset in the source array
  64548. * @returns the new Vector3
  64549. */
  64550. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  64551. /**
  64552. * Sets the given vector "result" with the element values from the index "offset" of the given array
  64553. * @param array defines the source array
  64554. * @param offset defines the offset in the source array
  64555. * @param result defines the Vector3 where to store the result
  64556. */
  64557. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  64558. /**
  64559. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  64560. * This function is deprecated. Use FromArrayToRef instead.
  64561. * @param array defines the source array
  64562. * @param offset defines the offset in the source array
  64563. * @param result defines the Vector3 where to store the result
  64564. */
  64565. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  64566. /**
  64567. * Sets the given vector "result" with the given floats.
  64568. * @param x defines the x coordinate of the source
  64569. * @param y defines the y coordinate of the source
  64570. * @param z defines the z coordinate of the source
  64571. * @param result defines the Vector3 where to store the result
  64572. */
  64573. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  64574. /**
  64575. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  64576. * @returns a new empty Vector3
  64577. */
  64578. static Zero(): Vector3;
  64579. /**
  64580. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  64581. * @returns a new unit Vector3
  64582. */
  64583. static One(): Vector3;
  64584. /**
  64585. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  64586. * @returns a new up Vector3
  64587. */
  64588. static Up(): Vector3;
  64589. /**
  64590. * Gets a up Vector3 that must not be updated
  64591. */
  64592. static readonly UpReadOnly: DeepImmutable<Vector3>;
  64593. /**
  64594. * Gets a zero Vector3 that must not be updated
  64595. */
  64596. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  64597. /**
  64598. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  64599. * @returns a new down Vector3
  64600. */
  64601. static Down(): Vector3;
  64602. /**
  64603. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64604. * @returns a new forward Vector3
  64605. */
  64606. static Forward(): Vector3;
  64607. /**
  64608. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64609. * @returns a new forward Vector3
  64610. */
  64611. static Backward(): Vector3;
  64612. /**
  64613. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64614. * @returns a new right Vector3
  64615. */
  64616. static Right(): Vector3;
  64617. /**
  64618. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64619. * @returns a new left Vector3
  64620. */
  64621. static Left(): Vector3;
  64622. /**
  64623. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64624. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64625. * @param vector defines the Vector3 to transform
  64626. * @param transformation defines the transformation matrix
  64627. * @returns the transformed Vector3
  64628. */
  64629. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64630. /**
  64631. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64632. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64633. * @param vector defines the Vector3 to transform
  64634. * @param transformation defines the transformation matrix
  64635. * @param result defines the Vector3 where to store the result
  64636. */
  64637. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64638. /**
  64639. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64640. * This method computes tranformed coordinates only, not transformed direction vectors
  64641. * @param x define the x coordinate of the source vector
  64642. * @param y define the y coordinate of the source vector
  64643. * @param z define the z coordinate of the source vector
  64644. * @param transformation defines the transformation matrix
  64645. * @param result defines the Vector3 where to store the result
  64646. */
  64647. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64648. /**
  64649. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64650. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64651. * @param vector defines the Vector3 to transform
  64652. * @param transformation defines the transformation matrix
  64653. * @returns the new Vector3
  64654. */
  64655. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64656. /**
  64657. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64658. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64659. * @param vector defines the Vector3 to transform
  64660. * @param transformation defines the transformation matrix
  64661. * @param result defines the Vector3 where to store the result
  64662. */
  64663. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64664. /**
  64665. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64666. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64667. * @param x define the x coordinate of the source vector
  64668. * @param y define the y coordinate of the source vector
  64669. * @param z define the z coordinate of the source vector
  64670. * @param transformation defines the transformation matrix
  64671. * @param result defines the Vector3 where to store the result
  64672. */
  64673. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64674. /**
  64675. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64676. * @param value1 defines the first control point
  64677. * @param value2 defines the second control point
  64678. * @param value3 defines the third control point
  64679. * @param value4 defines the fourth control point
  64680. * @param amount defines the amount on the spline to use
  64681. * @returns the new Vector3
  64682. */
  64683. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64684. /**
  64685. * 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"
  64686. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64687. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64688. * @param value defines the current value
  64689. * @param min defines the lower range value
  64690. * @param max defines the upper range value
  64691. * @returns the new Vector3
  64692. */
  64693. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64694. /**
  64695. * 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"
  64696. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64697. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64698. * @param value defines the current value
  64699. * @param min defines the lower range value
  64700. * @param max defines the upper range value
  64701. * @param result defines the Vector3 where to store the result
  64702. */
  64703. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64704. /**
  64705. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64706. * @param value1 defines the first control point
  64707. * @param tangent1 defines the first tangent vector
  64708. * @param value2 defines the second control point
  64709. * @param tangent2 defines the second tangent vector
  64710. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64711. * @returns the new Vector3
  64712. */
  64713. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64714. /**
  64715. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64716. * @param start defines the start value
  64717. * @param end defines the end value
  64718. * @param amount max defines amount between both (between 0 and 1)
  64719. * @returns the new Vector3
  64720. */
  64721. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64722. /**
  64723. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64724. * @param start defines the start value
  64725. * @param end defines the end value
  64726. * @param amount max defines amount between both (between 0 and 1)
  64727. * @param result defines the Vector3 where to store the result
  64728. */
  64729. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64730. /**
  64731. * Returns the dot product (float) between the vectors "left" and "right"
  64732. * @param left defines the left operand
  64733. * @param right defines the right operand
  64734. * @returns the dot product
  64735. */
  64736. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64737. /**
  64738. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64739. * The cross product is then orthogonal to both "left" and "right"
  64740. * @param left defines the left operand
  64741. * @param right defines the right operand
  64742. * @returns the cross product
  64743. */
  64744. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64745. /**
  64746. * Sets the given vector "result" with the cross product of "left" and "right"
  64747. * The cross product is then orthogonal to both "left" and "right"
  64748. * @param left defines the left operand
  64749. * @param right defines the right operand
  64750. * @param result defines the Vector3 where to store the result
  64751. */
  64752. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64753. /**
  64754. * Returns a new Vector3 as the normalization of the given vector
  64755. * @param vector defines the Vector3 to normalize
  64756. * @returns the new Vector3
  64757. */
  64758. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64759. /**
  64760. * Sets the given vector "result" with the normalization of the given first vector
  64761. * @param vector defines the Vector3 to normalize
  64762. * @param result defines the Vector3 where to store the result
  64763. */
  64764. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64765. /**
  64766. * Project a Vector3 onto screen space
  64767. * @param vector defines the Vector3 to project
  64768. * @param world defines the world matrix to use
  64769. * @param transform defines the transform (view x projection) matrix to use
  64770. * @param viewport defines the screen viewport to use
  64771. * @returns the new Vector3
  64772. */
  64773. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64774. /** @hidden */
  64775. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64776. /**
  64777. * Unproject from screen space to object space
  64778. * @param source defines the screen space Vector3 to use
  64779. * @param viewportWidth defines the current width of the viewport
  64780. * @param viewportHeight defines the current height of the viewport
  64781. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64782. * @param transform defines the transform (view x projection) matrix to use
  64783. * @returns the new Vector3
  64784. */
  64785. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64786. /**
  64787. * Unproject from screen space to object space
  64788. * @param source defines the screen space Vector3 to use
  64789. * @param viewportWidth defines the current width of the viewport
  64790. * @param viewportHeight defines the current height of the viewport
  64791. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64792. * @param view defines the view matrix to use
  64793. * @param projection defines the projection matrix to use
  64794. * @returns the new Vector3
  64795. */
  64796. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64797. /**
  64798. * Unproject from screen space to object space
  64799. * @param source defines the screen space Vector3 to use
  64800. * @param viewportWidth defines the current width of the viewport
  64801. * @param viewportHeight defines the current height of the viewport
  64802. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64803. * @param view defines the view matrix to use
  64804. * @param projection defines the projection matrix to use
  64805. * @param result defines the Vector3 where to store the result
  64806. */
  64807. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64808. /**
  64809. * Unproject from screen space to object space
  64810. * @param sourceX defines the screen space x coordinate to use
  64811. * @param sourceY defines the screen space y coordinate to use
  64812. * @param sourceZ defines the screen space z coordinate to use
  64813. * @param viewportWidth defines the current width of the viewport
  64814. * @param viewportHeight defines the current height of the viewport
  64815. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64816. * @param view defines the view matrix to use
  64817. * @param projection defines the projection matrix to use
  64818. * @param result defines the Vector3 where to store the result
  64819. */
  64820. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64821. /**
  64822. * Gets the minimal coordinate values between two Vector3
  64823. * @param left defines the first operand
  64824. * @param right defines the second operand
  64825. * @returns the new Vector3
  64826. */
  64827. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64828. /**
  64829. * Gets the maximal coordinate values between two Vector3
  64830. * @param left defines the first operand
  64831. * @param right defines the second operand
  64832. * @returns the new Vector3
  64833. */
  64834. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64835. /**
  64836. * Returns the distance between the vectors "value1" and "value2"
  64837. * @param value1 defines the first operand
  64838. * @param value2 defines the second operand
  64839. * @returns the distance
  64840. */
  64841. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64842. /**
  64843. * Returns the squared distance between the vectors "value1" and "value2"
  64844. * @param value1 defines the first operand
  64845. * @param value2 defines the second operand
  64846. * @returns the squared distance
  64847. */
  64848. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64849. /**
  64850. * Returns a new Vector3 located at the center between "value1" and "value2"
  64851. * @param value1 defines the first operand
  64852. * @param value2 defines the second operand
  64853. * @returns the new Vector3
  64854. */
  64855. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64856. /**
  64857. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64858. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64859. * to something in order to rotate it from its local system to the given target system
  64860. * Note: axis1, axis2 and axis3 are normalized during this operation
  64861. * @param axis1 defines the first axis
  64862. * @param axis2 defines the second axis
  64863. * @param axis3 defines the third axis
  64864. * @returns a new Vector3
  64865. */
  64866. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64867. /**
  64868. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64869. * @param axis1 defines the first axis
  64870. * @param axis2 defines the second axis
  64871. * @param axis3 defines the third axis
  64872. * @param ref defines the Vector3 where to store the result
  64873. */
  64874. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64875. }
  64876. /**
  64877. * Vector4 class created for EulerAngle class conversion to Quaternion
  64878. */
  64879. export class Vector4 {
  64880. /** x value of the vector */
  64881. x: number;
  64882. /** y value of the vector */
  64883. y: number;
  64884. /** z value of the vector */
  64885. z: number;
  64886. /** w value of the vector */
  64887. w: number;
  64888. /**
  64889. * Creates a Vector4 object from the given floats.
  64890. * @param x x value of the vector
  64891. * @param y y value of the vector
  64892. * @param z z value of the vector
  64893. * @param w w value of the vector
  64894. */
  64895. constructor(
  64896. /** x value of the vector */
  64897. x: number,
  64898. /** y value of the vector */
  64899. y: number,
  64900. /** z value of the vector */
  64901. z: number,
  64902. /** w value of the vector */
  64903. w: number);
  64904. /**
  64905. * Returns the string with the Vector4 coordinates.
  64906. * @returns a string containing all the vector values
  64907. */
  64908. toString(): string;
  64909. /**
  64910. * Returns the string "Vector4".
  64911. * @returns "Vector4"
  64912. */
  64913. getClassName(): string;
  64914. /**
  64915. * Returns the Vector4 hash code.
  64916. * @returns a unique hash code
  64917. */
  64918. getHashCode(): number;
  64919. /**
  64920. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64921. * @returns the resulting array
  64922. */
  64923. asArray(): number[];
  64924. /**
  64925. * Populates the given array from the given index with the Vector4 coordinates.
  64926. * @param array array to populate
  64927. * @param index index of the array to start at (default: 0)
  64928. * @returns the Vector4.
  64929. */
  64930. toArray(array: FloatArray, index?: number): Vector4;
  64931. /**
  64932. * Adds the given vector to the current Vector4.
  64933. * @param otherVector the vector to add
  64934. * @returns the updated Vector4.
  64935. */
  64936. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64937. /**
  64938. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64939. * @param otherVector the vector to add
  64940. * @returns the resulting vector
  64941. */
  64942. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64943. /**
  64944. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64945. * @param otherVector the vector to add
  64946. * @param result the vector to store the result
  64947. * @returns the current Vector4.
  64948. */
  64949. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64950. /**
  64951. * Subtract in place the given vector from the current Vector4.
  64952. * @param otherVector the vector to subtract
  64953. * @returns the updated Vector4.
  64954. */
  64955. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64956. /**
  64957. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64958. * @param otherVector the vector to add
  64959. * @returns the new vector with the result
  64960. */
  64961. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64962. /**
  64963. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64964. * @param otherVector the vector to subtract
  64965. * @param result the vector to store the result
  64966. * @returns the current Vector4.
  64967. */
  64968. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64969. /**
  64970. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64971. */
  64972. /**
  64973. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64974. * @param x value to subtract
  64975. * @param y value to subtract
  64976. * @param z value to subtract
  64977. * @param w value to subtract
  64978. * @returns new vector containing the result
  64979. */
  64980. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64981. /**
  64982. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64983. * @param x value to subtract
  64984. * @param y value to subtract
  64985. * @param z value to subtract
  64986. * @param w value to subtract
  64987. * @param result the vector to store the result in
  64988. * @returns the current Vector4.
  64989. */
  64990. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64991. /**
  64992. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64993. * @returns a new vector with the negated values
  64994. */
  64995. negate(): Vector4;
  64996. /**
  64997. * Multiplies the current Vector4 coordinates by scale (float).
  64998. * @param scale the number to scale with
  64999. * @returns the updated Vector4.
  65000. */
  65001. scaleInPlace(scale: number): Vector4;
  65002. /**
  65003. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  65004. * @param scale the number to scale with
  65005. * @returns a new vector with the result
  65006. */
  65007. scale(scale: number): Vector4;
  65008. /**
  65009. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  65010. * @param scale the number to scale with
  65011. * @param result a vector to store the result in
  65012. * @returns the current Vector4.
  65013. */
  65014. scaleToRef(scale: number, result: Vector4): Vector4;
  65015. /**
  65016. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  65017. * @param scale defines the scale factor
  65018. * @param result defines the Vector4 object where to store the result
  65019. * @returns the unmodified current Vector4
  65020. */
  65021. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  65022. /**
  65023. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  65024. * @param otherVector the vector to compare against
  65025. * @returns true if they are equal
  65026. */
  65027. equals(otherVector: DeepImmutable<Vector4>): boolean;
  65028. /**
  65029. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  65030. * @param otherVector vector to compare against
  65031. * @param epsilon (Default: very small number)
  65032. * @returns true if they are equal
  65033. */
  65034. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  65035. /**
  65036. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  65037. * @param x x value to compare against
  65038. * @param y y value to compare against
  65039. * @param z z value to compare against
  65040. * @param w w value to compare against
  65041. * @returns true if equal
  65042. */
  65043. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  65044. /**
  65045. * Multiplies in place the current Vector4 by the given one.
  65046. * @param otherVector vector to multiple with
  65047. * @returns the updated Vector4.
  65048. */
  65049. multiplyInPlace(otherVector: Vector4): Vector4;
  65050. /**
  65051. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  65052. * @param otherVector vector to multiple with
  65053. * @returns resulting new vector
  65054. */
  65055. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  65056. /**
  65057. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  65058. * @param otherVector vector to multiple with
  65059. * @param result vector to store the result
  65060. * @returns the current Vector4.
  65061. */
  65062. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65063. /**
  65064. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  65065. * @param x x value multiply with
  65066. * @param y y value multiply with
  65067. * @param z z value multiply with
  65068. * @param w w value multiply with
  65069. * @returns resulting new vector
  65070. */
  65071. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  65072. /**
  65073. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  65074. * @param otherVector vector to devide with
  65075. * @returns resulting new vector
  65076. */
  65077. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  65078. /**
  65079. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  65080. * @param otherVector vector to devide with
  65081. * @param result vector to store the result
  65082. * @returns the current Vector4.
  65083. */
  65084. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65085. /**
  65086. * Divides the current Vector3 coordinates by the given ones.
  65087. * @param otherVector vector to devide with
  65088. * @returns the updated Vector3.
  65089. */
  65090. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  65091. /**
  65092. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  65093. * @param other defines the second operand
  65094. * @returns the current updated Vector4
  65095. */
  65096. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  65097. /**
  65098. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  65099. * @param other defines the second operand
  65100. * @returns the current updated Vector4
  65101. */
  65102. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  65103. /**
  65104. * Gets a new Vector4 from current Vector4 floored values
  65105. * @returns a new Vector4
  65106. */
  65107. floor(): Vector4;
  65108. /**
  65109. * Gets a new Vector4 from current Vector3 floored values
  65110. * @returns a new Vector4
  65111. */
  65112. fract(): Vector4;
  65113. /**
  65114. * Returns the Vector4 length (float).
  65115. * @returns the length
  65116. */
  65117. length(): number;
  65118. /**
  65119. * Returns the Vector4 squared length (float).
  65120. * @returns the length squared
  65121. */
  65122. lengthSquared(): number;
  65123. /**
  65124. * Normalizes in place the Vector4.
  65125. * @returns the updated Vector4.
  65126. */
  65127. normalize(): Vector4;
  65128. /**
  65129. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  65130. * @returns this converted to a new vector3
  65131. */
  65132. toVector3(): Vector3;
  65133. /**
  65134. * Returns a new Vector4 copied from the current one.
  65135. * @returns the new cloned vector
  65136. */
  65137. clone(): Vector4;
  65138. /**
  65139. * Updates the current Vector4 with the given one coordinates.
  65140. * @param source the source vector to copy from
  65141. * @returns the updated Vector4.
  65142. */
  65143. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  65144. /**
  65145. * Updates the current Vector4 coordinates with the given floats.
  65146. * @param x float to copy from
  65147. * @param y float to copy from
  65148. * @param z float to copy from
  65149. * @param w float to copy from
  65150. * @returns the updated Vector4.
  65151. */
  65152. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  65153. /**
  65154. * Updates the current Vector4 coordinates with the given floats.
  65155. * @param x float to set from
  65156. * @param y float to set from
  65157. * @param z float to set from
  65158. * @param w float to set from
  65159. * @returns the updated Vector4.
  65160. */
  65161. set(x: number, y: number, z: number, w: number): Vector4;
  65162. /**
  65163. * Copies the given float to the current Vector3 coordinates
  65164. * @param v defines the x, y, z and w coordinates of the operand
  65165. * @returns the current updated Vector3
  65166. */
  65167. setAll(v: number): Vector4;
  65168. /**
  65169. * Returns a new Vector4 set from the starting index of the given array.
  65170. * @param array the array to pull values from
  65171. * @param offset the offset into the array to start at
  65172. * @returns the new vector
  65173. */
  65174. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  65175. /**
  65176. * Updates the given vector "result" from the starting index of the given array.
  65177. * @param array the array to pull values from
  65178. * @param offset the offset into the array to start at
  65179. * @param result the vector to store the result in
  65180. */
  65181. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  65182. /**
  65183. * Updates the given vector "result" from the starting index of the given Float32Array.
  65184. * @param array the array to pull values from
  65185. * @param offset the offset into the array to start at
  65186. * @param result the vector to store the result in
  65187. */
  65188. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  65189. /**
  65190. * Updates the given vector "result" coordinates from the given floats.
  65191. * @param x float to set from
  65192. * @param y float to set from
  65193. * @param z float to set from
  65194. * @param w float to set from
  65195. * @param result the vector to the floats in
  65196. */
  65197. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  65198. /**
  65199. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  65200. * @returns the new vector
  65201. */
  65202. static Zero(): Vector4;
  65203. /**
  65204. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  65205. * @returns the new vector
  65206. */
  65207. static One(): Vector4;
  65208. /**
  65209. * Returns a new normalized Vector4 from the given one.
  65210. * @param vector the vector to normalize
  65211. * @returns the vector
  65212. */
  65213. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  65214. /**
  65215. * Updates the given vector "result" from the normalization of the given one.
  65216. * @param vector the vector to normalize
  65217. * @param result the vector to store the result in
  65218. */
  65219. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  65220. /**
  65221. * Returns a vector with the minimum values from the left and right vectors
  65222. * @param left left vector to minimize
  65223. * @param right right vector to minimize
  65224. * @returns a new vector with the minimum of the left and right vector values
  65225. */
  65226. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  65227. /**
  65228. * Returns a vector with the maximum values from the left and right vectors
  65229. * @param left left vector to maximize
  65230. * @param right right vector to maximize
  65231. * @returns a new vector with the maximum of the left and right vector values
  65232. */
  65233. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  65234. /**
  65235. * Returns the distance (float) between the vectors "value1" and "value2".
  65236. * @param value1 value to calulate the distance between
  65237. * @param value2 value to calulate the distance between
  65238. * @return the distance between the two vectors
  65239. */
  65240. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  65241. /**
  65242. * Returns the squared distance (float) between the vectors "value1" and "value2".
  65243. * @param value1 value to calulate the distance between
  65244. * @param value2 value to calulate the distance between
  65245. * @return the distance between the two vectors squared
  65246. */
  65247. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  65248. /**
  65249. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  65250. * @param value1 value to calulate the center between
  65251. * @param value2 value to calulate the center between
  65252. * @return the center between the two vectors
  65253. */
  65254. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  65255. /**
  65256. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  65257. * This methods computes transformed normalized direction vectors only.
  65258. * @param vector the vector to transform
  65259. * @param transformation the transformation matrix to apply
  65260. * @returns the new vector
  65261. */
  65262. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  65263. /**
  65264. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  65265. * This methods computes transformed normalized direction vectors only.
  65266. * @param vector the vector to transform
  65267. * @param transformation the transformation matrix to apply
  65268. * @param result the vector to store the result in
  65269. */
  65270. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  65271. /**
  65272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  65273. * This methods computes transformed normalized direction vectors only.
  65274. * @param x value to transform
  65275. * @param y value to transform
  65276. * @param z value to transform
  65277. * @param w value to transform
  65278. * @param transformation the transformation matrix to apply
  65279. * @param result the vector to store the results in
  65280. */
  65281. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  65282. /**
  65283. * Creates a new Vector4 from a Vector3
  65284. * @param source defines the source data
  65285. * @param w defines the 4th component (default is 0)
  65286. * @returns a new Vector4
  65287. */
  65288. static FromVector3(source: Vector3, w?: number): Vector4;
  65289. }
  65290. /**
  65291. * Interface for the size containing width and height
  65292. */
  65293. export interface ISize {
  65294. /**
  65295. * Width
  65296. */
  65297. width: number;
  65298. /**
  65299. * Heighht
  65300. */
  65301. height: number;
  65302. }
  65303. /**
  65304. * Size containing widht and height
  65305. */
  65306. export class Size implements ISize {
  65307. /**
  65308. * Width
  65309. */
  65310. width: number;
  65311. /**
  65312. * Height
  65313. */
  65314. height: number;
  65315. /**
  65316. * Creates a Size object from the given width and height (floats).
  65317. * @param width width of the new size
  65318. * @param height height of the new size
  65319. */
  65320. constructor(width: number, height: number);
  65321. /**
  65322. * Returns a string with the Size width and height
  65323. * @returns a string with the Size width and height
  65324. */
  65325. toString(): string;
  65326. /**
  65327. * "Size"
  65328. * @returns the string "Size"
  65329. */
  65330. getClassName(): string;
  65331. /**
  65332. * Returns the Size hash code.
  65333. * @returns a hash code for a unique width and height
  65334. */
  65335. getHashCode(): number;
  65336. /**
  65337. * Updates the current size from the given one.
  65338. * @param src the given size
  65339. */
  65340. copyFrom(src: Size): void;
  65341. /**
  65342. * Updates in place the current Size from the given floats.
  65343. * @param width width of the new size
  65344. * @param height height of the new size
  65345. * @returns the updated Size.
  65346. */
  65347. copyFromFloats(width: number, height: number): Size;
  65348. /**
  65349. * Updates in place the current Size from the given floats.
  65350. * @param width width to set
  65351. * @param height height to set
  65352. * @returns the updated Size.
  65353. */
  65354. set(width: number, height: number): Size;
  65355. /**
  65356. * Multiplies the width and height by numbers
  65357. * @param w factor to multiple the width by
  65358. * @param h factor to multiple the height by
  65359. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  65360. */
  65361. multiplyByFloats(w: number, h: number): Size;
  65362. /**
  65363. * Clones the size
  65364. * @returns a new Size copied from the given one.
  65365. */
  65366. clone(): Size;
  65367. /**
  65368. * True if the current Size and the given one width and height are strictly equal.
  65369. * @param other the other size to compare against
  65370. * @returns True if the current Size and the given one width and height are strictly equal.
  65371. */
  65372. equals(other: Size): boolean;
  65373. /**
  65374. * The surface of the Size : width * height (float).
  65375. */
  65376. readonly surface: number;
  65377. /**
  65378. * Create a new size of zero
  65379. * @returns a new Size set to (0.0, 0.0)
  65380. */
  65381. static Zero(): Size;
  65382. /**
  65383. * Sums the width and height of two sizes
  65384. * @param otherSize size to add to this size
  65385. * @returns a new Size set as the addition result of the current Size and the given one.
  65386. */
  65387. add(otherSize: Size): Size;
  65388. /**
  65389. * Subtracts the width and height of two
  65390. * @param otherSize size to subtract to this size
  65391. * @returns a new Size set as the subtraction result of the given one from the current Size.
  65392. */
  65393. subtract(otherSize: Size): Size;
  65394. /**
  65395. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  65396. * @param start starting size to lerp between
  65397. * @param end end size to lerp between
  65398. * @param amount amount to lerp between the start and end values
  65399. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  65400. */
  65401. static Lerp(start: Size, end: Size, amount: number): Size;
  65402. }
  65403. /**
  65404. * Class used to store quaternion data
  65405. * @see https://en.wikipedia.org/wiki/Quaternion
  65406. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  65407. */
  65408. export class Quaternion {
  65409. /** defines the first component (0 by default) */
  65410. x: number;
  65411. /** defines the second component (0 by default) */
  65412. y: number;
  65413. /** defines the third component (0 by default) */
  65414. z: number;
  65415. /** defines the fourth component (1.0 by default) */
  65416. w: number;
  65417. /**
  65418. * Creates a new Quaternion from the given floats
  65419. * @param x defines the first component (0 by default)
  65420. * @param y defines the second component (0 by default)
  65421. * @param z defines the third component (0 by default)
  65422. * @param w defines the fourth component (1.0 by default)
  65423. */
  65424. constructor(
  65425. /** defines the first component (0 by default) */
  65426. x?: number,
  65427. /** defines the second component (0 by default) */
  65428. y?: number,
  65429. /** defines the third component (0 by default) */
  65430. z?: number,
  65431. /** defines the fourth component (1.0 by default) */
  65432. w?: number);
  65433. /**
  65434. * Gets a string representation for the current quaternion
  65435. * @returns a string with the Quaternion coordinates
  65436. */
  65437. toString(): string;
  65438. /**
  65439. * Gets the class name of the quaternion
  65440. * @returns the string "Quaternion"
  65441. */
  65442. getClassName(): string;
  65443. /**
  65444. * Gets a hash code for this quaternion
  65445. * @returns the quaternion hash code
  65446. */
  65447. getHashCode(): number;
  65448. /**
  65449. * Copy the quaternion to an array
  65450. * @returns a new array populated with 4 elements from the quaternion coordinates
  65451. */
  65452. asArray(): number[];
  65453. /**
  65454. * Check if two quaternions are equals
  65455. * @param otherQuaternion defines the second operand
  65456. * @return true if the current quaternion and the given one coordinates are strictly equals
  65457. */
  65458. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  65459. /**
  65460. * Clone the current quaternion
  65461. * @returns a new quaternion copied from the current one
  65462. */
  65463. clone(): Quaternion;
  65464. /**
  65465. * Copy a quaternion to the current one
  65466. * @param other defines the other quaternion
  65467. * @returns the updated current quaternion
  65468. */
  65469. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  65470. /**
  65471. * Updates the current quaternion with the given float coordinates
  65472. * @param x defines the x coordinate
  65473. * @param y defines the y coordinate
  65474. * @param z defines the z coordinate
  65475. * @param w defines the w coordinate
  65476. * @returns the updated current quaternion
  65477. */
  65478. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  65479. /**
  65480. * Updates the current quaternion from the given float coordinates
  65481. * @param x defines the x coordinate
  65482. * @param y defines the y coordinate
  65483. * @param z defines the z coordinate
  65484. * @param w defines the w coordinate
  65485. * @returns the updated current quaternion
  65486. */
  65487. set(x: number, y: number, z: number, w: number): Quaternion;
  65488. /**
  65489. * Adds two quaternions
  65490. * @param other defines the second operand
  65491. * @returns a new quaternion as the addition result of the given one and the current quaternion
  65492. */
  65493. add(other: DeepImmutable<Quaternion>): Quaternion;
  65494. /**
  65495. * Add a quaternion to the current one
  65496. * @param other defines the quaternion to add
  65497. * @returns the current quaternion
  65498. */
  65499. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  65500. /**
  65501. * Subtract two quaternions
  65502. * @param other defines the second operand
  65503. * @returns a new quaternion as the subtraction result of the given one from the current one
  65504. */
  65505. subtract(other: Quaternion): Quaternion;
  65506. /**
  65507. * Multiplies the current quaternion by a scale factor
  65508. * @param value defines the scale factor
  65509. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  65510. */
  65511. scale(value: number): Quaternion;
  65512. /**
  65513. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  65514. * @param scale defines the scale factor
  65515. * @param result defines the Quaternion object where to store the result
  65516. * @returns the unmodified current quaternion
  65517. */
  65518. scaleToRef(scale: number, result: Quaternion): Quaternion;
  65519. /**
  65520. * Multiplies in place the current quaternion by a scale factor
  65521. * @param value defines the scale factor
  65522. * @returns the current modified quaternion
  65523. */
  65524. scaleInPlace(value: number): Quaternion;
  65525. /**
  65526. * Scale the current quaternion values by a factor and add the result to a given quaternion
  65527. * @param scale defines the scale factor
  65528. * @param result defines the Quaternion object where to store the result
  65529. * @returns the unmodified current quaternion
  65530. */
  65531. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  65532. /**
  65533. * Multiplies two quaternions
  65534. * @param q1 defines the second operand
  65535. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  65536. */
  65537. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  65538. /**
  65539. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  65540. * @param q1 defines the second operand
  65541. * @param result defines the target quaternion
  65542. * @returns the current quaternion
  65543. */
  65544. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  65545. /**
  65546. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  65547. * @param q1 defines the second operand
  65548. * @returns the currentupdated quaternion
  65549. */
  65550. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  65551. /**
  65552. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  65553. * @param ref defines the target quaternion
  65554. * @returns the current quaternion
  65555. */
  65556. conjugateToRef(ref: Quaternion): Quaternion;
  65557. /**
  65558. * Conjugates in place (1-q) the current quaternion
  65559. * @returns the current updated quaternion
  65560. */
  65561. conjugateInPlace(): Quaternion;
  65562. /**
  65563. * Conjugates in place (1-q) the current quaternion
  65564. * @returns a new quaternion
  65565. */
  65566. conjugate(): Quaternion;
  65567. /**
  65568. * Gets length of current quaternion
  65569. * @returns the quaternion length (float)
  65570. */
  65571. length(): number;
  65572. /**
  65573. * Normalize in place the current quaternion
  65574. * @returns the current updated quaternion
  65575. */
  65576. normalize(): Quaternion;
  65577. /**
  65578. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  65579. * @param order is a reserved parameter and is ignore for now
  65580. * @returns a new Vector3 containing the Euler angles
  65581. */
  65582. toEulerAngles(order?: string): Vector3;
  65583. /**
  65584. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  65585. * @param result defines the vector which will be filled with the Euler angles
  65586. * @param order is a reserved parameter and is ignore for now
  65587. * @returns the current unchanged quaternion
  65588. */
  65589. toEulerAnglesToRef(result: Vector3): Quaternion;
  65590. /**
  65591. * Updates the given rotation matrix with the current quaternion values
  65592. * @param result defines the target matrix
  65593. * @returns the current unchanged quaternion
  65594. */
  65595. toRotationMatrix(result: Matrix): Quaternion;
  65596. /**
  65597. * Updates the current quaternion from the given rotation matrix values
  65598. * @param matrix defines the source matrix
  65599. * @returns the current updated quaternion
  65600. */
  65601. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65602. /**
  65603. * Creates a new quaternion from a rotation matrix
  65604. * @param matrix defines the source matrix
  65605. * @returns a new quaternion created from the given rotation matrix values
  65606. */
  65607. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65608. /**
  65609. * Updates the given quaternion with the given rotation matrix values
  65610. * @param matrix defines the source matrix
  65611. * @param result defines the target quaternion
  65612. */
  65613. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65614. /**
  65615. * Returns the dot product (float) between the quaternions "left" and "right"
  65616. * @param left defines the left operand
  65617. * @param right defines the right operand
  65618. * @returns the dot product
  65619. */
  65620. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65621. /**
  65622. * Checks if the two quaternions are close to each other
  65623. * @param quat0 defines the first quaternion to check
  65624. * @param quat1 defines the second quaternion to check
  65625. * @returns true if the two quaternions are close to each other
  65626. */
  65627. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65628. /**
  65629. * Creates an empty quaternion
  65630. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65631. */
  65632. static Zero(): Quaternion;
  65633. /**
  65634. * Inverse a given quaternion
  65635. * @param q defines the source quaternion
  65636. * @returns a new quaternion as the inverted current quaternion
  65637. */
  65638. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65639. /**
  65640. * Inverse a given quaternion
  65641. * @param q defines the source quaternion
  65642. * @param result the quaternion the result will be stored in
  65643. * @returns the result quaternion
  65644. */
  65645. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65646. /**
  65647. * Creates an identity quaternion
  65648. * @returns the identity quaternion
  65649. */
  65650. static Identity(): Quaternion;
  65651. /**
  65652. * Gets a boolean indicating if the given quaternion is identity
  65653. * @param quaternion defines the quaternion to check
  65654. * @returns true if the quaternion is identity
  65655. */
  65656. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65657. /**
  65658. * Creates a quaternion from a rotation around an axis
  65659. * @param axis defines the axis to use
  65660. * @param angle defines the angle to use
  65661. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65662. */
  65663. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65664. /**
  65665. * Creates a rotation around an axis and stores it into the given quaternion
  65666. * @param axis defines the axis to use
  65667. * @param angle defines the angle to use
  65668. * @param result defines the target quaternion
  65669. * @returns the target quaternion
  65670. */
  65671. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65672. /**
  65673. * Creates a new quaternion from data stored into an array
  65674. * @param array defines the data source
  65675. * @param offset defines the offset in the source array where the data starts
  65676. * @returns a new quaternion
  65677. */
  65678. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65679. /**
  65680. * Create a quaternion from Euler rotation angles
  65681. * @param x Pitch
  65682. * @param y Yaw
  65683. * @param z Roll
  65684. * @returns the new Quaternion
  65685. */
  65686. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65687. /**
  65688. * Updates a quaternion from Euler rotation angles
  65689. * @param x Pitch
  65690. * @param y Yaw
  65691. * @param z Roll
  65692. * @param result the quaternion to store the result
  65693. * @returns the updated quaternion
  65694. */
  65695. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65696. /**
  65697. * Create a quaternion from Euler rotation vector
  65698. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65699. * @returns the new Quaternion
  65700. */
  65701. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65702. /**
  65703. * Updates a quaternion from Euler rotation vector
  65704. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65705. * @param result the quaternion to store the result
  65706. * @returns the updated quaternion
  65707. */
  65708. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65709. /**
  65710. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65711. * @param yaw defines the rotation around Y axis
  65712. * @param pitch defines the rotation around X axis
  65713. * @param roll defines the rotation around Z axis
  65714. * @returns the new quaternion
  65715. */
  65716. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65717. /**
  65718. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65719. * @param yaw defines the rotation around Y axis
  65720. * @param pitch defines the rotation around X axis
  65721. * @param roll defines the rotation around Z axis
  65722. * @param result defines the target quaternion
  65723. */
  65724. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65725. /**
  65726. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65727. * @param alpha defines the rotation around first axis
  65728. * @param beta defines the rotation around second axis
  65729. * @param gamma defines the rotation around third axis
  65730. * @returns the new quaternion
  65731. */
  65732. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65733. /**
  65734. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65735. * @param alpha defines the rotation around first axis
  65736. * @param beta defines the rotation around second axis
  65737. * @param gamma defines the rotation around third axis
  65738. * @param result defines the target quaternion
  65739. */
  65740. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65741. /**
  65742. * 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)
  65743. * @param axis1 defines the first axis
  65744. * @param axis2 defines the second axis
  65745. * @param axis3 defines the third axis
  65746. * @returns the new quaternion
  65747. */
  65748. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65749. /**
  65750. * 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
  65751. * @param axis1 defines the first axis
  65752. * @param axis2 defines the second axis
  65753. * @param axis3 defines the third axis
  65754. * @param ref defines the target quaternion
  65755. */
  65756. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65757. /**
  65758. * Interpolates between two quaternions
  65759. * @param left defines first quaternion
  65760. * @param right defines second quaternion
  65761. * @param amount defines the gradient to use
  65762. * @returns the new interpolated quaternion
  65763. */
  65764. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65765. /**
  65766. * Interpolates between two quaternions and stores it into a target quaternion
  65767. * @param left defines first quaternion
  65768. * @param right defines second quaternion
  65769. * @param amount defines the gradient to use
  65770. * @param result defines the target quaternion
  65771. */
  65772. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65773. /**
  65774. * Interpolate between two quaternions using Hermite interpolation
  65775. * @param value1 defines first quaternion
  65776. * @param tangent1 defines the incoming tangent
  65777. * @param value2 defines second quaternion
  65778. * @param tangent2 defines the outgoing tangent
  65779. * @param amount defines the target quaternion
  65780. * @returns the new interpolated quaternion
  65781. */
  65782. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65783. }
  65784. /**
  65785. * Class used to store matrix data (4x4)
  65786. */
  65787. export class Matrix {
  65788. private static _updateFlagSeed;
  65789. private static _identityReadOnly;
  65790. private _isIdentity;
  65791. private _isIdentityDirty;
  65792. private _isIdentity3x2;
  65793. private _isIdentity3x2Dirty;
  65794. /**
  65795. * Gets the update flag of the matrix which is an unique number for the matrix.
  65796. * It will be incremented every time the matrix data change.
  65797. * You can use it to speed the comparison between two versions of the same matrix.
  65798. */
  65799. updateFlag: number;
  65800. private readonly _m;
  65801. /**
  65802. * Gets the internal data of the matrix
  65803. */
  65804. readonly m: DeepImmutable<Float32Array>;
  65805. /** @hidden */
  65806. _markAsUpdated(): void;
  65807. /** @hidden */
  65808. private _updateIdentityStatus;
  65809. /**
  65810. * Creates an empty matrix (filled with zeros)
  65811. */
  65812. constructor();
  65813. /**
  65814. * Check if the current matrix is identity
  65815. * @returns true is the matrix is the identity matrix
  65816. */
  65817. isIdentity(): boolean;
  65818. /**
  65819. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65820. * @returns true is the matrix is the identity matrix
  65821. */
  65822. isIdentityAs3x2(): boolean;
  65823. /**
  65824. * Gets the determinant of the matrix
  65825. * @returns the matrix determinant
  65826. */
  65827. determinant(): number;
  65828. /**
  65829. * Returns the matrix as a Float32Array
  65830. * @returns the matrix underlying array
  65831. */
  65832. toArray(): DeepImmutable<Float32Array>;
  65833. /**
  65834. * Returns the matrix as a Float32Array
  65835. * @returns the matrix underlying array.
  65836. */
  65837. asArray(): DeepImmutable<Float32Array>;
  65838. /**
  65839. * Inverts the current matrix in place
  65840. * @returns the current inverted matrix
  65841. */
  65842. invert(): Matrix;
  65843. /**
  65844. * Sets all the matrix elements to zero
  65845. * @returns the current matrix
  65846. */
  65847. reset(): Matrix;
  65848. /**
  65849. * Adds the current matrix with a second one
  65850. * @param other defines the matrix to add
  65851. * @returns a new matrix as the addition of the current matrix and the given one
  65852. */
  65853. add(other: DeepImmutable<Matrix>): Matrix;
  65854. /**
  65855. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65856. * @param other defines the matrix to add
  65857. * @param result defines the target matrix
  65858. * @returns the current matrix
  65859. */
  65860. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65861. /**
  65862. * Adds in place the given matrix to the current matrix
  65863. * @param other defines the second operand
  65864. * @returns the current updated matrix
  65865. */
  65866. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65867. /**
  65868. * Sets the given matrix to the current inverted Matrix
  65869. * @param other defines the target matrix
  65870. * @returns the unmodified current matrix
  65871. */
  65872. invertToRef(other: Matrix): Matrix;
  65873. /**
  65874. * add a value at the specified position in the current Matrix
  65875. * @param index the index of the value within the matrix. between 0 and 15.
  65876. * @param value the value to be added
  65877. * @returns the current updated matrix
  65878. */
  65879. addAtIndex(index: number, value: number): Matrix;
  65880. /**
  65881. * mutiply the specified position in the current Matrix by a value
  65882. * @param index the index of the value within the matrix. between 0 and 15.
  65883. * @param value the value to be added
  65884. * @returns the current updated matrix
  65885. */
  65886. multiplyAtIndex(index: number, value: number): Matrix;
  65887. /**
  65888. * Inserts the translation vector (using 3 floats) in the current matrix
  65889. * @param x defines the 1st component of the translation
  65890. * @param y defines the 2nd component of the translation
  65891. * @param z defines the 3rd component of the translation
  65892. * @returns the current updated matrix
  65893. */
  65894. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65895. /**
  65896. * Adds the translation vector (using 3 floats) in the current matrix
  65897. * @param x defines the 1st component of the translation
  65898. * @param y defines the 2nd component of the translation
  65899. * @param z defines the 3rd component of the translation
  65900. * @returns the current updated matrix
  65901. */
  65902. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65903. /**
  65904. * Inserts the translation vector in the current matrix
  65905. * @param vector3 defines the translation to insert
  65906. * @returns the current updated matrix
  65907. */
  65908. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65909. /**
  65910. * Gets the translation value of the current matrix
  65911. * @returns a new Vector3 as the extracted translation from the matrix
  65912. */
  65913. getTranslation(): Vector3;
  65914. /**
  65915. * Fill a Vector3 with the extracted translation from the matrix
  65916. * @param result defines the Vector3 where to store the translation
  65917. * @returns the current matrix
  65918. */
  65919. getTranslationToRef(result: Vector3): Matrix;
  65920. /**
  65921. * Remove rotation and scaling part from the matrix
  65922. * @returns the updated matrix
  65923. */
  65924. removeRotationAndScaling(): Matrix;
  65925. /**
  65926. * Multiply two matrices
  65927. * @param other defines the second operand
  65928. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65929. */
  65930. multiply(other: DeepImmutable<Matrix>): Matrix;
  65931. /**
  65932. * Copy the current matrix from the given one
  65933. * @param other defines the source matrix
  65934. * @returns the current updated matrix
  65935. */
  65936. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65937. /**
  65938. * Populates the given array from the starting index with the current matrix values
  65939. * @param array defines the target array
  65940. * @param offset defines the offset in the target array where to start storing values
  65941. * @returns the current matrix
  65942. */
  65943. copyToArray(array: Float32Array, offset?: number): Matrix;
  65944. /**
  65945. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65946. * @param other defines the second operand
  65947. * @param result defines the matrix where to store the multiplication
  65948. * @returns the current matrix
  65949. */
  65950. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65951. /**
  65952. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65953. * @param other defines the second operand
  65954. * @param result defines the array where to store the multiplication
  65955. * @param offset defines the offset in the target array where to start storing values
  65956. * @returns the current matrix
  65957. */
  65958. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65959. /**
  65960. * Check equality between this matrix and a second one
  65961. * @param value defines the second matrix to compare
  65962. * @returns true is the current matrix and the given one values are strictly equal
  65963. */
  65964. equals(value: DeepImmutable<Matrix>): boolean;
  65965. /**
  65966. * Clone the current matrix
  65967. * @returns a new matrix from the current matrix
  65968. */
  65969. clone(): Matrix;
  65970. /**
  65971. * Returns the name of the current matrix class
  65972. * @returns the string "Matrix"
  65973. */
  65974. getClassName(): string;
  65975. /**
  65976. * Gets the hash code of the current matrix
  65977. * @returns the hash code
  65978. */
  65979. getHashCode(): number;
  65980. /**
  65981. * Decomposes the current Matrix into a translation, rotation and scaling components
  65982. * @param scale defines the scale vector3 given as a reference to update
  65983. * @param rotation defines the rotation quaternion given as a reference to update
  65984. * @param translation defines the translation vector3 given as a reference to update
  65985. * @returns true if operation was successful
  65986. */
  65987. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65988. /**
  65989. * Gets specific row of the matrix
  65990. * @param index defines the number of the row to get
  65991. * @returns the index-th row of the current matrix as a new Vector4
  65992. */
  65993. getRow(index: number): Nullable<Vector4>;
  65994. /**
  65995. * Sets the index-th row of the current matrix to the vector4 values
  65996. * @param index defines the number of the row to set
  65997. * @param row defines the target vector4
  65998. * @returns the updated current matrix
  65999. */
  66000. setRow(index: number, row: Vector4): Matrix;
  66001. /**
  66002. * Compute the transpose of the matrix
  66003. * @returns the new transposed matrix
  66004. */
  66005. transpose(): Matrix;
  66006. /**
  66007. * Compute the transpose of the matrix and store it in a given matrix
  66008. * @param result defines the target matrix
  66009. * @returns the current matrix
  66010. */
  66011. transposeToRef(result: Matrix): Matrix;
  66012. /**
  66013. * Sets the index-th row of the current matrix with the given 4 x float values
  66014. * @param index defines the row index
  66015. * @param x defines the x component to set
  66016. * @param y defines the y component to set
  66017. * @param z defines the z component to set
  66018. * @param w defines the w component to set
  66019. * @returns the updated current matrix
  66020. */
  66021. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  66022. /**
  66023. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  66024. * @param scale defines the scale factor
  66025. * @returns a new matrix
  66026. */
  66027. scale(scale: number): Matrix;
  66028. /**
  66029. * Scale the current matrix values by a factor to a given result matrix
  66030. * @param scale defines the scale factor
  66031. * @param result defines the matrix to store the result
  66032. * @returns the current matrix
  66033. */
  66034. scaleToRef(scale: number, result: Matrix): Matrix;
  66035. /**
  66036. * Scale the current matrix values by a factor and add the result to a given matrix
  66037. * @param scale defines the scale factor
  66038. * @param result defines the Matrix to store the result
  66039. * @returns the current matrix
  66040. */
  66041. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  66042. /**
  66043. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  66044. * @param ref matrix to store the result
  66045. */
  66046. toNormalMatrix(ref: Matrix): void;
  66047. /**
  66048. * Gets only rotation part of the current matrix
  66049. * @returns a new matrix sets to the extracted rotation matrix from the current one
  66050. */
  66051. getRotationMatrix(): Matrix;
  66052. /**
  66053. * Extracts the rotation matrix from the current one and sets it as the given "result"
  66054. * @param result defines the target matrix to store data to
  66055. * @returns the current matrix
  66056. */
  66057. getRotationMatrixToRef(result: Matrix): Matrix;
  66058. /**
  66059. * Toggles model matrix from being right handed to left handed in place and vice versa
  66060. */
  66061. toggleModelMatrixHandInPlace(): void;
  66062. /**
  66063. * Toggles projection matrix from being right handed to left handed in place and vice versa
  66064. */
  66065. toggleProjectionMatrixHandInPlace(): void;
  66066. /**
  66067. * Creates a matrix from an array
  66068. * @param array defines the source array
  66069. * @param offset defines an offset in the source array
  66070. * @returns a new Matrix set from the starting index of the given array
  66071. */
  66072. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  66073. /**
  66074. * Copy the content of an array into a given matrix
  66075. * @param array defines the source array
  66076. * @param offset defines an offset in the source array
  66077. * @param result defines the target matrix
  66078. */
  66079. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  66080. /**
  66081. * Stores an array into a matrix after having multiplied each component by a given factor
  66082. * @param array defines the source array
  66083. * @param offset defines the offset in the source array
  66084. * @param scale defines the scaling factor
  66085. * @param result defines the target matrix
  66086. */
  66087. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  66088. /**
  66089. * Gets an identity matrix that must not be updated
  66090. */
  66091. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  66092. /**
  66093. * Stores a list of values (16) inside a given matrix
  66094. * @param initialM11 defines 1st value of 1st row
  66095. * @param initialM12 defines 2nd value of 1st row
  66096. * @param initialM13 defines 3rd value of 1st row
  66097. * @param initialM14 defines 4th value of 1st row
  66098. * @param initialM21 defines 1st value of 2nd row
  66099. * @param initialM22 defines 2nd value of 2nd row
  66100. * @param initialM23 defines 3rd value of 2nd row
  66101. * @param initialM24 defines 4th value of 2nd row
  66102. * @param initialM31 defines 1st value of 3rd row
  66103. * @param initialM32 defines 2nd value of 3rd row
  66104. * @param initialM33 defines 3rd value of 3rd row
  66105. * @param initialM34 defines 4th value of 3rd row
  66106. * @param initialM41 defines 1st value of 4th row
  66107. * @param initialM42 defines 2nd value of 4th row
  66108. * @param initialM43 defines 3rd value of 4th row
  66109. * @param initialM44 defines 4th value of 4th row
  66110. * @param result defines the target matrix
  66111. */
  66112. 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;
  66113. /**
  66114. * Creates new matrix from a list of values (16)
  66115. * @param initialM11 defines 1st value of 1st row
  66116. * @param initialM12 defines 2nd value of 1st row
  66117. * @param initialM13 defines 3rd value of 1st row
  66118. * @param initialM14 defines 4th value of 1st row
  66119. * @param initialM21 defines 1st value of 2nd row
  66120. * @param initialM22 defines 2nd value of 2nd row
  66121. * @param initialM23 defines 3rd value of 2nd row
  66122. * @param initialM24 defines 4th value of 2nd row
  66123. * @param initialM31 defines 1st value of 3rd row
  66124. * @param initialM32 defines 2nd value of 3rd row
  66125. * @param initialM33 defines 3rd value of 3rd row
  66126. * @param initialM34 defines 4th value of 3rd row
  66127. * @param initialM41 defines 1st value of 4th row
  66128. * @param initialM42 defines 2nd value of 4th row
  66129. * @param initialM43 defines 3rd value of 4th row
  66130. * @param initialM44 defines 4th value of 4th row
  66131. * @returns the new matrix
  66132. */
  66133. 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;
  66134. /**
  66135. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  66136. * @param scale defines the scale vector3
  66137. * @param rotation defines the rotation quaternion
  66138. * @param translation defines the translation vector3
  66139. * @returns a new matrix
  66140. */
  66141. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  66142. /**
  66143. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  66144. * @param scale defines the scale vector3
  66145. * @param rotation defines the rotation quaternion
  66146. * @param translation defines the translation vector3
  66147. * @param result defines the target matrix
  66148. */
  66149. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  66150. /**
  66151. * Creates a new identity matrix
  66152. * @returns a new identity matrix
  66153. */
  66154. static Identity(): Matrix;
  66155. /**
  66156. * Creates a new identity matrix and stores the result in a given matrix
  66157. * @param result defines the target matrix
  66158. */
  66159. static IdentityToRef(result: Matrix): void;
  66160. /**
  66161. * Creates a new zero matrix
  66162. * @returns a new zero matrix
  66163. */
  66164. static Zero(): Matrix;
  66165. /**
  66166. * Creates a new rotation matrix for "angle" radians around the X axis
  66167. * @param angle defines the angle (in radians) to use
  66168. * @return the new matrix
  66169. */
  66170. static RotationX(angle: number): Matrix;
  66171. /**
  66172. * Creates a new matrix as the invert of a given matrix
  66173. * @param source defines the source matrix
  66174. * @returns the new matrix
  66175. */
  66176. static Invert(source: DeepImmutable<Matrix>): Matrix;
  66177. /**
  66178. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  66179. * @param angle defines the angle (in radians) to use
  66180. * @param result defines the target matrix
  66181. */
  66182. static RotationXToRef(angle: number, result: Matrix): void;
  66183. /**
  66184. * Creates a new rotation matrix for "angle" radians around the Y axis
  66185. * @param angle defines the angle (in radians) to use
  66186. * @return the new matrix
  66187. */
  66188. static RotationY(angle: number): Matrix;
  66189. /**
  66190. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  66191. * @param angle defines the angle (in radians) to use
  66192. * @param result defines the target matrix
  66193. */
  66194. static RotationYToRef(angle: number, result: Matrix): void;
  66195. /**
  66196. * Creates a new rotation matrix for "angle" radians around the Z axis
  66197. * @param angle defines the angle (in radians) to use
  66198. * @return the new matrix
  66199. */
  66200. static RotationZ(angle: number): Matrix;
  66201. /**
  66202. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  66203. * @param angle defines the angle (in radians) to use
  66204. * @param result defines the target matrix
  66205. */
  66206. static RotationZToRef(angle: number, result: Matrix): void;
  66207. /**
  66208. * Creates a new rotation matrix for "angle" radians around the given axis
  66209. * @param axis defines the axis to use
  66210. * @param angle defines the angle (in radians) to use
  66211. * @return the new matrix
  66212. */
  66213. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  66214. /**
  66215. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  66216. * @param axis defines the axis to use
  66217. * @param angle defines the angle (in radians) to use
  66218. * @param result defines the target matrix
  66219. */
  66220. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  66221. /**
  66222. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  66223. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  66224. * @param from defines the vector to align
  66225. * @param to defines the vector to align to
  66226. * @param result defines the target matrix
  66227. */
  66228. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  66229. /**
  66230. * Creates a rotation matrix
  66231. * @param yaw defines the yaw angle in radians (Y axis)
  66232. * @param pitch defines the pitch angle in radians (X axis)
  66233. * @param roll defines the roll angle in radians (X axis)
  66234. * @returns the new rotation matrix
  66235. */
  66236. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  66237. /**
  66238. * Creates a rotation matrix and stores it in a given matrix
  66239. * @param yaw defines the yaw angle in radians (Y axis)
  66240. * @param pitch defines the pitch angle in radians (X axis)
  66241. * @param roll defines the roll angle in radians (X axis)
  66242. * @param result defines the target matrix
  66243. */
  66244. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  66245. /**
  66246. * Creates a scaling matrix
  66247. * @param x defines the scale factor on X axis
  66248. * @param y defines the scale factor on Y axis
  66249. * @param z defines the scale factor on Z axis
  66250. * @returns the new matrix
  66251. */
  66252. static Scaling(x: number, y: number, z: number): Matrix;
  66253. /**
  66254. * Creates a scaling matrix and stores it in a given matrix
  66255. * @param x defines the scale factor on X axis
  66256. * @param y defines the scale factor on Y axis
  66257. * @param z defines the scale factor on Z axis
  66258. * @param result defines the target matrix
  66259. */
  66260. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  66261. /**
  66262. * Creates a translation matrix
  66263. * @param x defines the translation on X axis
  66264. * @param y defines the translation on Y axis
  66265. * @param z defines the translationon Z axis
  66266. * @returns the new matrix
  66267. */
  66268. static Translation(x: number, y: number, z: number): Matrix;
  66269. /**
  66270. * Creates a translation matrix and stores it in a given matrix
  66271. * @param x defines the translation on X axis
  66272. * @param y defines the translation on Y axis
  66273. * @param z defines the translationon Z axis
  66274. * @param result defines the target matrix
  66275. */
  66276. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  66277. /**
  66278. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  66279. * @param startValue defines the start value
  66280. * @param endValue defines the end value
  66281. * @param gradient defines the gradient factor
  66282. * @returns the new matrix
  66283. */
  66284. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  66285. /**
  66286. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  66287. * @param startValue defines the start value
  66288. * @param endValue defines the end value
  66289. * @param gradient defines the gradient factor
  66290. * @param result defines the Matrix object where to store data
  66291. */
  66292. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66293. /**
  66294. * Builds a new matrix whose values are computed by:
  66295. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  66296. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  66297. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  66298. * @param startValue defines the first matrix
  66299. * @param endValue defines the second matrix
  66300. * @param gradient defines the gradient between the two matrices
  66301. * @returns the new matrix
  66302. */
  66303. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  66304. /**
  66305. * Update a matrix to values which are computed by:
  66306. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  66307. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  66308. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  66309. * @param startValue defines the first matrix
  66310. * @param endValue defines the second matrix
  66311. * @param gradient defines the gradient between the two matrices
  66312. * @param result defines the target matrix
  66313. */
  66314. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66315. /**
  66316. * 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"
  66317. * This function works in left handed mode
  66318. * @param eye defines the final position of the entity
  66319. * @param target defines where the entity should look at
  66320. * @param up defines the up vector for the entity
  66321. * @returns the new matrix
  66322. */
  66323. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66324. /**
  66325. * 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".
  66326. * This function works in left handed mode
  66327. * @param eye defines the final position of the entity
  66328. * @param target defines where the entity should look at
  66329. * @param up defines the up vector for the entity
  66330. * @param result defines the target matrix
  66331. */
  66332. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66333. /**
  66334. * 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"
  66335. * This function works in right handed mode
  66336. * @param eye defines the final position of the entity
  66337. * @param target defines where the entity should look at
  66338. * @param up defines the up vector for the entity
  66339. * @returns the new matrix
  66340. */
  66341. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66342. /**
  66343. * 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".
  66344. * This function works in right handed mode
  66345. * @param eye defines the final position of the entity
  66346. * @param target defines where the entity should look at
  66347. * @param up defines the up vector for the entity
  66348. * @param result defines the target matrix
  66349. */
  66350. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66351. /**
  66352. * Create a left-handed orthographic projection matrix
  66353. * @param width defines the viewport width
  66354. * @param height defines the viewport height
  66355. * @param znear defines the near clip plane
  66356. * @param zfar defines the far clip plane
  66357. * @returns a new matrix as a left-handed orthographic projection matrix
  66358. */
  66359. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66360. /**
  66361. * Store a left-handed orthographic projection to a given matrix
  66362. * @param width defines the viewport width
  66363. * @param height defines the viewport height
  66364. * @param znear defines the near clip plane
  66365. * @param zfar defines the far clip plane
  66366. * @param result defines the target matrix
  66367. */
  66368. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  66369. /**
  66370. * Create a left-handed orthographic projection matrix
  66371. * @param left defines the viewport left coordinate
  66372. * @param right defines the viewport right coordinate
  66373. * @param bottom defines the viewport bottom coordinate
  66374. * @param top defines the viewport top coordinate
  66375. * @param znear defines the near clip plane
  66376. * @param zfar defines the far clip plane
  66377. * @returns a new matrix as a left-handed orthographic projection matrix
  66378. */
  66379. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66380. /**
  66381. * Stores a left-handed orthographic projection into a given matrix
  66382. * @param left defines the viewport left coordinate
  66383. * @param right defines the viewport right coordinate
  66384. * @param bottom defines the viewport bottom coordinate
  66385. * @param top defines the viewport top coordinate
  66386. * @param znear defines the near clip plane
  66387. * @param zfar defines the far clip plane
  66388. * @param result defines the target matrix
  66389. */
  66390. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66391. /**
  66392. * Creates a right-handed orthographic projection matrix
  66393. * @param left defines the viewport left coordinate
  66394. * @param right defines the viewport right coordinate
  66395. * @param bottom defines the viewport bottom coordinate
  66396. * @param top defines the viewport top coordinate
  66397. * @param znear defines the near clip plane
  66398. * @param zfar defines the far clip plane
  66399. * @returns a new matrix as a right-handed orthographic projection matrix
  66400. */
  66401. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66402. /**
  66403. * Stores a right-handed orthographic projection into a given matrix
  66404. * @param left defines the viewport left coordinate
  66405. * @param right defines the viewport right coordinate
  66406. * @param bottom defines the viewport bottom coordinate
  66407. * @param top defines the viewport top coordinate
  66408. * @param znear defines the near clip plane
  66409. * @param zfar defines the far clip plane
  66410. * @param result defines the target matrix
  66411. */
  66412. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66413. /**
  66414. * Creates a left-handed perspective projection matrix
  66415. * @param width defines the viewport width
  66416. * @param height defines the viewport height
  66417. * @param znear defines the near clip plane
  66418. * @param zfar defines the far clip plane
  66419. * @returns a new matrix as a left-handed perspective projection matrix
  66420. */
  66421. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66422. /**
  66423. * Creates a left-handed perspective projection matrix
  66424. * @param fov defines the horizontal field of view
  66425. * @param aspect defines the aspect ratio
  66426. * @param znear defines the near clip plane
  66427. * @param zfar defines the far clip plane
  66428. * @returns a new matrix as a left-handed perspective projection matrix
  66429. */
  66430. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66431. /**
  66432. * Stores a left-handed perspective projection into a given matrix
  66433. * @param fov defines the horizontal field of view
  66434. * @param aspect defines the aspect ratio
  66435. * @param znear defines the near clip plane
  66436. * @param zfar defines the far clip plane
  66437. * @param result defines the target matrix
  66438. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66439. */
  66440. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66441. /**
  66442. * Creates a right-handed perspective projection matrix
  66443. * @param fov defines the horizontal field of view
  66444. * @param aspect defines the aspect ratio
  66445. * @param znear defines the near clip plane
  66446. * @param zfar defines the far clip plane
  66447. * @returns a new matrix as a right-handed perspective projection matrix
  66448. */
  66449. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66450. /**
  66451. * Stores a right-handed perspective projection into a given matrix
  66452. * @param fov defines the horizontal field of view
  66453. * @param aspect defines the aspect ratio
  66454. * @param znear defines the near clip plane
  66455. * @param zfar defines the far clip plane
  66456. * @param result defines the target matrix
  66457. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66458. */
  66459. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66460. /**
  66461. * Stores a perspective projection for WebVR info a given matrix
  66462. * @param fov defines the field of view
  66463. * @param znear defines the near clip plane
  66464. * @param zfar defines the far clip plane
  66465. * @param result defines the target matrix
  66466. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  66467. */
  66468. static PerspectiveFovWebVRToRef(fov: {
  66469. upDegrees: number;
  66470. downDegrees: number;
  66471. leftDegrees: number;
  66472. rightDegrees: number;
  66473. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  66474. /**
  66475. * Computes a complete transformation matrix
  66476. * @param viewport defines the viewport to use
  66477. * @param world defines the world matrix
  66478. * @param view defines the view matrix
  66479. * @param projection defines the projection matrix
  66480. * @param zmin defines the near clip plane
  66481. * @param zmax defines the far clip plane
  66482. * @returns the transformation matrix
  66483. */
  66484. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  66485. /**
  66486. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  66487. * @param matrix defines the matrix to use
  66488. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  66489. */
  66490. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  66491. /**
  66492. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  66493. * @param matrix defines the matrix to use
  66494. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  66495. */
  66496. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  66497. /**
  66498. * Compute the transpose of a given matrix
  66499. * @param matrix defines the matrix to transpose
  66500. * @returns the new matrix
  66501. */
  66502. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  66503. /**
  66504. * Compute the transpose of a matrix and store it in a target matrix
  66505. * @param matrix defines the matrix to transpose
  66506. * @param result defines the target matrix
  66507. */
  66508. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  66509. /**
  66510. * Computes a reflection matrix from a plane
  66511. * @param plane defines the reflection plane
  66512. * @returns a new matrix
  66513. */
  66514. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  66515. /**
  66516. * Computes a reflection matrix from a plane
  66517. * @param plane defines the reflection plane
  66518. * @param result defines the target matrix
  66519. */
  66520. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  66521. /**
  66522. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  66523. * @param xaxis defines the value of the 1st axis
  66524. * @param yaxis defines the value of the 2nd axis
  66525. * @param zaxis defines the value of the 3rd axis
  66526. * @param result defines the target matrix
  66527. */
  66528. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  66529. /**
  66530. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  66531. * @param quat defines the quaternion to use
  66532. * @param result defines the target matrix
  66533. */
  66534. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  66535. }
  66536. /**
  66537. * Represens a plane by the equation ax + by + cz + d = 0
  66538. */
  66539. export class Plane {
  66540. /**
  66541. * Normal of the plane (a,b,c)
  66542. */
  66543. normal: Vector3;
  66544. /**
  66545. * d component of the plane
  66546. */
  66547. d: number;
  66548. /**
  66549. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  66550. * @param a a component of the plane
  66551. * @param b b component of the plane
  66552. * @param c c component of the plane
  66553. * @param d d component of the plane
  66554. */
  66555. constructor(a: number, b: number, c: number, d: number);
  66556. /**
  66557. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  66558. */
  66559. asArray(): number[];
  66560. /**
  66561. * @returns a new plane copied from the current Plane.
  66562. */
  66563. clone(): Plane;
  66564. /**
  66565. * @returns the string "Plane".
  66566. */
  66567. getClassName(): string;
  66568. /**
  66569. * @returns the Plane hash code.
  66570. */
  66571. getHashCode(): number;
  66572. /**
  66573. * Normalize the current Plane in place.
  66574. * @returns the updated Plane.
  66575. */
  66576. normalize(): Plane;
  66577. /**
  66578. * Applies a transformation the plane and returns the result
  66579. * @param transformation the transformation matrix to be applied to the plane
  66580. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  66581. */
  66582. transform(transformation: DeepImmutable<Matrix>): Plane;
  66583. /**
  66584. * Calcualtte the dot product between the point and the plane normal
  66585. * @param point point to calculate the dot product with
  66586. * @returns the dot product (float) of the point coordinates and the plane normal.
  66587. */
  66588. dotCoordinate(point: DeepImmutable<Vector3>): number;
  66589. /**
  66590. * Updates the current Plane from the plane defined by the three given points.
  66591. * @param point1 one of the points used to contruct the plane
  66592. * @param point2 one of the points used to contruct the plane
  66593. * @param point3 one of the points used to contruct the plane
  66594. * @returns the updated Plane.
  66595. */
  66596. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66597. /**
  66598. * Checks if the plane is facing a given direction
  66599. * @param direction the direction to check if the plane is facing
  66600. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66601. * @returns True is the vector "direction" is the same side than the plane normal.
  66602. */
  66603. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66604. /**
  66605. * Calculates the distance to a point
  66606. * @param point point to calculate distance to
  66607. * @returns the signed distance (float) from the given point to the Plane.
  66608. */
  66609. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66610. /**
  66611. * Creates a plane from an array
  66612. * @param array the array to create a plane from
  66613. * @returns a new Plane from the given array.
  66614. */
  66615. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66616. /**
  66617. * Creates a plane from three points
  66618. * @param point1 point used to create the plane
  66619. * @param point2 point used to create the plane
  66620. * @param point3 point used to create the plane
  66621. * @returns a new Plane defined by the three given points.
  66622. */
  66623. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66624. /**
  66625. * Creates a plane from an origin point and a normal
  66626. * @param origin origin of the plane to be constructed
  66627. * @param normal normal of the plane to be constructed
  66628. * @returns a new Plane the normal vector to this plane at the given origin point.
  66629. * Note : the vector "normal" is updated because normalized.
  66630. */
  66631. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66632. /**
  66633. * Calculates the distance from a plane and a point
  66634. * @param origin origin of the plane to be constructed
  66635. * @param normal normal of the plane to be constructed
  66636. * @param point point to calculate distance to
  66637. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66638. */
  66639. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66640. }
  66641. /**
  66642. * Class used to represent a viewport on screen
  66643. */
  66644. export class Viewport {
  66645. /** viewport left coordinate */
  66646. x: number;
  66647. /** viewport top coordinate */
  66648. y: number;
  66649. /**viewport width */
  66650. width: number;
  66651. /** viewport height */
  66652. height: number;
  66653. /**
  66654. * Creates a Viewport object located at (x, y) and sized (width, height)
  66655. * @param x defines viewport left coordinate
  66656. * @param y defines viewport top coordinate
  66657. * @param width defines the viewport width
  66658. * @param height defines the viewport height
  66659. */
  66660. constructor(
  66661. /** viewport left coordinate */
  66662. x: number,
  66663. /** viewport top coordinate */
  66664. y: number,
  66665. /**viewport width */
  66666. width: number,
  66667. /** viewport height */
  66668. height: number);
  66669. /**
  66670. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66671. * @param renderWidth defines the rendering width
  66672. * @param renderHeight defines the rendering height
  66673. * @returns a new Viewport
  66674. */
  66675. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66676. /**
  66677. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66678. * @param renderWidth defines the rendering width
  66679. * @param renderHeight defines the rendering height
  66680. * @param ref defines the target viewport
  66681. * @returns the current viewport
  66682. */
  66683. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66684. /**
  66685. * Returns a new Viewport copied from the current one
  66686. * @returns a new Viewport
  66687. */
  66688. clone(): Viewport;
  66689. }
  66690. /**
  66691. * Reprasents a camera frustum
  66692. */
  66693. export class Frustum {
  66694. /**
  66695. * Gets the planes representing the frustum
  66696. * @param transform matrix to be applied to the returned planes
  66697. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66698. */
  66699. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66700. /**
  66701. * Gets the near frustum plane transformed by the transform matrix
  66702. * @param transform transformation matrix to be applied to the resulting frustum plane
  66703. * @param frustumPlane the resuling frustum plane
  66704. */
  66705. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66706. /**
  66707. * Gets the far frustum plane transformed by the transform matrix
  66708. * @param transform transformation matrix to be applied to the resulting frustum plane
  66709. * @param frustumPlane the resuling frustum plane
  66710. */
  66711. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66712. /**
  66713. * Gets the left frustum plane transformed by the transform matrix
  66714. * @param transform transformation matrix to be applied to the resulting frustum plane
  66715. * @param frustumPlane the resuling frustum plane
  66716. */
  66717. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66718. /**
  66719. * Gets the right frustum plane transformed by the transform matrix
  66720. * @param transform transformation matrix to be applied to the resulting frustum plane
  66721. * @param frustumPlane the resuling frustum plane
  66722. */
  66723. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66724. /**
  66725. * Gets the top frustum plane transformed by the transform matrix
  66726. * @param transform transformation matrix to be applied to the resulting frustum plane
  66727. * @param frustumPlane the resuling frustum plane
  66728. */
  66729. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66730. /**
  66731. * Gets the bottom frustum plane transformed by the transform matrix
  66732. * @param transform transformation matrix to be applied to the resulting frustum plane
  66733. * @param frustumPlane the resuling frustum plane
  66734. */
  66735. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66736. /**
  66737. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66738. * @param transform transformation matrix to be applied to the resulting frustum planes
  66739. * @param frustumPlanes the resuling frustum planes
  66740. */
  66741. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66742. }
  66743. /** Defines supported spaces */
  66744. export enum Space {
  66745. /** Local (object) space */
  66746. LOCAL = 0,
  66747. /** World space */
  66748. WORLD = 1,
  66749. /** Bone space */
  66750. BONE = 2
  66751. }
  66752. /** Defines the 3 main axes */
  66753. export class Axis {
  66754. /** X axis */
  66755. static X: Vector3;
  66756. /** Y axis */
  66757. static Y: Vector3;
  66758. /** Z axis */
  66759. static Z: Vector3;
  66760. }
  66761. /** Class used to represent a Bezier curve */
  66762. export class BezierCurve {
  66763. /**
  66764. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66765. * @param t defines the time
  66766. * @param x1 defines the left coordinate on X axis
  66767. * @param y1 defines the left coordinate on Y axis
  66768. * @param x2 defines the right coordinate on X axis
  66769. * @param y2 defines the right coordinate on Y axis
  66770. * @returns the interpolated value
  66771. */
  66772. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66773. }
  66774. /**
  66775. * Defines potential orientation for back face culling
  66776. */
  66777. export enum Orientation {
  66778. /**
  66779. * Clockwise
  66780. */
  66781. CW = 0,
  66782. /** Counter clockwise */
  66783. CCW = 1
  66784. }
  66785. /**
  66786. * Defines angle representation
  66787. */
  66788. export class Angle {
  66789. private _radians;
  66790. /**
  66791. * Creates an Angle object of "radians" radians (float).
  66792. * @param radians the angle in radians
  66793. */
  66794. constructor(radians: number);
  66795. /**
  66796. * Get value in degrees
  66797. * @returns the Angle value in degrees (float)
  66798. */
  66799. degrees(): number;
  66800. /**
  66801. * Get value in radians
  66802. * @returns the Angle value in radians (float)
  66803. */
  66804. radians(): number;
  66805. /**
  66806. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66807. * @param a defines first vector
  66808. * @param b defines second vector
  66809. * @returns a new Angle
  66810. */
  66811. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66812. /**
  66813. * Gets a new Angle object from the given float in radians
  66814. * @param radians defines the angle value in radians
  66815. * @returns a new Angle
  66816. */
  66817. static FromRadians(radians: number): Angle;
  66818. /**
  66819. * Gets a new Angle object from the given float in degrees
  66820. * @param degrees defines the angle value in degrees
  66821. * @returns a new Angle
  66822. */
  66823. static FromDegrees(degrees: number): Angle;
  66824. }
  66825. /**
  66826. * This represents an arc in a 2d space.
  66827. */
  66828. export class Arc2 {
  66829. /** Defines the start point of the arc */
  66830. startPoint: Vector2;
  66831. /** Defines the mid point of the arc */
  66832. midPoint: Vector2;
  66833. /** Defines the end point of the arc */
  66834. endPoint: Vector2;
  66835. /**
  66836. * Defines the center point of the arc.
  66837. */
  66838. centerPoint: Vector2;
  66839. /**
  66840. * Defines the radius of the arc.
  66841. */
  66842. radius: number;
  66843. /**
  66844. * Defines the angle of the arc (from mid point to end point).
  66845. */
  66846. angle: Angle;
  66847. /**
  66848. * Defines the start angle of the arc (from start point to middle point).
  66849. */
  66850. startAngle: Angle;
  66851. /**
  66852. * Defines the orientation of the arc (clock wise/counter clock wise).
  66853. */
  66854. orientation: Orientation;
  66855. /**
  66856. * Creates an Arc object from the three given points : start, middle and end.
  66857. * @param startPoint Defines the start point of the arc
  66858. * @param midPoint Defines the midlle point of the arc
  66859. * @param endPoint Defines the end point of the arc
  66860. */
  66861. constructor(
  66862. /** Defines the start point of the arc */
  66863. startPoint: Vector2,
  66864. /** Defines the mid point of the arc */
  66865. midPoint: Vector2,
  66866. /** Defines the end point of the arc */
  66867. endPoint: Vector2);
  66868. }
  66869. /**
  66870. * Represents a 2D path made up of multiple 2D points
  66871. */
  66872. export class Path2 {
  66873. private _points;
  66874. private _length;
  66875. /**
  66876. * If the path start and end point are the same
  66877. */
  66878. closed: boolean;
  66879. /**
  66880. * Creates a Path2 object from the starting 2D coordinates x and y.
  66881. * @param x the starting points x value
  66882. * @param y the starting points y value
  66883. */
  66884. constructor(x: number, y: number);
  66885. /**
  66886. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66887. * @param x the added points x value
  66888. * @param y the added points y value
  66889. * @returns the updated Path2.
  66890. */
  66891. addLineTo(x: number, y: number): Path2;
  66892. /**
  66893. * 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.
  66894. * @param midX middle point x value
  66895. * @param midY middle point y value
  66896. * @param endX end point x value
  66897. * @param endY end point y value
  66898. * @param numberOfSegments (default: 36)
  66899. * @returns the updated Path2.
  66900. */
  66901. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66902. /**
  66903. * Closes the Path2.
  66904. * @returns the Path2.
  66905. */
  66906. close(): Path2;
  66907. /**
  66908. * Gets the sum of the distance between each sequential point in the path
  66909. * @returns the Path2 total length (float).
  66910. */
  66911. length(): number;
  66912. /**
  66913. * Gets the points which construct the path
  66914. * @returns the Path2 internal array of points.
  66915. */
  66916. getPoints(): Vector2[];
  66917. /**
  66918. * Retreives the point at the distance aways from the starting point
  66919. * @param normalizedLengthPosition the length along the path to retreive the point from
  66920. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66921. */
  66922. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66923. /**
  66924. * Creates a new path starting from an x and y position
  66925. * @param x starting x value
  66926. * @param y starting y value
  66927. * @returns a new Path2 starting at the coordinates (x, y).
  66928. */
  66929. static StartingAt(x: number, y: number): Path2;
  66930. }
  66931. /**
  66932. * Represents a 3D path made up of multiple 3D points
  66933. */
  66934. export class Path3D {
  66935. /**
  66936. * an array of Vector3, the curve axis of the Path3D
  66937. */
  66938. path: Vector3[];
  66939. private _curve;
  66940. private _distances;
  66941. private _tangents;
  66942. private _normals;
  66943. private _binormals;
  66944. private _raw;
  66945. /**
  66946. * new Path3D(path, normal, raw)
  66947. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66948. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66949. * @param path an array of Vector3, the curve axis of the Path3D
  66950. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66951. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66952. */
  66953. constructor(
  66954. /**
  66955. * an array of Vector3, the curve axis of the Path3D
  66956. */
  66957. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66958. /**
  66959. * Returns the Path3D array of successive Vector3 designing its curve.
  66960. * @returns the Path3D array of successive Vector3 designing its curve.
  66961. */
  66962. getCurve(): Vector3[];
  66963. /**
  66964. * Returns an array populated with tangent vectors on each Path3D curve point.
  66965. * @returns an array populated with tangent vectors on each Path3D curve point.
  66966. */
  66967. getTangents(): Vector3[];
  66968. /**
  66969. * Returns an array populated with normal vectors on each Path3D curve point.
  66970. * @returns an array populated with normal vectors on each Path3D curve point.
  66971. */
  66972. getNormals(): Vector3[];
  66973. /**
  66974. * Returns an array populated with binormal vectors on each Path3D curve point.
  66975. * @returns an array populated with binormal vectors on each Path3D curve point.
  66976. */
  66977. getBinormals(): Vector3[];
  66978. /**
  66979. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66980. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66981. */
  66982. getDistances(): number[];
  66983. /**
  66984. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66985. * @param path path which all values are copied into the curves points
  66986. * @param firstNormal which should be projected onto the curve
  66987. * @returns the same object updated.
  66988. */
  66989. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66990. private _compute;
  66991. private _getFirstNonNullVector;
  66992. private _getLastNonNullVector;
  66993. private _normalVector;
  66994. }
  66995. /**
  66996. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66997. * A Curve3 is designed from a series of successive Vector3.
  66998. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66999. */
  67000. export class Curve3 {
  67001. private _points;
  67002. private _length;
  67003. /**
  67004. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  67005. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  67006. * @param v1 (Vector3) the control point
  67007. * @param v2 (Vector3) the end point of the Quadratic Bezier
  67008. * @param nbPoints (integer) the wanted number of points in the curve
  67009. * @returns the created Curve3
  67010. */
  67011. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  67012. /**
  67013. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  67014. * @param v0 (Vector3) the origin point of the Cubic Bezier
  67015. * @param v1 (Vector3) the first control point
  67016. * @param v2 (Vector3) the second control point
  67017. * @param v3 (Vector3) the end point of the Cubic Bezier
  67018. * @param nbPoints (integer) the wanted number of points in the curve
  67019. * @returns the created Curve3
  67020. */
  67021. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  67022. /**
  67023. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  67024. * @param p1 (Vector3) the origin point of the Hermite Spline
  67025. * @param t1 (Vector3) the tangent vector at the origin point
  67026. * @param p2 (Vector3) the end point of the Hermite Spline
  67027. * @param t2 (Vector3) the tangent vector at the end point
  67028. * @param nbPoints (integer) the wanted number of points in the curve
  67029. * @returns the created Curve3
  67030. */
  67031. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  67032. /**
  67033. * Returns a Curve3 object along a CatmullRom Spline curve :
  67034. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  67035. * @param nbPoints (integer) the wanted number of points between each curve control points
  67036. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  67037. * @returns the created Curve3
  67038. */
  67039. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  67040. /**
  67041. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  67042. * A Curve3 is designed from a series of successive Vector3.
  67043. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  67044. * @param points points which make up the curve
  67045. */
  67046. constructor(points: Vector3[]);
  67047. /**
  67048. * @returns the Curve3 stored array of successive Vector3
  67049. */
  67050. getPoints(): Vector3[];
  67051. /**
  67052. * @returns the computed length (float) of the curve.
  67053. */
  67054. length(): number;
  67055. /**
  67056. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  67057. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  67058. * curveA and curveB keep unchanged.
  67059. * @param curve the curve to continue from this curve
  67060. * @returns the newly constructed curve
  67061. */
  67062. continue(curve: DeepImmutable<Curve3>): Curve3;
  67063. private _computeLength;
  67064. }
  67065. /**
  67066. * Contains position and normal vectors for a vertex
  67067. */
  67068. export class PositionNormalVertex {
  67069. /** the position of the vertex (defaut: 0,0,0) */
  67070. position: Vector3;
  67071. /** the normal of the vertex (defaut: 0,1,0) */
  67072. normal: Vector3;
  67073. /**
  67074. * Creates a PositionNormalVertex
  67075. * @param position the position of the vertex (defaut: 0,0,0)
  67076. * @param normal the normal of the vertex (defaut: 0,1,0)
  67077. */
  67078. constructor(
  67079. /** the position of the vertex (defaut: 0,0,0) */
  67080. position?: Vector3,
  67081. /** the normal of the vertex (defaut: 0,1,0) */
  67082. normal?: Vector3);
  67083. /**
  67084. * Clones the PositionNormalVertex
  67085. * @returns the cloned PositionNormalVertex
  67086. */
  67087. clone(): PositionNormalVertex;
  67088. }
  67089. /**
  67090. * Contains position, normal and uv vectors for a vertex
  67091. */
  67092. export class PositionNormalTextureVertex {
  67093. /** the position of the vertex (defaut: 0,0,0) */
  67094. position: Vector3;
  67095. /** the normal of the vertex (defaut: 0,1,0) */
  67096. normal: Vector3;
  67097. /** the uv of the vertex (default: 0,0) */
  67098. uv: Vector2;
  67099. /**
  67100. * Creates a PositionNormalTextureVertex
  67101. * @param position the position of the vertex (defaut: 0,0,0)
  67102. * @param normal the normal of the vertex (defaut: 0,1,0)
  67103. * @param uv the uv of the vertex (default: 0,0)
  67104. */
  67105. constructor(
  67106. /** the position of the vertex (defaut: 0,0,0) */
  67107. position?: Vector3,
  67108. /** the normal of the vertex (defaut: 0,1,0) */
  67109. normal?: Vector3,
  67110. /** the uv of the vertex (default: 0,0) */
  67111. uv?: Vector2);
  67112. /**
  67113. * Clones the PositionNormalTextureVertex
  67114. * @returns the cloned PositionNormalTextureVertex
  67115. */
  67116. clone(): PositionNormalTextureVertex;
  67117. }
  67118. /**
  67119. * @hidden
  67120. */
  67121. export class Tmp {
  67122. static Color3: Color3[];
  67123. static Color4: Color4[];
  67124. static Vector2: Vector2[];
  67125. static Vector3: Vector3[];
  67126. static Vector4: Vector4[];
  67127. static Quaternion: Quaternion[];
  67128. static Matrix: Matrix[];
  67129. }
  67130. }
  67131. declare module BABYLON {
  67132. /**
  67133. * Class used to enable access to offline support
  67134. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67135. */
  67136. export interface IOfflineProvider {
  67137. /**
  67138. * Gets a boolean indicating if scene must be saved in the database
  67139. */
  67140. enableSceneOffline: boolean;
  67141. /**
  67142. * Gets a boolean indicating if textures must be saved in the database
  67143. */
  67144. enableTexturesOffline: boolean;
  67145. /**
  67146. * Open the offline support and make it available
  67147. * @param successCallback defines the callback to call on success
  67148. * @param errorCallback defines the callback to call on error
  67149. */
  67150. open(successCallback: () => void, errorCallback: () => void): void;
  67151. /**
  67152. * Loads an image from the offline support
  67153. * @param url defines the url to load from
  67154. * @param image defines the target DOM image
  67155. */
  67156. loadImage(url: string, image: HTMLImageElement): void;
  67157. /**
  67158. * Loads a file from offline support
  67159. * @param url defines the URL to load from
  67160. * @param sceneLoaded defines a callback to call on success
  67161. * @param progressCallBack defines a callback to call when progress changed
  67162. * @param errorCallback defines a callback to call on error
  67163. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67164. */
  67165. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67166. }
  67167. }
  67168. declare module BABYLON {
  67169. /**
  67170. * A class serves as a medium between the observable and its observers
  67171. */
  67172. export class EventState {
  67173. /**
  67174. * Create a new EventState
  67175. * @param mask defines the mask associated with this state
  67176. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67177. * @param target defines the original target of the state
  67178. * @param currentTarget defines the current target of the state
  67179. */
  67180. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  67181. /**
  67182. * Initialize the current event state
  67183. * @param mask defines the mask associated with this state
  67184. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67185. * @param target defines the original target of the state
  67186. * @param currentTarget defines the current target of the state
  67187. * @returns the current event state
  67188. */
  67189. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  67190. /**
  67191. * An Observer can set this property to true to prevent subsequent observers of being notified
  67192. */
  67193. skipNextObservers: boolean;
  67194. /**
  67195. * Get the mask value that were used to trigger the event corresponding to this EventState object
  67196. */
  67197. mask: number;
  67198. /**
  67199. * The object that originally notified the event
  67200. */
  67201. target?: any;
  67202. /**
  67203. * The current object in the bubbling phase
  67204. */
  67205. currentTarget?: any;
  67206. /**
  67207. * This will be populated with the return value of the last function that was executed.
  67208. * If it is the first function in the callback chain it will be the event data.
  67209. */
  67210. lastReturnValue?: any;
  67211. }
  67212. /**
  67213. * Represent an Observer registered to a given Observable object.
  67214. */
  67215. export class Observer<T> {
  67216. /**
  67217. * Defines the callback to call when the observer is notified
  67218. */
  67219. callback: (eventData: T, eventState: EventState) => void;
  67220. /**
  67221. * Defines the mask of the observer (used to filter notifications)
  67222. */
  67223. mask: number;
  67224. /**
  67225. * Defines the current scope used to restore the JS context
  67226. */
  67227. scope: any;
  67228. /** @hidden */
  67229. _willBeUnregistered: boolean;
  67230. /**
  67231. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  67232. */
  67233. unregisterOnNextCall: boolean;
  67234. /**
  67235. * Creates a new observer
  67236. * @param callback defines the callback to call when the observer is notified
  67237. * @param mask defines the mask of the observer (used to filter notifications)
  67238. * @param scope defines the current scope used to restore the JS context
  67239. */
  67240. constructor(
  67241. /**
  67242. * Defines the callback to call when the observer is notified
  67243. */
  67244. callback: (eventData: T, eventState: EventState) => void,
  67245. /**
  67246. * Defines the mask of the observer (used to filter notifications)
  67247. */
  67248. mask: number,
  67249. /**
  67250. * Defines the current scope used to restore the JS context
  67251. */
  67252. scope?: any);
  67253. }
  67254. /**
  67255. * Represent a list of observers registered to multiple Observables object.
  67256. */
  67257. export class MultiObserver<T> {
  67258. private _observers;
  67259. private _observables;
  67260. /**
  67261. * Release associated resources
  67262. */
  67263. dispose(): void;
  67264. /**
  67265. * Raise a callback when one of the observable will notify
  67266. * @param observables defines a list of observables to watch
  67267. * @param callback defines the callback to call on notification
  67268. * @param mask defines the mask used to filter notifications
  67269. * @param scope defines the current scope used to restore the JS context
  67270. * @returns the new MultiObserver
  67271. */
  67272. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  67273. }
  67274. /**
  67275. * The Observable class is a simple implementation of the Observable pattern.
  67276. *
  67277. * 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.
  67278. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  67279. * 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).
  67280. * 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.
  67281. */
  67282. export class Observable<T> {
  67283. private _observers;
  67284. private _eventState;
  67285. private _onObserverAdded;
  67286. /**
  67287. * Creates a new observable
  67288. * @param onObserverAdded defines a callback to call when a new observer is added
  67289. */
  67290. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67291. /**
  67292. * Create a new Observer with the specified callback
  67293. * @param callback the callback that will be executed for that Observer
  67294. * @param mask the mask used to filter observers
  67295. * @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.
  67296. * @param scope optional scope for the callback to be called from
  67297. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67298. * @returns the new observer created for the callback
  67299. */
  67300. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67301. /**
  67302. * Create a new Observer with the specified callback and unregisters after the next notification
  67303. * @param callback the callback that will be executed for that Observer
  67304. * @returns the new observer created for the callback
  67305. */
  67306. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67307. /**
  67308. * Remove an Observer from the Observable object
  67309. * @param observer the instance of the Observer to remove
  67310. * @returns false if it doesn't belong to this Observable
  67311. */
  67312. remove(observer: Nullable<Observer<T>>): boolean;
  67313. /**
  67314. * Remove a callback from the Observable object
  67315. * @param callback the callback to remove
  67316. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67317. * @returns false if it doesn't belong to this Observable
  67318. */
  67319. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67320. private _deferUnregister;
  67321. private _remove;
  67322. /**
  67323. * Moves the observable to the top of the observer list making it get called first when notified
  67324. * @param observer the observer to move
  67325. */
  67326. makeObserverTopPriority(observer: Observer<T>): void;
  67327. /**
  67328. * Moves the observable to the bottom of the observer list making it get called last when notified
  67329. * @param observer the observer to move
  67330. */
  67331. makeObserverBottomPriority(observer: Observer<T>): void;
  67332. /**
  67333. * Notify all Observers by calling their respective callback with the given data
  67334. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67335. * @param eventData defines the data to send to all observers
  67336. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67337. * @param target defines the original target of the state
  67338. * @param currentTarget defines the current target of the state
  67339. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67340. */
  67341. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67342. /**
  67343. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67344. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67345. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67346. * and it is crucial that all callbacks will be executed.
  67347. * The order of the callbacks is kept, callbacks are not executed parallel.
  67348. *
  67349. * @param eventData The data to be sent to each callback
  67350. * @param mask is used to filter observers defaults to -1
  67351. * @param target defines the callback target (see EventState)
  67352. * @param currentTarget defines he current object in the bubbling phase
  67353. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67354. */
  67355. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67356. /**
  67357. * Notify a specific observer
  67358. * @param observer defines the observer to notify
  67359. * @param eventData defines the data to be sent to each callback
  67360. * @param mask is used to filter observers defaults to -1
  67361. */
  67362. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67363. /**
  67364. * Gets a boolean indicating if the observable has at least one observer
  67365. * @returns true is the Observable has at least one Observer registered
  67366. */
  67367. hasObservers(): boolean;
  67368. /**
  67369. * Clear the list of observers
  67370. */
  67371. clear(): void;
  67372. /**
  67373. * Clone the current observable
  67374. * @returns a new observable
  67375. */
  67376. clone(): Observable<T>;
  67377. /**
  67378. * Does this observable handles observer registered with a given mask
  67379. * @param mask defines the mask to be tested
  67380. * @return whether or not one observer registered with the given mask is handeled
  67381. **/
  67382. hasSpecificMask(mask?: number): boolean;
  67383. }
  67384. }
  67385. declare module BABYLON {
  67386. /**
  67387. * Class used to help managing file picking and drag'n'drop
  67388. * File Storage
  67389. */
  67390. export class FilesInputStore {
  67391. /**
  67392. * List of files ready to be loaded
  67393. */
  67394. static FilesToLoad: {
  67395. [key: string]: File;
  67396. };
  67397. }
  67398. }
  67399. declare module BABYLON {
  67400. /** Defines the cross module used constants to avoid circular dependncies */
  67401. export class Constants {
  67402. /** Defines that alpha blending is disabled */
  67403. static readonly ALPHA_DISABLE: number;
  67404. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67405. static readonly ALPHA_ADD: number;
  67406. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67407. static readonly ALPHA_COMBINE: number;
  67408. /** Defines that alpha blending to DEST - SRC * DEST */
  67409. static readonly ALPHA_SUBTRACT: number;
  67410. /** Defines that alpha blending to SRC * DEST */
  67411. static readonly ALPHA_MULTIPLY: number;
  67412. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67413. static readonly ALPHA_MAXIMIZED: number;
  67414. /** Defines that alpha blending to SRC + DEST */
  67415. static readonly ALPHA_ONEONE: number;
  67416. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67417. static readonly ALPHA_PREMULTIPLIED: number;
  67418. /**
  67419. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67420. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67421. */
  67422. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67423. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67424. static readonly ALPHA_INTERPOLATE: number;
  67425. /**
  67426. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67427. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67428. */
  67429. static readonly ALPHA_SCREENMODE: number;
  67430. /** Defines that the ressource is not delayed*/
  67431. static readonly DELAYLOADSTATE_NONE: number;
  67432. /** Defines that the ressource was successfully delay loaded */
  67433. static readonly DELAYLOADSTATE_LOADED: number;
  67434. /** Defines that the ressource is currently delay loading */
  67435. static readonly DELAYLOADSTATE_LOADING: number;
  67436. /** Defines that the ressource is delayed and has not started loading */
  67437. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67438. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67439. static readonly NEVER: number;
  67440. /** 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 */
  67441. static readonly ALWAYS: number;
  67442. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67443. static readonly LESS: number;
  67444. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67445. static readonly EQUAL: number;
  67446. /** 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 */
  67447. static readonly LEQUAL: number;
  67448. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67449. static readonly GREATER: number;
  67450. /** 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 */
  67451. static readonly GEQUAL: number;
  67452. /** 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 */
  67453. static readonly NOTEQUAL: number;
  67454. /** Passed to stencilOperation to specify that stencil value must be kept */
  67455. static readonly KEEP: number;
  67456. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67457. static readonly REPLACE: number;
  67458. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67459. static readonly INCR: number;
  67460. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67461. static readonly DECR: number;
  67462. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67463. static readonly INVERT: number;
  67464. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67465. static readonly INCR_WRAP: number;
  67466. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67467. static readonly DECR_WRAP: number;
  67468. /** Texture is not repeating outside of 0..1 UVs */
  67469. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67470. /** Texture is repeating outside of 0..1 UVs */
  67471. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67472. /** Texture is repeating and mirrored */
  67473. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67474. /** ALPHA */
  67475. static readonly TEXTUREFORMAT_ALPHA: number;
  67476. /** LUMINANCE */
  67477. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67478. /** LUMINANCE_ALPHA */
  67479. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67480. /** RGB */
  67481. static readonly TEXTUREFORMAT_RGB: number;
  67482. /** RGBA */
  67483. static readonly TEXTUREFORMAT_RGBA: number;
  67484. /** RED */
  67485. static readonly TEXTUREFORMAT_RED: number;
  67486. /** RED (2nd reference) */
  67487. static readonly TEXTUREFORMAT_R: number;
  67488. /** RG */
  67489. static readonly TEXTUREFORMAT_RG: number;
  67490. /** RED_INTEGER */
  67491. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67492. /** RED_INTEGER (2nd reference) */
  67493. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67494. /** RG_INTEGER */
  67495. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67496. /** RGB_INTEGER */
  67497. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67498. /** RGBA_INTEGER */
  67499. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67500. /** UNSIGNED_BYTE */
  67501. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67502. /** UNSIGNED_BYTE (2nd reference) */
  67503. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67504. /** FLOAT */
  67505. static readonly TEXTURETYPE_FLOAT: number;
  67506. /** HALF_FLOAT */
  67507. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67508. /** BYTE */
  67509. static readonly TEXTURETYPE_BYTE: number;
  67510. /** SHORT */
  67511. static readonly TEXTURETYPE_SHORT: number;
  67512. /** UNSIGNED_SHORT */
  67513. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67514. /** INT */
  67515. static readonly TEXTURETYPE_INT: number;
  67516. /** UNSIGNED_INT */
  67517. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67518. /** UNSIGNED_SHORT_4_4_4_4 */
  67519. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67520. /** UNSIGNED_SHORT_5_5_5_1 */
  67521. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67522. /** UNSIGNED_SHORT_5_6_5 */
  67523. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67524. /** UNSIGNED_INT_2_10_10_10_REV */
  67525. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67526. /** UNSIGNED_INT_24_8 */
  67527. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67528. /** UNSIGNED_INT_10F_11F_11F_REV */
  67529. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67530. /** UNSIGNED_INT_5_9_9_9_REV */
  67531. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67532. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67533. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67534. /** nearest is mag = nearest and min = nearest and mip = linear */
  67535. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67536. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67537. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67538. /** Trilinear is mag = linear and min = linear and mip = linear */
  67539. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67540. /** nearest is mag = nearest and min = nearest and mip = linear */
  67541. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67542. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67543. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67544. /** Trilinear is mag = linear and min = linear and mip = linear */
  67545. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67546. /** mag = nearest and min = nearest and mip = nearest */
  67547. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67548. /** mag = nearest and min = linear and mip = nearest */
  67549. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67550. /** mag = nearest and min = linear and mip = linear */
  67551. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67552. /** mag = nearest and min = linear and mip = none */
  67553. static readonly TEXTURE_NEAREST_LINEAR: number;
  67554. /** mag = nearest and min = nearest and mip = none */
  67555. static readonly TEXTURE_NEAREST_NEAREST: number;
  67556. /** mag = linear and min = nearest and mip = nearest */
  67557. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67558. /** mag = linear and min = nearest and mip = linear */
  67559. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67560. /** mag = linear and min = linear and mip = none */
  67561. static readonly TEXTURE_LINEAR_LINEAR: number;
  67562. /** mag = linear and min = nearest and mip = none */
  67563. static readonly TEXTURE_LINEAR_NEAREST: number;
  67564. /** Explicit coordinates mode */
  67565. static readonly TEXTURE_EXPLICIT_MODE: number;
  67566. /** Spherical coordinates mode */
  67567. static readonly TEXTURE_SPHERICAL_MODE: number;
  67568. /** Planar coordinates mode */
  67569. static readonly TEXTURE_PLANAR_MODE: number;
  67570. /** Cubic coordinates mode */
  67571. static readonly TEXTURE_CUBIC_MODE: number;
  67572. /** Projection coordinates mode */
  67573. static readonly TEXTURE_PROJECTION_MODE: number;
  67574. /** Skybox coordinates mode */
  67575. static readonly TEXTURE_SKYBOX_MODE: number;
  67576. /** Inverse Cubic coordinates mode */
  67577. static readonly TEXTURE_INVCUBIC_MODE: number;
  67578. /** Equirectangular coordinates mode */
  67579. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67580. /** Equirectangular Fixed coordinates mode */
  67581. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67582. /** Equirectangular Fixed Mirrored coordinates mode */
  67583. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67584. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67585. static readonly SCALEMODE_FLOOR: number;
  67586. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67587. static readonly SCALEMODE_NEAREST: number;
  67588. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67589. static readonly SCALEMODE_CEILING: number;
  67590. /**
  67591. * The dirty texture flag value
  67592. */
  67593. static readonly MATERIAL_TextureDirtyFlag: number;
  67594. /**
  67595. * The dirty light flag value
  67596. */
  67597. static readonly MATERIAL_LightDirtyFlag: number;
  67598. /**
  67599. * The dirty fresnel flag value
  67600. */
  67601. static readonly MATERIAL_FresnelDirtyFlag: number;
  67602. /**
  67603. * The dirty attribute flag value
  67604. */
  67605. static readonly MATERIAL_AttributesDirtyFlag: number;
  67606. /**
  67607. * The dirty misc flag value
  67608. */
  67609. static readonly MATERIAL_MiscDirtyFlag: number;
  67610. /**
  67611. * The all dirty flag value
  67612. */
  67613. static readonly MATERIAL_AllDirtyFlag: number;
  67614. /**
  67615. * Returns the triangle fill mode
  67616. */
  67617. static readonly MATERIAL_TriangleFillMode: number;
  67618. /**
  67619. * Returns the wireframe mode
  67620. */
  67621. static readonly MATERIAL_WireFrameFillMode: number;
  67622. /**
  67623. * Returns the point fill mode
  67624. */
  67625. static readonly MATERIAL_PointFillMode: number;
  67626. /**
  67627. * Returns the point list draw mode
  67628. */
  67629. static readonly MATERIAL_PointListDrawMode: number;
  67630. /**
  67631. * Returns the line list draw mode
  67632. */
  67633. static readonly MATERIAL_LineListDrawMode: number;
  67634. /**
  67635. * Returns the line loop draw mode
  67636. */
  67637. static readonly MATERIAL_LineLoopDrawMode: number;
  67638. /**
  67639. * Returns the line strip draw mode
  67640. */
  67641. static readonly MATERIAL_LineStripDrawMode: number;
  67642. /**
  67643. * Returns the triangle strip draw mode
  67644. */
  67645. static readonly MATERIAL_TriangleStripDrawMode: number;
  67646. /**
  67647. * Returns the triangle fan draw mode
  67648. */
  67649. static readonly MATERIAL_TriangleFanDrawMode: number;
  67650. /**
  67651. * Stores the clock-wise side orientation
  67652. */
  67653. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67654. /**
  67655. * Stores the counter clock-wise side orientation
  67656. */
  67657. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67658. /**
  67659. * Nothing
  67660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67661. */
  67662. static readonly ACTION_NothingTrigger: number;
  67663. /**
  67664. * On pick
  67665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67666. */
  67667. static readonly ACTION_OnPickTrigger: number;
  67668. /**
  67669. * On left pick
  67670. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67671. */
  67672. static readonly ACTION_OnLeftPickTrigger: number;
  67673. /**
  67674. * On right pick
  67675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67676. */
  67677. static readonly ACTION_OnRightPickTrigger: number;
  67678. /**
  67679. * On center pick
  67680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67681. */
  67682. static readonly ACTION_OnCenterPickTrigger: number;
  67683. /**
  67684. * On pick down
  67685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67686. */
  67687. static readonly ACTION_OnPickDownTrigger: number;
  67688. /**
  67689. * On double pick
  67690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67691. */
  67692. static readonly ACTION_OnDoublePickTrigger: number;
  67693. /**
  67694. * On pick up
  67695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67696. */
  67697. static readonly ACTION_OnPickUpTrigger: number;
  67698. /**
  67699. * On pick out.
  67700. * This trigger will only be raised if you also declared a OnPickDown
  67701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67702. */
  67703. static readonly ACTION_OnPickOutTrigger: number;
  67704. /**
  67705. * On long press
  67706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67707. */
  67708. static readonly ACTION_OnLongPressTrigger: number;
  67709. /**
  67710. * On pointer over
  67711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67712. */
  67713. static readonly ACTION_OnPointerOverTrigger: number;
  67714. /**
  67715. * On pointer out
  67716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67717. */
  67718. static readonly ACTION_OnPointerOutTrigger: number;
  67719. /**
  67720. * On every frame
  67721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67722. */
  67723. static readonly ACTION_OnEveryFrameTrigger: number;
  67724. /**
  67725. * On intersection enter
  67726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67727. */
  67728. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67729. /**
  67730. * On intersection exit
  67731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67732. */
  67733. static readonly ACTION_OnIntersectionExitTrigger: number;
  67734. /**
  67735. * On key down
  67736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67737. */
  67738. static readonly ACTION_OnKeyDownTrigger: number;
  67739. /**
  67740. * On key up
  67741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67742. */
  67743. static readonly ACTION_OnKeyUpTrigger: number;
  67744. /**
  67745. * Billboard mode will only apply to Y axis
  67746. */
  67747. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67748. /**
  67749. * Billboard mode will apply to all axes
  67750. */
  67751. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67752. /**
  67753. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67754. */
  67755. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67756. /**
  67757. * Gets or sets base Assets URL
  67758. */
  67759. static PARTICLES_BaseAssetsUrl: string;
  67760. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67761. * Test order :
  67762. * Is the bounding sphere outside the frustum ?
  67763. * If not, are the bounding box vertices outside the frustum ?
  67764. * It not, then the cullable object is in the frustum.
  67765. */
  67766. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67767. /** Culling strategy : Bounding Sphere Only.
  67768. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67769. * It's also less accurate than the standard because some not visible objects can still be selected.
  67770. * Test : is the bounding sphere outside the frustum ?
  67771. * If not, then the cullable object is in the frustum.
  67772. */
  67773. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67774. /** Culling strategy : Optimistic Inclusion.
  67775. * This in an inclusion test first, then the standard exclusion test.
  67776. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67777. * 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.
  67778. * Anyway, it's as accurate as the standard strategy.
  67779. * Test :
  67780. * Is the cullable object bounding sphere center in the frustum ?
  67781. * If not, apply the default culling strategy.
  67782. */
  67783. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67784. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67785. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67786. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67787. * 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.
  67788. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67789. * Test :
  67790. * Is the cullable object bounding sphere center in the frustum ?
  67791. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67792. */
  67793. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67794. /**
  67795. * No logging while loading
  67796. */
  67797. static readonly SCENELOADER_NO_LOGGING: number;
  67798. /**
  67799. * Minimal logging while loading
  67800. */
  67801. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67802. /**
  67803. * Summary logging while loading
  67804. */
  67805. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67806. /**
  67807. * Detailled logging while loading
  67808. */
  67809. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67810. }
  67811. }
  67812. declare module BABYLON {
  67813. /**
  67814. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67815. * Babylon.js
  67816. */
  67817. export class DomManagement {
  67818. /**
  67819. * Checks if the window object exists
  67820. * @returns true if the window object exists
  67821. */
  67822. static IsWindowObjectExist(): boolean;
  67823. /**
  67824. * Extracts text content from a DOM element hierarchy
  67825. * @param element defines the root element
  67826. * @returns a string
  67827. */
  67828. static GetDOMTextContent(element: HTMLElement): string;
  67829. }
  67830. }
  67831. declare module BABYLON {
  67832. /**
  67833. * Logger used througouht the application to allow configuration of
  67834. * the log level required for the messages.
  67835. */
  67836. export class Logger {
  67837. /**
  67838. * No log
  67839. */
  67840. static readonly NoneLogLevel: number;
  67841. /**
  67842. * Only message logs
  67843. */
  67844. static readonly MessageLogLevel: number;
  67845. /**
  67846. * Only warning logs
  67847. */
  67848. static readonly WarningLogLevel: number;
  67849. /**
  67850. * Only error logs
  67851. */
  67852. static readonly ErrorLogLevel: number;
  67853. /**
  67854. * All logs
  67855. */
  67856. static readonly AllLogLevel: number;
  67857. private static _LogCache;
  67858. /**
  67859. * Gets a value indicating the number of loading errors
  67860. * @ignorenaming
  67861. */
  67862. static errorsCount: number;
  67863. /**
  67864. * Callback called when a new log is added
  67865. */
  67866. static OnNewCacheEntry: (entry: string) => void;
  67867. private static _AddLogEntry;
  67868. private static _FormatMessage;
  67869. private static _LogDisabled;
  67870. private static _LogEnabled;
  67871. private static _WarnDisabled;
  67872. private static _WarnEnabled;
  67873. private static _ErrorDisabled;
  67874. private static _ErrorEnabled;
  67875. /**
  67876. * Log a message to the console
  67877. */
  67878. static Log: (message: string) => void;
  67879. /**
  67880. * Write a warning message to the console
  67881. */
  67882. static Warn: (message: string) => void;
  67883. /**
  67884. * Write an error message to the console
  67885. */
  67886. static Error: (message: string) => void;
  67887. /**
  67888. * Gets current log cache (list of logs)
  67889. */
  67890. static readonly LogCache: string;
  67891. /**
  67892. * Clears the log cache
  67893. */
  67894. static ClearLogCache(): void;
  67895. /**
  67896. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67897. */
  67898. static LogLevels: number;
  67899. }
  67900. }
  67901. declare module BABYLON {
  67902. /** @hidden */
  67903. export class _TypeStore {
  67904. /** @hidden */
  67905. static RegisteredTypes: {
  67906. [key: string]: Object;
  67907. };
  67908. /** @hidden */
  67909. static GetClass(fqdn: string): any;
  67910. }
  67911. }
  67912. declare module BABYLON {
  67913. /**
  67914. * Class containing a set of static utilities functions for deep copy.
  67915. */
  67916. export class DeepCopier {
  67917. /**
  67918. * Tries to copy an object by duplicating every property
  67919. * @param source defines the source object
  67920. * @param destination defines the target object
  67921. * @param doNotCopyList defines a list of properties to avoid
  67922. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67923. */
  67924. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67925. }
  67926. }
  67927. declare module BABYLON {
  67928. /**
  67929. * Class containing a set of static utilities functions for precision date
  67930. */
  67931. export class PrecisionDate {
  67932. /**
  67933. * Gets either window.performance.now() if supported or Date.now() else
  67934. */
  67935. static readonly Now: number;
  67936. }
  67937. }
  67938. declare module BABYLON {
  67939. /** @hidden */
  67940. export class _DevTools {
  67941. static WarnImport(name: string): string;
  67942. }
  67943. }
  67944. declare module BABYLON {
  67945. /**
  67946. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67947. */
  67948. export class WebRequest {
  67949. private _xhr;
  67950. /**
  67951. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67952. * i.e. when loading files, where the server/service expects an Authorization header
  67953. */
  67954. static CustomRequestHeaders: {
  67955. [key: string]: string;
  67956. };
  67957. /**
  67958. * Add callback functions in this array to update all the requests before they get sent to the network
  67959. */
  67960. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  67961. private _injectCustomRequestHeaders;
  67962. /**
  67963. * Gets or sets a function to be called when loading progress changes
  67964. */
  67965. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67966. /**
  67967. * Returns client's state
  67968. */
  67969. readonly readyState: number;
  67970. /**
  67971. * Returns client's status
  67972. */
  67973. readonly status: number;
  67974. /**
  67975. * Returns client's status as a text
  67976. */
  67977. readonly statusText: string;
  67978. /**
  67979. * Returns client's response
  67980. */
  67981. readonly response: any;
  67982. /**
  67983. * Returns client's response url
  67984. */
  67985. readonly responseURL: string;
  67986. /**
  67987. * Returns client's response as text
  67988. */
  67989. readonly responseText: string;
  67990. /**
  67991. * Gets or sets the expected response type
  67992. */
  67993. responseType: XMLHttpRequestResponseType;
  67994. /** @hidden */
  67995. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67996. /** @hidden */
  67997. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67998. /**
  67999. * Cancels any network activity
  68000. */
  68001. abort(): void;
  68002. /**
  68003. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68004. * @param body defines an optional request body
  68005. */
  68006. send(body?: Document | BodyInit | null): void;
  68007. /**
  68008. * Sets the request method, request URL
  68009. * @param method defines the method to use (GET, POST, etc..)
  68010. * @param url defines the url to connect with
  68011. */
  68012. open(method: string, url: string): void;
  68013. }
  68014. }
  68015. declare module BABYLON {
  68016. /**
  68017. * Class used to evalaute queries containing `and` and `or` operators
  68018. */
  68019. export class AndOrNotEvaluator {
  68020. /**
  68021. * Evaluate a query
  68022. * @param query defines the query to evaluate
  68023. * @param evaluateCallback defines the callback used to filter result
  68024. * @returns true if the query matches
  68025. */
  68026. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68027. private static _HandleParenthesisContent;
  68028. private static _SimplifyNegation;
  68029. }
  68030. }
  68031. declare module BABYLON {
  68032. /**
  68033. * Class used to store custom tags
  68034. */
  68035. export class Tags {
  68036. /**
  68037. * Adds support for tags on the given object
  68038. * @param obj defines the object to use
  68039. */
  68040. static EnableFor(obj: any): void;
  68041. /**
  68042. * Removes tags support
  68043. * @param obj defines the object to use
  68044. */
  68045. static DisableFor(obj: any): void;
  68046. /**
  68047. * Gets a boolean indicating if the given object has tags
  68048. * @param obj defines the object to use
  68049. * @returns a boolean
  68050. */
  68051. static HasTags(obj: any): boolean;
  68052. /**
  68053. * Gets the tags available on a given object
  68054. * @param obj defines the object to use
  68055. * @param asString defines if the tags must be returned as a string instead of an array of strings
  68056. * @returns the tags
  68057. */
  68058. static GetTags(obj: any, asString?: boolean): any;
  68059. /**
  68060. * Adds tags to an object
  68061. * @param obj defines the object to use
  68062. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  68063. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  68064. */
  68065. static AddTagsTo(obj: any, tagsString: string): void;
  68066. /**
  68067. * @hidden
  68068. */
  68069. static _AddTagTo(obj: any, tag: string): void;
  68070. /**
  68071. * Removes specific tags from a specific object
  68072. * @param obj defines the object to use
  68073. * @param tagsString defines the tags to remove
  68074. */
  68075. static RemoveTagsFrom(obj: any, tagsString: string): void;
  68076. /**
  68077. * @hidden
  68078. */
  68079. static _RemoveTagFrom(obj: any, tag: string): void;
  68080. /**
  68081. * Defines if tags hosted on an object match a given query
  68082. * @param obj defines the object to use
  68083. * @param tagsQuery defines the tag query
  68084. * @returns a boolean
  68085. */
  68086. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  68087. }
  68088. }
  68089. declare module BABYLON {
  68090. /**
  68091. * Manages the defines for the Material
  68092. */
  68093. export class MaterialDefines {
  68094. /** @hidden */
  68095. protected _keys: string[];
  68096. private _isDirty;
  68097. /** @hidden */
  68098. _renderId: number;
  68099. /** @hidden */
  68100. _areLightsDirty: boolean;
  68101. /** @hidden */
  68102. _areAttributesDirty: boolean;
  68103. /** @hidden */
  68104. _areTexturesDirty: boolean;
  68105. /** @hidden */
  68106. _areFresnelDirty: boolean;
  68107. /** @hidden */
  68108. _areMiscDirty: boolean;
  68109. /** @hidden */
  68110. _areImageProcessingDirty: boolean;
  68111. /** @hidden */
  68112. _normals: boolean;
  68113. /** @hidden */
  68114. _uvs: boolean;
  68115. /** @hidden */
  68116. _needNormals: boolean;
  68117. /** @hidden */
  68118. _needUVs: boolean;
  68119. [id: string]: any;
  68120. /**
  68121. * Specifies if the material needs to be re-calculated
  68122. */
  68123. readonly isDirty: boolean;
  68124. /**
  68125. * Marks the material to indicate that it has been re-calculated
  68126. */
  68127. markAsProcessed(): void;
  68128. /**
  68129. * Marks the material to indicate that it needs to be re-calculated
  68130. */
  68131. markAsUnprocessed(): void;
  68132. /**
  68133. * Marks the material to indicate all of its defines need to be re-calculated
  68134. */
  68135. markAllAsDirty(): void;
  68136. /**
  68137. * Marks the material to indicate that image processing needs to be re-calculated
  68138. */
  68139. markAsImageProcessingDirty(): void;
  68140. /**
  68141. * Marks the material to indicate the lights need to be re-calculated
  68142. */
  68143. markAsLightDirty(): void;
  68144. /**
  68145. * Marks the attribute state as changed
  68146. */
  68147. markAsAttributesDirty(): void;
  68148. /**
  68149. * Marks the texture state as changed
  68150. */
  68151. markAsTexturesDirty(): void;
  68152. /**
  68153. * Marks the fresnel state as changed
  68154. */
  68155. markAsFresnelDirty(): void;
  68156. /**
  68157. * Marks the misc state as changed
  68158. */
  68159. markAsMiscDirty(): void;
  68160. /**
  68161. * Rebuilds the material defines
  68162. */
  68163. rebuild(): void;
  68164. /**
  68165. * Specifies if two material defines are equal
  68166. * @param other - A material define instance to compare to
  68167. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  68168. */
  68169. isEqual(other: MaterialDefines): boolean;
  68170. /**
  68171. * Clones this instance's defines to another instance
  68172. * @param other - material defines to clone values to
  68173. */
  68174. cloneTo(other: MaterialDefines): void;
  68175. /**
  68176. * Resets the material define values
  68177. */
  68178. reset(): void;
  68179. /**
  68180. * Converts the material define values to a string
  68181. * @returns - String of material define information
  68182. */
  68183. toString(): string;
  68184. }
  68185. }
  68186. declare module BABYLON {
  68187. /**
  68188. * Class used to store and describe the pipeline context associated with an effect
  68189. */
  68190. export interface IPipelineContext {
  68191. /**
  68192. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68193. */
  68194. isAsync: boolean;
  68195. /**
  68196. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68197. */
  68198. isReady: boolean;
  68199. /** @hidden */
  68200. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68201. }
  68202. }
  68203. declare module BABYLON {
  68204. /**
  68205. * Class used to store gfx data (like WebGLBuffer)
  68206. */
  68207. export class DataBuffer {
  68208. /**
  68209. * Gets or sets the number of objects referencing this buffer
  68210. */
  68211. references: number;
  68212. /** Gets or sets the size of the underlying buffer */
  68213. capacity: number;
  68214. /**
  68215. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  68216. */
  68217. is32Bits: boolean;
  68218. /**
  68219. * Gets the underlying buffer
  68220. */
  68221. readonly underlyingResource: any;
  68222. }
  68223. }
  68224. declare module BABYLON {
  68225. /** @hidden */
  68226. export interface IShaderProcessor {
  68227. attributeProcessor?: (attribute: string) => string;
  68228. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68229. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68230. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68231. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68232. lineProcessor?: (line: string, isFragment: boolean) => string;
  68233. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68234. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68235. }
  68236. }
  68237. declare module BABYLON {
  68238. /** @hidden */
  68239. export interface ProcessingOptions {
  68240. defines: string[];
  68241. indexParameters: any;
  68242. isFragment: boolean;
  68243. shouldUseHighPrecisionShader: boolean;
  68244. supportsUniformBuffers: boolean;
  68245. shadersRepository: string;
  68246. includesShadersStore: {
  68247. [key: string]: string;
  68248. };
  68249. processor?: IShaderProcessor;
  68250. version: string;
  68251. platformName: string;
  68252. lookForClosingBracketForUniformBuffer?: boolean;
  68253. }
  68254. }
  68255. declare module BABYLON {
  68256. /** @hidden */
  68257. export class ShaderCodeNode {
  68258. line: string;
  68259. children: ShaderCodeNode[];
  68260. additionalDefineKey?: string;
  68261. additionalDefineValue?: string;
  68262. isValid(preprocessors: {
  68263. [key: string]: string;
  68264. }): boolean;
  68265. process(preprocessors: {
  68266. [key: string]: string;
  68267. }, options: ProcessingOptions): string;
  68268. }
  68269. }
  68270. declare module BABYLON {
  68271. /** @hidden */
  68272. export class ShaderCodeCursor {
  68273. private _lines;
  68274. lineIndex: number;
  68275. readonly currentLine: string;
  68276. readonly canRead: boolean;
  68277. lines: string[];
  68278. }
  68279. }
  68280. declare module BABYLON {
  68281. /** @hidden */
  68282. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68283. process(preprocessors: {
  68284. [key: string]: string;
  68285. }, options: ProcessingOptions): string;
  68286. }
  68287. }
  68288. declare module BABYLON {
  68289. /** @hidden */
  68290. export class ShaderDefineExpression {
  68291. isTrue(preprocessors: {
  68292. [key: string]: string;
  68293. }): boolean;
  68294. }
  68295. }
  68296. declare module BABYLON {
  68297. /** @hidden */
  68298. export class ShaderCodeTestNode extends ShaderCodeNode {
  68299. testExpression: ShaderDefineExpression;
  68300. isValid(preprocessors: {
  68301. [key: string]: string;
  68302. }): boolean;
  68303. }
  68304. }
  68305. declare module BABYLON {
  68306. /** @hidden */
  68307. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68308. define: string;
  68309. not: boolean;
  68310. constructor(define: string, not?: boolean);
  68311. isTrue(preprocessors: {
  68312. [key: string]: string;
  68313. }): boolean;
  68314. }
  68315. }
  68316. declare module BABYLON {
  68317. /** @hidden */
  68318. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68319. leftOperand: ShaderDefineExpression;
  68320. rightOperand: ShaderDefineExpression;
  68321. isTrue(preprocessors: {
  68322. [key: string]: string;
  68323. }): boolean;
  68324. }
  68325. }
  68326. declare module BABYLON {
  68327. /** @hidden */
  68328. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68329. leftOperand: ShaderDefineExpression;
  68330. rightOperand: ShaderDefineExpression;
  68331. isTrue(preprocessors: {
  68332. [key: string]: string;
  68333. }): boolean;
  68334. }
  68335. }
  68336. declare module BABYLON {
  68337. /** @hidden */
  68338. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68339. define: string;
  68340. operand: string;
  68341. testValue: string;
  68342. constructor(define: string, operand: string, testValue: string);
  68343. isTrue(preprocessors: {
  68344. [key: string]: string;
  68345. }): boolean;
  68346. }
  68347. }
  68348. declare module BABYLON {
  68349. /** @hidden */
  68350. export class ShaderProcessor {
  68351. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68352. private static _ProcessPrecision;
  68353. private static _ExtractOperation;
  68354. private static _BuildSubExpression;
  68355. private static _BuildExpression;
  68356. private static _MoveCursorWithinIf;
  68357. private static _MoveCursor;
  68358. private static _EvaluatePreProcessors;
  68359. private static _PreparePreProcessors;
  68360. private static _ProcessShaderConversion;
  68361. private static _ProcessIncludes;
  68362. }
  68363. }
  68364. declare module BABYLON {
  68365. /**
  68366. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  68367. */
  68368. export class PerformanceMonitor {
  68369. private _enabled;
  68370. private _rollingFrameTime;
  68371. private _lastFrameTimeMs;
  68372. /**
  68373. * constructor
  68374. * @param frameSampleSize The number of samples required to saturate the sliding window
  68375. */
  68376. constructor(frameSampleSize?: number);
  68377. /**
  68378. * Samples current frame
  68379. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  68380. */
  68381. sampleFrame(timeMs?: number): void;
  68382. /**
  68383. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68384. */
  68385. readonly averageFrameTime: number;
  68386. /**
  68387. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68388. */
  68389. readonly averageFrameTimeVariance: number;
  68390. /**
  68391. * Returns the frame time of the most recent frame
  68392. */
  68393. readonly instantaneousFrameTime: number;
  68394. /**
  68395. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  68396. */
  68397. readonly averageFPS: number;
  68398. /**
  68399. * Returns the average framerate in frames per second using the most recent frame time
  68400. */
  68401. readonly instantaneousFPS: number;
  68402. /**
  68403. * Returns true if enough samples have been taken to completely fill the sliding window
  68404. */
  68405. readonly isSaturated: boolean;
  68406. /**
  68407. * Enables contributions to the sliding window sample set
  68408. */
  68409. enable(): void;
  68410. /**
  68411. * Disables contributions to the sliding window sample set
  68412. * Samples will not be interpolated over the disabled period
  68413. */
  68414. disable(): void;
  68415. /**
  68416. * Returns true if sampling is enabled
  68417. */
  68418. readonly isEnabled: boolean;
  68419. /**
  68420. * Resets performance monitor
  68421. */
  68422. reset(): void;
  68423. }
  68424. /**
  68425. * RollingAverage
  68426. *
  68427. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  68428. */
  68429. export class RollingAverage {
  68430. /**
  68431. * Current average
  68432. */
  68433. average: number;
  68434. /**
  68435. * Current variance
  68436. */
  68437. variance: number;
  68438. protected _samples: Array<number>;
  68439. protected _sampleCount: number;
  68440. protected _pos: number;
  68441. protected _m2: number;
  68442. /**
  68443. * constructor
  68444. * @param length The number of samples required to saturate the sliding window
  68445. */
  68446. constructor(length: number);
  68447. /**
  68448. * Adds a sample to the sample set
  68449. * @param v The sample value
  68450. */
  68451. add(v: number): void;
  68452. /**
  68453. * Returns previously added values or null if outside of history or outside the sliding window domain
  68454. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  68455. * @return Value previously recorded with add() or null if outside of range
  68456. */
  68457. history(i: number): number;
  68458. /**
  68459. * Returns true if enough samples have been taken to completely fill the sliding window
  68460. * @return true if sample-set saturated
  68461. */
  68462. isSaturated(): boolean;
  68463. /**
  68464. * Resets the rolling average (equivalent to 0 samples taken so far)
  68465. */
  68466. reset(): void;
  68467. /**
  68468. * Wraps a value around the sample range boundaries
  68469. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  68470. * @return Wrapped position in sample range
  68471. */
  68472. protected _wrapPosition(i: number): number;
  68473. }
  68474. }
  68475. declare module BABYLON {
  68476. /**
  68477. * This class implement a typical dictionary using a string as key and the generic type T as value.
  68478. * The underlying implementation relies on an associative array to ensure the best performances.
  68479. * The value can be anything including 'null' but except 'undefined'
  68480. */
  68481. export class StringDictionary<T> {
  68482. /**
  68483. * This will clear this dictionary and copy the content from the 'source' one.
  68484. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  68485. * @param source the dictionary to take the content from and copy to this dictionary
  68486. */
  68487. copyFrom(source: StringDictionary<T>): void;
  68488. /**
  68489. * Get a value based from its key
  68490. * @param key the given key to get the matching value from
  68491. * @return the value if found, otherwise undefined is returned
  68492. */
  68493. get(key: string): T | undefined;
  68494. /**
  68495. * Get a value from its key or add it if it doesn't exist.
  68496. * This method will ensure you that a given key/data will be present in the dictionary.
  68497. * @param key the given key to get the matching value from
  68498. * @param factory the factory that will create the value if the key is not present in the dictionary.
  68499. * The factory will only be invoked if there's no data for the given key.
  68500. * @return the value corresponding to the key.
  68501. */
  68502. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  68503. /**
  68504. * Get a value from its key if present in the dictionary otherwise add it
  68505. * @param key the key to get the value from
  68506. * @param val if there's no such key/value pair in the dictionary add it with this value
  68507. * @return the value corresponding to the key
  68508. */
  68509. getOrAdd(key: string, val: T): T;
  68510. /**
  68511. * Check if there's a given key in the dictionary
  68512. * @param key the key to check for
  68513. * @return true if the key is present, false otherwise
  68514. */
  68515. contains(key: string): boolean;
  68516. /**
  68517. * Add a new key and its corresponding value
  68518. * @param key the key to add
  68519. * @param value the value corresponding to the key
  68520. * @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
  68521. */
  68522. add(key: string, value: T): boolean;
  68523. /**
  68524. * Update a specific value associated to a key
  68525. * @param key defines the key to use
  68526. * @param value defines the value to store
  68527. * @returns true if the value was updated (or false if the key was not found)
  68528. */
  68529. set(key: string, value: T): boolean;
  68530. /**
  68531. * Get the element of the given key and remove it from the dictionary
  68532. * @param key defines the key to search
  68533. * @returns the value associated with the key or null if not found
  68534. */
  68535. getAndRemove(key: string): Nullable<T>;
  68536. /**
  68537. * Remove a key/value from the dictionary.
  68538. * @param key the key to remove
  68539. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  68540. */
  68541. remove(key: string): boolean;
  68542. /**
  68543. * Clear the whole content of the dictionary
  68544. */
  68545. clear(): void;
  68546. /**
  68547. * Gets the current count
  68548. */
  68549. readonly count: number;
  68550. /**
  68551. * Execute a callback on each key/val of the dictionary.
  68552. * Note that you can remove any element in this dictionary in the callback implementation
  68553. * @param callback the callback to execute on a given key/value pair
  68554. */
  68555. forEach(callback: (key: string, val: T) => void): void;
  68556. /**
  68557. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  68558. * If the callback returns null or undefined the method will iterate to the next key/value pair
  68559. * Note that you can remove any element in this dictionary in the callback implementation
  68560. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  68561. * @returns the first item
  68562. */
  68563. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  68564. private _count;
  68565. private _data;
  68566. }
  68567. }
  68568. declare module BABYLON {
  68569. /**
  68570. * Helper class that provides a small promise polyfill
  68571. */
  68572. export class PromisePolyfill {
  68573. /**
  68574. * Static function used to check if the polyfill is required
  68575. * If this is the case then the function will inject the polyfill to window.Promise
  68576. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  68577. */
  68578. static Apply(force?: boolean): void;
  68579. }
  68580. }
  68581. declare module BABYLON {
  68582. /**
  68583. * Class used to store data that will be store in GPU memory
  68584. */
  68585. export class Buffer {
  68586. private _engine;
  68587. private _buffer;
  68588. /** @hidden */
  68589. _data: Nullable<DataArray>;
  68590. private _updatable;
  68591. private _instanced;
  68592. /**
  68593. * Gets the byte stride.
  68594. */
  68595. readonly byteStride: number;
  68596. /**
  68597. * Constructor
  68598. * @param engine the engine
  68599. * @param data the data to use for this buffer
  68600. * @param updatable whether the data is updatable
  68601. * @param stride the stride (optional)
  68602. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68603. * @param instanced whether the buffer is instanced (optional)
  68604. * @param useBytes set to true if the stride in in bytes (optional)
  68605. */
  68606. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68607. /**
  68608. * Create a new VertexBuffer based on the current buffer
  68609. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68610. * @param offset defines offset in the buffer (0 by default)
  68611. * @param size defines the size in floats of attributes (position is 3 for instance)
  68612. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68613. * @param instanced defines if the vertex buffer contains indexed data
  68614. * @param useBytes defines if the offset and stride are in bytes
  68615. * @returns the new vertex buffer
  68616. */
  68617. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68618. /**
  68619. * Gets a boolean indicating if the Buffer is updatable?
  68620. * @returns true if the buffer is updatable
  68621. */
  68622. isUpdatable(): boolean;
  68623. /**
  68624. * Gets current buffer's data
  68625. * @returns a DataArray or null
  68626. */
  68627. getData(): Nullable<DataArray>;
  68628. /**
  68629. * Gets underlying native buffer
  68630. * @returns underlying native buffer
  68631. */
  68632. getBuffer(): Nullable<DataBuffer>;
  68633. /**
  68634. * Gets the stride in float32 units (i.e. byte stride / 4).
  68635. * May not be an integer if the byte stride is not divisible by 4.
  68636. * DEPRECATED. Use byteStride instead.
  68637. * @returns the stride in float32 units
  68638. */
  68639. getStrideSize(): number;
  68640. /**
  68641. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68642. * @param data defines the data to store
  68643. */
  68644. create(data?: Nullable<DataArray>): void;
  68645. /** @hidden */
  68646. _rebuild(): void;
  68647. /**
  68648. * Update current buffer data
  68649. * @param data defines the data to store
  68650. */
  68651. update(data: DataArray): void;
  68652. /**
  68653. * Updates the data directly.
  68654. * @param data the new data
  68655. * @param offset the new offset
  68656. * @param vertexCount the vertex count (optional)
  68657. * @param useBytes set to true if the offset is in bytes
  68658. */
  68659. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68660. /**
  68661. * Release all resources
  68662. */
  68663. dispose(): void;
  68664. }
  68665. /**
  68666. * Specialized buffer used to store vertex data
  68667. */
  68668. export class VertexBuffer {
  68669. /** @hidden */
  68670. _buffer: Buffer;
  68671. private _kind;
  68672. private _size;
  68673. private _ownsBuffer;
  68674. private _instanced;
  68675. private _instanceDivisor;
  68676. /**
  68677. * The byte type.
  68678. */
  68679. static readonly BYTE: number;
  68680. /**
  68681. * The unsigned byte type.
  68682. */
  68683. static readonly UNSIGNED_BYTE: number;
  68684. /**
  68685. * The short type.
  68686. */
  68687. static readonly SHORT: number;
  68688. /**
  68689. * The unsigned short type.
  68690. */
  68691. static readonly UNSIGNED_SHORT: number;
  68692. /**
  68693. * The integer type.
  68694. */
  68695. static readonly INT: number;
  68696. /**
  68697. * The unsigned integer type.
  68698. */
  68699. static readonly UNSIGNED_INT: number;
  68700. /**
  68701. * The float type.
  68702. */
  68703. static readonly FLOAT: number;
  68704. /**
  68705. * Gets or sets the instance divisor when in instanced mode
  68706. */
  68707. instanceDivisor: number;
  68708. /**
  68709. * Gets the byte stride.
  68710. */
  68711. readonly byteStride: number;
  68712. /**
  68713. * Gets the byte offset.
  68714. */
  68715. readonly byteOffset: number;
  68716. /**
  68717. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68718. */
  68719. readonly normalized: boolean;
  68720. /**
  68721. * Gets the data type of each component in the array.
  68722. */
  68723. readonly type: number;
  68724. /**
  68725. * Constructor
  68726. * @param engine the engine
  68727. * @param data the data to use for this vertex buffer
  68728. * @param kind the vertex buffer kind
  68729. * @param updatable whether the data is updatable
  68730. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68731. * @param stride the stride (optional)
  68732. * @param instanced whether the buffer is instanced (optional)
  68733. * @param offset the offset of the data (optional)
  68734. * @param size the number of components (optional)
  68735. * @param type the type of the component (optional)
  68736. * @param normalized whether the data contains normalized data (optional)
  68737. * @param useBytes set to true if stride and offset are in bytes (optional)
  68738. */
  68739. 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);
  68740. /** @hidden */
  68741. _rebuild(): void;
  68742. /**
  68743. * Returns the kind of the VertexBuffer (string)
  68744. * @returns a string
  68745. */
  68746. getKind(): string;
  68747. /**
  68748. * Gets a boolean indicating if the VertexBuffer is updatable?
  68749. * @returns true if the buffer is updatable
  68750. */
  68751. isUpdatable(): boolean;
  68752. /**
  68753. * Gets current buffer's data
  68754. * @returns a DataArray or null
  68755. */
  68756. getData(): Nullable<DataArray>;
  68757. /**
  68758. * Gets underlying native buffer
  68759. * @returns underlying native buffer
  68760. */
  68761. getBuffer(): Nullable<DataBuffer>;
  68762. /**
  68763. * Gets the stride in float32 units (i.e. byte stride / 4).
  68764. * May not be an integer if the byte stride is not divisible by 4.
  68765. * DEPRECATED. Use byteStride instead.
  68766. * @returns the stride in float32 units
  68767. */
  68768. getStrideSize(): number;
  68769. /**
  68770. * Returns the offset as a multiple of the type byte length.
  68771. * DEPRECATED. Use byteOffset instead.
  68772. * @returns the offset in bytes
  68773. */
  68774. getOffset(): number;
  68775. /**
  68776. * Returns the number of components per vertex attribute (integer)
  68777. * @returns the size in float
  68778. */
  68779. getSize(): number;
  68780. /**
  68781. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68782. * @returns true if this buffer is instanced
  68783. */
  68784. getIsInstanced(): boolean;
  68785. /**
  68786. * Returns the instancing divisor, zero for non-instanced (integer).
  68787. * @returns a number
  68788. */
  68789. getInstanceDivisor(): number;
  68790. /**
  68791. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68792. * @param data defines the data to store
  68793. */
  68794. create(data?: DataArray): void;
  68795. /**
  68796. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68797. * This function will create a new buffer if the current one is not updatable
  68798. * @param data defines the data to store
  68799. */
  68800. update(data: DataArray): void;
  68801. /**
  68802. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68803. * Returns the directly updated WebGLBuffer.
  68804. * @param data the new data
  68805. * @param offset the new offset
  68806. * @param useBytes set to true if the offset is in bytes
  68807. */
  68808. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68809. /**
  68810. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68811. */
  68812. dispose(): void;
  68813. /**
  68814. * Enumerates each value of this vertex buffer as numbers.
  68815. * @param count the number of values to enumerate
  68816. * @param callback the callback function called for each value
  68817. */
  68818. forEach(count: number, callback: (value: number, index: number) => void): void;
  68819. /**
  68820. * Positions
  68821. */
  68822. static readonly PositionKind: string;
  68823. /**
  68824. * Normals
  68825. */
  68826. static readonly NormalKind: string;
  68827. /**
  68828. * Tangents
  68829. */
  68830. static readonly TangentKind: string;
  68831. /**
  68832. * Texture coordinates
  68833. */
  68834. static readonly UVKind: string;
  68835. /**
  68836. * Texture coordinates 2
  68837. */
  68838. static readonly UV2Kind: string;
  68839. /**
  68840. * Texture coordinates 3
  68841. */
  68842. static readonly UV3Kind: string;
  68843. /**
  68844. * Texture coordinates 4
  68845. */
  68846. static readonly UV4Kind: string;
  68847. /**
  68848. * Texture coordinates 5
  68849. */
  68850. static readonly UV5Kind: string;
  68851. /**
  68852. * Texture coordinates 6
  68853. */
  68854. static readonly UV6Kind: string;
  68855. /**
  68856. * Colors
  68857. */
  68858. static readonly ColorKind: string;
  68859. /**
  68860. * Matrix indices (for bones)
  68861. */
  68862. static readonly MatricesIndicesKind: string;
  68863. /**
  68864. * Matrix weights (for bones)
  68865. */
  68866. static readonly MatricesWeightsKind: string;
  68867. /**
  68868. * Additional matrix indices (for bones)
  68869. */
  68870. static readonly MatricesIndicesExtraKind: string;
  68871. /**
  68872. * Additional matrix weights (for bones)
  68873. */
  68874. static readonly MatricesWeightsExtraKind: string;
  68875. /**
  68876. * Deduces the stride given a kind.
  68877. * @param kind The kind string to deduce
  68878. * @returns The deduced stride
  68879. */
  68880. static DeduceStride(kind: string): number;
  68881. /**
  68882. * Gets the byte length of the given type.
  68883. * @param type the type
  68884. * @returns the number of bytes
  68885. */
  68886. static GetTypeByteLength(type: number): number;
  68887. /**
  68888. * Enumerates each value of the given parameters as numbers.
  68889. * @param data the data to enumerate
  68890. * @param byteOffset the byte offset of the data
  68891. * @param byteStride the byte stride of the data
  68892. * @param componentCount the number of components per element
  68893. * @param componentType the type of the component
  68894. * @param count the number of values to enumerate
  68895. * @param normalized whether the data is normalized
  68896. * @param callback the callback function called for each value
  68897. */
  68898. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68899. private static _GetFloatValue;
  68900. }
  68901. }
  68902. declare module BABYLON {
  68903. /**
  68904. * Class representing spherical harmonics coefficients to the 3rd degree
  68905. */
  68906. export class SphericalHarmonics {
  68907. /**
  68908. * Defines whether or not the harmonics have been prescaled for rendering.
  68909. */
  68910. preScaled: boolean;
  68911. /**
  68912. * The l0,0 coefficients of the spherical harmonics
  68913. */
  68914. l00: Vector3;
  68915. /**
  68916. * The l1,-1 coefficients of the spherical harmonics
  68917. */
  68918. l1_1: Vector3;
  68919. /**
  68920. * The l1,0 coefficients of the spherical harmonics
  68921. */
  68922. l10: Vector3;
  68923. /**
  68924. * The l1,1 coefficients of the spherical harmonics
  68925. */
  68926. l11: Vector3;
  68927. /**
  68928. * The l2,-2 coefficients of the spherical harmonics
  68929. */
  68930. l2_2: Vector3;
  68931. /**
  68932. * The l2,-1 coefficients of the spherical harmonics
  68933. */
  68934. l2_1: Vector3;
  68935. /**
  68936. * The l2,0 coefficients of the spherical harmonics
  68937. */
  68938. l20: Vector3;
  68939. /**
  68940. * The l2,1 coefficients of the spherical harmonics
  68941. */
  68942. l21: Vector3;
  68943. /**
  68944. * The l2,2 coefficients of the spherical harmonics
  68945. */
  68946. l22: Vector3;
  68947. /**
  68948. * Adds a light to the spherical harmonics
  68949. * @param direction the direction of the light
  68950. * @param color the color of the light
  68951. * @param deltaSolidAngle the delta solid angle of the light
  68952. */
  68953. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  68954. /**
  68955. * Scales the spherical harmonics by the given amount
  68956. * @param scale the amount to scale
  68957. */
  68958. scaleInPlace(scale: number): void;
  68959. /**
  68960. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  68961. *
  68962. * ```
  68963. * E_lm = A_l * L_lm
  68964. * ```
  68965. *
  68966. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  68967. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68968. * the scaling factors are given in equation 9.
  68969. */
  68970. convertIncidentRadianceToIrradiance(): void;
  68971. /**
  68972. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68973. *
  68974. * ```
  68975. * L = (1/pi) * E * rho
  68976. * ```
  68977. *
  68978. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68979. */
  68980. convertIrradianceToLambertianRadiance(): void;
  68981. /**
  68982. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68983. * required operations at run time.
  68984. *
  68985. * This is simply done by scaling back the SH with Ylm constants parameter.
  68986. * The trigonometric part being applied by the shader at run time.
  68987. */
  68988. preScaleForRendering(): void;
  68989. /**
  68990. * Constructs a spherical harmonics from an array.
  68991. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68992. * @returns the spherical harmonics
  68993. */
  68994. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68995. /**
  68996. * Gets the spherical harmonics from polynomial
  68997. * @param polynomial the spherical polynomial
  68998. * @returns the spherical harmonics
  68999. */
  69000. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  69001. }
  69002. /**
  69003. * Class representing spherical polynomial coefficients to the 3rd degree
  69004. */
  69005. export class SphericalPolynomial {
  69006. private _harmonics;
  69007. /**
  69008. * The spherical harmonics used to create the polynomials.
  69009. */
  69010. readonly preScaledHarmonics: SphericalHarmonics;
  69011. /**
  69012. * The x coefficients of the spherical polynomial
  69013. */
  69014. x: Vector3;
  69015. /**
  69016. * The y coefficients of the spherical polynomial
  69017. */
  69018. y: Vector3;
  69019. /**
  69020. * The z coefficients of the spherical polynomial
  69021. */
  69022. z: Vector3;
  69023. /**
  69024. * The xx coefficients of the spherical polynomial
  69025. */
  69026. xx: Vector3;
  69027. /**
  69028. * The yy coefficients of the spherical polynomial
  69029. */
  69030. yy: Vector3;
  69031. /**
  69032. * The zz coefficients of the spherical polynomial
  69033. */
  69034. zz: Vector3;
  69035. /**
  69036. * The xy coefficients of the spherical polynomial
  69037. */
  69038. xy: Vector3;
  69039. /**
  69040. * The yz coefficients of the spherical polynomial
  69041. */
  69042. yz: Vector3;
  69043. /**
  69044. * The zx coefficients of the spherical polynomial
  69045. */
  69046. zx: Vector3;
  69047. /**
  69048. * Adds an ambient color to the spherical polynomial
  69049. * @param color the color to add
  69050. */
  69051. addAmbient(color: Color3): void;
  69052. /**
  69053. * Scales the spherical polynomial by the given amount
  69054. * @param scale the amount to scale
  69055. */
  69056. scaleInPlace(scale: number): void;
  69057. /**
  69058. * Gets the spherical polynomial from harmonics
  69059. * @param harmonics the spherical harmonics
  69060. * @returns the spherical polynomial
  69061. */
  69062. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  69063. /**
  69064. * Constructs a spherical polynomial from an array.
  69065. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  69066. * @returns the spherical polynomial
  69067. */
  69068. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  69069. }
  69070. }
  69071. declare module BABYLON {
  69072. /**
  69073. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  69074. */
  69075. export interface CubeMapInfo {
  69076. /**
  69077. * The pixel array for the front face.
  69078. * This is stored in format, left to right, up to down format.
  69079. */
  69080. front: Nullable<ArrayBufferView>;
  69081. /**
  69082. * The pixel array for the back face.
  69083. * This is stored in format, left to right, up to down format.
  69084. */
  69085. back: Nullable<ArrayBufferView>;
  69086. /**
  69087. * The pixel array for the left face.
  69088. * This is stored in format, left to right, up to down format.
  69089. */
  69090. left: Nullable<ArrayBufferView>;
  69091. /**
  69092. * The pixel array for the right face.
  69093. * This is stored in format, left to right, up to down format.
  69094. */
  69095. right: Nullable<ArrayBufferView>;
  69096. /**
  69097. * The pixel array for the up face.
  69098. * This is stored in format, left to right, up to down format.
  69099. */
  69100. up: Nullable<ArrayBufferView>;
  69101. /**
  69102. * The pixel array for the down face.
  69103. * This is stored in format, left to right, up to down format.
  69104. */
  69105. down: Nullable<ArrayBufferView>;
  69106. /**
  69107. * The size of the cubemap stored.
  69108. *
  69109. * Each faces will be size * size pixels.
  69110. */
  69111. size: number;
  69112. /**
  69113. * The format of the texture.
  69114. *
  69115. * RGBA, RGB.
  69116. */
  69117. format: number;
  69118. /**
  69119. * The type of the texture data.
  69120. *
  69121. * UNSIGNED_INT, FLOAT.
  69122. */
  69123. type: number;
  69124. /**
  69125. * Specifies whether the texture is in gamma space.
  69126. */
  69127. gammaSpace: boolean;
  69128. }
  69129. /**
  69130. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  69131. */
  69132. export class PanoramaToCubeMapTools {
  69133. private static FACE_FRONT;
  69134. private static FACE_BACK;
  69135. private static FACE_RIGHT;
  69136. private static FACE_LEFT;
  69137. private static FACE_DOWN;
  69138. private static FACE_UP;
  69139. /**
  69140. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  69141. *
  69142. * @param float32Array The source data.
  69143. * @param inputWidth The width of the input panorama.
  69144. * @param inputHeight The height of the input panorama.
  69145. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  69146. * @return The cubemap data
  69147. */
  69148. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  69149. private static CreateCubemapTexture;
  69150. private static CalcProjectionSpherical;
  69151. }
  69152. }
  69153. declare module BABYLON {
  69154. /**
  69155. * Helper class dealing with the extraction of spherical polynomial dataArray
  69156. * from a cube map.
  69157. */
  69158. export class CubeMapToSphericalPolynomialTools {
  69159. private static FileFaces;
  69160. /**
  69161. * Converts a texture to the according Spherical Polynomial data.
  69162. * This extracts the first 3 orders only as they are the only one used in the lighting.
  69163. *
  69164. * @param texture The texture to extract the information from.
  69165. * @return The Spherical Polynomial data.
  69166. */
  69167. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  69168. /**
  69169. * Converts a cubemap to the according Spherical Polynomial data.
  69170. * This extracts the first 3 orders only as they are the only one used in the lighting.
  69171. *
  69172. * @param cubeInfo The Cube map to extract the information from.
  69173. * @return The Spherical Polynomial data.
  69174. */
  69175. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  69176. }
  69177. }
  69178. declare module BABYLON {
  69179. /**
  69180. * The engine store class is responsible to hold all the instances of Engine and Scene created
  69181. * during the life time of the application.
  69182. */
  69183. export class EngineStore {
  69184. /** Gets the list of created engines */
  69185. static Instances: Engine[];
  69186. /** @hidden */
  69187. static _LastCreatedScene: Nullable<Scene>;
  69188. /**
  69189. * Gets the latest created engine
  69190. */
  69191. static readonly LastCreatedEngine: Nullable<Engine>;
  69192. /**
  69193. * Gets the latest created scene
  69194. */
  69195. static readonly LastCreatedScene: Nullable<Scene>;
  69196. }
  69197. }
  69198. declare module BABYLON {
  69199. /**
  69200. * Define options used to create a render target texture
  69201. */
  69202. export class RenderTargetCreationOptions {
  69203. /**
  69204. * Specifies is mipmaps must be generated
  69205. */
  69206. generateMipMaps?: boolean;
  69207. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69208. generateDepthBuffer?: boolean;
  69209. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69210. generateStencilBuffer?: boolean;
  69211. /** Defines texture type (int by default) */
  69212. type?: number;
  69213. /** Defines sampling mode (trilinear by default) */
  69214. samplingMode?: number;
  69215. /** Defines format (RGBA by default) */
  69216. format?: number;
  69217. }
  69218. }
  69219. declare module BABYLON {
  69220. /**
  69221. * @hidden
  69222. **/
  69223. export class _AlphaState {
  69224. private _isAlphaBlendDirty;
  69225. private _isBlendFunctionParametersDirty;
  69226. private _isBlendEquationParametersDirty;
  69227. private _isBlendConstantsDirty;
  69228. private _alphaBlend;
  69229. private _blendFunctionParameters;
  69230. private _blendEquationParameters;
  69231. private _blendConstants;
  69232. /**
  69233. * Initializes the state.
  69234. */
  69235. constructor();
  69236. readonly isDirty: boolean;
  69237. alphaBlend: boolean;
  69238. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  69239. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  69240. setAlphaEquationParameters(rgb: number, alpha: number): void;
  69241. reset(): void;
  69242. apply(gl: WebGLRenderingContext): void;
  69243. }
  69244. }
  69245. declare module BABYLON {
  69246. /**
  69247. * @hidden
  69248. **/
  69249. export class _DepthCullingState {
  69250. private _isDepthTestDirty;
  69251. private _isDepthMaskDirty;
  69252. private _isDepthFuncDirty;
  69253. private _isCullFaceDirty;
  69254. private _isCullDirty;
  69255. private _isZOffsetDirty;
  69256. private _isFrontFaceDirty;
  69257. private _depthTest;
  69258. private _depthMask;
  69259. private _depthFunc;
  69260. private _cull;
  69261. private _cullFace;
  69262. private _zOffset;
  69263. private _frontFace;
  69264. /**
  69265. * Initializes the state.
  69266. */
  69267. constructor();
  69268. readonly isDirty: boolean;
  69269. zOffset: number;
  69270. cullFace: Nullable<number>;
  69271. cull: Nullable<boolean>;
  69272. depthFunc: Nullable<number>;
  69273. depthMask: boolean;
  69274. depthTest: boolean;
  69275. frontFace: Nullable<number>;
  69276. reset(): void;
  69277. apply(gl: WebGLRenderingContext): void;
  69278. }
  69279. }
  69280. declare module BABYLON {
  69281. /**
  69282. * @hidden
  69283. **/
  69284. export class _StencilState {
  69285. /** 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 */
  69286. static readonly ALWAYS: number;
  69287. /** Passed to stencilOperation to specify that stencil value must be kept */
  69288. static readonly KEEP: number;
  69289. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69290. static readonly REPLACE: number;
  69291. private _isStencilTestDirty;
  69292. private _isStencilMaskDirty;
  69293. private _isStencilFuncDirty;
  69294. private _isStencilOpDirty;
  69295. private _stencilTest;
  69296. private _stencilMask;
  69297. private _stencilFunc;
  69298. private _stencilFuncRef;
  69299. private _stencilFuncMask;
  69300. private _stencilOpStencilFail;
  69301. private _stencilOpDepthFail;
  69302. private _stencilOpStencilDepthPass;
  69303. readonly isDirty: boolean;
  69304. stencilFunc: number;
  69305. stencilFuncRef: number;
  69306. stencilFuncMask: number;
  69307. stencilOpStencilFail: number;
  69308. stencilOpDepthFail: number;
  69309. stencilOpStencilDepthPass: number;
  69310. stencilMask: number;
  69311. stencilTest: boolean;
  69312. constructor();
  69313. reset(): void;
  69314. apply(gl: WebGLRenderingContext): void;
  69315. }
  69316. }
  69317. declare module BABYLON {
  69318. /**
  69319. * @hidden
  69320. **/
  69321. export class _TimeToken {
  69322. _startTimeQuery: Nullable<WebGLQuery>;
  69323. _endTimeQuery: Nullable<WebGLQuery>;
  69324. _timeElapsedQuery: Nullable<WebGLQuery>;
  69325. _timeElapsedQueryEnded: boolean;
  69326. }
  69327. }
  69328. declare module BABYLON {
  69329. /**
  69330. * Class used to store data associated with WebGL texture data for the engine
  69331. * This class should not be used directly
  69332. */
  69333. export class InternalTexture {
  69334. /** @hidden */
  69335. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  69336. /**
  69337. * The source of the texture data is unknown
  69338. */
  69339. static DATASOURCE_UNKNOWN: number;
  69340. /**
  69341. * Texture data comes from an URL
  69342. */
  69343. static DATASOURCE_URL: number;
  69344. /**
  69345. * Texture data is only used for temporary storage
  69346. */
  69347. static DATASOURCE_TEMP: number;
  69348. /**
  69349. * Texture data comes from raw data (ArrayBuffer)
  69350. */
  69351. static DATASOURCE_RAW: number;
  69352. /**
  69353. * Texture content is dynamic (video or dynamic texture)
  69354. */
  69355. static DATASOURCE_DYNAMIC: number;
  69356. /**
  69357. * Texture content is generated by rendering to it
  69358. */
  69359. static DATASOURCE_RENDERTARGET: number;
  69360. /**
  69361. * Texture content is part of a multi render target process
  69362. */
  69363. static DATASOURCE_MULTIRENDERTARGET: number;
  69364. /**
  69365. * Texture data comes from a cube data file
  69366. */
  69367. static DATASOURCE_CUBE: number;
  69368. /**
  69369. * Texture data comes from a raw cube data
  69370. */
  69371. static DATASOURCE_CUBERAW: number;
  69372. /**
  69373. * Texture data come from a prefiltered cube data file
  69374. */
  69375. static DATASOURCE_CUBEPREFILTERED: number;
  69376. /**
  69377. * Texture content is raw 3D data
  69378. */
  69379. static DATASOURCE_RAW3D: number;
  69380. /**
  69381. * Texture content is a depth texture
  69382. */
  69383. static DATASOURCE_DEPTHTEXTURE: number;
  69384. /**
  69385. * Texture data comes from a raw cube data encoded with RGBD
  69386. */
  69387. static DATASOURCE_CUBERAW_RGBD: number;
  69388. /**
  69389. * Defines if the texture is ready
  69390. */
  69391. isReady: boolean;
  69392. /**
  69393. * Defines if the texture is a cube texture
  69394. */
  69395. isCube: boolean;
  69396. /**
  69397. * Defines if the texture contains 3D data
  69398. */
  69399. is3D: boolean;
  69400. /**
  69401. * Defines if the texture contains multiview data
  69402. */
  69403. isMultiview: boolean;
  69404. /**
  69405. * Gets the URL used to load this texture
  69406. */
  69407. url: string;
  69408. /**
  69409. * Gets the sampling mode of the texture
  69410. */
  69411. samplingMode: number;
  69412. /**
  69413. * Gets a boolean indicating if the texture needs mipmaps generation
  69414. */
  69415. generateMipMaps: boolean;
  69416. /**
  69417. * Gets the number of samples used by the texture (WebGL2+ only)
  69418. */
  69419. samples: number;
  69420. /**
  69421. * Gets the type of the texture (int, float...)
  69422. */
  69423. type: number;
  69424. /**
  69425. * Gets the format of the texture (RGB, RGBA...)
  69426. */
  69427. format: number;
  69428. /**
  69429. * Observable called when the texture is loaded
  69430. */
  69431. onLoadedObservable: Observable<InternalTexture>;
  69432. /**
  69433. * Gets the width of the texture
  69434. */
  69435. width: number;
  69436. /**
  69437. * Gets the height of the texture
  69438. */
  69439. height: number;
  69440. /**
  69441. * Gets the depth of the texture
  69442. */
  69443. depth: number;
  69444. /**
  69445. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  69446. */
  69447. baseWidth: number;
  69448. /**
  69449. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  69450. */
  69451. baseHeight: number;
  69452. /**
  69453. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  69454. */
  69455. baseDepth: number;
  69456. /**
  69457. * Gets a boolean indicating if the texture is inverted on Y axis
  69458. */
  69459. invertY: boolean;
  69460. /** @hidden */
  69461. _invertVScale: boolean;
  69462. /** @hidden */
  69463. _associatedChannel: number;
  69464. /** @hidden */
  69465. _dataSource: number;
  69466. /** @hidden */
  69467. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  69468. /** @hidden */
  69469. _bufferView: Nullable<ArrayBufferView>;
  69470. /** @hidden */
  69471. _bufferViewArray: Nullable<ArrayBufferView[]>;
  69472. /** @hidden */
  69473. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  69474. /** @hidden */
  69475. _size: number;
  69476. /** @hidden */
  69477. _extension: string;
  69478. /** @hidden */
  69479. _files: Nullable<string[]>;
  69480. /** @hidden */
  69481. _workingCanvas: Nullable<HTMLCanvasElement>;
  69482. /** @hidden */
  69483. _workingContext: Nullable<CanvasRenderingContext2D>;
  69484. /** @hidden */
  69485. _framebuffer: Nullable<WebGLFramebuffer>;
  69486. /** @hidden */
  69487. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  69488. /** @hidden */
  69489. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  69490. /** @hidden */
  69491. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  69492. /** @hidden */
  69493. _attachments: Nullable<number[]>;
  69494. /** @hidden */
  69495. _cachedCoordinatesMode: Nullable<number>;
  69496. /** @hidden */
  69497. _cachedWrapU: Nullable<number>;
  69498. /** @hidden */
  69499. _cachedWrapV: Nullable<number>;
  69500. /** @hidden */
  69501. _cachedWrapR: Nullable<number>;
  69502. /** @hidden */
  69503. _cachedAnisotropicFilteringLevel: Nullable<number>;
  69504. /** @hidden */
  69505. _isDisabled: boolean;
  69506. /** @hidden */
  69507. _compression: Nullable<string>;
  69508. /** @hidden */
  69509. _generateStencilBuffer: boolean;
  69510. /** @hidden */
  69511. _generateDepthBuffer: boolean;
  69512. /** @hidden */
  69513. _comparisonFunction: number;
  69514. /** @hidden */
  69515. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  69516. /** @hidden */
  69517. _lodGenerationScale: number;
  69518. /** @hidden */
  69519. _lodGenerationOffset: number;
  69520. /** @hidden */
  69521. _colorTextureArray: Nullable<WebGLTexture>;
  69522. /** @hidden */
  69523. _depthStencilTextureArray: Nullable<WebGLTexture>;
  69524. /** @hidden */
  69525. _lodTextureHigh: Nullable<BaseTexture>;
  69526. /** @hidden */
  69527. _lodTextureMid: Nullable<BaseTexture>;
  69528. /** @hidden */
  69529. _lodTextureLow: Nullable<BaseTexture>;
  69530. /** @hidden */
  69531. _isRGBD: boolean;
  69532. /** @hidden */
  69533. _linearSpecularLOD: boolean;
  69534. /** @hidden */
  69535. _irradianceTexture: Nullable<BaseTexture>;
  69536. /** @hidden */
  69537. _webGLTexture: Nullable<WebGLTexture>;
  69538. /** @hidden */
  69539. _references: number;
  69540. private _engine;
  69541. /**
  69542. * Gets the Engine the texture belongs to.
  69543. * @returns The babylon engine
  69544. */
  69545. getEngine(): Engine;
  69546. /**
  69547. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  69548. */
  69549. readonly dataSource: number;
  69550. /**
  69551. * Creates a new InternalTexture
  69552. * @param engine defines the engine to use
  69553. * @param dataSource defines the type of data that will be used
  69554. * @param delayAllocation if the texture allocation should be delayed (default: false)
  69555. */
  69556. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  69557. /**
  69558. * Increments the number of references (ie. the number of Texture that point to it)
  69559. */
  69560. incrementReferences(): void;
  69561. /**
  69562. * Change the size of the texture (not the size of the content)
  69563. * @param width defines the new width
  69564. * @param height defines the new height
  69565. * @param depth defines the new depth (1 by default)
  69566. */
  69567. updateSize(width: int, height: int, depth?: int): void;
  69568. /** @hidden */
  69569. _rebuild(): void;
  69570. /** @hidden */
  69571. _swapAndDie(target: InternalTexture): void;
  69572. /**
  69573. * Dispose the current allocated resources
  69574. */
  69575. dispose(): void;
  69576. }
  69577. }
  69578. declare module BABYLON {
  69579. /**
  69580. * This represents the main contract an easing function should follow.
  69581. * Easing functions are used throughout the animation system.
  69582. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69583. */
  69584. export interface IEasingFunction {
  69585. /**
  69586. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69587. * of the easing function.
  69588. * The link below provides some of the most common examples of easing functions.
  69589. * @see https://easings.net/
  69590. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69591. * @returns the corresponding value on the curve defined by the easing function
  69592. */
  69593. ease(gradient: number): number;
  69594. }
  69595. /**
  69596. * Base class used for every default easing function.
  69597. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69598. */
  69599. export class EasingFunction implements IEasingFunction {
  69600. /**
  69601. * Interpolation follows the mathematical formula associated with the easing function.
  69602. */
  69603. static readonly EASINGMODE_EASEIN: number;
  69604. /**
  69605. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69606. */
  69607. static readonly EASINGMODE_EASEOUT: number;
  69608. /**
  69609. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69610. */
  69611. static readonly EASINGMODE_EASEINOUT: number;
  69612. private _easingMode;
  69613. /**
  69614. * Sets the easing mode of the current function.
  69615. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69616. */
  69617. setEasingMode(easingMode: number): void;
  69618. /**
  69619. * Gets the current easing mode.
  69620. * @returns the easing mode
  69621. */
  69622. getEasingMode(): number;
  69623. /**
  69624. * @hidden
  69625. */
  69626. easeInCore(gradient: number): number;
  69627. /**
  69628. * Given an input gradient between 0 and 1, this returns the corresponding value
  69629. * of the easing function.
  69630. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69631. * @returns the corresponding value on the curve defined by the easing function
  69632. */
  69633. ease(gradient: number): number;
  69634. }
  69635. /**
  69636. * Easing function with a circle shape (see link below).
  69637. * @see https://easings.net/#easeInCirc
  69638. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69639. */
  69640. export class CircleEase extends EasingFunction implements IEasingFunction {
  69641. /** @hidden */
  69642. easeInCore(gradient: number): number;
  69643. }
  69644. /**
  69645. * Easing function with a ease back shape (see link below).
  69646. * @see https://easings.net/#easeInBack
  69647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69648. */
  69649. export class BackEase extends EasingFunction implements IEasingFunction {
  69650. /** Defines the amplitude of the function */
  69651. amplitude: number;
  69652. /**
  69653. * Instantiates a back ease easing
  69654. * @see https://easings.net/#easeInBack
  69655. * @param amplitude Defines the amplitude of the function
  69656. */
  69657. constructor(
  69658. /** Defines the amplitude of the function */
  69659. amplitude?: number);
  69660. /** @hidden */
  69661. easeInCore(gradient: number): number;
  69662. }
  69663. /**
  69664. * Easing function with a bouncing shape (see link below).
  69665. * @see https://easings.net/#easeInBounce
  69666. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69667. */
  69668. export class BounceEase extends EasingFunction implements IEasingFunction {
  69669. /** Defines the number of bounces */
  69670. bounces: number;
  69671. /** Defines the amplitude of the bounce */
  69672. bounciness: number;
  69673. /**
  69674. * Instantiates a bounce easing
  69675. * @see https://easings.net/#easeInBounce
  69676. * @param bounces Defines the number of bounces
  69677. * @param bounciness Defines the amplitude of the bounce
  69678. */
  69679. constructor(
  69680. /** Defines the number of bounces */
  69681. bounces?: number,
  69682. /** Defines the amplitude of the bounce */
  69683. bounciness?: number);
  69684. /** @hidden */
  69685. easeInCore(gradient: number): number;
  69686. }
  69687. /**
  69688. * Easing function with a power of 3 shape (see link below).
  69689. * @see https://easings.net/#easeInCubic
  69690. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69691. */
  69692. export class CubicEase extends EasingFunction implements IEasingFunction {
  69693. /** @hidden */
  69694. easeInCore(gradient: number): number;
  69695. }
  69696. /**
  69697. * Easing function with an elastic shape (see link below).
  69698. * @see https://easings.net/#easeInElastic
  69699. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69700. */
  69701. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69702. /** Defines the number of oscillations*/
  69703. oscillations: number;
  69704. /** Defines the amplitude of the oscillations*/
  69705. springiness: number;
  69706. /**
  69707. * Instantiates an elastic easing function
  69708. * @see https://easings.net/#easeInElastic
  69709. * @param oscillations Defines the number of oscillations
  69710. * @param springiness Defines the amplitude of the oscillations
  69711. */
  69712. constructor(
  69713. /** Defines the number of oscillations*/
  69714. oscillations?: number,
  69715. /** Defines the amplitude of the oscillations*/
  69716. springiness?: number);
  69717. /** @hidden */
  69718. easeInCore(gradient: number): number;
  69719. }
  69720. /**
  69721. * Easing function with an exponential shape (see link below).
  69722. * @see https://easings.net/#easeInExpo
  69723. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69724. */
  69725. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69726. /** Defines the exponent of the function */
  69727. exponent: number;
  69728. /**
  69729. * Instantiates an exponential easing function
  69730. * @see https://easings.net/#easeInExpo
  69731. * @param exponent Defines the exponent of the function
  69732. */
  69733. constructor(
  69734. /** Defines the exponent of the function */
  69735. exponent?: number);
  69736. /** @hidden */
  69737. easeInCore(gradient: number): number;
  69738. }
  69739. /**
  69740. * Easing function with a power shape (see link below).
  69741. * @see https://easings.net/#easeInQuad
  69742. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69743. */
  69744. export class PowerEase extends EasingFunction implements IEasingFunction {
  69745. /** Defines the power of the function */
  69746. power: number;
  69747. /**
  69748. * Instantiates an power base easing function
  69749. * @see https://easings.net/#easeInQuad
  69750. * @param power Defines the power of the function
  69751. */
  69752. constructor(
  69753. /** Defines the power of the function */
  69754. power?: number);
  69755. /** @hidden */
  69756. easeInCore(gradient: number): number;
  69757. }
  69758. /**
  69759. * Easing function with a power of 2 shape (see link below).
  69760. * @see https://easings.net/#easeInQuad
  69761. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69762. */
  69763. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69764. /** @hidden */
  69765. easeInCore(gradient: number): number;
  69766. }
  69767. /**
  69768. * Easing function with a power of 4 shape (see link below).
  69769. * @see https://easings.net/#easeInQuart
  69770. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69771. */
  69772. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69773. /** @hidden */
  69774. easeInCore(gradient: number): number;
  69775. }
  69776. /**
  69777. * Easing function with a power of 5 shape (see link below).
  69778. * @see https://easings.net/#easeInQuint
  69779. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69780. */
  69781. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69782. /** @hidden */
  69783. easeInCore(gradient: number): number;
  69784. }
  69785. /**
  69786. * Easing function with a sin shape (see link below).
  69787. * @see https://easings.net/#easeInSine
  69788. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69789. */
  69790. export class SineEase extends EasingFunction implements IEasingFunction {
  69791. /** @hidden */
  69792. easeInCore(gradient: number): number;
  69793. }
  69794. /**
  69795. * Easing function with a bezier shape (see link below).
  69796. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69797. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69798. */
  69799. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69800. /** Defines the x component of the start tangent in the bezier curve */
  69801. x1: number;
  69802. /** Defines the y component of the start tangent in the bezier curve */
  69803. y1: number;
  69804. /** Defines the x component of the end tangent in the bezier curve */
  69805. x2: number;
  69806. /** Defines the y component of the end tangent in the bezier curve */
  69807. y2: number;
  69808. /**
  69809. * Instantiates a bezier function
  69810. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69811. * @param x1 Defines the x component of the start tangent in the bezier curve
  69812. * @param y1 Defines the y component of the start tangent in the bezier curve
  69813. * @param x2 Defines the x component of the end tangent in the bezier curve
  69814. * @param y2 Defines the y component of the end tangent in the bezier curve
  69815. */
  69816. constructor(
  69817. /** Defines the x component of the start tangent in the bezier curve */
  69818. x1?: number,
  69819. /** Defines the y component of the start tangent in the bezier curve */
  69820. y1?: number,
  69821. /** Defines the x component of the end tangent in the bezier curve */
  69822. x2?: number,
  69823. /** Defines the y component of the end tangent in the bezier curve */
  69824. y2?: number);
  69825. /** @hidden */
  69826. easeInCore(gradient: number): number;
  69827. }
  69828. }
  69829. declare module BABYLON {
  69830. /**
  69831. * Defines an interface which represents an animation key frame
  69832. */
  69833. export interface IAnimationKey {
  69834. /**
  69835. * Frame of the key frame
  69836. */
  69837. frame: number;
  69838. /**
  69839. * Value at the specifies key frame
  69840. */
  69841. value: any;
  69842. /**
  69843. * The input tangent for the cubic hermite spline
  69844. */
  69845. inTangent?: any;
  69846. /**
  69847. * The output tangent for the cubic hermite spline
  69848. */
  69849. outTangent?: any;
  69850. /**
  69851. * The animation interpolation type
  69852. */
  69853. interpolation?: AnimationKeyInterpolation;
  69854. }
  69855. /**
  69856. * Enum for the animation key frame interpolation type
  69857. */
  69858. export enum AnimationKeyInterpolation {
  69859. /**
  69860. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69861. */
  69862. STEP = 1
  69863. }
  69864. }
  69865. declare module BABYLON {
  69866. /**
  69867. * Represents the range of an animation
  69868. */
  69869. export class AnimationRange {
  69870. /**The name of the animation range**/
  69871. name: string;
  69872. /**The starting frame of the animation */
  69873. from: number;
  69874. /**The ending frame of the animation*/
  69875. to: number;
  69876. /**
  69877. * Initializes the range of an animation
  69878. * @param name The name of the animation range
  69879. * @param from The starting frame of the animation
  69880. * @param to The ending frame of the animation
  69881. */
  69882. constructor(
  69883. /**The name of the animation range**/
  69884. name: string,
  69885. /**The starting frame of the animation */
  69886. from: number,
  69887. /**The ending frame of the animation*/
  69888. to: number);
  69889. /**
  69890. * Makes a copy of the animation range
  69891. * @returns A copy of the animation range
  69892. */
  69893. clone(): AnimationRange;
  69894. }
  69895. }
  69896. declare module BABYLON {
  69897. /**
  69898. * Composed of a frame, and an action function
  69899. */
  69900. export class AnimationEvent {
  69901. /** The frame for which the event is triggered **/
  69902. frame: number;
  69903. /** The event to perform when triggered **/
  69904. action: (currentFrame: number) => void;
  69905. /** Specifies if the event should be triggered only once**/
  69906. onlyOnce?: boolean | undefined;
  69907. /**
  69908. * Specifies if the animation event is done
  69909. */
  69910. isDone: boolean;
  69911. /**
  69912. * Initializes the animation event
  69913. * @param frame The frame for which the event is triggered
  69914. * @param action The event to perform when triggered
  69915. * @param onlyOnce Specifies if the event should be triggered only once
  69916. */
  69917. constructor(
  69918. /** The frame for which the event is triggered **/
  69919. frame: number,
  69920. /** The event to perform when triggered **/
  69921. action: (currentFrame: number) => void,
  69922. /** Specifies if the event should be triggered only once**/
  69923. onlyOnce?: boolean | undefined);
  69924. /** @hidden */
  69925. _clone(): AnimationEvent;
  69926. }
  69927. }
  69928. declare module BABYLON {
  69929. /**
  69930. * Interface used to define a behavior
  69931. */
  69932. export interface Behavior<T> {
  69933. /** gets or sets behavior's name */
  69934. name: string;
  69935. /**
  69936. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69937. */
  69938. init(): void;
  69939. /**
  69940. * Called when the behavior is attached to a target
  69941. * @param target defines the target where the behavior is attached to
  69942. */
  69943. attach(target: T): void;
  69944. /**
  69945. * Called when the behavior is detached from its target
  69946. */
  69947. detach(): void;
  69948. }
  69949. /**
  69950. * Interface implemented by classes supporting behaviors
  69951. */
  69952. export interface IBehaviorAware<T> {
  69953. /**
  69954. * Attach a behavior
  69955. * @param behavior defines the behavior to attach
  69956. * @returns the current host
  69957. */
  69958. addBehavior(behavior: Behavior<T>): T;
  69959. /**
  69960. * Remove a behavior from the current object
  69961. * @param behavior defines the behavior to detach
  69962. * @returns the current host
  69963. */
  69964. removeBehavior(behavior: Behavior<T>): T;
  69965. /**
  69966. * Gets a behavior using its name to search
  69967. * @param name defines the name to search
  69968. * @returns the behavior or null if not found
  69969. */
  69970. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  69971. }
  69972. }
  69973. declare module BABYLON {
  69974. /**
  69975. * @hidden
  69976. */
  69977. export class IntersectionInfo {
  69978. bu: Nullable<number>;
  69979. bv: Nullable<number>;
  69980. distance: number;
  69981. faceId: number;
  69982. subMeshId: number;
  69983. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69984. }
  69985. }
  69986. declare module BABYLON {
  69987. /**
  69988. * Class used to store bounding sphere information
  69989. */
  69990. export class BoundingSphere {
  69991. /**
  69992. * Gets the center of the bounding sphere in local space
  69993. */
  69994. readonly center: Vector3;
  69995. /**
  69996. * Radius of the bounding sphere in local space
  69997. */
  69998. radius: number;
  69999. /**
  70000. * Gets the center of the bounding sphere in world space
  70001. */
  70002. readonly centerWorld: Vector3;
  70003. /**
  70004. * Radius of the bounding sphere in world space
  70005. */
  70006. radiusWorld: number;
  70007. /**
  70008. * Gets the minimum vector in local space
  70009. */
  70010. readonly minimum: Vector3;
  70011. /**
  70012. * Gets the maximum vector in local space
  70013. */
  70014. readonly maximum: Vector3;
  70015. private _worldMatrix;
  70016. private static readonly TmpVector3;
  70017. /**
  70018. * Creates a new bounding sphere
  70019. * @param min defines the minimum vector (in local space)
  70020. * @param max defines the maximum vector (in local space)
  70021. * @param worldMatrix defines the new world matrix
  70022. */
  70023. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70024. /**
  70025. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  70026. * @param min defines the new minimum vector (in local space)
  70027. * @param max defines the new maximum vector (in local space)
  70028. * @param worldMatrix defines the new world matrix
  70029. */
  70030. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70031. /**
  70032. * Scale the current bounding sphere by applying a scale factor
  70033. * @param factor defines the scale factor to apply
  70034. * @returns the current bounding box
  70035. */
  70036. scale(factor: number): BoundingSphere;
  70037. /**
  70038. * Gets the world matrix of the bounding box
  70039. * @returns a matrix
  70040. */
  70041. getWorldMatrix(): DeepImmutable<Matrix>;
  70042. /** @hidden */
  70043. _update(worldMatrix: DeepImmutable<Matrix>): void;
  70044. /**
  70045. * Tests if the bounding sphere is intersecting the frustum planes
  70046. * @param frustumPlanes defines the frustum planes to test
  70047. * @returns true if there is an intersection
  70048. */
  70049. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70050. /**
  70051. * Tests if the bounding sphere center is in between the frustum planes.
  70052. * Used for optimistic fast inclusion.
  70053. * @param frustumPlanes defines the frustum planes to test
  70054. * @returns true if the sphere center is in between the frustum planes
  70055. */
  70056. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70057. /**
  70058. * Tests if a point is inside the bounding sphere
  70059. * @param point defines the point to test
  70060. * @returns true if the point is inside the bounding sphere
  70061. */
  70062. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70063. /**
  70064. * Checks if two sphere intersct
  70065. * @param sphere0 sphere 0
  70066. * @param sphere1 sphere 1
  70067. * @returns true if the speres intersect
  70068. */
  70069. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  70070. }
  70071. }
  70072. declare module BABYLON {
  70073. /**
  70074. * Class used to store bounding box information
  70075. */
  70076. export class BoundingBox implements ICullable {
  70077. /**
  70078. * Gets the 8 vectors representing the bounding box in local space
  70079. */
  70080. readonly vectors: Vector3[];
  70081. /**
  70082. * Gets the center of the bounding box in local space
  70083. */
  70084. readonly center: Vector3;
  70085. /**
  70086. * Gets the center of the bounding box in world space
  70087. */
  70088. readonly centerWorld: Vector3;
  70089. /**
  70090. * Gets the extend size in local space
  70091. */
  70092. readonly extendSize: Vector3;
  70093. /**
  70094. * Gets the extend size in world space
  70095. */
  70096. readonly extendSizeWorld: Vector3;
  70097. /**
  70098. * Gets the OBB (object bounding box) directions
  70099. */
  70100. readonly directions: Vector3[];
  70101. /**
  70102. * Gets the 8 vectors representing the bounding box in world space
  70103. */
  70104. readonly vectorsWorld: Vector3[];
  70105. /**
  70106. * Gets the minimum vector in world space
  70107. */
  70108. readonly minimumWorld: Vector3;
  70109. /**
  70110. * Gets the maximum vector in world space
  70111. */
  70112. readonly maximumWorld: Vector3;
  70113. /**
  70114. * Gets the minimum vector in local space
  70115. */
  70116. readonly minimum: Vector3;
  70117. /**
  70118. * Gets the maximum vector in local space
  70119. */
  70120. readonly maximum: Vector3;
  70121. private _worldMatrix;
  70122. private static readonly TmpVector3;
  70123. /**
  70124. * @hidden
  70125. */
  70126. _tag: number;
  70127. /**
  70128. * Creates a new bounding box
  70129. * @param min defines the minimum vector (in local space)
  70130. * @param max defines the maximum vector (in local space)
  70131. * @param worldMatrix defines the new world matrix
  70132. */
  70133. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70134. /**
  70135. * Recreates the entire bounding box from scratch as if we call the constructor in place
  70136. * @param min defines the new minimum vector (in local space)
  70137. * @param max defines the new maximum vector (in local space)
  70138. * @param worldMatrix defines the new world matrix
  70139. */
  70140. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70141. /**
  70142. * Scale the current bounding box by applying a scale factor
  70143. * @param factor defines the scale factor to apply
  70144. * @returns the current bounding box
  70145. */
  70146. scale(factor: number): BoundingBox;
  70147. /**
  70148. * Gets the world matrix of the bounding box
  70149. * @returns a matrix
  70150. */
  70151. getWorldMatrix(): DeepImmutable<Matrix>;
  70152. /** @hidden */
  70153. _update(world: DeepImmutable<Matrix>): void;
  70154. /**
  70155. * Tests if the bounding box is intersecting the frustum planes
  70156. * @param frustumPlanes defines the frustum planes to test
  70157. * @returns true if there is an intersection
  70158. */
  70159. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70160. /**
  70161. * Tests if the bounding box is entirely inside the frustum planes
  70162. * @param frustumPlanes defines the frustum planes to test
  70163. * @returns true if there is an inclusion
  70164. */
  70165. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70166. /**
  70167. * Tests if a point is inside the bounding box
  70168. * @param point defines the point to test
  70169. * @returns true if the point is inside the bounding box
  70170. */
  70171. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70172. /**
  70173. * Tests if the bounding box intersects with a bounding sphere
  70174. * @param sphere defines the sphere to test
  70175. * @returns true if there is an intersection
  70176. */
  70177. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  70178. /**
  70179. * Tests if the bounding box intersects with a box defined by a min and max vectors
  70180. * @param min defines the min vector to use
  70181. * @param max defines the max vector to use
  70182. * @returns true if there is an intersection
  70183. */
  70184. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  70185. /**
  70186. * Tests if two bounding boxes are intersections
  70187. * @param box0 defines the first box to test
  70188. * @param box1 defines the second box to test
  70189. * @returns true if there is an intersection
  70190. */
  70191. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  70192. /**
  70193. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  70194. * @param minPoint defines the minimum vector of the bounding box
  70195. * @param maxPoint defines the maximum vector of the bounding box
  70196. * @param sphereCenter defines the sphere center
  70197. * @param sphereRadius defines the sphere radius
  70198. * @returns true if there is an intersection
  70199. */
  70200. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  70201. /**
  70202. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  70203. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70204. * @param frustumPlanes defines the frustum planes to test
  70205. * @return true if there is an inclusion
  70206. */
  70207. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70208. /**
  70209. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  70210. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70211. * @param frustumPlanes defines the frustum planes to test
  70212. * @return true if there is an intersection
  70213. */
  70214. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70215. }
  70216. }
  70217. declare module BABYLON {
  70218. /** @hidden */
  70219. export class Collider {
  70220. /** Define if a collision was found */
  70221. collisionFound: boolean;
  70222. /**
  70223. * Define last intersection point in local space
  70224. */
  70225. intersectionPoint: Vector3;
  70226. /**
  70227. * Define last collided mesh
  70228. */
  70229. collidedMesh: Nullable<AbstractMesh>;
  70230. private _collisionPoint;
  70231. private _planeIntersectionPoint;
  70232. private _tempVector;
  70233. private _tempVector2;
  70234. private _tempVector3;
  70235. private _tempVector4;
  70236. private _edge;
  70237. private _baseToVertex;
  70238. private _destinationPoint;
  70239. private _slidePlaneNormal;
  70240. private _displacementVector;
  70241. /** @hidden */
  70242. _radius: Vector3;
  70243. /** @hidden */
  70244. _retry: number;
  70245. private _velocity;
  70246. private _basePoint;
  70247. private _epsilon;
  70248. /** @hidden */
  70249. _velocityWorldLength: number;
  70250. /** @hidden */
  70251. _basePointWorld: Vector3;
  70252. private _velocityWorld;
  70253. private _normalizedVelocity;
  70254. /** @hidden */
  70255. _initialVelocity: Vector3;
  70256. /** @hidden */
  70257. _initialPosition: Vector3;
  70258. private _nearestDistance;
  70259. private _collisionMask;
  70260. collisionMask: number;
  70261. /**
  70262. * Gets the plane normal used to compute the sliding response (in local space)
  70263. */
  70264. readonly slidePlaneNormal: Vector3;
  70265. /** @hidden */
  70266. _initialize(source: Vector3, dir: Vector3, e: number): void;
  70267. /** @hidden */
  70268. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  70269. /** @hidden */
  70270. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  70271. /** @hidden */
  70272. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  70273. /** @hidden */
  70274. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  70275. /** @hidden */
  70276. _getResponse(pos: Vector3, vel: Vector3): void;
  70277. }
  70278. }
  70279. declare module BABYLON {
  70280. /**
  70281. * Interface for cullable objects
  70282. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  70283. */
  70284. export interface ICullable {
  70285. /**
  70286. * Checks if the object or part of the object is in the frustum
  70287. * @param frustumPlanes Camera near/planes
  70288. * @returns true if the object is in frustum otherwise false
  70289. */
  70290. isInFrustum(frustumPlanes: Plane[]): boolean;
  70291. /**
  70292. * Checks if a cullable object (mesh...) is in the camera frustum
  70293. * Unlike isInFrustum this cheks the full bounding box
  70294. * @param frustumPlanes Camera near/planes
  70295. * @returns true if the object is in frustum otherwise false
  70296. */
  70297. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  70298. }
  70299. /**
  70300. * Info for a bounding data of a mesh
  70301. */
  70302. export class BoundingInfo implements ICullable {
  70303. /**
  70304. * Bounding box for the mesh
  70305. */
  70306. readonly boundingBox: BoundingBox;
  70307. /**
  70308. * Bounding sphere for the mesh
  70309. */
  70310. readonly boundingSphere: BoundingSphere;
  70311. private _isLocked;
  70312. private static readonly TmpVector3;
  70313. /**
  70314. * Constructs bounding info
  70315. * @param minimum min vector of the bounding box/sphere
  70316. * @param maximum max vector of the bounding box/sphere
  70317. * @param worldMatrix defines the new world matrix
  70318. */
  70319. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70320. /**
  70321. * Recreates the entire bounding info from scratch as if we call the constructor in place
  70322. * @param min defines the new minimum vector (in local space)
  70323. * @param max defines the new maximum vector (in local space)
  70324. * @param worldMatrix defines the new world matrix
  70325. */
  70326. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70327. /**
  70328. * min vector of the bounding box/sphere
  70329. */
  70330. readonly minimum: Vector3;
  70331. /**
  70332. * max vector of the bounding box/sphere
  70333. */
  70334. readonly maximum: Vector3;
  70335. /**
  70336. * If the info is locked and won't be updated to avoid perf overhead
  70337. */
  70338. isLocked: boolean;
  70339. /**
  70340. * Updates the bounding sphere and box
  70341. * @param world world matrix to be used to update
  70342. */
  70343. update(world: DeepImmutable<Matrix>): void;
  70344. /**
  70345. * Recreate the bounding info to be centered around a specific point given a specific extend.
  70346. * @param center New center of the bounding info
  70347. * @param extend New extend of the bounding info
  70348. * @returns the current bounding info
  70349. */
  70350. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  70351. /**
  70352. * Scale the current bounding info by applying a scale factor
  70353. * @param factor defines the scale factor to apply
  70354. * @returns the current bounding info
  70355. */
  70356. scale(factor: number): BoundingInfo;
  70357. /**
  70358. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  70359. * @param frustumPlanes defines the frustum to test
  70360. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  70361. * @returns true if the bounding info is in the frustum planes
  70362. */
  70363. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  70364. /**
  70365. * Gets the world distance between the min and max points of the bounding box
  70366. */
  70367. readonly diagonalLength: number;
  70368. /**
  70369. * Checks if a cullable object (mesh...) is in the camera frustum
  70370. * Unlike isInFrustum this cheks the full bounding box
  70371. * @param frustumPlanes Camera near/planes
  70372. * @returns true if the object is in frustum otherwise false
  70373. */
  70374. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70375. /** @hidden */
  70376. _checkCollision(collider: Collider): boolean;
  70377. /**
  70378. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  70379. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70380. * @param point the point to check intersection with
  70381. * @returns if the point intersects
  70382. */
  70383. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70384. /**
  70385. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70386. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70387. * @param boundingInfo the bounding info to check intersection with
  70388. * @param precise if the intersection should be done using OBB
  70389. * @returns if the bounding info intersects
  70390. */
  70391. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70392. }
  70393. }
  70394. declare module BABYLON {
  70395. /**
  70396. * Defines an array and its length.
  70397. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70398. */
  70399. export interface ISmartArrayLike<T> {
  70400. /**
  70401. * The data of the array.
  70402. */
  70403. data: Array<T>;
  70404. /**
  70405. * The active length of the array.
  70406. */
  70407. length: number;
  70408. }
  70409. /**
  70410. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70411. */
  70412. export class SmartArray<T> implements ISmartArrayLike<T> {
  70413. /**
  70414. * The full set of data from the array.
  70415. */
  70416. data: Array<T>;
  70417. /**
  70418. * The active length of the array.
  70419. */
  70420. length: number;
  70421. protected _id: number;
  70422. /**
  70423. * Instantiates a Smart Array.
  70424. * @param capacity defines the default capacity of the array.
  70425. */
  70426. constructor(capacity: number);
  70427. /**
  70428. * Pushes a value at the end of the active data.
  70429. * @param value defines the object to push in the array.
  70430. */
  70431. push(value: T): void;
  70432. /**
  70433. * Iterates over the active data and apply the lambda to them.
  70434. * @param func defines the action to apply on each value.
  70435. */
  70436. forEach(func: (content: T) => void): void;
  70437. /**
  70438. * Sorts the full sets of data.
  70439. * @param compareFn defines the comparison function to apply.
  70440. */
  70441. sort(compareFn: (a: T, b: T) => number): void;
  70442. /**
  70443. * Resets the active data to an empty array.
  70444. */
  70445. reset(): void;
  70446. /**
  70447. * Releases all the data from the array as well as the array.
  70448. */
  70449. dispose(): void;
  70450. /**
  70451. * Concats the active data with a given array.
  70452. * @param array defines the data to concatenate with.
  70453. */
  70454. concat(array: any): void;
  70455. /**
  70456. * Returns the position of a value in the active data.
  70457. * @param value defines the value to find the index for
  70458. * @returns the index if found in the active data otherwise -1
  70459. */
  70460. indexOf(value: T): number;
  70461. /**
  70462. * Returns whether an element is part of the active data.
  70463. * @param value defines the value to look for
  70464. * @returns true if found in the active data otherwise false
  70465. */
  70466. contains(value: T): boolean;
  70467. private static _GlobalId;
  70468. }
  70469. /**
  70470. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70471. * The data in this array can only be present once
  70472. */
  70473. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70474. private _duplicateId;
  70475. /**
  70476. * Pushes a value at the end of the active data.
  70477. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70478. * @param value defines the object to push in the array.
  70479. */
  70480. push(value: T): void;
  70481. /**
  70482. * Pushes a value at the end of the active data.
  70483. * If the data is already present, it won t be added again
  70484. * @param value defines the object to push in the array.
  70485. * @returns true if added false if it was already present
  70486. */
  70487. pushNoDuplicate(value: T): boolean;
  70488. /**
  70489. * Resets the active data to an empty array.
  70490. */
  70491. reset(): void;
  70492. /**
  70493. * Concats the active data with a given array.
  70494. * This ensures no dupplicate will be present in the result.
  70495. * @param array defines the data to concatenate with.
  70496. */
  70497. concatWithNoDuplicate(array: any): void;
  70498. }
  70499. }
  70500. declare module BABYLON {
  70501. /**
  70502. * Enum that determines the text-wrapping mode to use.
  70503. */
  70504. export enum InspectableType {
  70505. /**
  70506. * Checkbox for booleans
  70507. */
  70508. Checkbox = 0,
  70509. /**
  70510. * Sliders for numbers
  70511. */
  70512. Slider = 1,
  70513. /**
  70514. * Vector3
  70515. */
  70516. Vector3 = 2,
  70517. /**
  70518. * Quaternions
  70519. */
  70520. Quaternion = 3,
  70521. /**
  70522. * Color3
  70523. */
  70524. Color3 = 4
  70525. }
  70526. /**
  70527. * Interface used to define custom inspectable properties.
  70528. * This interface is used by the inspector to display custom property grids
  70529. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70530. */
  70531. export interface IInspectable {
  70532. /**
  70533. * Gets the label to display
  70534. */
  70535. label: string;
  70536. /**
  70537. * Gets the name of the property to edit
  70538. */
  70539. propertyName: string;
  70540. /**
  70541. * Gets the type of the editor to use
  70542. */
  70543. type: InspectableType;
  70544. /**
  70545. * Gets the minimum value of the property when using in "slider" mode
  70546. */
  70547. min?: number;
  70548. /**
  70549. * Gets the maximum value of the property when using in "slider" mode
  70550. */
  70551. max?: number;
  70552. /**
  70553. * Gets the setp to use when using in "slider" mode
  70554. */
  70555. step?: number;
  70556. }
  70557. }
  70558. declare module BABYLON {
  70559. /**
  70560. * This represents the required contract to create a new type of texture loader.
  70561. */
  70562. export interface IInternalTextureLoader {
  70563. /**
  70564. * Defines wether the loader supports cascade loading the different faces.
  70565. */
  70566. supportCascades: boolean;
  70567. /**
  70568. * This returns if the loader support the current file information.
  70569. * @param extension defines the file extension of the file being loaded
  70570. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70571. * @param fallback defines the fallback internal texture if any
  70572. * @param isBase64 defines whether the texture is encoded as a base64
  70573. * @param isBuffer defines whether the texture data are stored as a buffer
  70574. * @returns true if the loader can load the specified file
  70575. */
  70576. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70577. /**
  70578. * Transform the url before loading if required.
  70579. * @param rootUrl the url of the texture
  70580. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70581. * @returns the transformed texture
  70582. */
  70583. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70584. /**
  70585. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70586. * @param rootUrl the url of the texture
  70587. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70588. * @returns the fallback texture
  70589. */
  70590. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70591. /**
  70592. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70593. * @param data contains the texture data
  70594. * @param texture defines the BabylonJS internal texture
  70595. * @param createPolynomials will be true if polynomials have been requested
  70596. * @param onLoad defines the callback to trigger once the texture is ready
  70597. * @param onError defines the callback to trigger in case of error
  70598. */
  70599. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70600. /**
  70601. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70602. * @param data contains the texture data
  70603. * @param texture defines the BabylonJS internal texture
  70604. * @param callback defines the method to call once ready to upload
  70605. */
  70606. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70607. }
  70608. }
  70609. declare module BABYLON {
  70610. interface Engine {
  70611. /**
  70612. * Creates a depth stencil cube texture.
  70613. * This is only available in WebGL 2.
  70614. * @param size The size of face edge in the cube texture.
  70615. * @param options The options defining the cube texture.
  70616. * @returns The cube texture
  70617. */
  70618. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70619. /**
  70620. * Creates a cube texture
  70621. * @param rootUrl defines the url where the files to load is located
  70622. * @param scene defines the current scene
  70623. * @param files defines the list of files to load (1 per face)
  70624. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70625. * @param onLoad defines an optional callback raised when the texture is loaded
  70626. * @param onError defines an optional callback raised if there is an issue to load the texture
  70627. * @param format defines the format of the data
  70628. * @param forcedExtension defines the extension to use to pick the right loader
  70629. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70630. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70631. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70632. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70633. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70634. * @returns the cube texture as an InternalTexture
  70635. */
  70636. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  70637. /**
  70638. * Creates a cube texture
  70639. * @param rootUrl defines the url where the files to load is located
  70640. * @param scene defines the current scene
  70641. * @param files defines the list of files to load (1 per face)
  70642. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70643. * @param onLoad defines an optional callback raised when the texture is loaded
  70644. * @param onError defines an optional callback raised if there is an issue to load the texture
  70645. * @param format defines the format of the data
  70646. * @param forcedExtension defines the extension to use to pick the right loader
  70647. * @returns the cube texture as an InternalTexture
  70648. */
  70649. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  70650. /**
  70651. * Creates a cube texture
  70652. * @param rootUrl defines the url where the files to load is located
  70653. * @param scene defines the current scene
  70654. * @param files defines the list of files to load (1 per face)
  70655. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70656. * @param onLoad defines an optional callback raised when the texture is loaded
  70657. * @param onError defines an optional callback raised if there is an issue to load the texture
  70658. * @param format defines the format of the data
  70659. * @param forcedExtension defines the extension to use to pick the right loader
  70660. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70661. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70662. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70663. * @returns the cube texture as an InternalTexture
  70664. */
  70665. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  70666. /** @hidden */
  70667. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70668. /** @hidden */
  70669. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70670. /** @hidden */
  70671. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70672. /** @hidden */
  70673. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70674. }
  70675. }
  70676. declare module BABYLON {
  70677. /**
  70678. * Class for creating a cube texture
  70679. */
  70680. export class CubeTexture extends BaseTexture {
  70681. private _delayedOnLoad;
  70682. /**
  70683. * The url of the texture
  70684. */
  70685. url: string;
  70686. /**
  70687. * Gets or sets the center of the bounding box associated with the cube texture.
  70688. * It must define where the camera used to render the texture was set
  70689. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70690. */
  70691. boundingBoxPosition: Vector3;
  70692. private _boundingBoxSize;
  70693. /**
  70694. * Gets or sets the size of the bounding box associated with the cube texture
  70695. * When defined, the cubemap will switch to local mode
  70696. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70697. * @example https://www.babylonjs-playground.com/#RNASML
  70698. */
  70699. /**
  70700. * Returns the bounding box size
  70701. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70702. */
  70703. boundingBoxSize: Vector3;
  70704. protected _rotationY: number;
  70705. /**
  70706. * Sets texture matrix rotation angle around Y axis in radians.
  70707. */
  70708. /**
  70709. * Gets texture matrix rotation angle around Y axis radians.
  70710. */
  70711. rotationY: number;
  70712. /**
  70713. * Are mip maps generated for this texture or not.
  70714. */
  70715. readonly noMipmap: boolean;
  70716. private _noMipmap;
  70717. private _files;
  70718. private _extensions;
  70719. private _textureMatrix;
  70720. private _format;
  70721. private _createPolynomials;
  70722. /** @hidden */
  70723. _prefiltered: boolean;
  70724. /**
  70725. * Creates a cube texture from an array of image urls
  70726. * @param files defines an array of image urls
  70727. * @param scene defines the hosting scene
  70728. * @param noMipmap specifies if mip maps are not used
  70729. * @returns a cube texture
  70730. */
  70731. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70732. /**
  70733. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70734. * @param url defines the url of the prefiltered texture
  70735. * @param scene defines the scene the texture is attached to
  70736. * @param forcedExtension defines the extension of the file if different from the url
  70737. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70738. * @return the prefiltered texture
  70739. */
  70740. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70741. /**
  70742. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70743. * as prefiltered data.
  70744. * @param rootUrl defines the url of the texture or the root name of the six images
  70745. * @param scene defines the scene the texture is attached to
  70746. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70747. * @param noMipmap defines if mipmaps should be created or not
  70748. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70749. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70750. * @param onError defines a callback triggered in case of error during load
  70751. * @param format defines the internal format to use for the texture once loaded
  70752. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70753. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70754. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70755. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70756. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70757. * @return the cube texture
  70758. */
  70759. 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);
  70760. /**
  70761. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70762. */
  70763. readonly isPrefiltered: boolean;
  70764. /**
  70765. * Get the current class name of the texture useful for serialization or dynamic coding.
  70766. * @returns "CubeTexture"
  70767. */
  70768. getClassName(): string;
  70769. /**
  70770. * Update the url (and optional buffer) of this texture if url was null during construction.
  70771. * @param url the url of the texture
  70772. * @param forcedExtension defines the extension to use
  70773. * @param onLoad callback called when the texture is loaded (defaults to null)
  70774. */
  70775. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70776. /**
  70777. * Delays loading of the cube texture
  70778. * @param forcedExtension defines the extension to use
  70779. */
  70780. delayLoad(forcedExtension?: string): void;
  70781. /**
  70782. * Returns the reflection texture matrix
  70783. * @returns the reflection texture matrix
  70784. */
  70785. getReflectionTextureMatrix(): Matrix;
  70786. /**
  70787. * Sets the reflection texture matrix
  70788. * @param value Reflection texture matrix
  70789. */
  70790. setReflectionTextureMatrix(value: Matrix): void;
  70791. /**
  70792. * Parses text to create a cube texture
  70793. * @param parsedTexture define the serialized text to read from
  70794. * @param scene defines the hosting scene
  70795. * @param rootUrl defines the root url of the cube texture
  70796. * @returns a cube texture
  70797. */
  70798. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70799. /**
  70800. * Makes a clone, or deep copy, of the cube texture
  70801. * @returns a new cube texture
  70802. */
  70803. clone(): CubeTexture;
  70804. }
  70805. }
  70806. declare module BABYLON {
  70807. /** @hidden */
  70808. export var postprocessVertexShader: {
  70809. name: string;
  70810. shader: string;
  70811. };
  70812. }
  70813. declare module BABYLON {
  70814. /**
  70815. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  70816. * This is the base of the follow, arc rotate cameras and Free camera
  70817. * @see http://doc.babylonjs.com/features/cameras
  70818. */
  70819. export class TargetCamera extends Camera {
  70820. private static _RigCamTransformMatrix;
  70821. private static _TargetTransformMatrix;
  70822. private static _TargetFocalPoint;
  70823. /**
  70824. * Define the current direction the camera is moving to
  70825. */
  70826. cameraDirection: Vector3;
  70827. /**
  70828. * Define the current rotation the camera is rotating to
  70829. */
  70830. cameraRotation: Vector2;
  70831. /**
  70832. * When set, the up vector of the camera will be updated by the rotation of the camera
  70833. */
  70834. updateUpVectorFromRotation: boolean;
  70835. private _tmpQuaternion;
  70836. /**
  70837. * Define the current rotation of the camera
  70838. */
  70839. rotation: Vector3;
  70840. /**
  70841. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  70842. */
  70843. rotationQuaternion: Quaternion;
  70844. /**
  70845. * Define the current speed of the camera
  70846. */
  70847. speed: number;
  70848. /**
  70849. * Add cconstraint to the camera to prevent it to move freely in all directions and
  70850. * around all axis.
  70851. */
  70852. noRotationConstraint: boolean;
  70853. /**
  70854. * Define the current target of the camera as an object or a position.
  70855. */
  70856. lockedTarget: any;
  70857. /** @hidden */
  70858. _currentTarget: Vector3;
  70859. /** @hidden */
  70860. _initialFocalDistance: number;
  70861. /** @hidden */
  70862. _viewMatrix: Matrix;
  70863. /** @hidden */
  70864. _camMatrix: Matrix;
  70865. /** @hidden */
  70866. _cameraTransformMatrix: Matrix;
  70867. /** @hidden */
  70868. _cameraRotationMatrix: Matrix;
  70869. /** @hidden */
  70870. _referencePoint: Vector3;
  70871. /** @hidden */
  70872. _transformedReferencePoint: Vector3;
  70873. protected _globalCurrentTarget: Vector3;
  70874. protected _globalCurrentUpVector: Vector3;
  70875. /** @hidden */
  70876. _reset: () => void;
  70877. private _defaultUp;
  70878. /**
  70879. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  70880. * This is the base of the follow, arc rotate cameras and Free camera
  70881. * @see http://doc.babylonjs.com/features/cameras
  70882. * @param name Defines the name of the camera in the scene
  70883. * @param position Defines the start position of the camera in the scene
  70884. * @param scene Defines the scene the camera belongs to
  70885. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70886. */
  70887. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70888. /**
  70889. * Gets the position in front of the camera at a given distance.
  70890. * @param distance The distance from the camera we want the position to be
  70891. * @returns the position
  70892. */
  70893. getFrontPosition(distance: number): Vector3;
  70894. /** @hidden */
  70895. _getLockedTargetPosition(): Nullable<Vector3>;
  70896. private _storedPosition;
  70897. private _storedRotation;
  70898. private _storedRotationQuaternion;
  70899. /**
  70900. * Store current camera state of the camera (fov, position, rotation, etc..)
  70901. * @returns the camera
  70902. */
  70903. storeState(): Camera;
  70904. /**
  70905. * Restored camera state. You must call storeState() first
  70906. * @returns whether it was successful or not
  70907. * @hidden
  70908. */
  70909. _restoreStateValues(): boolean;
  70910. /** @hidden */
  70911. _initCache(): void;
  70912. /** @hidden */
  70913. _updateCache(ignoreParentClass?: boolean): void;
  70914. /** @hidden */
  70915. _isSynchronizedViewMatrix(): boolean;
  70916. /** @hidden */
  70917. _computeLocalCameraSpeed(): number;
  70918. /**
  70919. * Defines the target the camera should look at.
  70920. * This will automatically adapt alpha beta and radius to fit within the new target.
  70921. * @param target Defines the new target as a Vector or a mesh
  70922. */
  70923. setTarget(target: Vector3): void;
  70924. /**
  70925. * Return the current target position of the camera. This value is expressed in local space.
  70926. * @returns the target position
  70927. */
  70928. getTarget(): Vector3;
  70929. /** @hidden */
  70930. _decideIfNeedsToMove(): boolean;
  70931. /** @hidden */
  70932. _updatePosition(): void;
  70933. /** @hidden */
  70934. _checkInputs(): void;
  70935. protected _updateCameraRotationMatrix(): void;
  70936. /**
  70937. * 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)
  70938. * @returns the current camera
  70939. */
  70940. private _rotateUpVectorWithCameraRotationMatrix;
  70941. private _cachedRotationZ;
  70942. private _cachedQuaternionRotationZ;
  70943. /** @hidden */
  70944. _getViewMatrix(): Matrix;
  70945. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  70946. /**
  70947. * @hidden
  70948. */
  70949. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  70950. /**
  70951. * @hidden
  70952. */
  70953. _updateRigCameras(): void;
  70954. private _getRigCamPositionAndTarget;
  70955. /**
  70956. * Gets the current object class name.
  70957. * @return the class name
  70958. */
  70959. getClassName(): string;
  70960. }
  70961. }
  70962. declare module BABYLON {
  70963. /**
  70964. * @ignore
  70965. * This is a list of all the different input types that are available in the application.
  70966. * Fo instance: ArcRotateCameraGamepadInput...
  70967. */
  70968. export var CameraInputTypes: {};
  70969. /**
  70970. * This is the contract to implement in order to create a new input class.
  70971. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70972. */
  70973. export interface ICameraInput<TCamera extends Camera> {
  70974. /**
  70975. * Defines the camera the input is attached to.
  70976. */
  70977. camera: Nullable<TCamera>;
  70978. /**
  70979. * Gets the class name of the current intput.
  70980. * @returns the class name
  70981. */
  70982. getClassName(): string;
  70983. /**
  70984. * Get the friendly name associated with the input class.
  70985. * @returns the input friendly name
  70986. */
  70987. getSimpleName(): string;
  70988. /**
  70989. * Attach the input controls to a specific dom element to get the input from.
  70990. * @param element Defines the element the controls should be listened from
  70991. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70992. */
  70993. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70994. /**
  70995. * Detach the current controls from the specified dom element.
  70996. * @param element Defines the element to stop listening the inputs from
  70997. */
  70998. detachControl(element: Nullable<HTMLElement>): void;
  70999. /**
  71000. * Update the current camera state depending on the inputs that have been used this frame.
  71001. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71002. */
  71003. checkInputs?: () => void;
  71004. }
  71005. /**
  71006. * Represents a map of input types to input instance or input index to input instance.
  71007. */
  71008. export interface CameraInputsMap<TCamera extends Camera> {
  71009. /**
  71010. * Accessor to the input by input type.
  71011. */
  71012. [name: string]: ICameraInput<TCamera>;
  71013. /**
  71014. * Accessor to the input by input index.
  71015. */
  71016. [idx: number]: ICameraInput<TCamera>;
  71017. }
  71018. /**
  71019. * This represents the input manager used within a camera.
  71020. * It helps dealing with all the different kind of input attached to a camera.
  71021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71022. */
  71023. export class CameraInputsManager<TCamera extends Camera> {
  71024. /**
  71025. * Defines the list of inputs attahed to the camera.
  71026. */
  71027. attached: CameraInputsMap<TCamera>;
  71028. /**
  71029. * Defines the dom element the camera is collecting inputs from.
  71030. * This is null if the controls have not been attached.
  71031. */
  71032. attachedElement: Nullable<HTMLElement>;
  71033. /**
  71034. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71035. */
  71036. noPreventDefault: boolean;
  71037. /**
  71038. * Defined the camera the input manager belongs to.
  71039. */
  71040. camera: TCamera;
  71041. /**
  71042. * Update the current camera state depending on the inputs that have been used this frame.
  71043. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71044. */
  71045. checkInputs: () => void;
  71046. /**
  71047. * Instantiate a new Camera Input Manager.
  71048. * @param camera Defines the camera the input manager blongs to
  71049. */
  71050. constructor(camera: TCamera);
  71051. /**
  71052. * Add an input method to a camera
  71053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71054. * @param input camera input method
  71055. */
  71056. add(input: ICameraInput<TCamera>): void;
  71057. /**
  71058. * Remove a specific input method from a camera
  71059. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71060. * @param inputToRemove camera input method
  71061. */
  71062. remove(inputToRemove: ICameraInput<TCamera>): void;
  71063. /**
  71064. * Remove a specific input type from a camera
  71065. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71066. * @param inputType the type of the input to remove
  71067. */
  71068. removeByType(inputType: string): void;
  71069. private _addCheckInputs;
  71070. /**
  71071. * Attach the input controls to the currently attached dom element to listen the events from.
  71072. * @param input Defines the input to attach
  71073. */
  71074. attachInput(input: ICameraInput<TCamera>): void;
  71075. /**
  71076. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71077. * @param element Defines the dom element to collect the events from
  71078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71079. */
  71080. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71081. /**
  71082. * Detach the current manager inputs controls from a specific dom element.
  71083. * @param element Defines the dom element to collect the events from
  71084. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71085. */
  71086. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71087. /**
  71088. * Rebuild the dynamic inputCheck function from the current list of
  71089. * defined inputs in the manager.
  71090. */
  71091. rebuildInputCheck(): void;
  71092. /**
  71093. * Remove all attached input methods from a camera
  71094. */
  71095. clear(): void;
  71096. /**
  71097. * Serialize the current input manager attached to a camera.
  71098. * This ensures than once parsed,
  71099. * the input associated to the camera will be identical to the current ones
  71100. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71101. */
  71102. serialize(serializedCamera: any): void;
  71103. /**
  71104. * Parses an input manager serialized JSON to restore the previous list of inputs
  71105. * and states associated to a camera.
  71106. * @param parsedCamera Defines the JSON to parse
  71107. */
  71108. parse(parsedCamera: any): void;
  71109. }
  71110. }
  71111. declare module BABYLON {
  71112. /**
  71113. * Gather the list of keyboard event types as constants.
  71114. */
  71115. export class KeyboardEventTypes {
  71116. /**
  71117. * The keydown event is fired when a key becomes active (pressed).
  71118. */
  71119. static readonly KEYDOWN: number;
  71120. /**
  71121. * The keyup event is fired when a key has been released.
  71122. */
  71123. static readonly KEYUP: number;
  71124. }
  71125. /**
  71126. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71127. */
  71128. export class KeyboardInfo {
  71129. /**
  71130. * Defines the type of event (KeyboardEventTypes)
  71131. */
  71132. type: number;
  71133. /**
  71134. * Defines the related dom event
  71135. */
  71136. event: KeyboardEvent;
  71137. /**
  71138. * Instantiates a new keyboard info.
  71139. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71140. * @param type Defines the type of event (KeyboardEventTypes)
  71141. * @param event Defines the related dom event
  71142. */
  71143. constructor(
  71144. /**
  71145. * Defines the type of event (KeyboardEventTypes)
  71146. */
  71147. type: number,
  71148. /**
  71149. * Defines the related dom event
  71150. */
  71151. event: KeyboardEvent);
  71152. }
  71153. /**
  71154. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71155. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  71156. */
  71157. export class KeyboardInfoPre extends KeyboardInfo {
  71158. /**
  71159. * Defines the type of event (KeyboardEventTypes)
  71160. */
  71161. type: number;
  71162. /**
  71163. * Defines the related dom event
  71164. */
  71165. event: KeyboardEvent;
  71166. /**
  71167. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  71168. */
  71169. skipOnPointerObservable: boolean;
  71170. /**
  71171. * Instantiates a new keyboard pre info.
  71172. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71173. * @param type Defines the type of event (KeyboardEventTypes)
  71174. * @param event Defines the related dom event
  71175. */
  71176. constructor(
  71177. /**
  71178. * Defines the type of event (KeyboardEventTypes)
  71179. */
  71180. type: number,
  71181. /**
  71182. * Defines the related dom event
  71183. */
  71184. event: KeyboardEvent);
  71185. }
  71186. }
  71187. declare module BABYLON {
  71188. /**
  71189. * Manage the keyboard inputs to control the movement of a free camera.
  71190. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71191. */
  71192. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  71193. /**
  71194. * Defines the camera the input is attached to.
  71195. */
  71196. camera: FreeCamera;
  71197. /**
  71198. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71199. */
  71200. keysUp: number[];
  71201. /**
  71202. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71203. */
  71204. keysDown: number[];
  71205. /**
  71206. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71207. */
  71208. keysLeft: number[];
  71209. /**
  71210. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71211. */
  71212. keysRight: number[];
  71213. private _keys;
  71214. private _onCanvasBlurObserver;
  71215. private _onKeyboardObserver;
  71216. private _engine;
  71217. private _scene;
  71218. /**
  71219. * Attach the input controls to a specific dom element to get the input from.
  71220. * @param element Defines the element the controls should be listened from
  71221. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71222. */
  71223. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71224. /**
  71225. * Detach the current controls from the specified dom element.
  71226. * @param element Defines the element to stop listening the inputs from
  71227. */
  71228. detachControl(element: Nullable<HTMLElement>): void;
  71229. /**
  71230. * Update the current camera state depending on the inputs that have been used this frame.
  71231. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71232. */
  71233. checkInputs(): void;
  71234. /**
  71235. * Gets the class name of the current intput.
  71236. * @returns the class name
  71237. */
  71238. getClassName(): string;
  71239. /** @hidden */
  71240. _onLostFocus(): void;
  71241. /**
  71242. * Get the friendly name associated with the input class.
  71243. * @returns the input friendly name
  71244. */
  71245. getSimpleName(): string;
  71246. }
  71247. }
  71248. declare module BABYLON {
  71249. /**
  71250. * A multi-material is used to apply different materials to different parts of the same object without the need of
  71251. * separate meshes. This can be use to improve performances.
  71252. * @see http://doc.babylonjs.com/how_to/multi_materials
  71253. */
  71254. export class MultiMaterial extends Material {
  71255. private _subMaterials;
  71256. /**
  71257. * Gets or Sets the list of Materials used within the multi material.
  71258. * They need to be ordered according to the submeshes order in the associated mesh
  71259. */
  71260. subMaterials: Nullable<Material>[];
  71261. /**
  71262. * Function used to align with Node.getChildren()
  71263. * @returns the list of Materials used within the multi material
  71264. */
  71265. getChildren(): Nullable<Material>[];
  71266. /**
  71267. * Instantiates a new Multi Material
  71268. * A multi-material is used to apply different materials to different parts of the same object without the need of
  71269. * separate meshes. This can be use to improve performances.
  71270. * @see http://doc.babylonjs.com/how_to/multi_materials
  71271. * @param name Define the name in the scene
  71272. * @param scene Define the scene the material belongs to
  71273. */
  71274. constructor(name: string, scene: Scene);
  71275. private _hookArray;
  71276. /**
  71277. * Get one of the submaterial by its index in the submaterials array
  71278. * @param index The index to look the sub material at
  71279. * @returns The Material if the index has been defined
  71280. */
  71281. getSubMaterial(index: number): Nullable<Material>;
  71282. /**
  71283. * Get the list of active textures for the whole sub materials list.
  71284. * @returns All the textures that will be used during the rendering
  71285. */
  71286. getActiveTextures(): BaseTexture[];
  71287. /**
  71288. * Gets the current class name of the material e.g. "MultiMaterial"
  71289. * Mainly use in serialization.
  71290. * @returns the class name
  71291. */
  71292. getClassName(): string;
  71293. /**
  71294. * Checks if the material is ready to render the requested sub mesh
  71295. * @param mesh Define the mesh the submesh belongs to
  71296. * @param subMesh Define the sub mesh to look readyness for
  71297. * @param useInstances Define whether or not the material is used with instances
  71298. * @returns true if ready, otherwise false
  71299. */
  71300. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  71301. /**
  71302. * Clones the current material and its related sub materials
  71303. * @param name Define the name of the newly cloned material
  71304. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  71305. * @returns the cloned material
  71306. */
  71307. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  71308. /**
  71309. * Serializes the materials into a JSON representation.
  71310. * @returns the JSON representation
  71311. */
  71312. serialize(): any;
  71313. /**
  71314. * Dispose the material and release its associated resources
  71315. * @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)
  71316. * @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)
  71317. * @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)
  71318. */
  71319. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  71320. /**
  71321. * Creates a MultiMaterial from parsed MultiMaterial data.
  71322. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  71323. * @param scene defines the hosting scene
  71324. * @returns a new MultiMaterial
  71325. */
  71326. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  71327. }
  71328. }
  71329. declare module BABYLON {
  71330. /**
  71331. * Class used to represent data loading progression
  71332. */
  71333. export class SceneLoaderFlags {
  71334. private static _ForceFullSceneLoadingForIncremental;
  71335. private static _ShowLoadingScreen;
  71336. private static _CleanBoneMatrixWeights;
  71337. private static _loggingLevel;
  71338. /**
  71339. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  71340. */
  71341. static ForceFullSceneLoadingForIncremental: boolean;
  71342. /**
  71343. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  71344. */
  71345. static ShowLoadingScreen: boolean;
  71346. /**
  71347. * Defines the current logging level (while loading the scene)
  71348. * @ignorenaming
  71349. */
  71350. static loggingLevel: number;
  71351. /**
  71352. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  71353. */
  71354. static CleanBoneMatrixWeights: boolean;
  71355. }
  71356. }
  71357. declare module BABYLON {
  71358. /**
  71359. * 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.
  71360. * @see https://doc.babylonjs.com/how_to/transformnode
  71361. */
  71362. export class TransformNode extends Node {
  71363. /**
  71364. * Object will not rotate to face the camera
  71365. */
  71366. static BILLBOARDMODE_NONE: number;
  71367. /**
  71368. * Object will rotate to face the camera but only on the x axis
  71369. */
  71370. static BILLBOARDMODE_X: number;
  71371. /**
  71372. * Object will rotate to face the camera but only on the y axis
  71373. */
  71374. static BILLBOARDMODE_Y: number;
  71375. /**
  71376. * Object will rotate to face the camera but only on the z axis
  71377. */
  71378. static BILLBOARDMODE_Z: number;
  71379. /**
  71380. * Object will rotate to face the camera
  71381. */
  71382. static BILLBOARDMODE_ALL: number;
  71383. private _forward;
  71384. private _forwardInverted;
  71385. private _up;
  71386. private _right;
  71387. private _rightInverted;
  71388. private _position;
  71389. private _rotation;
  71390. private _rotationQuaternion;
  71391. protected _scaling: Vector3;
  71392. protected _isDirty: boolean;
  71393. private _transformToBoneReferal;
  71394. private _billboardMode;
  71395. /**
  71396. * Gets or sets the billboard mode. Default is 0.
  71397. *
  71398. * | Value | Type | Description |
  71399. * | --- | --- | --- |
  71400. * | 0 | BILLBOARDMODE_NONE | |
  71401. * | 1 | BILLBOARDMODE_X | |
  71402. * | 2 | BILLBOARDMODE_Y | |
  71403. * | 4 | BILLBOARDMODE_Z | |
  71404. * | 7 | BILLBOARDMODE_ALL | |
  71405. *
  71406. */
  71407. billboardMode: number;
  71408. private _preserveParentRotationForBillboard;
  71409. /**
  71410. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  71411. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  71412. */
  71413. preserveParentRotationForBillboard: boolean;
  71414. /**
  71415. * 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
  71416. */
  71417. scalingDeterminant: number;
  71418. private _infiniteDistance;
  71419. /**
  71420. * Gets or sets the distance of the object to max, often used by skybox
  71421. */
  71422. infiniteDistance: boolean;
  71423. /**
  71424. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  71425. * By default the system will update normals to compensate
  71426. */
  71427. ignoreNonUniformScaling: boolean;
  71428. /**
  71429. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  71430. */
  71431. reIntegrateRotationIntoRotationQuaternion: boolean;
  71432. /** @hidden */
  71433. _poseMatrix: Nullable<Matrix>;
  71434. /** @hidden */
  71435. _localMatrix: Matrix;
  71436. private _usePivotMatrix;
  71437. private _absolutePosition;
  71438. private _pivotMatrix;
  71439. private _pivotMatrixInverse;
  71440. protected _postMultiplyPivotMatrix: boolean;
  71441. protected _isWorldMatrixFrozen: boolean;
  71442. /** @hidden */
  71443. _indexInSceneTransformNodesArray: number;
  71444. /**
  71445. * An event triggered after the world matrix is updated
  71446. */
  71447. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  71448. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  71449. /**
  71450. * Gets a string identifying the name of the class
  71451. * @returns "TransformNode" string
  71452. */
  71453. getClassName(): string;
  71454. /**
  71455. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  71456. */
  71457. position: Vector3;
  71458. /**
  71459. * 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)).
  71460. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  71461. */
  71462. rotation: Vector3;
  71463. /**
  71464. * 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)).
  71465. */
  71466. scaling: Vector3;
  71467. /**
  71468. * 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).
  71469. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  71470. */
  71471. rotationQuaternion: Nullable<Quaternion>;
  71472. /**
  71473. * The forward direction of that transform in world space.
  71474. */
  71475. readonly forward: Vector3;
  71476. /**
  71477. * The up direction of that transform in world space.
  71478. */
  71479. readonly up: Vector3;
  71480. /**
  71481. * The right direction of that transform in world space.
  71482. */
  71483. readonly right: Vector3;
  71484. /**
  71485. * Copies the parameter passed Matrix into the mesh Pose matrix.
  71486. * @param matrix the matrix to copy the pose from
  71487. * @returns this TransformNode.
  71488. */
  71489. updatePoseMatrix(matrix: Matrix): TransformNode;
  71490. /**
  71491. * Returns the mesh Pose matrix.
  71492. * @returns the pose matrix
  71493. */
  71494. getPoseMatrix(): Matrix;
  71495. /** @hidden */
  71496. _isSynchronized(): boolean;
  71497. /** @hidden */
  71498. _initCache(): void;
  71499. /**
  71500. * Flag the transform node as dirty (Forcing it to update everything)
  71501. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  71502. * @returns this transform node
  71503. */
  71504. markAsDirty(property: string): TransformNode;
  71505. /**
  71506. * Returns the current mesh absolute position.
  71507. * Returns a Vector3.
  71508. */
  71509. readonly absolutePosition: Vector3;
  71510. /**
  71511. * Sets a new matrix to apply before all other transformation
  71512. * @param matrix defines the transform matrix
  71513. * @returns the current TransformNode
  71514. */
  71515. setPreTransformMatrix(matrix: Matrix): TransformNode;
  71516. /**
  71517. * Sets a new pivot matrix to the current node
  71518. * @param matrix defines the new pivot matrix to use
  71519. * @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
  71520. * @returns the current TransformNode
  71521. */
  71522. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  71523. /**
  71524. * Returns the mesh pivot matrix.
  71525. * Default : Identity.
  71526. * @returns the matrix
  71527. */
  71528. getPivotMatrix(): Matrix;
  71529. /**
  71530. * Prevents the World matrix to be computed any longer.
  71531. * @returns the TransformNode.
  71532. */
  71533. freezeWorldMatrix(): TransformNode;
  71534. /**
  71535. * Allows back the World matrix computation.
  71536. * @returns the TransformNode.
  71537. */
  71538. unfreezeWorldMatrix(): this;
  71539. /**
  71540. * True if the World matrix has been frozen.
  71541. */
  71542. readonly isWorldMatrixFrozen: boolean;
  71543. /**
  71544. * Retuns the mesh absolute position in the World.
  71545. * @returns a Vector3.
  71546. */
  71547. getAbsolutePosition(): Vector3;
  71548. /**
  71549. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  71550. * @param absolutePosition the absolute position to set
  71551. * @returns the TransformNode.
  71552. */
  71553. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  71554. /**
  71555. * Sets the mesh position in its local space.
  71556. * @param vector3 the position to set in localspace
  71557. * @returns the TransformNode.
  71558. */
  71559. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  71560. /**
  71561. * Returns the mesh position in the local space from the current World matrix values.
  71562. * @returns a new Vector3.
  71563. */
  71564. getPositionExpressedInLocalSpace(): Vector3;
  71565. /**
  71566. * Translates the mesh along the passed Vector3 in its local space.
  71567. * @param vector3 the distance to translate in localspace
  71568. * @returns the TransformNode.
  71569. */
  71570. locallyTranslate(vector3: Vector3): TransformNode;
  71571. private static _lookAtVectorCache;
  71572. /**
  71573. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  71574. * @param targetPoint the position (must be in same space as current mesh) to look at
  71575. * @param yawCor optional yaw (y-axis) correction in radians
  71576. * @param pitchCor optional pitch (x-axis) correction in radians
  71577. * @param rollCor optional roll (z-axis) correction in radians
  71578. * @param space the choosen space of the target
  71579. * @returns the TransformNode.
  71580. */
  71581. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  71582. /**
  71583. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71584. * This Vector3 is expressed in the World space.
  71585. * @param localAxis axis to rotate
  71586. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71587. */
  71588. getDirection(localAxis: Vector3): Vector3;
  71589. /**
  71590. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  71591. * localAxis is expressed in the mesh local space.
  71592. * result is computed in the Wordl space from the mesh World matrix.
  71593. * @param localAxis axis to rotate
  71594. * @param result the resulting transformnode
  71595. * @returns this TransformNode.
  71596. */
  71597. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  71598. /**
  71599. * Sets this transform node rotation to the given local axis.
  71600. * @param localAxis the axis in local space
  71601. * @param yawCor optional yaw (y-axis) correction in radians
  71602. * @param pitchCor optional pitch (x-axis) correction in radians
  71603. * @param rollCor optional roll (z-axis) correction in radians
  71604. * @returns this TransformNode
  71605. */
  71606. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  71607. /**
  71608. * Sets a new pivot point to the current node
  71609. * @param point defines the new pivot point to use
  71610. * @param space defines if the point is in world or local space (local by default)
  71611. * @returns the current TransformNode
  71612. */
  71613. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  71614. /**
  71615. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  71616. * @returns the pivot point
  71617. */
  71618. getPivotPoint(): Vector3;
  71619. /**
  71620. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  71621. * @param result the vector3 to store the result
  71622. * @returns this TransformNode.
  71623. */
  71624. getPivotPointToRef(result: Vector3): TransformNode;
  71625. /**
  71626. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  71627. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  71628. */
  71629. getAbsolutePivotPoint(): Vector3;
  71630. /**
  71631. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  71632. * @param result vector3 to store the result
  71633. * @returns this TransformNode.
  71634. */
  71635. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  71636. /**
  71637. * Defines the passed node as the parent of the current node.
  71638. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  71639. * @see https://doc.babylonjs.com/how_to/parenting
  71640. * @param node the node ot set as the parent
  71641. * @returns this TransformNode.
  71642. */
  71643. setParent(node: Nullable<Node>): TransformNode;
  71644. private _nonUniformScaling;
  71645. /**
  71646. * True if the scaling property of this object is non uniform eg. (1,2,1)
  71647. */
  71648. readonly nonUniformScaling: boolean;
  71649. /** @hidden */
  71650. _updateNonUniformScalingState(value: boolean): boolean;
  71651. /**
  71652. * Attach the current TransformNode to another TransformNode associated with a bone
  71653. * @param bone Bone affecting the TransformNode
  71654. * @param affectedTransformNode TransformNode associated with the bone
  71655. * @returns this object
  71656. */
  71657. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  71658. /**
  71659. * Detach the transform node if its associated with a bone
  71660. * @returns this object
  71661. */
  71662. detachFromBone(): TransformNode;
  71663. private static _rotationAxisCache;
  71664. /**
  71665. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  71666. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71667. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71668. * The passed axis is also normalized.
  71669. * @param axis the axis to rotate around
  71670. * @param amount the amount to rotate in radians
  71671. * @param space Space to rotate in (Default: local)
  71672. * @returns the TransformNode.
  71673. */
  71674. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  71675. /**
  71676. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  71677. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71678. * The passed axis is also normalized. .
  71679. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  71680. * @param point the point to rotate around
  71681. * @param axis the axis to rotate around
  71682. * @param amount the amount to rotate in radians
  71683. * @returns the TransformNode
  71684. */
  71685. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  71686. /**
  71687. * Translates the mesh along the axis vector for the passed distance in the given space.
  71688. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71689. * @param axis the axis to translate in
  71690. * @param distance the distance to translate
  71691. * @param space Space to rotate in (Default: local)
  71692. * @returns the TransformNode.
  71693. */
  71694. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  71695. /**
  71696. * Adds a rotation step to the mesh current rotation.
  71697. * x, y, z are Euler angles expressed in radians.
  71698. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  71699. * This means this rotation is made in the mesh local space only.
  71700. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  71701. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  71702. * ```javascript
  71703. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  71704. * ```
  71705. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  71706. * 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.
  71707. * @param x Rotation to add
  71708. * @param y Rotation to add
  71709. * @param z Rotation to add
  71710. * @returns the TransformNode.
  71711. */
  71712. addRotation(x: number, y: number, z: number): TransformNode;
  71713. /**
  71714. * @hidden
  71715. */
  71716. protected _getEffectiveParent(): Nullable<Node>;
  71717. /**
  71718. * Computes the world matrix of the node
  71719. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71720. * @returns the world matrix
  71721. */
  71722. computeWorldMatrix(force?: boolean): Matrix;
  71723. protected _afterComputeWorldMatrix(): void;
  71724. /**
  71725. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  71726. * @param func callback function to add
  71727. *
  71728. * @returns the TransformNode.
  71729. */
  71730. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71731. /**
  71732. * Removes a registered callback function.
  71733. * @param func callback function to remove
  71734. * @returns the TransformNode.
  71735. */
  71736. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71737. /**
  71738. * Gets the position of the current mesh in camera space
  71739. * @param camera defines the camera to use
  71740. * @returns a position
  71741. */
  71742. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  71743. /**
  71744. * Returns the distance from the mesh to the active camera
  71745. * @param camera defines the camera to use
  71746. * @returns the distance
  71747. */
  71748. getDistanceToCamera(camera?: Nullable<Camera>): number;
  71749. /**
  71750. * Clone the current transform node
  71751. * @param name Name of the new clone
  71752. * @param newParent New parent for the clone
  71753. * @param doNotCloneChildren Do not clone children hierarchy
  71754. * @returns the new transform node
  71755. */
  71756. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  71757. /**
  71758. * Serializes the objects information.
  71759. * @param currentSerializationObject defines the object to serialize in
  71760. * @returns the serialized object
  71761. */
  71762. serialize(currentSerializationObject?: any): any;
  71763. /**
  71764. * Returns a new TransformNode object parsed from the source provided.
  71765. * @param parsedTransformNode is the source.
  71766. * @param scene the scne the object belongs to
  71767. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  71768. * @returns a new TransformNode object parsed from the source provided.
  71769. */
  71770. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  71771. /**
  71772. * Get all child-transformNodes of this node
  71773. * @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
  71774. * @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
  71775. * @returns an array of TransformNode
  71776. */
  71777. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  71778. /**
  71779. * Releases resources associated with this transform node.
  71780. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  71781. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  71782. */
  71783. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  71784. /**
  71785. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  71786. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  71787. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  71788. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  71789. * @returns the current mesh
  71790. */
  71791. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  71792. }
  71793. }
  71794. declare module BABYLON {
  71795. /**
  71796. * Class used to override all child animations of a given target
  71797. */
  71798. export class AnimationPropertiesOverride {
  71799. /**
  71800. * Gets or sets a value indicating if animation blending must be used
  71801. */
  71802. enableBlending: boolean;
  71803. /**
  71804. * Gets or sets the blending speed to use when enableBlending is true
  71805. */
  71806. blendingSpeed: number;
  71807. /**
  71808. * Gets or sets the default loop mode to use
  71809. */
  71810. loopMode: number;
  71811. }
  71812. }
  71813. declare module BABYLON {
  71814. /**
  71815. * Class used to store bone information
  71816. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  71817. */
  71818. export class Bone extends Node {
  71819. /**
  71820. * defines the bone name
  71821. */
  71822. name: string;
  71823. private static _tmpVecs;
  71824. private static _tmpQuat;
  71825. private static _tmpMats;
  71826. /**
  71827. * Gets the list of child bones
  71828. */
  71829. children: Bone[];
  71830. /** Gets the animations associated with this bone */
  71831. animations: Animation[];
  71832. /**
  71833. * Gets or sets bone length
  71834. */
  71835. length: number;
  71836. /**
  71837. * @hidden Internal only
  71838. * Set this value to map this bone to a different index in the transform matrices
  71839. * Set this value to -1 to exclude the bone from the transform matrices
  71840. */
  71841. _index: Nullable<number>;
  71842. private _skeleton;
  71843. private _localMatrix;
  71844. private _restPose;
  71845. private _baseMatrix;
  71846. private _absoluteTransform;
  71847. private _invertedAbsoluteTransform;
  71848. private _parent;
  71849. private _scalingDeterminant;
  71850. private _worldTransform;
  71851. private _localScaling;
  71852. private _localRotation;
  71853. private _localPosition;
  71854. private _needToDecompose;
  71855. private _needToCompose;
  71856. /** @hidden */
  71857. _linkedTransformNode: Nullable<TransformNode>;
  71858. /** @hidden */
  71859. _waitingTransformNodeId: Nullable<string>;
  71860. /** @hidden */
  71861. /** @hidden */
  71862. _matrix: Matrix;
  71863. /**
  71864. * Create a new bone
  71865. * @param name defines the bone name
  71866. * @param skeleton defines the parent skeleton
  71867. * @param parentBone defines the parent (can be null if the bone is the root)
  71868. * @param localMatrix defines the local matrix
  71869. * @param restPose defines the rest pose matrix
  71870. * @param baseMatrix defines the base matrix
  71871. * @param index defines index of the bone in the hiearchy
  71872. */
  71873. constructor(
  71874. /**
  71875. * defines the bone name
  71876. */
  71877. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  71878. /**
  71879. * Gets the current object class name.
  71880. * @return the class name
  71881. */
  71882. getClassName(): string;
  71883. /**
  71884. * Gets the parent skeleton
  71885. * @returns a skeleton
  71886. */
  71887. getSkeleton(): Skeleton;
  71888. /**
  71889. * Gets parent bone
  71890. * @returns a bone or null if the bone is the root of the bone hierarchy
  71891. */
  71892. getParent(): Nullable<Bone>;
  71893. /**
  71894. * Returns an array containing the root bones
  71895. * @returns an array containing the root bones
  71896. */
  71897. getChildren(): Array<Bone>;
  71898. /**
  71899. * Sets the parent bone
  71900. * @param parent defines the parent (can be null if the bone is the root)
  71901. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71902. */
  71903. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  71904. /**
  71905. * Gets the local matrix
  71906. * @returns a matrix
  71907. */
  71908. getLocalMatrix(): Matrix;
  71909. /**
  71910. * Gets the base matrix (initial matrix which remains unchanged)
  71911. * @returns a matrix
  71912. */
  71913. getBaseMatrix(): Matrix;
  71914. /**
  71915. * Gets the rest pose matrix
  71916. * @returns a matrix
  71917. */
  71918. getRestPose(): Matrix;
  71919. /**
  71920. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  71921. */
  71922. getWorldMatrix(): Matrix;
  71923. /**
  71924. * Sets the local matrix to rest pose matrix
  71925. */
  71926. returnToRest(): void;
  71927. /**
  71928. * Gets the inverse of the absolute transform matrix.
  71929. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  71930. * @returns a matrix
  71931. */
  71932. getInvertedAbsoluteTransform(): Matrix;
  71933. /**
  71934. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  71935. * @returns a matrix
  71936. */
  71937. getAbsoluteTransform(): Matrix;
  71938. /**
  71939. * Links with the given transform node.
  71940. * The local matrix of this bone is copied from the transform node every frame.
  71941. * @param transformNode defines the transform node to link to
  71942. */
  71943. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  71944. /** Gets or sets current position (in local space) */
  71945. position: Vector3;
  71946. /** Gets or sets current rotation (in local space) */
  71947. rotation: Vector3;
  71948. /** Gets or sets current rotation quaternion (in local space) */
  71949. rotationQuaternion: Quaternion;
  71950. /** Gets or sets current scaling (in local space) */
  71951. scaling: Vector3;
  71952. /**
  71953. * Gets the animation properties override
  71954. */
  71955. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  71956. private _decompose;
  71957. private _compose;
  71958. /**
  71959. * Update the base and local matrices
  71960. * @param matrix defines the new base or local matrix
  71961. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71962. * @param updateLocalMatrix defines if the local matrix should be updated
  71963. */
  71964. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  71965. /** @hidden */
  71966. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  71967. /**
  71968. * Flag the bone as dirty (Forcing it to update everything)
  71969. */
  71970. markAsDirty(): void;
  71971. /** @hidden */
  71972. _markAsDirtyAndCompose(): void;
  71973. private _markAsDirtyAndDecompose;
  71974. /**
  71975. * Translate the bone in local or world space
  71976. * @param vec The amount to translate the bone
  71977. * @param space The space that the translation is in
  71978. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71979. */
  71980. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71981. /**
  71982. * Set the postion of the bone in local or world space
  71983. * @param position The position to set the bone
  71984. * @param space The space that the position is in
  71985. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71986. */
  71987. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71988. /**
  71989. * Set the absolute position of the bone (world space)
  71990. * @param position The position to set the bone
  71991. * @param mesh The mesh that this bone is attached to
  71992. */
  71993. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  71994. /**
  71995. * Scale the bone on the x, y and z axes (in local space)
  71996. * @param x The amount to scale the bone on the x axis
  71997. * @param y The amount to scale the bone on the y axis
  71998. * @param z The amount to scale the bone on the z axis
  71999. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  72000. */
  72001. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  72002. /**
  72003. * Set the bone scaling in local space
  72004. * @param scale defines the scaling vector
  72005. */
  72006. setScale(scale: Vector3): void;
  72007. /**
  72008. * Gets the current scaling in local space
  72009. * @returns the current scaling vector
  72010. */
  72011. getScale(): Vector3;
  72012. /**
  72013. * Gets the current scaling in local space and stores it in a target vector
  72014. * @param result defines the target vector
  72015. */
  72016. getScaleToRef(result: Vector3): void;
  72017. /**
  72018. * Set the yaw, pitch, and roll of the bone in local or world space
  72019. * @param yaw The rotation of the bone on the y axis
  72020. * @param pitch The rotation of the bone on the x axis
  72021. * @param roll The rotation of the bone on the z axis
  72022. * @param space The space that the axes of rotation are in
  72023. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72024. */
  72025. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  72026. /**
  72027. * Add a rotation to the bone on an axis in local or world space
  72028. * @param axis The axis to rotate the bone on
  72029. * @param amount The amount to rotate the bone
  72030. * @param space The space that the axis is in
  72031. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72032. */
  72033. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  72034. /**
  72035. * Set the rotation of the bone to a particular axis angle in local or world space
  72036. * @param axis The axis to rotate the bone on
  72037. * @param angle The angle that the bone should be rotated to
  72038. * @param space The space that the axis is in
  72039. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72040. */
  72041. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  72042. /**
  72043. * Set the euler rotation of the bone in local of world space
  72044. * @param rotation The euler rotation that the bone should be set to
  72045. * @param space The space that the rotation is in
  72046. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72047. */
  72048. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  72049. /**
  72050. * Set the quaternion rotation of the bone in local of world space
  72051. * @param quat The quaternion rotation that the bone should be set to
  72052. * @param space The space that the rotation is in
  72053. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72054. */
  72055. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  72056. /**
  72057. * Set the rotation matrix of the bone in local of world space
  72058. * @param rotMat The rotation matrix that the bone should be set to
  72059. * @param space The space that the rotation is in
  72060. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72061. */
  72062. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  72063. private _rotateWithMatrix;
  72064. private _getNegativeRotationToRef;
  72065. /**
  72066. * Get the position of the bone in local or world space
  72067. * @param space The space that the returned position is in
  72068. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72069. * @returns The position of the bone
  72070. */
  72071. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  72072. /**
  72073. * Copy the position of the bone to a vector3 in local or world space
  72074. * @param space The space that the returned position is in
  72075. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72076. * @param result The vector3 to copy the position to
  72077. */
  72078. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  72079. /**
  72080. * Get the absolute position of the bone (world space)
  72081. * @param mesh The mesh that this bone is attached to
  72082. * @returns The absolute position of the bone
  72083. */
  72084. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  72085. /**
  72086. * Copy the absolute position of the bone (world space) to the result param
  72087. * @param mesh The mesh that this bone is attached to
  72088. * @param result The vector3 to copy the absolute position to
  72089. */
  72090. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  72091. /**
  72092. * Compute the absolute transforms of this bone and its children
  72093. */
  72094. computeAbsoluteTransforms(): void;
  72095. /**
  72096. * Get the world direction from an axis that is in the local space of the bone
  72097. * @param localAxis The local direction that is used to compute the world direction
  72098. * @param mesh The mesh that this bone is attached to
  72099. * @returns The world direction
  72100. */
  72101. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72102. /**
  72103. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  72104. * @param localAxis The local direction that is used to compute the world direction
  72105. * @param mesh The mesh that this bone is attached to
  72106. * @param result The vector3 that the world direction will be copied to
  72107. */
  72108. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72109. /**
  72110. * Get the euler rotation of the bone in local or world space
  72111. * @param space The space that the rotation should be in
  72112. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72113. * @returns The euler rotation
  72114. */
  72115. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  72116. /**
  72117. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  72118. * @param space The space that the rotation should be in
  72119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72120. * @param result The vector3 that the rotation should be copied to
  72121. */
  72122. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72123. /**
  72124. * Get the quaternion rotation of the bone in either local or world space
  72125. * @param space The space that the rotation should be in
  72126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72127. * @returns The quaternion rotation
  72128. */
  72129. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  72130. /**
  72131. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  72132. * @param space The space that the rotation should be in
  72133. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72134. * @param result The quaternion that the rotation should be copied to
  72135. */
  72136. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  72137. /**
  72138. * Get the rotation matrix of the bone in local or world space
  72139. * @param space The space that the rotation should be in
  72140. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72141. * @returns The rotation matrix
  72142. */
  72143. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  72144. /**
  72145. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  72146. * @param space The space that the rotation should be in
  72147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72148. * @param result The quaternion that the rotation should be copied to
  72149. */
  72150. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  72151. /**
  72152. * Get the world position of a point that is in the local space of the bone
  72153. * @param position The local position
  72154. * @param mesh The mesh that this bone is attached to
  72155. * @returns The world position
  72156. */
  72157. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72158. /**
  72159. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  72160. * @param position The local position
  72161. * @param mesh The mesh that this bone is attached to
  72162. * @param result The vector3 that the world position should be copied to
  72163. */
  72164. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72165. /**
  72166. * Get the local position of a point that is in world space
  72167. * @param position The world position
  72168. * @param mesh The mesh that this bone is attached to
  72169. * @returns The local position
  72170. */
  72171. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72172. /**
  72173. * Get the local position of a point that is in world space and copy it to the result param
  72174. * @param position The world position
  72175. * @param mesh The mesh that this bone is attached to
  72176. * @param result The vector3 that the local position should be copied to
  72177. */
  72178. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72179. }
  72180. }
  72181. declare module BABYLON {
  72182. interface Engine {
  72183. /**
  72184. * Creates a raw texture
  72185. * @param data defines the data to store in the texture
  72186. * @param width defines the width of the texture
  72187. * @param height defines the height of the texture
  72188. * @param format defines the format of the data
  72189. * @param generateMipMaps defines if the engine should generate the mip levels
  72190. * @param invertY defines if data must be stored with Y axis inverted
  72191. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  72192. * @param compression defines the compression used (null by default)
  72193. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72194. * @returns the raw texture inside an InternalTexture
  72195. */
  72196. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  72197. /**
  72198. * Update a raw texture
  72199. * @param texture defines the texture to update
  72200. * @param data defines the data to store in the texture
  72201. * @param format defines the format of the data
  72202. * @param invertY defines if data must be stored with Y axis inverted
  72203. */
  72204. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  72205. /**
  72206. * Update a raw texture
  72207. * @param texture defines the texture to update
  72208. * @param data defines the data to store in the texture
  72209. * @param format defines the format of the data
  72210. * @param invertY defines if data must be stored with Y axis inverted
  72211. * @param compression defines the compression used (null by default)
  72212. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72213. */
  72214. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  72215. /**
  72216. * Creates a new raw cube texture
  72217. * @param data defines the array of data to use to create each face
  72218. * @param size defines the size of the textures
  72219. * @param format defines the format of the data
  72220. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72221. * @param generateMipMaps defines if the engine should generate the mip levels
  72222. * @param invertY defines if data must be stored with Y axis inverted
  72223. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72224. * @param compression defines the compression used (null by default)
  72225. * @returns the cube texture as an InternalTexture
  72226. */
  72227. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  72228. /**
  72229. * Update a raw cube texture
  72230. * @param texture defines the texture to udpdate
  72231. * @param data defines the data to store
  72232. * @param format defines the data format
  72233. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72234. * @param invertY defines if data must be stored with Y axis inverted
  72235. */
  72236. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  72237. /**
  72238. * Update a raw cube texture
  72239. * @param texture defines the texture to udpdate
  72240. * @param data defines the data to store
  72241. * @param format defines the data format
  72242. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72243. * @param invertY defines if data must be stored with Y axis inverted
  72244. * @param compression defines the compression used (null by default)
  72245. */
  72246. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  72247. /**
  72248. * Update a raw cube texture
  72249. * @param texture defines the texture to udpdate
  72250. * @param data defines the data to store
  72251. * @param format defines the data format
  72252. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72253. * @param invertY defines if data must be stored with Y axis inverted
  72254. * @param compression defines the compression used (null by default)
  72255. * @param level defines which level of the texture to update
  72256. */
  72257. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  72258. /**
  72259. * Creates a new raw cube texture from a specified url
  72260. * @param url defines the url where the data is located
  72261. * @param scene defines the current scene
  72262. * @param size defines the size of the textures
  72263. * @param format defines the format of the data
  72264. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72265. * @param noMipmap defines if the engine should avoid generating the mip levels
  72266. * @param callback defines a callback used to extract texture data from loaded data
  72267. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  72268. * @param onLoad defines a callback called when texture is loaded
  72269. * @param onError defines a callback called if there is an error
  72270. * @returns the cube texture as an InternalTexture
  72271. */
  72272. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  72273. /**
  72274. * Creates a new raw cube texture from a specified url
  72275. * @param url defines the url where the data is located
  72276. * @param scene defines the current scene
  72277. * @param size defines the size of the textures
  72278. * @param format defines the format of the data
  72279. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72280. * @param noMipmap defines if the engine should avoid generating the mip levels
  72281. * @param callback defines a callback used to extract texture data from loaded data
  72282. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  72283. * @param onLoad defines a callback called when texture is loaded
  72284. * @param onError defines a callback called if there is an error
  72285. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72286. * @param invertY defines if data must be stored with Y axis inverted
  72287. * @returns the cube texture as an InternalTexture
  72288. */
  72289. 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;
  72290. /**
  72291. * Creates a new raw 3D texture
  72292. * @param data defines the data used to create the texture
  72293. * @param width defines the width of the texture
  72294. * @param height defines the height of the texture
  72295. * @param depth defines the depth of the texture
  72296. * @param format defines the format of the texture
  72297. * @param generateMipMaps defines if the engine must generate mip levels
  72298. * @param invertY defines if data must be stored with Y axis inverted
  72299. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72300. * @param compression defines the compressed used (can be null)
  72301. * @param textureType defines the compressed used (can be null)
  72302. * @returns a new raw 3D texture (stored in an InternalTexture)
  72303. */
  72304. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  72305. /**
  72306. * Update a raw 3D texture
  72307. * @param texture defines the texture to update
  72308. * @param data defines the data to store
  72309. * @param format defines the data format
  72310. * @param invertY defines if data must be stored with Y axis inverted
  72311. */
  72312. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  72313. /**
  72314. * Update a raw 3D texture
  72315. * @param texture defines the texture to update
  72316. * @param data defines the data to store
  72317. * @param format defines the data format
  72318. * @param invertY defines if data must be stored with Y axis inverted
  72319. * @param compression defines the used compression (can be null)
  72320. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  72321. */
  72322. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  72323. }
  72324. }
  72325. declare module BABYLON {
  72326. /**
  72327. * Raw texture can help creating a texture directly from an array of data.
  72328. * This can be super useful if you either get the data from an uncompressed source or
  72329. * if you wish to create your texture pixel by pixel.
  72330. */
  72331. export class RawTexture extends Texture {
  72332. /**
  72333. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72334. */
  72335. format: number;
  72336. private _engine;
  72337. /**
  72338. * Instantiates a new RawTexture.
  72339. * Raw texture can help creating a texture directly from an array of data.
  72340. * This can be super useful if you either get the data from an uncompressed source or
  72341. * if you wish to create your texture pixel by pixel.
  72342. * @param data define the array of data to use to create the texture
  72343. * @param width define the width of the texture
  72344. * @param height define the height of the texture
  72345. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72346. * @param scene define the scene the texture belongs to
  72347. * @param generateMipMaps define whether mip maps should be generated or not
  72348. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72349. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72350. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72351. */
  72352. constructor(data: ArrayBufferView, width: number, height: number,
  72353. /**
  72354. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72355. */
  72356. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  72357. /**
  72358. * Updates the texture underlying data.
  72359. * @param data Define the new data of the texture
  72360. */
  72361. update(data: ArrayBufferView): void;
  72362. /**
  72363. * Creates a luminance texture from some data.
  72364. * @param data Define the texture data
  72365. * @param width Define the width of the texture
  72366. * @param height Define the height of the texture
  72367. * @param scene Define the scene the texture belongs to
  72368. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72369. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72370. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72371. * @returns the luminance texture
  72372. */
  72373. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72374. /**
  72375. * Creates a luminance alpha texture from some data.
  72376. * @param data Define the texture data
  72377. * @param width Define the width of the texture
  72378. * @param height Define the height of the texture
  72379. * @param scene Define the scene the texture belongs to
  72380. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72381. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72382. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72383. * @returns the luminance alpha texture
  72384. */
  72385. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72386. /**
  72387. * Creates an alpha texture from some data.
  72388. * @param data Define the texture data
  72389. * @param width Define the width of the texture
  72390. * @param height Define the height of the texture
  72391. * @param scene Define the scene the texture belongs to
  72392. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72393. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72394. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72395. * @returns the alpha texture
  72396. */
  72397. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72398. /**
  72399. * Creates a RGB texture from some data.
  72400. * @param data Define the texture data
  72401. * @param width Define the width of the texture
  72402. * @param height Define the height of the texture
  72403. * @param scene Define the scene the texture belongs to
  72404. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72405. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72406. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72407. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72408. * @returns the RGB alpha texture
  72409. */
  72410. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72411. /**
  72412. * Creates a RGBA texture from some data.
  72413. * @param data Define the texture data
  72414. * @param width Define the width of the texture
  72415. * @param height Define the height of the texture
  72416. * @param scene Define the scene the texture belongs to
  72417. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72418. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72419. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72420. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72421. * @returns the RGBA texture
  72422. */
  72423. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72424. /**
  72425. * Creates a R texture from some data.
  72426. * @param data Define the texture data
  72427. * @param width Define the width of the texture
  72428. * @param height Define the height of the texture
  72429. * @param scene Define the scene the texture belongs to
  72430. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72431. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72432. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72433. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72434. * @returns the R texture
  72435. */
  72436. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72437. }
  72438. }
  72439. declare module BABYLON {
  72440. /**
  72441. * Defines a runtime animation
  72442. */
  72443. export class RuntimeAnimation {
  72444. private _events;
  72445. /**
  72446. * The current frame of the runtime animation
  72447. */
  72448. private _currentFrame;
  72449. /**
  72450. * The animation used by the runtime animation
  72451. */
  72452. private _animation;
  72453. /**
  72454. * The target of the runtime animation
  72455. */
  72456. private _target;
  72457. /**
  72458. * The initiating animatable
  72459. */
  72460. private _host;
  72461. /**
  72462. * The original value of the runtime animation
  72463. */
  72464. private _originalValue;
  72465. /**
  72466. * The original blend value of the runtime animation
  72467. */
  72468. private _originalBlendValue;
  72469. /**
  72470. * The offsets cache of the runtime animation
  72471. */
  72472. private _offsetsCache;
  72473. /**
  72474. * The high limits cache of the runtime animation
  72475. */
  72476. private _highLimitsCache;
  72477. /**
  72478. * Specifies if the runtime animation has been stopped
  72479. */
  72480. private _stopped;
  72481. /**
  72482. * The blending factor of the runtime animation
  72483. */
  72484. private _blendingFactor;
  72485. /**
  72486. * The BabylonJS scene
  72487. */
  72488. private _scene;
  72489. /**
  72490. * The current value of the runtime animation
  72491. */
  72492. private _currentValue;
  72493. /** @hidden */
  72494. _animationState: _IAnimationState;
  72495. /**
  72496. * The active target of the runtime animation
  72497. */
  72498. private _activeTargets;
  72499. private _currentActiveTarget;
  72500. private _directTarget;
  72501. /**
  72502. * The target path of the runtime animation
  72503. */
  72504. private _targetPath;
  72505. /**
  72506. * The weight of the runtime animation
  72507. */
  72508. private _weight;
  72509. /**
  72510. * The ratio offset of the runtime animation
  72511. */
  72512. private _ratioOffset;
  72513. /**
  72514. * The previous delay of the runtime animation
  72515. */
  72516. private _previousDelay;
  72517. /**
  72518. * The previous ratio of the runtime animation
  72519. */
  72520. private _previousRatio;
  72521. private _enableBlending;
  72522. private _keys;
  72523. private _minFrame;
  72524. private _maxFrame;
  72525. private _minValue;
  72526. private _maxValue;
  72527. private _targetIsArray;
  72528. /**
  72529. * Gets the current frame of the runtime animation
  72530. */
  72531. readonly currentFrame: number;
  72532. /**
  72533. * Gets the weight of the runtime animation
  72534. */
  72535. readonly weight: number;
  72536. /**
  72537. * Gets the current value of the runtime animation
  72538. */
  72539. readonly currentValue: any;
  72540. /**
  72541. * Gets the target path of the runtime animation
  72542. */
  72543. readonly targetPath: string;
  72544. /**
  72545. * Gets the actual target of the runtime animation
  72546. */
  72547. readonly target: any;
  72548. /** @hidden */
  72549. _onLoop: () => void;
  72550. /**
  72551. * Create a new RuntimeAnimation object
  72552. * @param target defines the target of the animation
  72553. * @param animation defines the source animation object
  72554. * @param scene defines the hosting scene
  72555. * @param host defines the initiating Animatable
  72556. */
  72557. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  72558. private _preparePath;
  72559. /**
  72560. * Gets the animation from the runtime animation
  72561. */
  72562. readonly animation: Animation;
  72563. /**
  72564. * Resets the runtime animation to the beginning
  72565. * @param restoreOriginal defines whether to restore the target property to the original value
  72566. */
  72567. reset(restoreOriginal?: boolean): void;
  72568. /**
  72569. * Specifies if the runtime animation is stopped
  72570. * @returns Boolean specifying if the runtime animation is stopped
  72571. */
  72572. isStopped(): boolean;
  72573. /**
  72574. * Disposes of the runtime animation
  72575. */
  72576. dispose(): void;
  72577. /**
  72578. * Apply the interpolated value to the target
  72579. * @param currentValue defines the value computed by the animation
  72580. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  72581. */
  72582. setValue(currentValue: any, weight: number): void;
  72583. private _getOriginalValues;
  72584. private _setValue;
  72585. /**
  72586. * Gets the loop pmode of the runtime animation
  72587. * @returns Loop Mode
  72588. */
  72589. private _getCorrectLoopMode;
  72590. /**
  72591. * Move the current animation to a given frame
  72592. * @param frame defines the frame to move to
  72593. */
  72594. goToFrame(frame: number): void;
  72595. /**
  72596. * @hidden Internal use only
  72597. */
  72598. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  72599. /**
  72600. * Execute the current animation
  72601. * @param delay defines the delay to add to the current frame
  72602. * @param from defines the lower bound of the animation range
  72603. * @param to defines the upper bound of the animation range
  72604. * @param loop defines if the current animation must loop
  72605. * @param speedRatio defines the current speed ratio
  72606. * @param weight defines the weight of the animation (default is -1 so no weight)
  72607. * @param onLoop optional callback called when animation loops
  72608. * @returns a boolean indicating if the animation is running
  72609. */
  72610. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  72611. }
  72612. }
  72613. declare module BABYLON {
  72614. /**
  72615. * Class used to store an actual running animation
  72616. */
  72617. export class Animatable {
  72618. /** defines the target object */
  72619. target: any;
  72620. /** defines the starting frame number (default is 0) */
  72621. fromFrame: number;
  72622. /** defines the ending frame number (default is 100) */
  72623. toFrame: number;
  72624. /** defines if the animation must loop (default is false) */
  72625. loopAnimation: boolean;
  72626. /** defines a callback to call when animation ends if it is not looping */
  72627. onAnimationEnd?: (() => void) | null | undefined;
  72628. /** defines a callback to call when animation loops */
  72629. onAnimationLoop?: (() => void) | null | undefined;
  72630. private _localDelayOffset;
  72631. private _pausedDelay;
  72632. private _runtimeAnimations;
  72633. private _paused;
  72634. private _scene;
  72635. private _speedRatio;
  72636. private _weight;
  72637. private _syncRoot;
  72638. /**
  72639. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  72640. * This will only apply for non looping animation (default is true)
  72641. */
  72642. disposeOnEnd: boolean;
  72643. /**
  72644. * Gets a boolean indicating if the animation has started
  72645. */
  72646. animationStarted: boolean;
  72647. /**
  72648. * Observer raised when the animation ends
  72649. */
  72650. onAnimationEndObservable: Observable<Animatable>;
  72651. /**
  72652. * Observer raised when the animation loops
  72653. */
  72654. onAnimationLoopObservable: Observable<Animatable>;
  72655. /**
  72656. * Gets the root Animatable used to synchronize and normalize animations
  72657. */
  72658. readonly syncRoot: Nullable<Animatable>;
  72659. /**
  72660. * Gets the current frame of the first RuntimeAnimation
  72661. * Used to synchronize Animatables
  72662. */
  72663. readonly masterFrame: number;
  72664. /**
  72665. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  72666. */
  72667. weight: number;
  72668. /**
  72669. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  72670. */
  72671. speedRatio: number;
  72672. /**
  72673. * Creates a new Animatable
  72674. * @param scene defines the hosting scene
  72675. * @param target defines the target object
  72676. * @param fromFrame defines the starting frame number (default is 0)
  72677. * @param toFrame defines the ending frame number (default is 100)
  72678. * @param loopAnimation defines if the animation must loop (default is false)
  72679. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  72680. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  72681. * @param animations defines a group of animation to add to the new Animatable
  72682. * @param onAnimationLoop defines a callback to call when animation loops
  72683. */
  72684. constructor(scene: Scene,
  72685. /** defines the target object */
  72686. target: any,
  72687. /** defines the starting frame number (default is 0) */
  72688. fromFrame?: number,
  72689. /** defines the ending frame number (default is 100) */
  72690. toFrame?: number,
  72691. /** defines if the animation must loop (default is false) */
  72692. loopAnimation?: boolean, speedRatio?: number,
  72693. /** defines a callback to call when animation ends if it is not looping */
  72694. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  72695. /** defines a callback to call when animation loops */
  72696. onAnimationLoop?: (() => void) | null | undefined);
  72697. /**
  72698. * Synchronize and normalize current Animatable with a source Animatable
  72699. * This is useful when using animation weights and when animations are not of the same length
  72700. * @param root defines the root Animatable to synchronize with
  72701. * @returns the current Animatable
  72702. */
  72703. syncWith(root: Animatable): Animatable;
  72704. /**
  72705. * Gets the list of runtime animations
  72706. * @returns an array of RuntimeAnimation
  72707. */
  72708. getAnimations(): RuntimeAnimation[];
  72709. /**
  72710. * Adds more animations to the current animatable
  72711. * @param target defines the target of the animations
  72712. * @param animations defines the new animations to add
  72713. */
  72714. appendAnimations(target: any, animations: Animation[]): void;
  72715. /**
  72716. * Gets the source animation for a specific property
  72717. * @param property defines the propertyu to look for
  72718. * @returns null or the source animation for the given property
  72719. */
  72720. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  72721. /**
  72722. * Gets the runtime animation for a specific property
  72723. * @param property defines the propertyu to look for
  72724. * @returns null or the runtime animation for the given property
  72725. */
  72726. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  72727. /**
  72728. * Resets the animatable to its original state
  72729. */
  72730. reset(): void;
  72731. /**
  72732. * Allows the animatable to blend with current running animations
  72733. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72734. * @param blendingSpeed defines the blending speed to use
  72735. */
  72736. enableBlending(blendingSpeed: number): void;
  72737. /**
  72738. * Disable animation blending
  72739. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72740. */
  72741. disableBlending(): void;
  72742. /**
  72743. * Jump directly to a given frame
  72744. * @param frame defines the frame to jump to
  72745. */
  72746. goToFrame(frame: number): void;
  72747. /**
  72748. * Pause the animation
  72749. */
  72750. pause(): void;
  72751. /**
  72752. * Restart the animation
  72753. */
  72754. restart(): void;
  72755. private _raiseOnAnimationEnd;
  72756. /**
  72757. * Stop and delete the current animation
  72758. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  72759. * @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)
  72760. */
  72761. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  72762. /**
  72763. * Wait asynchronously for the animation to end
  72764. * @returns a promise which will be fullfilled when the animation ends
  72765. */
  72766. waitAsync(): Promise<Animatable>;
  72767. /** @hidden */
  72768. _animate(delay: number): boolean;
  72769. }
  72770. interface Scene {
  72771. /** @hidden */
  72772. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  72773. /** @hidden */
  72774. _processLateAnimationBindingsForMatrices(holder: {
  72775. totalWeight: number;
  72776. animations: RuntimeAnimation[];
  72777. originalValue: Matrix;
  72778. }): any;
  72779. /** @hidden */
  72780. _processLateAnimationBindingsForQuaternions(holder: {
  72781. totalWeight: number;
  72782. animations: RuntimeAnimation[];
  72783. originalValue: Quaternion;
  72784. }, refQuaternion: Quaternion): Quaternion;
  72785. /** @hidden */
  72786. _processLateAnimationBindings(): void;
  72787. /**
  72788. * Will start the animation sequence of a given target
  72789. * @param target defines the target
  72790. * @param from defines from which frame should animation start
  72791. * @param to defines until which frame should animation run.
  72792. * @param weight defines the weight to apply to the animation (1.0 by default)
  72793. * @param loop defines if the animation loops
  72794. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72795. * @param onAnimationEnd defines the function to be executed when the animation ends
  72796. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72797. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72798. * @param onAnimationLoop defines the callback to call when an animation loops
  72799. * @returns the animatable object created for this animation
  72800. */
  72801. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72802. /**
  72803. * Will start the animation sequence of a given target
  72804. * @param target defines the target
  72805. * @param from defines from which frame should animation start
  72806. * @param to defines until which frame should animation run.
  72807. * @param loop defines if the animation loops
  72808. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72809. * @param onAnimationEnd defines the function to be executed when the animation ends
  72810. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72811. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72812. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  72813. * @param onAnimationLoop defines the callback to call when an animation loops
  72814. * @returns the animatable object created for this animation
  72815. */
  72816. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72817. /**
  72818. * Will start the animation sequence of a given target and its hierarchy
  72819. * @param target defines the target
  72820. * @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.
  72821. * @param from defines from which frame should animation start
  72822. * @param to defines until which frame should animation run.
  72823. * @param loop defines if the animation loops
  72824. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72825. * @param onAnimationEnd defines the function to be executed when the animation ends
  72826. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72827. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72828. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72829. * @param onAnimationLoop defines the callback to call when an animation loops
  72830. * @returns the list of created animatables
  72831. */
  72832. 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[];
  72833. /**
  72834. * Begin a new animation on a given node
  72835. * @param target defines the target where the animation will take place
  72836. * @param animations defines the list of animations to start
  72837. * @param from defines the initial value
  72838. * @param to defines the final value
  72839. * @param loop defines if you want animation to loop (off by default)
  72840. * @param speedRatio defines the speed ratio to apply to all animations
  72841. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72842. * @param onAnimationLoop defines the callback to call when an animation loops
  72843. * @returns the list of created animatables
  72844. */
  72845. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  72846. /**
  72847. * Begin a new animation on a given node and its hierarchy
  72848. * @param target defines the root node where the animation will take place
  72849. * @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.
  72850. * @param animations defines the list of animations to start
  72851. * @param from defines the initial value
  72852. * @param to defines the final value
  72853. * @param loop defines if you want animation to loop (off by default)
  72854. * @param speedRatio defines the speed ratio to apply to all animations
  72855. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72856. * @param onAnimationLoop defines the callback to call when an animation loops
  72857. * @returns the list of animatables created for all nodes
  72858. */
  72859. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  72860. /**
  72861. * Gets the animatable associated with a specific target
  72862. * @param target defines the target of the animatable
  72863. * @returns the required animatable if found
  72864. */
  72865. getAnimatableByTarget(target: any): Nullable<Animatable>;
  72866. /**
  72867. * Gets all animatables associated with a given target
  72868. * @param target defines the target to look animatables for
  72869. * @returns an array of Animatables
  72870. */
  72871. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  72872. /**
  72873. * Stops and removes all animations that have been applied to the scene
  72874. */
  72875. stopAllAnimations(): void;
  72876. }
  72877. interface Bone {
  72878. /**
  72879. * Copy an animation range from another bone
  72880. * @param source defines the source bone
  72881. * @param rangeName defines the range name to copy
  72882. * @param frameOffset defines the frame offset
  72883. * @param rescaleAsRequired defines if rescaling must be applied if required
  72884. * @param skelDimensionsRatio defines the scaling ratio
  72885. * @returns true if operation was successful
  72886. */
  72887. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  72888. }
  72889. }
  72890. declare module BABYLON {
  72891. /**
  72892. * Class used to handle skinning animations
  72893. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  72894. */
  72895. export class Skeleton implements IAnimatable {
  72896. /** defines the skeleton name */
  72897. name: string;
  72898. /** defines the skeleton Id */
  72899. id: string;
  72900. /**
  72901. * Defines the list of child bones
  72902. */
  72903. bones: Bone[];
  72904. /**
  72905. * Defines an estimate of the dimension of the skeleton at rest
  72906. */
  72907. dimensionsAtRest: Vector3;
  72908. /**
  72909. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  72910. */
  72911. needInitialSkinMatrix: boolean;
  72912. /**
  72913. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  72914. */
  72915. overrideMesh: Nullable<AbstractMesh>;
  72916. /**
  72917. * Gets the list of animations attached to this skeleton
  72918. */
  72919. animations: Array<Animation>;
  72920. private _scene;
  72921. private _isDirty;
  72922. private _transformMatrices;
  72923. private _transformMatrixTexture;
  72924. private _meshesWithPoseMatrix;
  72925. private _animatables;
  72926. private _identity;
  72927. private _synchronizedWithMesh;
  72928. private _ranges;
  72929. private _lastAbsoluteTransformsUpdateId;
  72930. private _canUseTextureForBones;
  72931. private _uniqueId;
  72932. /** @hidden */
  72933. _numBonesWithLinkedTransformNode: number;
  72934. /** @hidden */
  72935. _hasWaitingData: Nullable<boolean>;
  72936. /**
  72937. * Specifies if the skeleton should be serialized
  72938. */
  72939. doNotSerialize: boolean;
  72940. private _useTextureToStoreBoneMatrices;
  72941. /**
  72942. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  72943. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  72944. */
  72945. useTextureToStoreBoneMatrices: boolean;
  72946. private _animationPropertiesOverride;
  72947. /**
  72948. * Gets or sets the animation properties override
  72949. */
  72950. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72951. /**
  72952. * List of inspectable custom properties (used by the Inspector)
  72953. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72954. */
  72955. inspectableCustomProperties: IInspectable[];
  72956. /**
  72957. * An observable triggered before computing the skeleton's matrices
  72958. */
  72959. onBeforeComputeObservable: Observable<Skeleton>;
  72960. /**
  72961. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  72962. */
  72963. readonly isUsingTextureForMatrices: boolean;
  72964. /**
  72965. * Gets the unique ID of this skeleton
  72966. */
  72967. readonly uniqueId: number;
  72968. /**
  72969. * Creates a new skeleton
  72970. * @param name defines the skeleton name
  72971. * @param id defines the skeleton Id
  72972. * @param scene defines the hosting scene
  72973. */
  72974. constructor(
  72975. /** defines the skeleton name */
  72976. name: string,
  72977. /** defines the skeleton Id */
  72978. id: string, scene: Scene);
  72979. /**
  72980. * Gets the current object class name.
  72981. * @return the class name
  72982. */
  72983. getClassName(): string;
  72984. /**
  72985. * Returns an array containing the root bones
  72986. * @returns an array containing the root bones
  72987. */
  72988. getChildren(): Array<Bone>;
  72989. /**
  72990. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  72991. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72992. * @returns a Float32Array containing matrices data
  72993. */
  72994. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  72995. /**
  72996. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  72997. * @returns a raw texture containing the data
  72998. */
  72999. getTransformMatrixTexture(): Nullable<RawTexture>;
  73000. /**
  73001. * Gets the current hosting scene
  73002. * @returns a scene object
  73003. */
  73004. getScene(): Scene;
  73005. /**
  73006. * Gets a string representing the current skeleton data
  73007. * @param fullDetails defines a boolean indicating if we want a verbose version
  73008. * @returns a string representing the current skeleton data
  73009. */
  73010. toString(fullDetails?: boolean): string;
  73011. /**
  73012. * Get bone's index searching by name
  73013. * @param name defines bone's name to search for
  73014. * @return the indice of the bone. Returns -1 if not found
  73015. */
  73016. getBoneIndexByName(name: string): number;
  73017. /**
  73018. * Creater a new animation range
  73019. * @param name defines the name of the range
  73020. * @param from defines the start key
  73021. * @param to defines the end key
  73022. */
  73023. createAnimationRange(name: string, from: number, to: number): void;
  73024. /**
  73025. * Delete a specific animation range
  73026. * @param name defines the name of the range
  73027. * @param deleteFrames defines if frames must be removed as well
  73028. */
  73029. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  73030. /**
  73031. * Gets a specific animation range
  73032. * @param name defines the name of the range to look for
  73033. * @returns the requested animation range or null if not found
  73034. */
  73035. getAnimationRange(name: string): Nullable<AnimationRange>;
  73036. /**
  73037. * Gets the list of all animation ranges defined on this skeleton
  73038. * @returns an array
  73039. */
  73040. getAnimationRanges(): Nullable<AnimationRange>[];
  73041. /**
  73042. * Copy animation range from a source skeleton.
  73043. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  73044. * @param source defines the source skeleton
  73045. * @param name defines the name of the range to copy
  73046. * @param rescaleAsRequired defines if rescaling must be applied if required
  73047. * @returns true if operation was successful
  73048. */
  73049. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  73050. /**
  73051. * Forces the skeleton to go to rest pose
  73052. */
  73053. returnToRest(): void;
  73054. private _getHighestAnimationFrame;
  73055. /**
  73056. * Begin a specific animation range
  73057. * @param name defines the name of the range to start
  73058. * @param loop defines if looping must be turned on (false by default)
  73059. * @param speedRatio defines the speed ratio to apply (1 by default)
  73060. * @param onAnimationEnd defines a callback which will be called when animation will end
  73061. * @returns a new animatable
  73062. */
  73063. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  73064. /** @hidden */
  73065. _markAsDirty(): void;
  73066. /** @hidden */
  73067. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  73068. /** @hidden */
  73069. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  73070. private _computeTransformMatrices;
  73071. /**
  73072. * Build all resources required to render a skeleton
  73073. */
  73074. prepare(): void;
  73075. /**
  73076. * Gets the list of animatables currently running for this skeleton
  73077. * @returns an array of animatables
  73078. */
  73079. getAnimatables(): IAnimatable[];
  73080. /**
  73081. * Clone the current skeleton
  73082. * @param name defines the name of the new skeleton
  73083. * @param id defines the id of the new skeleton
  73084. * @returns the new skeleton
  73085. */
  73086. clone(name: string, id: string): Skeleton;
  73087. /**
  73088. * Enable animation blending for this skeleton
  73089. * @param blendingSpeed defines the blending speed to apply
  73090. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  73091. */
  73092. enableBlending(blendingSpeed?: number): void;
  73093. /**
  73094. * Releases all resources associated with the current skeleton
  73095. */
  73096. dispose(): void;
  73097. /**
  73098. * Serialize the skeleton in a JSON object
  73099. * @returns a JSON object
  73100. */
  73101. serialize(): any;
  73102. /**
  73103. * Creates a new skeleton from serialized data
  73104. * @param parsedSkeleton defines the serialized data
  73105. * @param scene defines the hosting scene
  73106. * @returns a new skeleton
  73107. */
  73108. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  73109. /**
  73110. * Compute all node absolute transforms
  73111. * @param forceUpdate defines if computation must be done even if cache is up to date
  73112. */
  73113. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  73114. /**
  73115. * Gets the root pose matrix
  73116. * @returns a matrix
  73117. */
  73118. getPoseMatrix(): Nullable<Matrix>;
  73119. /**
  73120. * Sorts bones per internal index
  73121. */
  73122. sortBones(): void;
  73123. private _sortBones;
  73124. }
  73125. }
  73126. declare module BABYLON {
  73127. /**
  73128. * Defines a target to use with MorphTargetManager
  73129. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73130. */
  73131. export class MorphTarget implements IAnimatable {
  73132. /** defines the name of the target */
  73133. name: string;
  73134. /**
  73135. * Gets or sets the list of animations
  73136. */
  73137. animations: Animation[];
  73138. private _scene;
  73139. private _positions;
  73140. private _normals;
  73141. private _tangents;
  73142. private _uvs;
  73143. private _influence;
  73144. /**
  73145. * Observable raised when the influence changes
  73146. */
  73147. onInfluenceChanged: Observable<boolean>;
  73148. /** @hidden */
  73149. _onDataLayoutChanged: Observable<void>;
  73150. /**
  73151. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  73152. */
  73153. influence: number;
  73154. /**
  73155. * Gets or sets the id of the morph Target
  73156. */
  73157. id: string;
  73158. private _animationPropertiesOverride;
  73159. /**
  73160. * Gets or sets the animation properties override
  73161. */
  73162. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  73163. /**
  73164. * Creates a new MorphTarget
  73165. * @param name defines the name of the target
  73166. * @param influence defines the influence to use
  73167. * @param scene defines the scene the morphtarget belongs to
  73168. */
  73169. constructor(
  73170. /** defines the name of the target */
  73171. name: string, influence?: number, scene?: Nullable<Scene>);
  73172. /**
  73173. * Gets a boolean defining if the target contains position data
  73174. */
  73175. readonly hasPositions: boolean;
  73176. /**
  73177. * Gets a boolean defining if the target contains normal data
  73178. */
  73179. readonly hasNormals: boolean;
  73180. /**
  73181. * Gets a boolean defining if the target contains tangent data
  73182. */
  73183. readonly hasTangents: boolean;
  73184. /**
  73185. * Gets a boolean defining if the target contains texture coordinates data
  73186. */
  73187. readonly hasUVs: boolean;
  73188. /**
  73189. * Affects position data to this target
  73190. * @param data defines the position data to use
  73191. */
  73192. setPositions(data: Nullable<FloatArray>): void;
  73193. /**
  73194. * Gets the position data stored in this target
  73195. * @returns a FloatArray containing the position data (or null if not present)
  73196. */
  73197. getPositions(): Nullable<FloatArray>;
  73198. /**
  73199. * Affects normal data to this target
  73200. * @param data defines the normal data to use
  73201. */
  73202. setNormals(data: Nullable<FloatArray>): void;
  73203. /**
  73204. * Gets the normal data stored in this target
  73205. * @returns a FloatArray containing the normal data (or null if not present)
  73206. */
  73207. getNormals(): Nullable<FloatArray>;
  73208. /**
  73209. * Affects tangent data to this target
  73210. * @param data defines the tangent data to use
  73211. */
  73212. setTangents(data: Nullable<FloatArray>): void;
  73213. /**
  73214. * Gets the tangent data stored in this target
  73215. * @returns a FloatArray containing the tangent data (or null if not present)
  73216. */
  73217. getTangents(): Nullable<FloatArray>;
  73218. /**
  73219. * Affects texture coordinates data to this target
  73220. * @param data defines the texture coordinates data to use
  73221. */
  73222. setUVs(data: Nullable<FloatArray>): void;
  73223. /**
  73224. * Gets the texture coordinates data stored in this target
  73225. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  73226. */
  73227. getUVs(): Nullable<FloatArray>;
  73228. /**
  73229. * Serializes the current target into a Serialization object
  73230. * @returns the serialized object
  73231. */
  73232. serialize(): any;
  73233. /**
  73234. * Returns the string "MorphTarget"
  73235. * @returns "MorphTarget"
  73236. */
  73237. getClassName(): string;
  73238. /**
  73239. * Creates a new target from serialized data
  73240. * @param serializationObject defines the serialized data to use
  73241. * @returns a new MorphTarget
  73242. */
  73243. static Parse(serializationObject: any): MorphTarget;
  73244. /**
  73245. * Creates a MorphTarget from mesh data
  73246. * @param mesh defines the source mesh
  73247. * @param name defines the name to use for the new target
  73248. * @param influence defines the influence to attach to the target
  73249. * @returns a new MorphTarget
  73250. */
  73251. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  73252. }
  73253. }
  73254. declare module BABYLON {
  73255. /**
  73256. * This class is used to deform meshes using morphing between different targets
  73257. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73258. */
  73259. export class MorphTargetManager {
  73260. private _targets;
  73261. private _targetInfluenceChangedObservers;
  73262. private _targetDataLayoutChangedObservers;
  73263. private _activeTargets;
  73264. private _scene;
  73265. private _influences;
  73266. private _supportsNormals;
  73267. private _supportsTangents;
  73268. private _supportsUVs;
  73269. private _vertexCount;
  73270. private _uniqueId;
  73271. private _tempInfluences;
  73272. /**
  73273. * Creates a new MorphTargetManager
  73274. * @param scene defines the current scene
  73275. */
  73276. constructor(scene?: Nullable<Scene>);
  73277. /**
  73278. * Gets the unique ID of this manager
  73279. */
  73280. readonly uniqueId: number;
  73281. /**
  73282. * Gets the number of vertices handled by this manager
  73283. */
  73284. readonly vertexCount: number;
  73285. /**
  73286. * Gets a boolean indicating if this manager supports morphing of normals
  73287. */
  73288. readonly supportsNormals: boolean;
  73289. /**
  73290. * Gets a boolean indicating if this manager supports morphing of tangents
  73291. */
  73292. readonly supportsTangents: boolean;
  73293. /**
  73294. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  73295. */
  73296. readonly supportsUVs: boolean;
  73297. /**
  73298. * Gets the number of targets stored in this manager
  73299. */
  73300. readonly numTargets: number;
  73301. /**
  73302. * Gets the number of influencers (ie. the number of targets with influences > 0)
  73303. */
  73304. readonly numInfluencers: number;
  73305. /**
  73306. * Gets the list of influences (one per target)
  73307. */
  73308. readonly influences: Float32Array;
  73309. /**
  73310. * Gets the active target at specified index. An active target is a target with an influence > 0
  73311. * @param index defines the index to check
  73312. * @returns the requested target
  73313. */
  73314. getActiveTarget(index: number): MorphTarget;
  73315. /**
  73316. * Gets the target at specified index
  73317. * @param index defines the index to check
  73318. * @returns the requested target
  73319. */
  73320. getTarget(index: number): MorphTarget;
  73321. /**
  73322. * Add a new target to this manager
  73323. * @param target defines the target to add
  73324. */
  73325. addTarget(target: MorphTarget): void;
  73326. /**
  73327. * Removes a target from the manager
  73328. * @param target defines the target to remove
  73329. */
  73330. removeTarget(target: MorphTarget): void;
  73331. /**
  73332. * Serializes the current manager into a Serialization object
  73333. * @returns the serialized object
  73334. */
  73335. serialize(): any;
  73336. private _syncActiveTargets;
  73337. /**
  73338. * Syncrhonize the targets with all the meshes using this morph target manager
  73339. */
  73340. synchronize(): void;
  73341. /**
  73342. * Creates a new MorphTargetManager from serialized data
  73343. * @param serializationObject defines the serialized data
  73344. * @param scene defines the hosting scene
  73345. * @returns the new MorphTargetManager
  73346. */
  73347. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  73348. }
  73349. }
  73350. declare module BABYLON {
  73351. /**
  73352. * Groups all the scene component constants in one place to ease maintenance.
  73353. * @hidden
  73354. */
  73355. export class SceneComponentConstants {
  73356. static readonly NAME_EFFECTLAYER: string;
  73357. static readonly NAME_LAYER: string;
  73358. static readonly NAME_LENSFLARESYSTEM: string;
  73359. static readonly NAME_BOUNDINGBOXRENDERER: string;
  73360. static readonly NAME_PARTICLESYSTEM: string;
  73361. static readonly NAME_GAMEPAD: string;
  73362. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  73363. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  73364. static readonly NAME_DEPTHRENDERER: string;
  73365. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  73366. static readonly NAME_SPRITE: string;
  73367. static readonly NAME_OUTLINERENDERER: string;
  73368. static readonly NAME_PROCEDURALTEXTURE: string;
  73369. static readonly NAME_SHADOWGENERATOR: string;
  73370. static readonly NAME_OCTREE: string;
  73371. static readonly NAME_PHYSICSENGINE: string;
  73372. static readonly NAME_AUDIO: string;
  73373. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  73374. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73375. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  73376. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73377. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  73378. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  73379. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  73380. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  73381. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  73382. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  73383. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  73384. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  73385. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  73386. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  73387. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  73388. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  73389. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  73390. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  73391. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  73392. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  73393. static readonly STEP_AFTERRENDER_AUDIO: number;
  73394. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  73395. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  73396. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  73397. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  73398. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  73399. static readonly STEP_POINTERMOVE_SPRITE: number;
  73400. static readonly STEP_POINTERDOWN_SPRITE: number;
  73401. static readonly STEP_POINTERUP_SPRITE: number;
  73402. }
  73403. /**
  73404. * This represents a scene component.
  73405. *
  73406. * This is used to decouple the dependency the scene is having on the different workloads like
  73407. * layers, post processes...
  73408. */
  73409. export interface ISceneComponent {
  73410. /**
  73411. * The name of the component. Each component must have a unique name.
  73412. */
  73413. name: string;
  73414. /**
  73415. * The scene the component belongs to.
  73416. */
  73417. scene: Scene;
  73418. /**
  73419. * Register the component to one instance of a scene.
  73420. */
  73421. register(): void;
  73422. /**
  73423. * Rebuilds the elements related to this component in case of
  73424. * context lost for instance.
  73425. */
  73426. rebuild(): void;
  73427. /**
  73428. * Disposes the component and the associated ressources.
  73429. */
  73430. dispose(): void;
  73431. }
  73432. /**
  73433. * This represents a SERIALIZABLE scene component.
  73434. *
  73435. * This extends Scene Component to add Serialization methods on top.
  73436. */
  73437. export interface ISceneSerializableComponent extends ISceneComponent {
  73438. /**
  73439. * Adds all the elements from the container to the scene
  73440. * @param container the container holding the elements
  73441. */
  73442. addFromContainer(container: AbstractScene): void;
  73443. /**
  73444. * Removes all the elements in the container from the scene
  73445. * @param container contains the elements to remove
  73446. * @param dispose if the removed element should be disposed (default: false)
  73447. */
  73448. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73449. /**
  73450. * Serializes the component data to the specified json object
  73451. * @param serializationObject The object to serialize to
  73452. */
  73453. serialize(serializationObject: any): void;
  73454. }
  73455. /**
  73456. * Strong typing of a Mesh related stage step action
  73457. */
  73458. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  73459. /**
  73460. * Strong typing of a Evaluate Sub Mesh related stage step action
  73461. */
  73462. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  73463. /**
  73464. * Strong typing of a Active Mesh related stage step action
  73465. */
  73466. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  73467. /**
  73468. * Strong typing of a Camera related stage step action
  73469. */
  73470. export type CameraStageAction = (camera: Camera) => void;
  73471. /**
  73472. * Strong typing of a Camera Frame buffer related stage step action
  73473. */
  73474. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  73475. /**
  73476. * Strong typing of a Render Target related stage step action
  73477. */
  73478. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  73479. /**
  73480. * Strong typing of a RenderingGroup related stage step action
  73481. */
  73482. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  73483. /**
  73484. * Strong typing of a Mesh Render related stage step action
  73485. */
  73486. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  73487. /**
  73488. * Strong typing of a simple stage step action
  73489. */
  73490. export type SimpleStageAction = () => void;
  73491. /**
  73492. * Strong typing of a render target action.
  73493. */
  73494. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  73495. /**
  73496. * Strong typing of a pointer move action.
  73497. */
  73498. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  73499. /**
  73500. * Strong typing of a pointer up/down action.
  73501. */
  73502. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  73503. /**
  73504. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  73505. * @hidden
  73506. */
  73507. export class Stage<T extends Function> extends Array<{
  73508. index: number;
  73509. component: ISceneComponent;
  73510. action: T;
  73511. }> {
  73512. /**
  73513. * Hide ctor from the rest of the world.
  73514. * @param items The items to add.
  73515. */
  73516. private constructor();
  73517. /**
  73518. * Creates a new Stage.
  73519. * @returns A new instance of a Stage
  73520. */
  73521. static Create<T extends Function>(): Stage<T>;
  73522. /**
  73523. * Registers a step in an ordered way in the targeted stage.
  73524. * @param index Defines the position to register the step in
  73525. * @param component Defines the component attached to the step
  73526. * @param action Defines the action to launch during the step
  73527. */
  73528. registerStep(index: number, component: ISceneComponent, action: T): void;
  73529. /**
  73530. * Clears all the steps from the stage.
  73531. */
  73532. clear(): void;
  73533. }
  73534. }
  73535. declare module BABYLON {
  73536. /**
  73537. * Class used to represent a specific level of detail of a mesh
  73538. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  73539. */
  73540. export class MeshLODLevel {
  73541. /** Defines the distance where this level should star being displayed */
  73542. distance: number;
  73543. /** Defines the mesh to use to render this level */
  73544. mesh: Nullable<Mesh>;
  73545. /**
  73546. * Creates a new LOD level
  73547. * @param distance defines the distance where this level should star being displayed
  73548. * @param mesh defines the mesh to use to render this level
  73549. */
  73550. constructor(
  73551. /** Defines the distance where this level should star being displayed */
  73552. distance: number,
  73553. /** Defines the mesh to use to render this level */
  73554. mesh: Nullable<Mesh>);
  73555. }
  73556. }
  73557. declare module BABYLON {
  73558. /**
  73559. * Interface describing all the common properties and methods a shadow light needs to implement.
  73560. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73561. * as well as binding the different shadow properties to the effects.
  73562. */
  73563. export interface IShadowLight extends Light {
  73564. /**
  73565. * The light id in the scene (used in scene.findLighById for instance)
  73566. */
  73567. id: string;
  73568. /**
  73569. * The position the shdow will be casted from.
  73570. */
  73571. position: Vector3;
  73572. /**
  73573. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73574. */
  73575. direction: Vector3;
  73576. /**
  73577. * The transformed position. Position of the light in world space taking parenting in account.
  73578. */
  73579. transformedPosition: Vector3;
  73580. /**
  73581. * The transformed direction. Direction of the light in world space taking parenting in account.
  73582. */
  73583. transformedDirection: Vector3;
  73584. /**
  73585. * The friendly name of the light in the scene.
  73586. */
  73587. name: string;
  73588. /**
  73589. * Defines the shadow projection clipping minimum z value.
  73590. */
  73591. shadowMinZ: number;
  73592. /**
  73593. * Defines the shadow projection clipping maximum z value.
  73594. */
  73595. shadowMaxZ: number;
  73596. /**
  73597. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73598. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73599. */
  73600. computeTransformedInformation(): boolean;
  73601. /**
  73602. * Gets the scene the light belongs to.
  73603. * @returns The scene
  73604. */
  73605. getScene(): Scene;
  73606. /**
  73607. * Callback defining a custom Projection Matrix Builder.
  73608. * This can be used to override the default projection matrix computation.
  73609. */
  73610. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73611. /**
  73612. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73613. * @param matrix The materix to updated with the projection information
  73614. * @param viewMatrix The transform matrix of the light
  73615. * @param renderList The list of mesh to render in the map
  73616. * @returns The current light
  73617. */
  73618. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73619. /**
  73620. * Gets the current depth scale used in ESM.
  73621. * @returns The scale
  73622. */
  73623. getDepthScale(): number;
  73624. /**
  73625. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73626. * @returns true if a cube texture needs to be use
  73627. */
  73628. needCube(): boolean;
  73629. /**
  73630. * Detects if the projection matrix requires to be recomputed this frame.
  73631. * @returns true if it requires to be recomputed otherwise, false.
  73632. */
  73633. needProjectionMatrixCompute(): boolean;
  73634. /**
  73635. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73636. */
  73637. forceProjectionMatrixCompute(): void;
  73638. /**
  73639. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73640. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73641. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73642. */
  73643. getShadowDirection(faceIndex?: number): Vector3;
  73644. /**
  73645. * Gets the minZ used for shadow according to both the scene and the light.
  73646. * @param activeCamera The camera we are returning the min for
  73647. * @returns the depth min z
  73648. */
  73649. getDepthMinZ(activeCamera: Camera): number;
  73650. /**
  73651. * Gets the maxZ used for shadow according to both the scene and the light.
  73652. * @param activeCamera The camera we are returning the max for
  73653. * @returns the depth max z
  73654. */
  73655. getDepthMaxZ(activeCamera: Camera): number;
  73656. }
  73657. /**
  73658. * Base implementation IShadowLight
  73659. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73660. */
  73661. export abstract class ShadowLight extends Light implements IShadowLight {
  73662. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73663. protected _position: Vector3;
  73664. protected _setPosition(value: Vector3): void;
  73665. /**
  73666. * Sets the position the shadow will be casted from. Also use as the light position for both
  73667. * point and spot lights.
  73668. */
  73669. /**
  73670. * Sets the position the shadow will be casted from. Also use as the light position for both
  73671. * point and spot lights.
  73672. */
  73673. position: Vector3;
  73674. protected _direction: Vector3;
  73675. protected _setDirection(value: Vector3): void;
  73676. /**
  73677. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73678. * Also use as the light direction on spot and directional lights.
  73679. */
  73680. /**
  73681. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73682. * Also use as the light direction on spot and directional lights.
  73683. */
  73684. direction: Vector3;
  73685. private _shadowMinZ;
  73686. /**
  73687. * Gets the shadow projection clipping minimum z value.
  73688. */
  73689. /**
  73690. * Sets the shadow projection clipping minimum z value.
  73691. */
  73692. shadowMinZ: number;
  73693. private _shadowMaxZ;
  73694. /**
  73695. * Sets the shadow projection clipping maximum z value.
  73696. */
  73697. /**
  73698. * Gets the shadow projection clipping maximum z value.
  73699. */
  73700. shadowMaxZ: number;
  73701. /**
  73702. * Callback defining a custom Projection Matrix Builder.
  73703. * This can be used to override the default projection matrix computation.
  73704. */
  73705. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73706. /**
  73707. * The transformed position. Position of the light in world space taking parenting in account.
  73708. */
  73709. transformedPosition: Vector3;
  73710. /**
  73711. * The transformed direction. Direction of the light in world space taking parenting in account.
  73712. */
  73713. transformedDirection: Vector3;
  73714. private _needProjectionMatrixCompute;
  73715. /**
  73716. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73717. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73718. */
  73719. computeTransformedInformation(): boolean;
  73720. /**
  73721. * Return the depth scale used for the shadow map.
  73722. * @returns the depth scale.
  73723. */
  73724. getDepthScale(): number;
  73725. /**
  73726. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73727. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73728. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73729. */
  73730. getShadowDirection(faceIndex?: number): Vector3;
  73731. /**
  73732. * Returns the ShadowLight absolute position in the World.
  73733. * @returns the position vector in world space
  73734. */
  73735. getAbsolutePosition(): Vector3;
  73736. /**
  73737. * Sets the ShadowLight direction toward the passed target.
  73738. * @param target The point to target in local space
  73739. * @returns the updated ShadowLight direction
  73740. */
  73741. setDirectionToTarget(target: Vector3): Vector3;
  73742. /**
  73743. * Returns the light rotation in euler definition.
  73744. * @returns the x y z rotation in local space.
  73745. */
  73746. getRotation(): Vector3;
  73747. /**
  73748. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73749. * @returns true if a cube texture needs to be use
  73750. */
  73751. needCube(): boolean;
  73752. /**
  73753. * Detects if the projection matrix requires to be recomputed this frame.
  73754. * @returns true if it requires to be recomputed otherwise, false.
  73755. */
  73756. needProjectionMatrixCompute(): boolean;
  73757. /**
  73758. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73759. */
  73760. forceProjectionMatrixCompute(): void;
  73761. /** @hidden */
  73762. _initCache(): void;
  73763. /** @hidden */
  73764. _isSynchronized(): boolean;
  73765. /**
  73766. * Computes the world matrix of the node
  73767. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73768. * @returns the world matrix
  73769. */
  73770. computeWorldMatrix(force?: boolean): Matrix;
  73771. /**
  73772. * Gets the minZ used for shadow according to both the scene and the light.
  73773. * @param activeCamera The camera we are returning the min for
  73774. * @returns the depth min z
  73775. */
  73776. getDepthMinZ(activeCamera: Camera): number;
  73777. /**
  73778. * Gets the maxZ used for shadow according to both the scene and the light.
  73779. * @param activeCamera The camera we are returning the max for
  73780. * @returns the depth max z
  73781. */
  73782. getDepthMaxZ(activeCamera: Camera): number;
  73783. /**
  73784. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73785. * @param matrix The materix to updated with the projection information
  73786. * @param viewMatrix The transform matrix of the light
  73787. * @param renderList The list of mesh to render in the map
  73788. * @returns The current light
  73789. */
  73790. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73791. }
  73792. }
  73793. declare module BABYLON {
  73794. /**
  73795. * "Static Class" containing the most commonly used helper while dealing with material for
  73796. * rendering purpose.
  73797. *
  73798. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73799. *
  73800. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73801. */
  73802. export class MaterialHelper {
  73803. /**
  73804. * Bind the current view position to an effect.
  73805. * @param effect The effect to be bound
  73806. * @param scene The scene the eyes position is used from
  73807. */
  73808. static BindEyePosition(effect: Effect, scene: Scene): void;
  73809. /**
  73810. * Helps preparing the defines values about the UVs in used in the effect.
  73811. * UVs are shared as much as we can accross channels in the shaders.
  73812. * @param texture The texture we are preparing the UVs for
  73813. * @param defines The defines to update
  73814. * @param key The channel key "diffuse", "specular"... used in the shader
  73815. */
  73816. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73817. /**
  73818. * Binds a texture matrix value to its corrsponding uniform
  73819. * @param texture The texture to bind the matrix for
  73820. * @param uniformBuffer The uniform buffer receivin the data
  73821. * @param key The channel key "diffuse", "specular"... used in the shader
  73822. */
  73823. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73824. /**
  73825. * Gets the current status of the fog (should it be enabled?)
  73826. * @param mesh defines the mesh to evaluate for fog support
  73827. * @param scene defines the hosting scene
  73828. * @returns true if fog must be enabled
  73829. */
  73830. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73831. /**
  73832. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73833. * @param mesh defines the current mesh
  73834. * @param scene defines the current scene
  73835. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73836. * @param pointsCloud defines if point cloud rendering has to be turned on
  73837. * @param fogEnabled defines if fog has to be turned on
  73838. * @param alphaTest defines if alpha testing has to be turned on
  73839. * @param defines defines the current list of defines
  73840. */
  73841. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73842. /**
  73843. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73844. * @param scene defines the current scene
  73845. * @param engine defines the current engine
  73846. * @param defines specifies the list of active defines
  73847. * @param useInstances defines if instances have to be turned on
  73848. * @param useClipPlane defines if clip plane have to be turned on
  73849. */
  73850. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73851. /**
  73852. * Prepares the defines for bones
  73853. * @param mesh The mesh containing the geometry data we will draw
  73854. * @param defines The defines to update
  73855. */
  73856. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73857. /**
  73858. * Prepares the defines for morph targets
  73859. * @param mesh The mesh containing the geometry data we will draw
  73860. * @param defines The defines to update
  73861. */
  73862. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73863. /**
  73864. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73865. * @param mesh The mesh containing the geometry data we will draw
  73866. * @param defines The defines to update
  73867. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73868. * @param useBones Precise whether bones should be used or not (override mesh info)
  73869. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73870. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73871. * @returns false if defines are considered not dirty and have not been checked
  73872. */
  73873. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73874. /**
  73875. * Prepares the defines related to multiview
  73876. * @param scene The scene we are intending to draw
  73877. * @param defines The defines to update
  73878. */
  73879. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73880. /**
  73881. * Prepares the defines related to the light information passed in parameter
  73882. * @param scene The scene we are intending to draw
  73883. * @param mesh The mesh the effect is compiling for
  73884. * @param light The light the effect is compiling for
  73885. * @param lightIndex The index of the light
  73886. * @param defines The defines to update
  73887. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73888. * @param state Defines the current state regarding what is needed (normals, etc...)
  73889. */
  73890. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73891. needNormals: boolean;
  73892. needRebuild: boolean;
  73893. shadowEnabled: boolean;
  73894. specularEnabled: boolean;
  73895. lightmapMode: boolean;
  73896. }): void;
  73897. /**
  73898. * Prepares the defines related to the light information passed in parameter
  73899. * @param scene The scene we are intending to draw
  73900. * @param mesh The mesh the effect is compiling for
  73901. * @param defines The defines to update
  73902. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73903. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73904. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73905. * @returns true if normals will be required for the rest of the effect
  73906. */
  73907. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73908. /**
  73909. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73910. * @param lightIndex defines the light index
  73911. * @param uniformsList The uniform list
  73912. * @param samplersList The sampler list
  73913. * @param projectedLightTexture defines if projected texture must be used
  73914. * @param uniformBuffersList defines an optional list of uniform buffers
  73915. */
  73916. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73917. /**
  73918. * Prepares the uniforms and samplers list to be used in the effect
  73919. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73920. * @param samplersList The sampler list
  73921. * @param defines The defines helping in the list generation
  73922. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73923. */
  73924. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73925. /**
  73926. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73927. * @param defines The defines to update while falling back
  73928. * @param fallbacks The authorized effect fallbacks
  73929. * @param maxSimultaneousLights The maximum number of lights allowed
  73930. * @param rank the current rank of the Effect
  73931. * @returns The newly affected rank
  73932. */
  73933. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73934. private static _TmpMorphInfluencers;
  73935. /**
  73936. * Prepares the list of attributes required for morph targets according to the effect defines.
  73937. * @param attribs The current list of supported attribs
  73938. * @param mesh The mesh to prepare the morph targets attributes for
  73939. * @param influencers The number of influencers
  73940. */
  73941. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73942. /**
  73943. * Prepares the list of attributes required for morph targets according to the effect defines.
  73944. * @param attribs The current list of supported attribs
  73945. * @param mesh The mesh to prepare the morph targets attributes for
  73946. * @param defines The current Defines of the effect
  73947. */
  73948. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73949. /**
  73950. * Prepares the list of attributes required for bones according to the effect defines.
  73951. * @param attribs The current list of supported attribs
  73952. * @param mesh The mesh to prepare the bones attributes for
  73953. * @param defines The current Defines of the effect
  73954. * @param fallbacks The current efffect fallback strategy
  73955. */
  73956. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73957. /**
  73958. * Check and prepare the list of attributes required for instances according to the effect defines.
  73959. * @param attribs The current list of supported attribs
  73960. * @param defines The current MaterialDefines of the effect
  73961. */
  73962. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73963. /**
  73964. * Add the list of attributes required for instances to the attribs array.
  73965. * @param attribs The current list of supported attribs
  73966. */
  73967. static PushAttributesForInstances(attribs: string[]): void;
  73968. /**
  73969. * Binds the light shadow information to the effect for the given mesh.
  73970. * @param light The light containing the generator
  73971. * @param scene The scene the lights belongs to
  73972. * @param mesh The mesh we are binding the information to render
  73973. * @param lightIndex The light index in the effect used to render the mesh
  73974. * @param effect The effect we are binding the data to
  73975. */
  73976. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73977. /**
  73978. * Binds the light information to the effect.
  73979. * @param light The light containing the generator
  73980. * @param effect The effect we are binding the data to
  73981. * @param lightIndex The light index in the effect used to render
  73982. */
  73983. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73984. /**
  73985. * Binds the lights information from the scene to the effect for the given mesh.
  73986. * @param light Light to bind
  73987. * @param lightIndex Light index
  73988. * @param scene The scene where the light belongs to
  73989. * @param mesh The mesh we are binding the information to render
  73990. * @param effect The effect we are binding the data to
  73991. * @param useSpecular Defines if specular is supported
  73992. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73993. */
  73994. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  73995. /**
  73996. * Binds the lights information from the scene to the effect for the given mesh.
  73997. * @param scene The scene the lights belongs to
  73998. * @param mesh The mesh we are binding the information to render
  73999. * @param effect The effect we are binding the data to
  74000. * @param defines The generated defines for the effect
  74001. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74002. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74003. */
  74004. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  74005. private static _tempFogColor;
  74006. /**
  74007. * Binds the fog information from the scene to the effect for the given mesh.
  74008. * @param scene The scene the lights belongs to
  74009. * @param mesh The mesh we are binding the information to render
  74010. * @param effect The effect we are binding the data to
  74011. * @param linearSpace Defines if the fog effect is applied in linear space
  74012. */
  74013. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74014. /**
  74015. * Binds the bones information from the mesh to the effect.
  74016. * @param mesh The mesh we are binding the information to render
  74017. * @param effect The effect we are binding the data to
  74018. */
  74019. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74020. /**
  74021. * Binds the morph targets information from the mesh to the effect.
  74022. * @param abstractMesh The mesh we are binding the information to render
  74023. * @param effect The effect we are binding the data to
  74024. */
  74025. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74026. /**
  74027. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74028. * @param defines The generated defines used in the effect
  74029. * @param effect The effect we are binding the data to
  74030. * @param scene The scene we are willing to render with logarithmic scale for
  74031. */
  74032. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74033. /**
  74034. * Binds the clip plane information from the scene to the effect.
  74035. * @param scene The scene the clip plane information are extracted from
  74036. * @param effect The effect we are binding the data to
  74037. */
  74038. static BindClipPlane(effect: Effect, scene: Scene): void;
  74039. }
  74040. }
  74041. declare module BABYLON {
  74042. /** @hidden */
  74043. export var shadowMapPixelShader: {
  74044. name: string;
  74045. shader: string;
  74046. };
  74047. }
  74048. declare module BABYLON {
  74049. /** @hidden */
  74050. export var bonesDeclaration: {
  74051. name: string;
  74052. shader: string;
  74053. };
  74054. }
  74055. declare module BABYLON {
  74056. /** @hidden */
  74057. export var morphTargetsVertexGlobalDeclaration: {
  74058. name: string;
  74059. shader: string;
  74060. };
  74061. }
  74062. declare module BABYLON {
  74063. /** @hidden */
  74064. export var morphTargetsVertexDeclaration: {
  74065. name: string;
  74066. shader: string;
  74067. };
  74068. }
  74069. declare module BABYLON {
  74070. /** @hidden */
  74071. export var instancesDeclaration: {
  74072. name: string;
  74073. shader: string;
  74074. };
  74075. }
  74076. declare module BABYLON {
  74077. /** @hidden */
  74078. export var helperFunctions: {
  74079. name: string;
  74080. shader: string;
  74081. };
  74082. }
  74083. declare module BABYLON {
  74084. /** @hidden */
  74085. export var morphTargetsVertex: {
  74086. name: string;
  74087. shader: string;
  74088. };
  74089. }
  74090. declare module BABYLON {
  74091. /** @hidden */
  74092. export var instancesVertex: {
  74093. name: string;
  74094. shader: string;
  74095. };
  74096. }
  74097. declare module BABYLON {
  74098. /** @hidden */
  74099. export var bonesVertex: {
  74100. name: string;
  74101. shader: string;
  74102. };
  74103. }
  74104. declare module BABYLON {
  74105. /** @hidden */
  74106. export var shadowMapVertexShader: {
  74107. name: string;
  74108. shader: string;
  74109. };
  74110. }
  74111. declare module BABYLON {
  74112. /** @hidden */
  74113. export var depthBoxBlurPixelShader: {
  74114. name: string;
  74115. shader: string;
  74116. };
  74117. }
  74118. declare module BABYLON {
  74119. /**
  74120. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74121. */
  74122. export interface ICustomShaderOptions {
  74123. /**
  74124. * Gets or sets the custom shader name to use
  74125. */
  74126. shaderName: string;
  74127. /**
  74128. * The list of attribute names used in the shader
  74129. */
  74130. attributes?: string[];
  74131. /**
  74132. * The list of unifrom names used in the shader
  74133. */
  74134. uniforms?: string[];
  74135. /**
  74136. * The list of sampler names used in the shader
  74137. */
  74138. samplers?: string[];
  74139. /**
  74140. * The list of defines used in the shader
  74141. */
  74142. defines?: string[];
  74143. }
  74144. /**
  74145. * Interface to implement to create a shadow generator compatible with BJS.
  74146. */
  74147. export interface IShadowGenerator {
  74148. /**
  74149. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74150. * @returns The render target texture if present otherwise, null
  74151. */
  74152. getShadowMap(): Nullable<RenderTargetTexture>;
  74153. /**
  74154. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74155. * @returns The render target texture if the shadow map is present otherwise, null
  74156. */
  74157. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74158. /**
  74159. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74160. * @param subMesh The submesh we want to render in the shadow map
  74161. * @param useInstances Defines wether will draw in the map using instances
  74162. * @returns true if ready otherwise, false
  74163. */
  74164. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74165. /**
  74166. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74167. * @param defines Defines of the material we want to update
  74168. * @param lightIndex Index of the light in the enabled light list of the material
  74169. */
  74170. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74171. /**
  74172. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74173. * defined in the generator but impacting the effect).
  74174. * It implies the unifroms available on the materials are the standard BJS ones.
  74175. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74176. * @param effect The effect we are binfing the information for
  74177. */
  74178. bindShadowLight(lightIndex: string, effect: Effect): void;
  74179. /**
  74180. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74181. * (eq to shadow prjection matrix * light transform matrix)
  74182. * @returns The transform matrix used to create the shadow map
  74183. */
  74184. getTransformMatrix(): Matrix;
  74185. /**
  74186. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74187. * Cube and 2D textures for instance.
  74188. */
  74189. recreateShadowMap(): void;
  74190. /**
  74191. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74192. * @param onCompiled Callback triggered at the and of the effects compilation
  74193. * @param options Sets of optional options forcing the compilation with different modes
  74194. */
  74195. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74196. useInstances: boolean;
  74197. }>): void;
  74198. /**
  74199. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74200. * @param options Sets of optional options forcing the compilation with different modes
  74201. * @returns A promise that resolves when the compilation completes
  74202. */
  74203. forceCompilationAsync(options?: Partial<{
  74204. useInstances: boolean;
  74205. }>): Promise<void>;
  74206. /**
  74207. * Serializes the shadow generator setup to a json object.
  74208. * @returns The serialized JSON object
  74209. */
  74210. serialize(): any;
  74211. /**
  74212. * Disposes the Shadow map and related Textures and effects.
  74213. */
  74214. dispose(): void;
  74215. }
  74216. /**
  74217. * Default implementation IShadowGenerator.
  74218. * This is the main object responsible of generating shadows in the framework.
  74219. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  74220. */
  74221. export class ShadowGenerator implements IShadowGenerator {
  74222. /**
  74223. * Shadow generator mode None: no filtering applied.
  74224. */
  74225. static readonly FILTER_NONE: number;
  74226. /**
  74227. * Shadow generator mode ESM: Exponential Shadow Mapping.
  74228. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74229. */
  74230. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  74231. /**
  74232. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  74233. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  74234. */
  74235. static readonly FILTER_POISSONSAMPLING: number;
  74236. /**
  74237. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  74238. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74239. */
  74240. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  74241. /**
  74242. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  74243. * edge artifacts on steep falloff.
  74244. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74245. */
  74246. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  74247. /**
  74248. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  74249. * edge artifacts on steep falloff.
  74250. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74251. */
  74252. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  74253. /**
  74254. * Shadow generator mode PCF: Percentage Closer Filtering
  74255. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74256. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  74257. */
  74258. static readonly FILTER_PCF: number;
  74259. /**
  74260. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  74261. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74262. * Contact Hardening
  74263. */
  74264. static readonly FILTER_PCSS: number;
  74265. /**
  74266. * Reserved for PCF and PCSS
  74267. * Highest Quality.
  74268. *
  74269. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  74270. *
  74271. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  74272. */
  74273. static readonly QUALITY_HIGH: number;
  74274. /**
  74275. * Reserved for PCF and PCSS
  74276. * Good tradeoff for quality/perf cross devices
  74277. *
  74278. * Execute PCF on a 3*3 kernel.
  74279. *
  74280. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  74281. */
  74282. static readonly QUALITY_MEDIUM: number;
  74283. /**
  74284. * Reserved for PCF and PCSS
  74285. * The lowest quality but the fastest.
  74286. *
  74287. * Execute PCF on a 1*1 kernel.
  74288. *
  74289. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  74290. */
  74291. static readonly QUALITY_LOW: number;
  74292. /** Gets or sets the custom shader name to use */
  74293. customShaderOptions: ICustomShaderOptions;
  74294. /**
  74295. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  74296. */
  74297. onBeforeShadowMapRenderObservable: Observable<Effect>;
  74298. /**
  74299. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  74300. */
  74301. onAfterShadowMapRenderObservable: Observable<Effect>;
  74302. /**
  74303. * Observable triggered before a mesh is rendered in the shadow map.
  74304. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  74305. */
  74306. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  74307. /**
  74308. * Observable triggered after a mesh is rendered in the shadow map.
  74309. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  74310. */
  74311. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  74312. private _bias;
  74313. /**
  74314. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  74315. */
  74316. /**
  74317. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  74318. */
  74319. bias: number;
  74320. private _normalBias;
  74321. /**
  74322. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74323. */
  74324. /**
  74325. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74326. */
  74327. normalBias: number;
  74328. private _blurBoxOffset;
  74329. /**
  74330. * Gets the blur box offset: offset applied during the blur pass.
  74331. * Only useful if useKernelBlur = false
  74332. */
  74333. /**
  74334. * Sets the blur box offset: offset applied during the blur pass.
  74335. * Only useful if useKernelBlur = false
  74336. */
  74337. blurBoxOffset: number;
  74338. private _blurScale;
  74339. /**
  74340. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  74341. * 2 means half of the size.
  74342. */
  74343. /**
  74344. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  74345. * 2 means half of the size.
  74346. */
  74347. blurScale: number;
  74348. private _blurKernel;
  74349. /**
  74350. * Gets the blur kernel: kernel size of the blur pass.
  74351. * Only useful if useKernelBlur = true
  74352. */
  74353. /**
  74354. * Sets the blur kernel: kernel size of the blur pass.
  74355. * Only useful if useKernelBlur = true
  74356. */
  74357. blurKernel: number;
  74358. private _useKernelBlur;
  74359. /**
  74360. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  74361. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74362. */
  74363. /**
  74364. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74365. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74366. */
  74367. useKernelBlur: boolean;
  74368. private _depthScale;
  74369. /**
  74370. * Gets the depth scale used in ESM mode.
  74371. */
  74372. /**
  74373. * Sets the depth scale used in ESM mode.
  74374. * This can override the scale stored on the light.
  74375. */
  74376. depthScale: number;
  74377. private _filter;
  74378. /**
  74379. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74380. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74381. */
  74382. /**
  74383. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74384. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74385. */
  74386. filter: number;
  74387. /**
  74388. * Gets if the current filter is set to Poisson Sampling.
  74389. */
  74390. /**
  74391. * Sets the current filter to Poisson Sampling.
  74392. */
  74393. usePoissonSampling: boolean;
  74394. /**
  74395. * Gets if the current filter is set to ESM.
  74396. */
  74397. /**
  74398. * Sets the current filter is to ESM.
  74399. */
  74400. useExponentialShadowMap: boolean;
  74401. /**
  74402. * Gets if the current filter is set to filtered ESM.
  74403. */
  74404. /**
  74405. * Gets if the current filter is set to filtered ESM.
  74406. */
  74407. useBlurExponentialShadowMap: boolean;
  74408. /**
  74409. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74410. * exponential to prevent steep falloff artifacts).
  74411. */
  74412. /**
  74413. * Sets the current filter to "close ESM" (using the inverse of the
  74414. * exponential to prevent steep falloff artifacts).
  74415. */
  74416. useCloseExponentialShadowMap: boolean;
  74417. /**
  74418. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74419. * exponential to prevent steep falloff artifacts).
  74420. */
  74421. /**
  74422. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74423. * exponential to prevent steep falloff artifacts).
  74424. */
  74425. useBlurCloseExponentialShadowMap: boolean;
  74426. /**
  74427. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74428. */
  74429. /**
  74430. * Sets the current filter to "PCF" (percentage closer filtering).
  74431. */
  74432. usePercentageCloserFiltering: boolean;
  74433. private _filteringQuality;
  74434. /**
  74435. * Gets the PCF or PCSS Quality.
  74436. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74437. */
  74438. /**
  74439. * Sets the PCF or PCSS Quality.
  74440. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74441. */
  74442. filteringQuality: number;
  74443. /**
  74444. * Gets if the current filter is set to "PCSS" (contact hardening).
  74445. */
  74446. /**
  74447. * Sets the current filter to "PCSS" (contact hardening).
  74448. */
  74449. useContactHardeningShadow: boolean;
  74450. private _contactHardeningLightSizeUVRatio;
  74451. /**
  74452. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74453. * Using a ratio helps keeping shape stability independently of the map size.
  74454. *
  74455. * It does not account for the light projection as it was having too much
  74456. * instability during the light setup or during light position changes.
  74457. *
  74458. * Only valid if useContactHardeningShadow is true.
  74459. */
  74460. /**
  74461. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74462. * Using a ratio helps keeping shape stability independently of the map size.
  74463. *
  74464. * It does not account for the light projection as it was having too much
  74465. * instability during the light setup or during light position changes.
  74466. *
  74467. * Only valid if useContactHardeningShadow is true.
  74468. */
  74469. contactHardeningLightSizeUVRatio: number;
  74470. private _darkness;
  74471. /** Gets or sets the actual darkness of a shadow */
  74472. darkness: number;
  74473. /**
  74474. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74475. * 0 means strongest and 1 would means no shadow.
  74476. * @returns the darkness.
  74477. */
  74478. getDarkness(): number;
  74479. /**
  74480. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74481. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74482. * @returns the shadow generator allowing fluent coding.
  74483. */
  74484. setDarkness(darkness: number): ShadowGenerator;
  74485. private _transparencyShadow;
  74486. /** Gets or sets the ability to have transparent shadow */
  74487. transparencyShadow: boolean;
  74488. /**
  74489. * Sets the ability to have transparent shadow (boolean).
  74490. * @param transparent True if transparent else False
  74491. * @returns the shadow generator allowing fluent coding
  74492. */
  74493. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74494. private _shadowMap;
  74495. private _shadowMap2;
  74496. /**
  74497. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74498. * @returns The render target texture if present otherwise, null
  74499. */
  74500. getShadowMap(): Nullable<RenderTargetTexture>;
  74501. /**
  74502. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74503. * @returns The render target texture if the shadow map is present otherwise, null
  74504. */
  74505. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74506. /**
  74507. * Gets the class name of that object
  74508. * @returns "ShadowGenerator"
  74509. */
  74510. getClassName(): string;
  74511. /**
  74512. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74513. * @param mesh Mesh to add
  74514. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74515. * @returns the Shadow Generator itself
  74516. */
  74517. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74518. /**
  74519. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74520. * @param mesh Mesh to remove
  74521. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74522. * @returns the Shadow Generator itself
  74523. */
  74524. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74525. /**
  74526. * Controls the extent to which the shadows fade out at the edge of the frustum
  74527. * Used only by directionals and spots
  74528. */
  74529. frustumEdgeFalloff: number;
  74530. private _light;
  74531. /**
  74532. * Returns the associated light object.
  74533. * @returns the light generating the shadow
  74534. */
  74535. getLight(): IShadowLight;
  74536. /**
  74537. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74538. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74539. * It might on the other hand introduce peter panning.
  74540. */
  74541. forceBackFacesOnly: boolean;
  74542. private _scene;
  74543. private _lightDirection;
  74544. private _effect;
  74545. private _viewMatrix;
  74546. private _projectionMatrix;
  74547. private _transformMatrix;
  74548. private _cachedPosition;
  74549. private _cachedDirection;
  74550. private _cachedDefines;
  74551. private _currentRenderID;
  74552. private _boxBlurPostprocess;
  74553. private _kernelBlurXPostprocess;
  74554. private _kernelBlurYPostprocess;
  74555. private _blurPostProcesses;
  74556. private _mapSize;
  74557. private _currentFaceIndex;
  74558. private _currentFaceIndexCache;
  74559. private _textureType;
  74560. private _defaultTextureMatrix;
  74561. /** @hidden */
  74562. static _SceneComponentInitialization: (scene: Scene) => void;
  74563. /**
  74564. * Creates a ShadowGenerator object.
  74565. * A ShadowGenerator is the required tool to use the shadows.
  74566. * Each light casting shadows needs to use its own ShadowGenerator.
  74567. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74568. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74569. * @param light The light object generating the shadows.
  74570. * @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.
  74571. */
  74572. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74573. private _initializeGenerator;
  74574. private _initializeShadowMap;
  74575. private _initializeBlurRTTAndPostProcesses;
  74576. private _renderForShadowMap;
  74577. private _renderSubMeshForShadowMap;
  74578. private _applyFilterValues;
  74579. /**
  74580. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74581. * @param onCompiled Callback triggered at the and of the effects compilation
  74582. * @param options Sets of optional options forcing the compilation with different modes
  74583. */
  74584. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74585. useInstances: boolean;
  74586. }>): void;
  74587. /**
  74588. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74589. * @param options Sets of optional options forcing the compilation with different modes
  74590. * @returns A promise that resolves when the compilation completes
  74591. */
  74592. forceCompilationAsync(options?: Partial<{
  74593. useInstances: boolean;
  74594. }>): Promise<void>;
  74595. /**
  74596. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74597. * @param subMesh The submesh we want to render in the shadow map
  74598. * @param useInstances Defines wether will draw in the map using instances
  74599. * @returns true if ready otherwise, false
  74600. */
  74601. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74602. /**
  74603. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74604. * @param defines Defines of the material we want to update
  74605. * @param lightIndex Index of the light in the enabled light list of the material
  74606. */
  74607. prepareDefines(defines: any, lightIndex: number): void;
  74608. /**
  74609. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74610. * defined in the generator but impacting the effect).
  74611. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74612. * @param effect The effect we are binfing the information for
  74613. */
  74614. bindShadowLight(lightIndex: string, effect: Effect): void;
  74615. /**
  74616. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74617. * (eq to shadow prjection matrix * light transform matrix)
  74618. * @returns The transform matrix used to create the shadow map
  74619. */
  74620. getTransformMatrix(): Matrix;
  74621. /**
  74622. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74623. * Cube and 2D textures for instance.
  74624. */
  74625. recreateShadowMap(): void;
  74626. private _disposeBlurPostProcesses;
  74627. private _disposeRTTandPostProcesses;
  74628. /**
  74629. * Disposes the ShadowGenerator.
  74630. * Returns nothing.
  74631. */
  74632. dispose(): void;
  74633. /**
  74634. * Serializes the shadow generator setup to a json object.
  74635. * @returns The serialized JSON object
  74636. */
  74637. serialize(): any;
  74638. /**
  74639. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74640. * @param parsedShadowGenerator The JSON object to parse
  74641. * @param scene The scene to create the shadow map for
  74642. * @returns The parsed shadow generator
  74643. */
  74644. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74645. }
  74646. }
  74647. declare module BABYLON {
  74648. /**
  74649. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74650. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74651. * 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.
  74652. */
  74653. export abstract class Light extends Node {
  74654. /**
  74655. * Falloff Default: light is falling off following the material specification:
  74656. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74657. */
  74658. static readonly FALLOFF_DEFAULT: number;
  74659. /**
  74660. * Falloff Physical: light is falling off following the inverse squared distance law.
  74661. */
  74662. static readonly FALLOFF_PHYSICAL: number;
  74663. /**
  74664. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74665. * to enhance interoperability with other engines.
  74666. */
  74667. static readonly FALLOFF_GLTF: number;
  74668. /**
  74669. * Falloff Standard: light is falling off like in the standard material
  74670. * to enhance interoperability with other materials.
  74671. */
  74672. static readonly FALLOFF_STANDARD: number;
  74673. /**
  74674. * If every light affecting the material is in this lightmapMode,
  74675. * material.lightmapTexture adds or multiplies
  74676. * (depends on material.useLightmapAsShadowmap)
  74677. * after every other light calculations.
  74678. */
  74679. static readonly LIGHTMAP_DEFAULT: number;
  74680. /**
  74681. * material.lightmapTexture as only diffuse lighting from this light
  74682. * adds only specular lighting from this light
  74683. * adds dynamic shadows
  74684. */
  74685. static readonly LIGHTMAP_SPECULAR: number;
  74686. /**
  74687. * material.lightmapTexture as only lighting
  74688. * no light calculation from this light
  74689. * only adds dynamic shadows from this light
  74690. */
  74691. static readonly LIGHTMAP_SHADOWSONLY: number;
  74692. /**
  74693. * Each light type uses the default quantity according to its type:
  74694. * point/spot lights use luminous intensity
  74695. * directional lights use illuminance
  74696. */
  74697. static readonly INTENSITYMODE_AUTOMATIC: number;
  74698. /**
  74699. * lumen (lm)
  74700. */
  74701. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74702. /**
  74703. * candela (lm/sr)
  74704. */
  74705. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74706. /**
  74707. * lux (lm/m^2)
  74708. */
  74709. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74710. /**
  74711. * nit (cd/m^2)
  74712. */
  74713. static readonly INTENSITYMODE_LUMINANCE: number;
  74714. /**
  74715. * Light type const id of the point light.
  74716. */
  74717. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74718. /**
  74719. * Light type const id of the directional light.
  74720. */
  74721. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74722. /**
  74723. * Light type const id of the spot light.
  74724. */
  74725. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74726. /**
  74727. * Light type const id of the hemispheric light.
  74728. */
  74729. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74730. /**
  74731. * Diffuse gives the basic color to an object.
  74732. */
  74733. diffuse: Color3;
  74734. /**
  74735. * Specular produces a highlight color on an object.
  74736. * Note: This is note affecting PBR materials.
  74737. */
  74738. specular: Color3;
  74739. /**
  74740. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74741. * falling off base on range or angle.
  74742. * This can be set to any values in Light.FALLOFF_x.
  74743. *
  74744. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74745. * other types of materials.
  74746. */
  74747. falloffType: number;
  74748. /**
  74749. * Strength of the light.
  74750. * Note: By default it is define in the framework own unit.
  74751. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74752. */
  74753. intensity: number;
  74754. private _range;
  74755. protected _inverseSquaredRange: number;
  74756. /**
  74757. * Defines how far from the source the light is impacting in scene units.
  74758. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74759. */
  74760. /**
  74761. * Defines how far from the source the light is impacting in scene units.
  74762. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74763. */
  74764. range: number;
  74765. /**
  74766. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74767. * of light.
  74768. */
  74769. private _photometricScale;
  74770. private _intensityMode;
  74771. /**
  74772. * Gets the photometric scale used to interpret the intensity.
  74773. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74774. */
  74775. /**
  74776. * Sets the photometric scale used to interpret the intensity.
  74777. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74778. */
  74779. intensityMode: number;
  74780. private _radius;
  74781. /**
  74782. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74783. */
  74784. /**
  74785. * sets the light radius used by PBR Materials to simulate soft area lights.
  74786. */
  74787. radius: number;
  74788. private _renderPriority;
  74789. /**
  74790. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74791. * exceeding the number allowed of the materials.
  74792. */
  74793. renderPriority: number;
  74794. private _shadowEnabled;
  74795. /**
  74796. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74797. * the current shadow generator.
  74798. */
  74799. /**
  74800. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74801. * the current shadow generator.
  74802. */
  74803. shadowEnabled: boolean;
  74804. private _includedOnlyMeshes;
  74805. /**
  74806. * Gets the only meshes impacted by this light.
  74807. */
  74808. /**
  74809. * Sets the only meshes impacted by this light.
  74810. */
  74811. includedOnlyMeshes: AbstractMesh[];
  74812. private _excludedMeshes;
  74813. /**
  74814. * Gets the meshes not impacted by this light.
  74815. */
  74816. /**
  74817. * Sets the meshes not impacted by this light.
  74818. */
  74819. excludedMeshes: AbstractMesh[];
  74820. private _excludeWithLayerMask;
  74821. /**
  74822. * Gets the layer id use to find what meshes are not impacted by the light.
  74823. * Inactive if 0
  74824. */
  74825. /**
  74826. * Sets the layer id use to find what meshes are not impacted by the light.
  74827. * Inactive if 0
  74828. */
  74829. excludeWithLayerMask: number;
  74830. private _includeOnlyWithLayerMask;
  74831. /**
  74832. * Gets the layer id use to find what meshes are impacted by the light.
  74833. * Inactive if 0
  74834. */
  74835. /**
  74836. * Sets the layer id use to find what meshes are impacted by the light.
  74837. * Inactive if 0
  74838. */
  74839. includeOnlyWithLayerMask: number;
  74840. private _lightmapMode;
  74841. /**
  74842. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74843. */
  74844. /**
  74845. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74846. */
  74847. lightmapMode: number;
  74848. /**
  74849. * Shadow generator associted to the light.
  74850. * @hidden Internal use only.
  74851. */
  74852. _shadowGenerator: Nullable<IShadowGenerator>;
  74853. /**
  74854. * @hidden Internal use only.
  74855. */
  74856. _excludedMeshesIds: string[];
  74857. /**
  74858. * @hidden Internal use only.
  74859. */
  74860. _includedOnlyMeshesIds: string[];
  74861. /**
  74862. * The current light unifom buffer.
  74863. * @hidden Internal use only.
  74864. */
  74865. _uniformBuffer: UniformBuffer;
  74866. /**
  74867. * Creates a Light object in the scene.
  74868. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74869. * @param name The firendly name of the light
  74870. * @param scene The scene the light belongs too
  74871. */
  74872. constructor(name: string, scene: Scene);
  74873. protected abstract _buildUniformLayout(): void;
  74874. /**
  74875. * Sets the passed Effect "effect" with the Light information.
  74876. * @param effect The effect to update
  74877. * @param lightIndex The index of the light in the effect to update
  74878. * @returns The light
  74879. */
  74880. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74881. /**
  74882. * Returns the string "Light".
  74883. * @returns the class name
  74884. */
  74885. getClassName(): string;
  74886. /** @hidden */
  74887. readonly _isLight: boolean;
  74888. /**
  74889. * Converts the light information to a readable string for debug purpose.
  74890. * @param fullDetails Supports for multiple levels of logging within scene loading
  74891. * @returns the human readable light info
  74892. */
  74893. toString(fullDetails?: boolean): string;
  74894. /** @hidden */
  74895. protected _syncParentEnabledState(): void;
  74896. /**
  74897. * Set the enabled state of this node.
  74898. * @param value - the new enabled state
  74899. */
  74900. setEnabled(value: boolean): void;
  74901. /**
  74902. * Returns the Light associated shadow generator if any.
  74903. * @return the associated shadow generator.
  74904. */
  74905. getShadowGenerator(): Nullable<IShadowGenerator>;
  74906. /**
  74907. * Returns a Vector3, the absolute light position in the World.
  74908. * @returns the world space position of the light
  74909. */
  74910. getAbsolutePosition(): Vector3;
  74911. /**
  74912. * Specifies if the light will affect the passed mesh.
  74913. * @param mesh The mesh to test against the light
  74914. * @return true the mesh is affected otherwise, false.
  74915. */
  74916. canAffectMesh(mesh: AbstractMesh): boolean;
  74917. /**
  74918. * Sort function to order lights for rendering.
  74919. * @param a First Light object to compare to second.
  74920. * @param b Second Light object to compare first.
  74921. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74922. */
  74923. static CompareLightsPriority(a: Light, b: Light): number;
  74924. /**
  74925. * Releases resources associated with this node.
  74926. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74927. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74928. */
  74929. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74930. /**
  74931. * Returns the light type ID (integer).
  74932. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74933. */
  74934. getTypeID(): number;
  74935. /**
  74936. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74937. * @returns the scaled intensity in intensity mode unit
  74938. */
  74939. getScaledIntensity(): number;
  74940. /**
  74941. * Returns a new Light object, named "name", from the current one.
  74942. * @param name The name of the cloned light
  74943. * @returns the new created light
  74944. */
  74945. clone(name: string): Nullable<Light>;
  74946. /**
  74947. * Serializes the current light into a Serialization object.
  74948. * @returns the serialized object.
  74949. */
  74950. serialize(): any;
  74951. /**
  74952. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74953. * This new light is named "name" and added to the passed scene.
  74954. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74955. * @param name The friendly name of the light
  74956. * @param scene The scene the new light will belong to
  74957. * @returns the constructor function
  74958. */
  74959. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74960. /**
  74961. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74962. * @param parsedLight The JSON representation of the light
  74963. * @param scene The scene to create the parsed light in
  74964. * @returns the created light after parsing
  74965. */
  74966. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74967. private _hookArrayForExcluded;
  74968. private _hookArrayForIncludedOnly;
  74969. private _resyncMeshes;
  74970. /**
  74971. * Forces the meshes to update their light related information in their rendering used effects
  74972. * @hidden Internal Use Only
  74973. */
  74974. _markMeshesAsLightDirty(): void;
  74975. /**
  74976. * Recomputes the cached photometric scale if needed.
  74977. */
  74978. private _computePhotometricScale;
  74979. /**
  74980. * Returns the Photometric Scale according to the light type and intensity mode.
  74981. */
  74982. private _getPhotometricScale;
  74983. /**
  74984. * Reorder the light in the scene according to their defined priority.
  74985. * @hidden Internal Use Only
  74986. */
  74987. _reorderLightsInScene(): void;
  74988. /**
  74989. * Prepares the list of defines specific to the light type.
  74990. * @param defines the list of defines
  74991. * @param lightIndex defines the index of the light for the effect
  74992. */
  74993. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74994. }
  74995. }
  74996. declare module BABYLON {
  74997. /**
  74998. * Creates an instance based on a source mesh.
  74999. */
  75000. export class InstancedMesh extends AbstractMesh {
  75001. private _sourceMesh;
  75002. private _currentLOD;
  75003. /** @hidden */
  75004. _indexInSourceMeshInstanceArray: number;
  75005. constructor(name: string, source: Mesh);
  75006. /**
  75007. * Returns the string "InstancedMesh".
  75008. */
  75009. getClassName(): string;
  75010. /** Gets the list of lights affecting that mesh */
  75011. readonly lightSources: Light[];
  75012. _resyncLightSources(): void;
  75013. _resyncLighSource(light: Light): void;
  75014. _removeLightSource(light: Light): void;
  75015. /**
  75016. * If the source mesh receives shadows
  75017. */
  75018. readonly receiveShadows: boolean;
  75019. /**
  75020. * The material of the source mesh
  75021. */
  75022. readonly material: Nullable<Material>;
  75023. /**
  75024. * Visibility of the source mesh
  75025. */
  75026. readonly visibility: number;
  75027. /**
  75028. * Skeleton of the source mesh
  75029. */
  75030. readonly skeleton: Nullable<Skeleton>;
  75031. /**
  75032. * Rendering ground id of the source mesh
  75033. */
  75034. renderingGroupId: number;
  75035. /**
  75036. * Returns the total number of vertices (integer).
  75037. */
  75038. getTotalVertices(): number;
  75039. /**
  75040. * Returns a positive integer : the total number of indices in this mesh geometry.
  75041. * @returns the numner of indices or zero if the mesh has no geometry.
  75042. */
  75043. getTotalIndices(): number;
  75044. /**
  75045. * The source mesh of the instance
  75046. */
  75047. readonly sourceMesh: Mesh;
  75048. /**
  75049. * Is this node ready to be used/rendered
  75050. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75051. * @return {boolean} is it ready
  75052. */
  75053. isReady(completeCheck?: boolean): boolean;
  75054. /**
  75055. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75056. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75057. * @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.
  75058. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75059. */
  75060. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75061. /**
  75062. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75063. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75064. * The `data` are either a numeric array either a Float32Array.
  75065. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75066. * 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).
  75067. * Note that a new underlying VertexBuffer object is created each call.
  75068. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75069. *
  75070. * Possible `kind` values :
  75071. * - VertexBuffer.PositionKind
  75072. * - VertexBuffer.UVKind
  75073. * - VertexBuffer.UV2Kind
  75074. * - VertexBuffer.UV3Kind
  75075. * - VertexBuffer.UV4Kind
  75076. * - VertexBuffer.UV5Kind
  75077. * - VertexBuffer.UV6Kind
  75078. * - VertexBuffer.ColorKind
  75079. * - VertexBuffer.MatricesIndicesKind
  75080. * - VertexBuffer.MatricesIndicesExtraKind
  75081. * - VertexBuffer.MatricesWeightsKind
  75082. * - VertexBuffer.MatricesWeightsExtraKind
  75083. *
  75084. * Returns the Mesh.
  75085. */
  75086. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75087. /**
  75088. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75089. * If the mesh has no geometry, it is simply returned as it is.
  75090. * The `data` are either a numeric array either a Float32Array.
  75091. * No new underlying VertexBuffer object is created.
  75092. * 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.
  75093. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75094. *
  75095. * Possible `kind` values :
  75096. * - VertexBuffer.PositionKind
  75097. * - VertexBuffer.UVKind
  75098. * - VertexBuffer.UV2Kind
  75099. * - VertexBuffer.UV3Kind
  75100. * - VertexBuffer.UV4Kind
  75101. * - VertexBuffer.UV5Kind
  75102. * - VertexBuffer.UV6Kind
  75103. * - VertexBuffer.ColorKind
  75104. * - VertexBuffer.MatricesIndicesKind
  75105. * - VertexBuffer.MatricesIndicesExtraKind
  75106. * - VertexBuffer.MatricesWeightsKind
  75107. * - VertexBuffer.MatricesWeightsExtraKind
  75108. *
  75109. * Returns the Mesh.
  75110. */
  75111. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75112. /**
  75113. * Sets the mesh indices.
  75114. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  75115. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  75116. * This method creates a new index buffer each call.
  75117. * Returns the Mesh.
  75118. */
  75119. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  75120. /**
  75121. * Boolean : True if the mesh owns the requested kind of data.
  75122. */
  75123. isVerticesDataPresent(kind: string): boolean;
  75124. /**
  75125. * Returns an array of indices (IndicesArray).
  75126. */
  75127. getIndices(): Nullable<IndicesArray>;
  75128. readonly _positions: Nullable<Vector3[]>;
  75129. /**
  75130. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75131. * This means the mesh underlying bounding box and sphere are recomputed.
  75132. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75133. * @returns the current mesh
  75134. */
  75135. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  75136. /** @hidden */
  75137. _preActivate(): InstancedMesh;
  75138. /** @hidden */
  75139. _activate(renderId: number, intermediateRendering: boolean): boolean;
  75140. /** @hidden */
  75141. _postActivate(): void;
  75142. getWorldMatrix(): Matrix;
  75143. readonly isAnInstance: boolean;
  75144. /**
  75145. * Returns the current associated LOD AbstractMesh.
  75146. */
  75147. getLOD(camera: Camera): AbstractMesh;
  75148. /** @hidden */
  75149. _syncSubMeshes(): InstancedMesh;
  75150. /** @hidden */
  75151. _generatePointsArray(): boolean;
  75152. /**
  75153. * Creates a new InstancedMesh from the current mesh.
  75154. * - name (string) : the cloned mesh name
  75155. * - newParent (optional Node) : the optional Node to parent the clone to.
  75156. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  75157. *
  75158. * Returns the clone.
  75159. */
  75160. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  75161. /**
  75162. * Disposes the InstancedMesh.
  75163. * Returns nothing.
  75164. */
  75165. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75166. }
  75167. }
  75168. declare module BABYLON {
  75169. /**
  75170. * Defines the options associated with the creation of a shader material.
  75171. */
  75172. export interface IShaderMaterialOptions {
  75173. /**
  75174. * Does the material work in alpha blend mode
  75175. */
  75176. needAlphaBlending: boolean;
  75177. /**
  75178. * Does the material work in alpha test mode
  75179. */
  75180. needAlphaTesting: boolean;
  75181. /**
  75182. * The list of attribute names used in the shader
  75183. */
  75184. attributes: string[];
  75185. /**
  75186. * The list of unifrom names used in the shader
  75187. */
  75188. uniforms: string[];
  75189. /**
  75190. * The list of UBO names used in the shader
  75191. */
  75192. uniformBuffers: string[];
  75193. /**
  75194. * The list of sampler names used in the shader
  75195. */
  75196. samplers: string[];
  75197. /**
  75198. * The list of defines used in the shader
  75199. */
  75200. defines: string[];
  75201. }
  75202. /**
  75203. * 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.
  75204. *
  75205. * This returned material effects how the mesh will look based on the code in the shaders.
  75206. *
  75207. * @see http://doc.babylonjs.com/how_to/shader_material
  75208. */
  75209. export class ShaderMaterial extends Material {
  75210. private _shaderPath;
  75211. private _options;
  75212. private _textures;
  75213. private _textureArrays;
  75214. private _floats;
  75215. private _ints;
  75216. private _floatsArrays;
  75217. private _colors3;
  75218. private _colors3Arrays;
  75219. private _colors4;
  75220. private _colors4Arrays;
  75221. private _vectors2;
  75222. private _vectors3;
  75223. private _vectors4;
  75224. private _matrices;
  75225. private _matrices3x3;
  75226. private _matrices2x2;
  75227. private _vectors2Arrays;
  75228. private _vectors3Arrays;
  75229. private _vectors4Arrays;
  75230. private _cachedWorldViewMatrix;
  75231. private _cachedWorldViewProjectionMatrix;
  75232. private _renderId;
  75233. /**
  75234. * Instantiate a new shader material.
  75235. * 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.
  75236. * This returned material effects how the mesh will look based on the code in the shaders.
  75237. * @see http://doc.babylonjs.com/how_to/shader_material
  75238. * @param name Define the name of the material in the scene
  75239. * @param scene Define the scene the material belongs to
  75240. * @param shaderPath Defines the route to the shader code in one of three ways:
  75241. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  75242. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  75243. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  75244. * @param options Define the options used to create the shader
  75245. */
  75246. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  75247. /**
  75248. * Gets the options used to compile the shader.
  75249. * They can be modified to trigger a new compilation
  75250. */
  75251. readonly options: IShaderMaterialOptions;
  75252. /**
  75253. * Gets the current class name of the material e.g. "ShaderMaterial"
  75254. * Mainly use in serialization.
  75255. * @returns the class name
  75256. */
  75257. getClassName(): string;
  75258. /**
  75259. * Specifies if the material will require alpha blending
  75260. * @returns a boolean specifying if alpha blending is needed
  75261. */
  75262. needAlphaBlending(): boolean;
  75263. /**
  75264. * Specifies if this material should be rendered in alpha test mode
  75265. * @returns a boolean specifying if an alpha test is needed.
  75266. */
  75267. needAlphaTesting(): boolean;
  75268. private _checkUniform;
  75269. /**
  75270. * Set a texture in the shader.
  75271. * @param name Define the name of the uniform samplers as defined in the shader
  75272. * @param texture Define the texture to bind to this sampler
  75273. * @return the material itself allowing "fluent" like uniform updates
  75274. */
  75275. setTexture(name: string, texture: Texture): ShaderMaterial;
  75276. /**
  75277. * Set a texture array in the shader.
  75278. * @param name Define the name of the uniform sampler array as defined in the shader
  75279. * @param textures Define the list of textures to bind to this sampler
  75280. * @return the material itself allowing "fluent" like uniform updates
  75281. */
  75282. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  75283. /**
  75284. * Set a float in the shader.
  75285. * @param name Define the name of the uniform as defined in the shader
  75286. * @param value Define the value to give to the uniform
  75287. * @return the material itself allowing "fluent" like uniform updates
  75288. */
  75289. setFloat(name: string, value: number): ShaderMaterial;
  75290. /**
  75291. * Set a int in the shader.
  75292. * @param name Define the name of the uniform as defined in the shader
  75293. * @param value Define the value to give to the uniform
  75294. * @return the material itself allowing "fluent" like uniform updates
  75295. */
  75296. setInt(name: string, value: number): ShaderMaterial;
  75297. /**
  75298. * Set an array of floats in the shader.
  75299. * @param name Define the name of the uniform as defined in the shader
  75300. * @param value Define the value to give to the uniform
  75301. * @return the material itself allowing "fluent" like uniform updates
  75302. */
  75303. setFloats(name: string, value: number[]): ShaderMaterial;
  75304. /**
  75305. * Set a vec3 in the shader from a Color3.
  75306. * @param name Define the name of the uniform as defined in the shader
  75307. * @param value Define the value to give to the uniform
  75308. * @return the material itself allowing "fluent" like uniform updates
  75309. */
  75310. setColor3(name: string, value: Color3): ShaderMaterial;
  75311. /**
  75312. * Set a vec3 array in the shader from a Color3 array.
  75313. * @param name Define the name of the uniform as defined in the shader
  75314. * @param value Define the value to give to the uniform
  75315. * @return the material itself allowing "fluent" like uniform updates
  75316. */
  75317. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75318. /**
  75319. * Set a vec4 in the shader from a Color4.
  75320. * @param name Define the name of the uniform as defined in the shader
  75321. * @param value Define the value to give to the uniform
  75322. * @return the material itself allowing "fluent" like uniform updates
  75323. */
  75324. setColor4(name: string, value: Color4): ShaderMaterial;
  75325. /**
  75326. * Set a vec4 array in the shader from a Color4 array.
  75327. * @param name Define the name of the uniform as defined in the shader
  75328. * @param value Define the value to give to the uniform
  75329. * @return the material itself allowing "fluent" like uniform updates
  75330. */
  75331. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  75332. /**
  75333. * Set a vec2 in the shader from a Vector2.
  75334. * @param name Define the name of the uniform as defined in the shader
  75335. * @param value Define the value to give to the uniform
  75336. * @return the material itself allowing "fluent" like uniform updates
  75337. */
  75338. setVector2(name: string, value: Vector2): ShaderMaterial;
  75339. /**
  75340. * Set a vec3 in the shader from a Vector3.
  75341. * @param name Define the name of the uniform as defined in the shader
  75342. * @param value Define the value to give to the uniform
  75343. * @return the material itself allowing "fluent" like uniform updates
  75344. */
  75345. setVector3(name: string, value: Vector3): ShaderMaterial;
  75346. /**
  75347. * Set a vec4 in the shader from a Vector4.
  75348. * @param name Define the name of the uniform as defined in the shader
  75349. * @param value Define the value to give to the uniform
  75350. * @return the material itself allowing "fluent" like uniform updates
  75351. */
  75352. setVector4(name: string, value: Vector4): ShaderMaterial;
  75353. /**
  75354. * Set a mat4 in the shader from a Matrix.
  75355. * @param name Define the name of the uniform as defined in the shader
  75356. * @param value Define the value to give to the uniform
  75357. * @return the material itself allowing "fluent" like uniform updates
  75358. */
  75359. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75360. /**
  75361. * Set a mat3 in the shader from a Float32Array.
  75362. * @param name Define the name of the uniform as defined in the shader
  75363. * @param value Define the value to give to the uniform
  75364. * @return the material itself allowing "fluent" like uniform updates
  75365. */
  75366. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75367. /**
  75368. * Set a mat2 in the shader from a Float32Array.
  75369. * @param name Define the name of the uniform as defined in the shader
  75370. * @param value Define the value to give to the uniform
  75371. * @return the material itself allowing "fluent" like uniform updates
  75372. */
  75373. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75374. /**
  75375. * Set a vec2 array in the shader from a number array.
  75376. * @param name Define the name of the uniform as defined in the shader
  75377. * @param value Define the value to give to the uniform
  75378. * @return the material itself allowing "fluent" like uniform updates
  75379. */
  75380. setArray2(name: string, value: number[]): ShaderMaterial;
  75381. /**
  75382. * Set a vec3 array in the shader from a number array.
  75383. * @param name Define the name of the uniform as defined in the shader
  75384. * @param value Define the value to give to the uniform
  75385. * @return the material itself allowing "fluent" like uniform updates
  75386. */
  75387. setArray3(name: string, value: number[]): ShaderMaterial;
  75388. /**
  75389. * Set a vec4 array in the shader from a number array.
  75390. * @param name Define the name of the uniform as defined in the shader
  75391. * @param value Define the value to give to the uniform
  75392. * @return the material itself allowing "fluent" like uniform updates
  75393. */
  75394. setArray4(name: string, value: number[]): ShaderMaterial;
  75395. private _checkCache;
  75396. /**
  75397. * Specifies that the submesh is ready to be used
  75398. * @param mesh defines the mesh to check
  75399. * @param subMesh defines which submesh to check
  75400. * @param useInstances specifies that instances should be used
  75401. * @returns a boolean indicating that the submesh is ready or not
  75402. */
  75403. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75404. /**
  75405. * Checks if the material is ready to render the requested mesh
  75406. * @param mesh Define the mesh to render
  75407. * @param useInstances Define whether or not the material is used with instances
  75408. * @returns true if ready, otherwise false
  75409. */
  75410. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75411. /**
  75412. * Binds the world matrix to the material
  75413. * @param world defines the world transformation matrix
  75414. */
  75415. bindOnlyWorldMatrix(world: Matrix): void;
  75416. /**
  75417. * Binds the material to the mesh
  75418. * @param world defines the world transformation matrix
  75419. * @param mesh defines the mesh to bind the material to
  75420. */
  75421. bind(world: Matrix, mesh?: Mesh): void;
  75422. /**
  75423. * Gets the active textures from the material
  75424. * @returns an array of textures
  75425. */
  75426. getActiveTextures(): BaseTexture[];
  75427. /**
  75428. * Specifies if the material uses a texture
  75429. * @param texture defines the texture to check against the material
  75430. * @returns a boolean specifying if the material uses the texture
  75431. */
  75432. hasTexture(texture: BaseTexture): boolean;
  75433. /**
  75434. * Makes a duplicate of the material, and gives it a new name
  75435. * @param name defines the new name for the duplicated material
  75436. * @returns the cloned material
  75437. */
  75438. clone(name: string): ShaderMaterial;
  75439. /**
  75440. * Disposes the material
  75441. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75442. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75443. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75444. */
  75445. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75446. /**
  75447. * Serializes this material in a JSON representation
  75448. * @returns the serialized material object
  75449. */
  75450. serialize(): any;
  75451. /**
  75452. * Creates a shader material from parsed shader material data
  75453. * @param source defines the JSON represnetation of the material
  75454. * @param scene defines the hosting scene
  75455. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75456. * @returns a new material
  75457. */
  75458. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75459. }
  75460. }
  75461. declare module BABYLON {
  75462. /** @hidden */
  75463. export var clipPlaneFragmentDeclaration: {
  75464. name: string;
  75465. shader: string;
  75466. };
  75467. }
  75468. declare module BABYLON {
  75469. /** @hidden */
  75470. export var clipPlaneFragment: {
  75471. name: string;
  75472. shader: string;
  75473. };
  75474. }
  75475. declare module BABYLON {
  75476. /** @hidden */
  75477. export var colorPixelShader: {
  75478. name: string;
  75479. shader: string;
  75480. };
  75481. }
  75482. declare module BABYLON {
  75483. /** @hidden */
  75484. export var clipPlaneVertexDeclaration: {
  75485. name: string;
  75486. shader: string;
  75487. };
  75488. }
  75489. declare module BABYLON {
  75490. /** @hidden */
  75491. export var clipPlaneVertex: {
  75492. name: string;
  75493. shader: string;
  75494. };
  75495. }
  75496. declare module BABYLON {
  75497. /** @hidden */
  75498. export var colorVertexShader: {
  75499. name: string;
  75500. shader: string;
  75501. };
  75502. }
  75503. declare module BABYLON {
  75504. /**
  75505. * Line mesh
  75506. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75507. */
  75508. export class LinesMesh extends Mesh {
  75509. /**
  75510. * If vertex color should be applied to the mesh
  75511. */
  75512. readonly useVertexColor?: boolean | undefined;
  75513. /**
  75514. * If vertex alpha should be applied to the mesh
  75515. */
  75516. readonly useVertexAlpha?: boolean | undefined;
  75517. /**
  75518. * Color of the line (Default: White)
  75519. */
  75520. color: Color3;
  75521. /**
  75522. * Alpha of the line (Default: 1)
  75523. */
  75524. alpha: number;
  75525. /**
  75526. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75527. * This margin is expressed in world space coordinates, so its value may vary.
  75528. * Default value is 0.1
  75529. */
  75530. intersectionThreshold: number;
  75531. private _colorShader;
  75532. private color4;
  75533. /**
  75534. * Creates a new LinesMesh
  75535. * @param name defines the name
  75536. * @param scene defines the hosting scene
  75537. * @param parent defines the parent mesh if any
  75538. * @param source defines the optional source LinesMesh used to clone data from
  75539. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75540. * When false, achieved by calling a clone(), also passing False.
  75541. * This will make creation of children, recursive.
  75542. * @param useVertexColor defines if this LinesMesh supports vertex color
  75543. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75544. */
  75545. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75546. /**
  75547. * If vertex color should be applied to the mesh
  75548. */
  75549. useVertexColor?: boolean | undefined,
  75550. /**
  75551. * If vertex alpha should be applied to the mesh
  75552. */
  75553. useVertexAlpha?: boolean | undefined);
  75554. private _addClipPlaneDefine;
  75555. private _removeClipPlaneDefine;
  75556. isReady(): boolean;
  75557. /**
  75558. * Returns the string "LineMesh"
  75559. */
  75560. getClassName(): string;
  75561. /**
  75562. * @hidden
  75563. */
  75564. /**
  75565. * @hidden
  75566. */
  75567. material: Material;
  75568. /**
  75569. * @hidden
  75570. */
  75571. readonly checkCollisions: boolean;
  75572. /** @hidden */
  75573. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75574. /** @hidden */
  75575. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75576. /**
  75577. * Disposes of the line mesh
  75578. * @param doNotRecurse If children should be disposed
  75579. */
  75580. dispose(doNotRecurse?: boolean): void;
  75581. /**
  75582. * Returns a new LineMesh object cloned from the current one.
  75583. */
  75584. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75585. /**
  75586. * Creates a new InstancedLinesMesh object from the mesh model.
  75587. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75588. * @param name defines the name of the new instance
  75589. * @returns a new InstancedLinesMesh
  75590. */
  75591. createInstance(name: string): InstancedLinesMesh;
  75592. }
  75593. /**
  75594. * Creates an instance based on a source LinesMesh
  75595. */
  75596. export class InstancedLinesMesh extends InstancedMesh {
  75597. /**
  75598. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75599. * This margin is expressed in world space coordinates, so its value may vary.
  75600. * Initilized with the intersectionThreshold value of the source LinesMesh
  75601. */
  75602. intersectionThreshold: number;
  75603. constructor(name: string, source: LinesMesh);
  75604. /**
  75605. * Returns the string "InstancedLinesMesh".
  75606. */
  75607. getClassName(): string;
  75608. }
  75609. }
  75610. declare module BABYLON {
  75611. /**
  75612. * Mesh representing the gorund
  75613. */
  75614. export class GroundMesh extends Mesh {
  75615. /** If octree should be generated */
  75616. generateOctree: boolean;
  75617. private _heightQuads;
  75618. /** @hidden */
  75619. _subdivisionsX: number;
  75620. /** @hidden */
  75621. _subdivisionsY: number;
  75622. /** @hidden */
  75623. _width: number;
  75624. /** @hidden */
  75625. _height: number;
  75626. /** @hidden */
  75627. _minX: number;
  75628. /** @hidden */
  75629. _maxX: number;
  75630. /** @hidden */
  75631. _minZ: number;
  75632. /** @hidden */
  75633. _maxZ: number;
  75634. constructor(name: string, scene: Scene);
  75635. /**
  75636. * "GroundMesh"
  75637. * @returns "GroundMesh"
  75638. */
  75639. getClassName(): string;
  75640. /**
  75641. * The minimum of x and y subdivisions
  75642. */
  75643. readonly subdivisions: number;
  75644. /**
  75645. * X subdivisions
  75646. */
  75647. readonly subdivisionsX: number;
  75648. /**
  75649. * Y subdivisions
  75650. */
  75651. readonly subdivisionsY: number;
  75652. /**
  75653. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75654. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75655. * @param chunksCount the number of subdivisions for x and y
  75656. * @param octreeBlocksSize (Default: 32)
  75657. */
  75658. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75659. /**
  75660. * Returns a height (y) value in the Worl system :
  75661. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75662. * @param x x coordinate
  75663. * @param z z coordinate
  75664. * @returns the ground y position if (x, z) are outside the ground surface.
  75665. */
  75666. getHeightAtCoordinates(x: number, z: number): number;
  75667. /**
  75668. * Returns a normalized vector (Vector3) orthogonal to the ground
  75669. * at the ground coordinates (x, z) expressed in the World system.
  75670. * @param x x coordinate
  75671. * @param z z coordinate
  75672. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75673. */
  75674. getNormalAtCoordinates(x: number, z: number): Vector3;
  75675. /**
  75676. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75677. * at the ground coordinates (x, z) expressed in the World system.
  75678. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75679. * @param x x coordinate
  75680. * @param z z coordinate
  75681. * @param ref vector to store the result
  75682. * @returns the GroundMesh.
  75683. */
  75684. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75685. /**
  75686. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75687. * if the ground has been updated.
  75688. * This can be used in the render loop.
  75689. * @returns the GroundMesh.
  75690. */
  75691. updateCoordinateHeights(): GroundMesh;
  75692. private _getFacetAt;
  75693. private _initHeightQuads;
  75694. private _computeHeightQuads;
  75695. /**
  75696. * Serializes this ground mesh
  75697. * @param serializationObject object to write serialization to
  75698. */
  75699. serialize(serializationObject: any): void;
  75700. /**
  75701. * Parses a serialized ground mesh
  75702. * @param parsedMesh the serialized mesh
  75703. * @param scene the scene to create the ground mesh in
  75704. * @returns the created ground mesh
  75705. */
  75706. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75707. }
  75708. }
  75709. declare module BABYLON {
  75710. /**
  75711. * Interface for Physics-Joint data
  75712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75713. */
  75714. export interface PhysicsJointData {
  75715. /**
  75716. * The main pivot of the joint
  75717. */
  75718. mainPivot?: Vector3;
  75719. /**
  75720. * The connected pivot of the joint
  75721. */
  75722. connectedPivot?: Vector3;
  75723. /**
  75724. * The main axis of the joint
  75725. */
  75726. mainAxis?: Vector3;
  75727. /**
  75728. * The connected axis of the joint
  75729. */
  75730. connectedAxis?: Vector3;
  75731. /**
  75732. * The collision of the joint
  75733. */
  75734. collision?: boolean;
  75735. /**
  75736. * Native Oimo/Cannon/Energy data
  75737. */
  75738. nativeParams?: any;
  75739. }
  75740. /**
  75741. * This is a holder class for the physics joint created by the physics plugin
  75742. * It holds a set of functions to control the underlying joint
  75743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75744. */
  75745. export class PhysicsJoint {
  75746. /**
  75747. * The type of the physics joint
  75748. */
  75749. type: number;
  75750. /**
  75751. * The data for the physics joint
  75752. */
  75753. jointData: PhysicsJointData;
  75754. private _physicsJoint;
  75755. protected _physicsPlugin: IPhysicsEnginePlugin;
  75756. /**
  75757. * Initializes the physics joint
  75758. * @param type The type of the physics joint
  75759. * @param jointData The data for the physics joint
  75760. */
  75761. constructor(
  75762. /**
  75763. * The type of the physics joint
  75764. */
  75765. type: number,
  75766. /**
  75767. * The data for the physics joint
  75768. */
  75769. jointData: PhysicsJointData);
  75770. /**
  75771. * Gets the physics joint
  75772. */
  75773. /**
  75774. * Sets the physics joint
  75775. */
  75776. physicsJoint: any;
  75777. /**
  75778. * Sets the physics plugin
  75779. */
  75780. physicsPlugin: IPhysicsEnginePlugin;
  75781. /**
  75782. * Execute a function that is physics-plugin specific.
  75783. * @param {Function} func the function that will be executed.
  75784. * It accepts two parameters: the physics world and the physics joint
  75785. */
  75786. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75787. /**
  75788. * Distance-Joint type
  75789. */
  75790. static DistanceJoint: number;
  75791. /**
  75792. * Hinge-Joint type
  75793. */
  75794. static HingeJoint: number;
  75795. /**
  75796. * Ball-and-Socket joint type
  75797. */
  75798. static BallAndSocketJoint: number;
  75799. /**
  75800. * Wheel-Joint type
  75801. */
  75802. static WheelJoint: number;
  75803. /**
  75804. * Slider-Joint type
  75805. */
  75806. static SliderJoint: number;
  75807. /**
  75808. * Prismatic-Joint type
  75809. */
  75810. static PrismaticJoint: number;
  75811. /**
  75812. * Universal-Joint type
  75813. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75814. */
  75815. static UniversalJoint: number;
  75816. /**
  75817. * Hinge-Joint 2 type
  75818. */
  75819. static Hinge2Joint: number;
  75820. /**
  75821. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75822. */
  75823. static PointToPointJoint: number;
  75824. /**
  75825. * Spring-Joint type
  75826. */
  75827. static SpringJoint: number;
  75828. /**
  75829. * Lock-Joint type
  75830. */
  75831. static LockJoint: number;
  75832. }
  75833. /**
  75834. * A class representing a physics distance joint
  75835. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75836. */
  75837. export class DistanceJoint extends PhysicsJoint {
  75838. /**
  75839. *
  75840. * @param jointData The data for the Distance-Joint
  75841. */
  75842. constructor(jointData: DistanceJointData);
  75843. /**
  75844. * Update the predefined distance.
  75845. * @param maxDistance The maximum preferred distance
  75846. * @param minDistance The minimum preferred distance
  75847. */
  75848. updateDistance(maxDistance: number, minDistance?: number): void;
  75849. }
  75850. /**
  75851. * Represents a Motor-Enabled Joint
  75852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75853. */
  75854. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75855. /**
  75856. * Initializes the Motor-Enabled Joint
  75857. * @param type The type of the joint
  75858. * @param jointData The physica joint data for the joint
  75859. */
  75860. constructor(type: number, jointData: PhysicsJointData);
  75861. /**
  75862. * Set the motor values.
  75863. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75864. * @param force the force to apply
  75865. * @param maxForce max force for this motor.
  75866. */
  75867. setMotor(force?: number, maxForce?: number): void;
  75868. /**
  75869. * Set the motor's limits.
  75870. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75871. * @param upperLimit The upper limit of the motor
  75872. * @param lowerLimit The lower limit of the motor
  75873. */
  75874. setLimit(upperLimit: number, lowerLimit?: number): void;
  75875. }
  75876. /**
  75877. * This class represents a single physics Hinge-Joint
  75878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75879. */
  75880. export class HingeJoint extends MotorEnabledJoint {
  75881. /**
  75882. * Initializes the Hinge-Joint
  75883. * @param jointData The joint data for the Hinge-Joint
  75884. */
  75885. constructor(jointData: PhysicsJointData);
  75886. /**
  75887. * Set the motor values.
  75888. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75889. * @param {number} force the force to apply
  75890. * @param {number} maxForce max force for this motor.
  75891. */
  75892. setMotor(force?: number, maxForce?: number): void;
  75893. /**
  75894. * Set the motor's limits.
  75895. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75896. * @param upperLimit The upper limit of the motor
  75897. * @param lowerLimit The lower limit of the motor
  75898. */
  75899. setLimit(upperLimit: number, lowerLimit?: number): void;
  75900. }
  75901. /**
  75902. * This class represents a dual hinge physics joint (same as wheel joint)
  75903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75904. */
  75905. export class Hinge2Joint extends MotorEnabledJoint {
  75906. /**
  75907. * Initializes the Hinge2-Joint
  75908. * @param jointData The joint data for the Hinge2-Joint
  75909. */
  75910. constructor(jointData: PhysicsJointData);
  75911. /**
  75912. * Set the motor values.
  75913. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75914. * @param {number} targetSpeed the speed the motor is to reach
  75915. * @param {number} maxForce max force for this motor.
  75916. * @param {motorIndex} the motor's index, 0 or 1.
  75917. */
  75918. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  75919. /**
  75920. * Set the motor limits.
  75921. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75922. * @param {number} upperLimit the upper limit
  75923. * @param {number} lowerLimit lower limit
  75924. * @param {motorIndex} the motor's index, 0 or 1.
  75925. */
  75926. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75927. }
  75928. /**
  75929. * Interface for a motor enabled joint
  75930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75931. */
  75932. export interface IMotorEnabledJoint {
  75933. /**
  75934. * Physics joint
  75935. */
  75936. physicsJoint: any;
  75937. /**
  75938. * Sets the motor of the motor-enabled joint
  75939. * @param force The force of the motor
  75940. * @param maxForce The maximum force of the motor
  75941. * @param motorIndex The index of the motor
  75942. */
  75943. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  75944. /**
  75945. * Sets the limit of the motor
  75946. * @param upperLimit The upper limit of the motor
  75947. * @param lowerLimit The lower limit of the motor
  75948. * @param motorIndex The index of the motor
  75949. */
  75950. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75951. }
  75952. /**
  75953. * Joint data for a Distance-Joint
  75954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75955. */
  75956. export interface DistanceJointData extends PhysicsJointData {
  75957. /**
  75958. * Max distance the 2 joint objects can be apart
  75959. */
  75960. maxDistance: number;
  75961. }
  75962. /**
  75963. * Joint data from a spring joint
  75964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75965. */
  75966. export interface SpringJointData extends PhysicsJointData {
  75967. /**
  75968. * Length of the spring
  75969. */
  75970. length: number;
  75971. /**
  75972. * Stiffness of the spring
  75973. */
  75974. stiffness: number;
  75975. /**
  75976. * Damping of the spring
  75977. */
  75978. damping: number;
  75979. /** this callback will be called when applying the force to the impostors. */
  75980. forceApplicationCallback: () => void;
  75981. }
  75982. }
  75983. declare module BABYLON {
  75984. /**
  75985. * Holds the data for the raycast result
  75986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75987. */
  75988. export class PhysicsRaycastResult {
  75989. private _hasHit;
  75990. private _hitDistance;
  75991. private _hitNormalWorld;
  75992. private _hitPointWorld;
  75993. private _rayFromWorld;
  75994. private _rayToWorld;
  75995. /**
  75996. * Gets if there was a hit
  75997. */
  75998. readonly hasHit: boolean;
  75999. /**
  76000. * Gets the distance from the hit
  76001. */
  76002. readonly hitDistance: number;
  76003. /**
  76004. * Gets the hit normal/direction in the world
  76005. */
  76006. readonly hitNormalWorld: Vector3;
  76007. /**
  76008. * Gets the hit point in the world
  76009. */
  76010. readonly hitPointWorld: Vector3;
  76011. /**
  76012. * Gets the ray "start point" of the ray in the world
  76013. */
  76014. readonly rayFromWorld: Vector3;
  76015. /**
  76016. * Gets the ray "end point" of the ray in the world
  76017. */
  76018. readonly rayToWorld: Vector3;
  76019. /**
  76020. * Sets the hit data (normal & point in world space)
  76021. * @param hitNormalWorld defines the normal in world space
  76022. * @param hitPointWorld defines the point in world space
  76023. */
  76024. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  76025. /**
  76026. * Sets the distance from the start point to the hit point
  76027. * @param distance
  76028. */
  76029. setHitDistance(distance: number): void;
  76030. /**
  76031. * Calculates the distance manually
  76032. */
  76033. calculateHitDistance(): void;
  76034. /**
  76035. * Resets all the values to default
  76036. * @param from The from point on world space
  76037. * @param to The to point on world space
  76038. */
  76039. reset(from?: Vector3, to?: Vector3): void;
  76040. }
  76041. /**
  76042. * Interface for the size containing width and height
  76043. */
  76044. interface IXYZ {
  76045. /**
  76046. * X
  76047. */
  76048. x: number;
  76049. /**
  76050. * Y
  76051. */
  76052. y: number;
  76053. /**
  76054. * Z
  76055. */
  76056. z: number;
  76057. }
  76058. }
  76059. declare module BABYLON {
  76060. /**
  76061. * Interface used to describe a physics joint
  76062. */
  76063. export interface PhysicsImpostorJoint {
  76064. /** Defines the main impostor to which the joint is linked */
  76065. mainImpostor: PhysicsImpostor;
  76066. /** Defines the impostor that is connected to the main impostor using this joint */
  76067. connectedImpostor: PhysicsImpostor;
  76068. /** Defines the joint itself */
  76069. joint: PhysicsJoint;
  76070. }
  76071. /** @hidden */
  76072. export interface IPhysicsEnginePlugin {
  76073. world: any;
  76074. name: string;
  76075. setGravity(gravity: Vector3): void;
  76076. setTimeStep(timeStep: number): void;
  76077. getTimeStep(): number;
  76078. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76079. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76080. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76081. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76082. removePhysicsBody(impostor: PhysicsImpostor): void;
  76083. generateJoint(joint: PhysicsImpostorJoint): void;
  76084. removeJoint(joint: PhysicsImpostorJoint): void;
  76085. isSupported(): boolean;
  76086. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76087. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76088. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76089. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76090. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76091. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76092. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76093. getBodyMass(impostor: PhysicsImpostor): number;
  76094. getBodyFriction(impostor: PhysicsImpostor): number;
  76095. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76096. getBodyRestitution(impostor: PhysicsImpostor): number;
  76097. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76098. getBodyPressure?(impostor: PhysicsImpostor): number;
  76099. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  76100. getBodyStiffness?(impostor: PhysicsImpostor): number;
  76101. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  76102. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  76103. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  76104. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  76105. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  76106. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  76107. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  76108. sleepBody(impostor: PhysicsImpostor): void;
  76109. wakeUpBody(impostor: PhysicsImpostor): void;
  76110. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  76111. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76112. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76113. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76114. getRadius(impostor: PhysicsImpostor): number;
  76115. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76116. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76117. dispose(): void;
  76118. }
  76119. /**
  76120. * Interface used to define a physics engine
  76121. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76122. */
  76123. export interface IPhysicsEngine {
  76124. /**
  76125. * Gets the gravity vector used by the simulation
  76126. */
  76127. gravity: Vector3;
  76128. /**
  76129. * Sets the gravity vector used by the simulation
  76130. * @param gravity defines the gravity vector to use
  76131. */
  76132. setGravity(gravity: Vector3): void;
  76133. /**
  76134. * Set the time step of the physics engine.
  76135. * Default is 1/60.
  76136. * To slow it down, enter 1/600 for example.
  76137. * To speed it up, 1/30
  76138. * @param newTimeStep the new timestep to apply to this world.
  76139. */
  76140. setTimeStep(newTimeStep: number): void;
  76141. /**
  76142. * Get the time step of the physics engine.
  76143. * @returns the current time step
  76144. */
  76145. getTimeStep(): number;
  76146. /**
  76147. * Release all resources
  76148. */
  76149. dispose(): void;
  76150. /**
  76151. * Gets the name of the current physics plugin
  76152. * @returns the name of the plugin
  76153. */
  76154. getPhysicsPluginName(): string;
  76155. /**
  76156. * Adding a new impostor for the impostor tracking.
  76157. * This will be done by the impostor itself.
  76158. * @param impostor the impostor to add
  76159. */
  76160. addImpostor(impostor: PhysicsImpostor): void;
  76161. /**
  76162. * Remove an impostor from the engine.
  76163. * This impostor and its mesh will not longer be updated by the physics engine.
  76164. * @param impostor the impostor to remove
  76165. */
  76166. removeImpostor(impostor: PhysicsImpostor): void;
  76167. /**
  76168. * Add a joint to the physics engine
  76169. * @param mainImpostor defines the main impostor to which the joint is added.
  76170. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76171. * @param joint defines the joint that will connect both impostors.
  76172. */
  76173. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76174. /**
  76175. * Removes a joint from the simulation
  76176. * @param mainImpostor defines the impostor used with the joint
  76177. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76178. * @param joint defines the joint to remove
  76179. */
  76180. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76181. /**
  76182. * Gets the current plugin used to run the simulation
  76183. * @returns current plugin
  76184. */
  76185. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76186. /**
  76187. * Gets the list of physic impostors
  76188. * @returns an array of PhysicsImpostor
  76189. */
  76190. getImpostors(): Array<PhysicsImpostor>;
  76191. /**
  76192. * Gets the impostor for a physics enabled object
  76193. * @param object defines the object impersonated by the impostor
  76194. * @returns the PhysicsImpostor or null if not found
  76195. */
  76196. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76197. /**
  76198. * Gets the impostor for a physics body object
  76199. * @param body defines physics body used by the impostor
  76200. * @returns the PhysicsImpostor or null if not found
  76201. */
  76202. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76203. /**
  76204. * Does a raycast in the physics world
  76205. * @param from when should the ray start?
  76206. * @param to when should the ray end?
  76207. * @returns PhysicsRaycastResult
  76208. */
  76209. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  76210. /**
  76211. * Called by the scene. No need to call it.
  76212. * @param delta defines the timespam between frames
  76213. */
  76214. _step(delta: number): void;
  76215. }
  76216. }
  76217. declare module BABYLON {
  76218. /**
  76219. * The interface for the physics imposter parameters
  76220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76221. */
  76222. export interface PhysicsImpostorParameters {
  76223. /**
  76224. * The mass of the physics imposter
  76225. */
  76226. mass: number;
  76227. /**
  76228. * The friction of the physics imposter
  76229. */
  76230. friction?: number;
  76231. /**
  76232. * The coefficient of restitution of the physics imposter
  76233. */
  76234. restitution?: number;
  76235. /**
  76236. * The native options of the physics imposter
  76237. */
  76238. nativeOptions?: any;
  76239. /**
  76240. * Specifies if the parent should be ignored
  76241. */
  76242. ignoreParent?: boolean;
  76243. /**
  76244. * Specifies if bi-directional transformations should be disabled
  76245. */
  76246. disableBidirectionalTransformation?: boolean;
  76247. /**
  76248. * The pressure inside the physics imposter, soft object only
  76249. */
  76250. pressure?: number;
  76251. /**
  76252. * The stiffness the physics imposter, soft object only
  76253. */
  76254. stiffness?: number;
  76255. /**
  76256. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  76257. */
  76258. velocityIterations?: number;
  76259. /**
  76260. * The number of iterations used in maintaining consistent vertex positions, soft object only
  76261. */
  76262. positionIterations?: number;
  76263. /**
  76264. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  76265. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  76266. * Add to fix multiple points
  76267. */
  76268. fixedPoints?: number;
  76269. /**
  76270. * The collision margin around a soft object
  76271. */
  76272. margin?: number;
  76273. /**
  76274. * The collision margin around a soft object
  76275. */
  76276. damping?: number;
  76277. /**
  76278. * The path for a rope based on an extrusion
  76279. */
  76280. path?: any;
  76281. /**
  76282. * The shape of an extrusion used for a rope based on an extrusion
  76283. */
  76284. shape?: any;
  76285. }
  76286. /**
  76287. * Interface for a physics-enabled object
  76288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76289. */
  76290. export interface IPhysicsEnabledObject {
  76291. /**
  76292. * The position of the physics-enabled object
  76293. */
  76294. position: Vector3;
  76295. /**
  76296. * The rotation of the physics-enabled object
  76297. */
  76298. rotationQuaternion: Nullable<Quaternion>;
  76299. /**
  76300. * The scale of the physics-enabled object
  76301. */
  76302. scaling: Vector3;
  76303. /**
  76304. * The rotation of the physics-enabled object
  76305. */
  76306. rotation?: Vector3;
  76307. /**
  76308. * The parent of the physics-enabled object
  76309. */
  76310. parent?: any;
  76311. /**
  76312. * The bounding info of the physics-enabled object
  76313. * @returns The bounding info of the physics-enabled object
  76314. */
  76315. getBoundingInfo(): BoundingInfo;
  76316. /**
  76317. * Computes the world matrix
  76318. * @param force Specifies if the world matrix should be computed by force
  76319. * @returns A world matrix
  76320. */
  76321. computeWorldMatrix(force: boolean): Matrix;
  76322. /**
  76323. * Gets the world matrix
  76324. * @returns A world matrix
  76325. */
  76326. getWorldMatrix?(): Matrix;
  76327. /**
  76328. * Gets the child meshes
  76329. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76330. * @returns An array of abstract meshes
  76331. */
  76332. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76333. /**
  76334. * Gets the vertex data
  76335. * @param kind The type of vertex data
  76336. * @returns A nullable array of numbers, or a float32 array
  76337. */
  76338. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76339. /**
  76340. * Gets the indices from the mesh
  76341. * @returns A nullable array of index arrays
  76342. */
  76343. getIndices?(): Nullable<IndicesArray>;
  76344. /**
  76345. * Gets the scene from the mesh
  76346. * @returns the indices array or null
  76347. */
  76348. getScene?(): Scene;
  76349. /**
  76350. * Gets the absolute position from the mesh
  76351. * @returns the absolute position
  76352. */
  76353. getAbsolutePosition(): Vector3;
  76354. /**
  76355. * Gets the absolute pivot point from the mesh
  76356. * @returns the absolute pivot point
  76357. */
  76358. getAbsolutePivotPoint(): Vector3;
  76359. /**
  76360. * Rotates the mesh
  76361. * @param axis The axis of rotation
  76362. * @param amount The amount of rotation
  76363. * @param space The space of the rotation
  76364. * @returns The rotation transform node
  76365. */
  76366. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76367. /**
  76368. * Translates the mesh
  76369. * @param axis The axis of translation
  76370. * @param distance The distance of translation
  76371. * @param space The space of the translation
  76372. * @returns The transform node
  76373. */
  76374. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76375. /**
  76376. * Sets the absolute position of the mesh
  76377. * @param absolutePosition The absolute position of the mesh
  76378. * @returns The transform node
  76379. */
  76380. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76381. /**
  76382. * Gets the class name of the mesh
  76383. * @returns The class name
  76384. */
  76385. getClassName(): string;
  76386. }
  76387. /**
  76388. * Represents a physics imposter
  76389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76390. */
  76391. export class PhysicsImpostor {
  76392. /**
  76393. * The physics-enabled object used as the physics imposter
  76394. */
  76395. object: IPhysicsEnabledObject;
  76396. /**
  76397. * The type of the physics imposter
  76398. */
  76399. type: number;
  76400. private _options;
  76401. private _scene?;
  76402. /**
  76403. * The default object size of the imposter
  76404. */
  76405. static DEFAULT_OBJECT_SIZE: Vector3;
  76406. /**
  76407. * The identity quaternion of the imposter
  76408. */
  76409. static IDENTITY_QUATERNION: Quaternion;
  76410. /** @hidden */
  76411. _pluginData: any;
  76412. private _physicsEngine;
  76413. private _physicsBody;
  76414. private _bodyUpdateRequired;
  76415. private _onBeforePhysicsStepCallbacks;
  76416. private _onAfterPhysicsStepCallbacks;
  76417. /** @hidden */
  76418. _onPhysicsCollideCallbacks: Array<{
  76419. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76420. otherImpostors: Array<PhysicsImpostor>;
  76421. }>;
  76422. private _deltaPosition;
  76423. private _deltaRotation;
  76424. private _deltaRotationConjugated;
  76425. /** @hidden */
  76426. _isFromLine: boolean;
  76427. private _parent;
  76428. private _isDisposed;
  76429. private static _tmpVecs;
  76430. private static _tmpQuat;
  76431. /**
  76432. * Specifies if the physics imposter is disposed
  76433. */
  76434. readonly isDisposed: boolean;
  76435. /**
  76436. * Gets the mass of the physics imposter
  76437. */
  76438. mass: number;
  76439. /**
  76440. * Gets the coefficient of friction
  76441. */
  76442. /**
  76443. * Sets the coefficient of friction
  76444. */
  76445. friction: number;
  76446. /**
  76447. * Gets the coefficient of restitution
  76448. */
  76449. /**
  76450. * Sets the coefficient of restitution
  76451. */
  76452. restitution: number;
  76453. /**
  76454. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  76455. */
  76456. /**
  76457. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  76458. */
  76459. pressure: number;
  76460. /**
  76461. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76462. */
  76463. /**
  76464. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76465. */
  76466. stiffness: number;
  76467. /**
  76468. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76469. */
  76470. /**
  76471. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76472. */
  76473. velocityIterations: number;
  76474. /**
  76475. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76476. */
  76477. /**
  76478. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76479. */
  76480. positionIterations: number;
  76481. /**
  76482. * The unique id of the physics imposter
  76483. * set by the physics engine when adding this impostor to the array
  76484. */
  76485. uniqueId: number;
  76486. /**
  76487. * @hidden
  76488. */
  76489. soft: boolean;
  76490. /**
  76491. * @hidden
  76492. */
  76493. segments: number;
  76494. private _joints;
  76495. /**
  76496. * Initializes the physics imposter
  76497. * @param object The physics-enabled object used as the physics imposter
  76498. * @param type The type of the physics imposter
  76499. * @param _options The options for the physics imposter
  76500. * @param _scene The Babylon scene
  76501. */
  76502. constructor(
  76503. /**
  76504. * The physics-enabled object used as the physics imposter
  76505. */
  76506. object: IPhysicsEnabledObject,
  76507. /**
  76508. * The type of the physics imposter
  76509. */
  76510. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76511. /**
  76512. * This function will completly initialize this impostor.
  76513. * It will create a new body - but only if this mesh has no parent.
  76514. * If it has, this impostor will not be used other than to define the impostor
  76515. * of the child mesh.
  76516. * @hidden
  76517. */
  76518. _init(): void;
  76519. private _getPhysicsParent;
  76520. /**
  76521. * Should a new body be generated.
  76522. * @returns boolean specifying if body initialization is required
  76523. */
  76524. isBodyInitRequired(): boolean;
  76525. /**
  76526. * Sets the updated scaling
  76527. * @param updated Specifies if the scaling is updated
  76528. */
  76529. setScalingUpdated(): void;
  76530. /**
  76531. * Force a regeneration of this or the parent's impostor's body.
  76532. * Use under cautious - This will remove all joints already implemented.
  76533. */
  76534. forceUpdate(): void;
  76535. /**
  76536. * Gets the body that holds this impostor. Either its own, or its parent.
  76537. */
  76538. /**
  76539. * Set the physics body. Used mainly by the physics engine/plugin
  76540. */
  76541. physicsBody: any;
  76542. /**
  76543. * Get the parent of the physics imposter
  76544. * @returns Physics imposter or null
  76545. */
  76546. /**
  76547. * Sets the parent of the physics imposter
  76548. */
  76549. parent: Nullable<PhysicsImpostor>;
  76550. /**
  76551. * Resets the update flags
  76552. */
  76553. resetUpdateFlags(): void;
  76554. /**
  76555. * Gets the object extend size
  76556. * @returns the object extend size
  76557. */
  76558. getObjectExtendSize(): Vector3;
  76559. /**
  76560. * Gets the object center
  76561. * @returns The object center
  76562. */
  76563. getObjectCenter(): Vector3;
  76564. /**
  76565. * Get a specific parametes from the options parameter
  76566. * @param paramName The object parameter name
  76567. * @returns The object parameter
  76568. */
  76569. getParam(paramName: string): any;
  76570. /**
  76571. * Sets a specific parameter in the options given to the physics plugin
  76572. * @param paramName The parameter name
  76573. * @param value The value of the parameter
  76574. */
  76575. setParam(paramName: string, value: number): void;
  76576. /**
  76577. * Specifically change the body's mass option. Won't recreate the physics body object
  76578. * @param mass The mass of the physics imposter
  76579. */
  76580. setMass(mass: number): void;
  76581. /**
  76582. * Gets the linear velocity
  76583. * @returns linear velocity or null
  76584. */
  76585. getLinearVelocity(): Nullable<Vector3>;
  76586. /**
  76587. * Sets the linear velocity
  76588. * @param velocity linear velocity or null
  76589. */
  76590. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76591. /**
  76592. * Gets the angular velocity
  76593. * @returns angular velocity or null
  76594. */
  76595. getAngularVelocity(): Nullable<Vector3>;
  76596. /**
  76597. * Sets the angular velocity
  76598. * @param velocity The velocity or null
  76599. */
  76600. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76601. /**
  76602. * Execute a function with the physics plugin native code
  76603. * Provide a function the will have two variables - the world object and the physics body object
  76604. * @param func The function to execute with the physics plugin native code
  76605. */
  76606. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76607. /**
  76608. * Register a function that will be executed before the physics world is stepping forward
  76609. * @param func The function to execute before the physics world is stepped forward
  76610. */
  76611. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76612. /**
  76613. * Unregister a function that will be executed before the physics world is stepping forward
  76614. * @param func The function to execute before the physics world is stepped forward
  76615. */
  76616. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76617. /**
  76618. * Register a function that will be executed after the physics step
  76619. * @param func The function to execute after physics step
  76620. */
  76621. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76622. /**
  76623. * Unregisters a function that will be executed after the physics step
  76624. * @param func The function to execute after physics step
  76625. */
  76626. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76627. /**
  76628. * register a function that will be executed when this impostor collides against a different body
  76629. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76630. * @param func Callback that is executed on collision
  76631. */
  76632. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76633. /**
  76634. * Unregisters the physics imposter on contact
  76635. * @param collideAgainst The physics object to collide against
  76636. * @param func Callback to execute on collision
  76637. */
  76638. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76639. private _tmpQuat;
  76640. private _tmpQuat2;
  76641. /**
  76642. * Get the parent rotation
  76643. * @returns The parent rotation
  76644. */
  76645. getParentsRotation(): Quaternion;
  76646. /**
  76647. * this function is executed by the physics engine.
  76648. */
  76649. beforeStep: () => void;
  76650. /**
  76651. * this function is executed by the physics engine
  76652. */
  76653. afterStep: () => void;
  76654. /**
  76655. * Legacy collision detection event support
  76656. */
  76657. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76658. /**
  76659. * event and body object due to cannon's event-based architecture.
  76660. */
  76661. onCollide: (e: {
  76662. body: any;
  76663. }) => void;
  76664. /**
  76665. * Apply a force
  76666. * @param force The force to apply
  76667. * @param contactPoint The contact point for the force
  76668. * @returns The physics imposter
  76669. */
  76670. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76671. /**
  76672. * Apply an impulse
  76673. * @param force The impulse force
  76674. * @param contactPoint The contact point for the impulse force
  76675. * @returns The physics imposter
  76676. */
  76677. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76678. /**
  76679. * A help function to create a joint
  76680. * @param otherImpostor A physics imposter used to create a joint
  76681. * @param jointType The type of joint
  76682. * @param jointData The data for the joint
  76683. * @returns The physics imposter
  76684. */
  76685. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76686. /**
  76687. * Add a joint to this impostor with a different impostor
  76688. * @param otherImpostor A physics imposter used to add a joint
  76689. * @param joint The joint to add
  76690. * @returns The physics imposter
  76691. */
  76692. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76693. /**
  76694. * Add an anchor to a cloth impostor
  76695. * @param otherImpostor rigid impostor to anchor to
  76696. * @param width ratio across width from 0 to 1
  76697. * @param height ratio up height from 0 to 1
  76698. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  76699. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  76700. * @returns impostor the soft imposter
  76701. */
  76702. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76703. /**
  76704. * Add a hook to a rope impostor
  76705. * @param otherImpostor rigid impostor to anchor to
  76706. * @param length ratio across rope from 0 to 1
  76707. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  76708. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  76709. * @returns impostor the rope imposter
  76710. */
  76711. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76712. /**
  76713. * Will keep this body still, in a sleep mode.
  76714. * @returns the physics imposter
  76715. */
  76716. sleep(): PhysicsImpostor;
  76717. /**
  76718. * Wake the body up.
  76719. * @returns The physics imposter
  76720. */
  76721. wakeUp(): PhysicsImpostor;
  76722. /**
  76723. * Clones the physics imposter
  76724. * @param newObject The physics imposter clones to this physics-enabled object
  76725. * @returns A nullable physics imposter
  76726. */
  76727. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76728. /**
  76729. * Disposes the physics imposter
  76730. */
  76731. dispose(): void;
  76732. /**
  76733. * Sets the delta position
  76734. * @param position The delta position amount
  76735. */
  76736. setDeltaPosition(position: Vector3): void;
  76737. /**
  76738. * Sets the delta rotation
  76739. * @param rotation The delta rotation amount
  76740. */
  76741. setDeltaRotation(rotation: Quaternion): void;
  76742. /**
  76743. * Gets the box size of the physics imposter and stores the result in the input parameter
  76744. * @param result Stores the box size
  76745. * @returns The physics imposter
  76746. */
  76747. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76748. /**
  76749. * Gets the radius of the physics imposter
  76750. * @returns Radius of the physics imposter
  76751. */
  76752. getRadius(): number;
  76753. /**
  76754. * Sync a bone with this impostor
  76755. * @param bone The bone to sync to the impostor.
  76756. * @param boneMesh The mesh that the bone is influencing.
  76757. * @param jointPivot The pivot of the joint / bone in local space.
  76758. * @param distToJoint Optional distance from the impostor to the joint.
  76759. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76760. */
  76761. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76762. /**
  76763. * Sync impostor to a bone
  76764. * @param bone The bone that the impostor will be synced to.
  76765. * @param boneMesh The mesh that the bone is influencing.
  76766. * @param jointPivot The pivot of the joint / bone in local space.
  76767. * @param distToJoint Optional distance from the impostor to the joint.
  76768. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76769. * @param boneAxis Optional vector3 axis the bone is aligned with
  76770. */
  76771. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76772. /**
  76773. * No-Imposter type
  76774. */
  76775. static NoImpostor: number;
  76776. /**
  76777. * Sphere-Imposter type
  76778. */
  76779. static SphereImpostor: number;
  76780. /**
  76781. * Box-Imposter type
  76782. */
  76783. static BoxImpostor: number;
  76784. /**
  76785. * Plane-Imposter type
  76786. */
  76787. static PlaneImpostor: number;
  76788. /**
  76789. * Mesh-imposter type
  76790. */
  76791. static MeshImpostor: number;
  76792. /**
  76793. * Capsule-Impostor type (Ammo.js plugin only)
  76794. */
  76795. static CapsuleImpostor: number;
  76796. /**
  76797. * Cylinder-Imposter type
  76798. */
  76799. static CylinderImpostor: number;
  76800. /**
  76801. * Particle-Imposter type
  76802. */
  76803. static ParticleImpostor: number;
  76804. /**
  76805. * Heightmap-Imposter type
  76806. */
  76807. static HeightmapImpostor: number;
  76808. /**
  76809. * ConvexHull-Impostor type (Ammo.js plugin only)
  76810. */
  76811. static ConvexHullImpostor: number;
  76812. /**
  76813. * Rope-Imposter type
  76814. */
  76815. static RopeImpostor: number;
  76816. /**
  76817. * Cloth-Imposter type
  76818. */
  76819. static ClothImpostor: number;
  76820. /**
  76821. * Softbody-Imposter type
  76822. */
  76823. static SoftbodyImpostor: number;
  76824. }
  76825. }
  76826. declare module BABYLON {
  76827. /**
  76828. * @hidden
  76829. **/
  76830. export class _CreationDataStorage {
  76831. closePath?: boolean;
  76832. closeArray?: boolean;
  76833. idx: number[];
  76834. dashSize: number;
  76835. gapSize: number;
  76836. path3D: Path3D;
  76837. pathArray: Vector3[][];
  76838. arc: number;
  76839. radius: number;
  76840. cap: number;
  76841. tessellation: number;
  76842. }
  76843. /**
  76844. * @hidden
  76845. **/
  76846. class _InstanceDataStorage {
  76847. visibleInstances: any;
  76848. batchCache: _InstancesBatch;
  76849. instancesBufferSize: number;
  76850. instancesBuffer: Nullable<Buffer>;
  76851. instancesData: Float32Array;
  76852. overridenInstanceCount: number;
  76853. isFrozen: boolean;
  76854. previousBatch: Nullable<_InstancesBatch>;
  76855. hardwareInstancedRendering: boolean;
  76856. sideOrientation: number;
  76857. }
  76858. /**
  76859. * @hidden
  76860. **/
  76861. export class _InstancesBatch {
  76862. mustReturn: boolean;
  76863. visibleInstances: Nullable<InstancedMesh[]>[];
  76864. renderSelf: boolean[];
  76865. hardwareInstancedRendering: boolean[];
  76866. }
  76867. /**
  76868. * Class used to represent renderable models
  76869. */
  76870. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76871. /**
  76872. * Mesh side orientation : usually the external or front surface
  76873. */
  76874. static readonly FRONTSIDE: number;
  76875. /**
  76876. * Mesh side orientation : usually the internal or back surface
  76877. */
  76878. static readonly BACKSIDE: number;
  76879. /**
  76880. * Mesh side orientation : both internal and external or front and back surfaces
  76881. */
  76882. static readonly DOUBLESIDE: number;
  76883. /**
  76884. * Mesh side orientation : by default, `FRONTSIDE`
  76885. */
  76886. static readonly DEFAULTSIDE: number;
  76887. /**
  76888. * Mesh cap setting : no cap
  76889. */
  76890. static readonly NO_CAP: number;
  76891. /**
  76892. * Mesh cap setting : one cap at the beginning of the mesh
  76893. */
  76894. static readonly CAP_START: number;
  76895. /**
  76896. * Mesh cap setting : one cap at the end of the mesh
  76897. */
  76898. static readonly CAP_END: number;
  76899. /**
  76900. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76901. */
  76902. static readonly CAP_ALL: number;
  76903. /**
  76904. * Mesh pattern setting : no flip or rotate
  76905. */
  76906. static readonly NO_FLIP: number;
  76907. /**
  76908. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  76909. */
  76910. static readonly FLIP_TILE: number;
  76911. /**
  76912. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  76913. */
  76914. static readonly ROTATE_TILE: number;
  76915. /**
  76916. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  76917. */
  76918. static readonly FLIP_ROW: number;
  76919. /**
  76920. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  76921. */
  76922. static readonly ROTATE_ROW: number;
  76923. /**
  76924. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  76925. */
  76926. static readonly FLIP_N_ROTATE_TILE: number;
  76927. /**
  76928. * Mesh pattern setting : rotate pattern and rotate
  76929. */
  76930. static readonly FLIP_N_ROTATE_ROW: number;
  76931. /**
  76932. * Mesh tile positioning : part tiles same on left/right or top/bottom
  76933. */
  76934. static readonly CENTER: number;
  76935. /**
  76936. * Mesh tile positioning : part tiles on left
  76937. */
  76938. static readonly LEFT: number;
  76939. /**
  76940. * Mesh tile positioning : part tiles on right
  76941. */
  76942. static readonly RIGHT: number;
  76943. /**
  76944. * Mesh tile positioning : part tiles on top
  76945. */
  76946. static readonly TOP: number;
  76947. /**
  76948. * Mesh tile positioning : part tiles on bottom
  76949. */
  76950. static readonly BOTTOM: number;
  76951. /**
  76952. * Gets the default side orientation.
  76953. * @param orientation the orientation to value to attempt to get
  76954. * @returns the default orientation
  76955. * @hidden
  76956. */
  76957. static _GetDefaultSideOrientation(orientation?: number): number;
  76958. private _internalMeshDataInfo;
  76959. /**
  76960. * An event triggered before rendering the mesh
  76961. */
  76962. readonly onBeforeRenderObservable: Observable<Mesh>;
  76963. /**
  76964. * An event triggered before binding the mesh
  76965. */
  76966. readonly onBeforeBindObservable: Observable<Mesh>;
  76967. /**
  76968. * An event triggered after rendering the mesh
  76969. */
  76970. readonly onAfterRenderObservable: Observable<Mesh>;
  76971. /**
  76972. * An event triggered before drawing the mesh
  76973. */
  76974. readonly onBeforeDrawObservable: Observable<Mesh>;
  76975. private _onBeforeDrawObserver;
  76976. /**
  76977. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  76978. */
  76979. onBeforeDraw: () => void;
  76980. /**
  76981. * Gets the delay loading state of the mesh (when delay loading is turned on)
  76982. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  76983. */
  76984. delayLoadState: number;
  76985. /**
  76986. * Gets the list of instances created from this mesh
  76987. * it is not supposed to be modified manually.
  76988. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  76989. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76990. */
  76991. instances: InstancedMesh[];
  76992. /**
  76993. * Gets the file containing delay loading data for this mesh
  76994. */
  76995. delayLoadingFile: string;
  76996. /** @hidden */
  76997. _binaryInfo: any;
  76998. /**
  76999. * User defined function used to change how LOD level selection is done
  77000. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77001. */
  77002. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77003. /**
  77004. * Gets or sets the morph target manager
  77005. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77006. */
  77007. morphTargetManager: Nullable<MorphTargetManager>;
  77008. /** @hidden */
  77009. _creationDataStorage: Nullable<_CreationDataStorage>;
  77010. /** @hidden */
  77011. _geometry: Nullable<Geometry>;
  77012. /** @hidden */
  77013. _delayInfo: Array<string>;
  77014. /** @hidden */
  77015. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77016. /** @hidden */
  77017. _instanceDataStorage: _InstanceDataStorage;
  77018. private _effectiveMaterial;
  77019. /** @hidden */
  77020. _shouldGenerateFlatShading: boolean;
  77021. /** @hidden */
  77022. _originalBuilderSideOrientation: number;
  77023. /**
  77024. * Use this property to change the original side orientation defined at construction time
  77025. */
  77026. overrideMaterialSideOrientation: Nullable<number>;
  77027. /**
  77028. * Gets the source mesh (the one used to clone this one from)
  77029. */
  77030. readonly source: Nullable<Mesh>;
  77031. /**
  77032. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77033. */
  77034. isUnIndexed: boolean;
  77035. /**
  77036. * @constructor
  77037. * @param name The value used by scene.getMeshByName() to do a lookup.
  77038. * @param scene The scene to add this mesh to.
  77039. * @param parent The parent of this mesh, if it has one
  77040. * @param source An optional Mesh from which geometry is shared, cloned.
  77041. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77042. * When false, achieved by calling a clone(), also passing False.
  77043. * This will make creation of children, recursive.
  77044. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77045. */
  77046. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77047. /**
  77048. * Gets the class name
  77049. * @returns the string "Mesh".
  77050. */
  77051. getClassName(): string;
  77052. /** @hidden */
  77053. readonly _isMesh: boolean;
  77054. /**
  77055. * Returns a description of this mesh
  77056. * @param fullDetails define if full details about this mesh must be used
  77057. * @returns a descriptive string representing this mesh
  77058. */
  77059. toString(fullDetails?: boolean): string;
  77060. /** @hidden */
  77061. _unBindEffect(): void;
  77062. /**
  77063. * Gets a boolean indicating if this mesh has LOD
  77064. */
  77065. readonly hasLODLevels: boolean;
  77066. /**
  77067. * Gets the list of MeshLODLevel associated with the current mesh
  77068. * @returns an array of MeshLODLevel
  77069. */
  77070. getLODLevels(): MeshLODLevel[];
  77071. private _sortLODLevels;
  77072. /**
  77073. * Add a mesh as LOD level triggered at the given distance.
  77074. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77075. * @param distance The distance from the center of the object to show this level
  77076. * @param mesh The mesh to be added as LOD level (can be null)
  77077. * @return This mesh (for chaining)
  77078. */
  77079. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77080. /**
  77081. * Returns the LOD level mesh at the passed distance or null if not found.
  77082. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77083. * @param distance The distance from the center of the object to show this level
  77084. * @returns a Mesh or `null`
  77085. */
  77086. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77087. /**
  77088. * Remove a mesh from the LOD array
  77089. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77090. * @param mesh defines the mesh to be removed
  77091. * @return This mesh (for chaining)
  77092. */
  77093. removeLODLevel(mesh: Mesh): Mesh;
  77094. /**
  77095. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77096. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77097. * @param camera defines the camera to use to compute distance
  77098. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77099. * @return This mesh (for chaining)
  77100. */
  77101. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77102. /**
  77103. * Gets the mesh internal Geometry object
  77104. */
  77105. readonly geometry: Nullable<Geometry>;
  77106. /**
  77107. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77108. * @returns the total number of vertices
  77109. */
  77110. getTotalVertices(): number;
  77111. /**
  77112. * Returns the content of an associated vertex buffer
  77113. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77114. * - VertexBuffer.PositionKind
  77115. * - VertexBuffer.UVKind
  77116. * - VertexBuffer.UV2Kind
  77117. * - VertexBuffer.UV3Kind
  77118. * - VertexBuffer.UV4Kind
  77119. * - VertexBuffer.UV5Kind
  77120. * - VertexBuffer.UV6Kind
  77121. * - VertexBuffer.ColorKind
  77122. * - VertexBuffer.MatricesIndicesKind
  77123. * - VertexBuffer.MatricesIndicesExtraKind
  77124. * - VertexBuffer.MatricesWeightsKind
  77125. * - VertexBuffer.MatricesWeightsExtraKind
  77126. * @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
  77127. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77128. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77129. */
  77130. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77131. /**
  77132. * Returns the mesh VertexBuffer object from the requested `kind`
  77133. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77134. * - VertexBuffer.PositionKind
  77135. * - VertexBuffer.NormalKind
  77136. * - VertexBuffer.UVKind
  77137. * - VertexBuffer.UV2Kind
  77138. * - VertexBuffer.UV3Kind
  77139. * - VertexBuffer.UV4Kind
  77140. * - VertexBuffer.UV5Kind
  77141. * - VertexBuffer.UV6Kind
  77142. * - VertexBuffer.ColorKind
  77143. * - VertexBuffer.MatricesIndicesKind
  77144. * - VertexBuffer.MatricesIndicesExtraKind
  77145. * - VertexBuffer.MatricesWeightsKind
  77146. * - VertexBuffer.MatricesWeightsExtraKind
  77147. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77148. */
  77149. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77150. /**
  77151. * Tests if a specific vertex buffer is associated with this mesh
  77152. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77153. * - VertexBuffer.PositionKind
  77154. * - VertexBuffer.NormalKind
  77155. * - VertexBuffer.UVKind
  77156. * - VertexBuffer.UV2Kind
  77157. * - VertexBuffer.UV3Kind
  77158. * - VertexBuffer.UV4Kind
  77159. * - VertexBuffer.UV5Kind
  77160. * - VertexBuffer.UV6Kind
  77161. * - VertexBuffer.ColorKind
  77162. * - VertexBuffer.MatricesIndicesKind
  77163. * - VertexBuffer.MatricesIndicesExtraKind
  77164. * - VertexBuffer.MatricesWeightsKind
  77165. * - VertexBuffer.MatricesWeightsExtraKind
  77166. * @returns a boolean
  77167. */
  77168. isVerticesDataPresent(kind: string): boolean;
  77169. /**
  77170. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77171. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77172. * - VertexBuffer.PositionKind
  77173. * - VertexBuffer.UVKind
  77174. * - VertexBuffer.UV2Kind
  77175. * - VertexBuffer.UV3Kind
  77176. * - VertexBuffer.UV4Kind
  77177. * - VertexBuffer.UV5Kind
  77178. * - VertexBuffer.UV6Kind
  77179. * - VertexBuffer.ColorKind
  77180. * - VertexBuffer.MatricesIndicesKind
  77181. * - VertexBuffer.MatricesIndicesExtraKind
  77182. * - VertexBuffer.MatricesWeightsKind
  77183. * - VertexBuffer.MatricesWeightsExtraKind
  77184. * @returns a boolean
  77185. */
  77186. isVertexBufferUpdatable(kind: string): boolean;
  77187. /**
  77188. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77189. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77190. * - VertexBuffer.PositionKind
  77191. * - VertexBuffer.NormalKind
  77192. * - VertexBuffer.UVKind
  77193. * - VertexBuffer.UV2Kind
  77194. * - VertexBuffer.UV3Kind
  77195. * - VertexBuffer.UV4Kind
  77196. * - VertexBuffer.UV5Kind
  77197. * - VertexBuffer.UV6Kind
  77198. * - VertexBuffer.ColorKind
  77199. * - VertexBuffer.MatricesIndicesKind
  77200. * - VertexBuffer.MatricesIndicesExtraKind
  77201. * - VertexBuffer.MatricesWeightsKind
  77202. * - VertexBuffer.MatricesWeightsExtraKind
  77203. * @returns an array of strings
  77204. */
  77205. getVerticesDataKinds(): string[];
  77206. /**
  77207. * Returns a positive integer : the total number of indices in this mesh geometry.
  77208. * @returns the numner of indices or zero if the mesh has no geometry.
  77209. */
  77210. getTotalIndices(): number;
  77211. /**
  77212. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77213. * @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.
  77214. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77215. * @returns the indices array or an empty array if the mesh has no geometry
  77216. */
  77217. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77218. readonly isBlocked: boolean;
  77219. /**
  77220. * Determine if the current mesh is ready to be rendered
  77221. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77222. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77223. * @returns true if all associated assets are ready (material, textures, shaders)
  77224. */
  77225. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77226. /**
  77227. * 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.
  77228. */
  77229. readonly areNormalsFrozen: boolean;
  77230. /**
  77231. * 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.
  77232. * @returns the current mesh
  77233. */
  77234. freezeNormals(): Mesh;
  77235. /**
  77236. * 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
  77237. * @returns the current mesh
  77238. */
  77239. unfreezeNormals(): Mesh;
  77240. /**
  77241. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77242. */
  77243. overridenInstanceCount: number;
  77244. /** @hidden */
  77245. _preActivate(): Mesh;
  77246. /** @hidden */
  77247. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77248. /** @hidden */
  77249. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77250. /**
  77251. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77252. * This means the mesh underlying bounding box and sphere are recomputed.
  77253. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77254. * @returns the current mesh
  77255. */
  77256. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77257. /** @hidden */
  77258. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77259. /**
  77260. * This function will subdivide the mesh into multiple submeshes
  77261. * @param count defines the expected number of submeshes
  77262. */
  77263. subdivide(count: number): void;
  77264. /**
  77265. * Copy a FloatArray into a specific associated vertex buffer
  77266. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77267. * - VertexBuffer.PositionKind
  77268. * - VertexBuffer.UVKind
  77269. * - VertexBuffer.UV2Kind
  77270. * - VertexBuffer.UV3Kind
  77271. * - VertexBuffer.UV4Kind
  77272. * - VertexBuffer.UV5Kind
  77273. * - VertexBuffer.UV6Kind
  77274. * - VertexBuffer.ColorKind
  77275. * - VertexBuffer.MatricesIndicesKind
  77276. * - VertexBuffer.MatricesIndicesExtraKind
  77277. * - VertexBuffer.MatricesWeightsKind
  77278. * - VertexBuffer.MatricesWeightsExtraKind
  77279. * @param data defines the data source
  77280. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77281. * @param stride defines the data stride size (can be null)
  77282. * @returns the current mesh
  77283. */
  77284. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77285. /**
  77286. * Flags an associated vertex buffer as updatable
  77287. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77288. * - VertexBuffer.PositionKind
  77289. * - VertexBuffer.UVKind
  77290. * - VertexBuffer.UV2Kind
  77291. * - VertexBuffer.UV3Kind
  77292. * - VertexBuffer.UV4Kind
  77293. * - VertexBuffer.UV5Kind
  77294. * - VertexBuffer.UV6Kind
  77295. * - VertexBuffer.ColorKind
  77296. * - VertexBuffer.MatricesIndicesKind
  77297. * - VertexBuffer.MatricesIndicesExtraKind
  77298. * - VertexBuffer.MatricesWeightsKind
  77299. * - VertexBuffer.MatricesWeightsExtraKind
  77300. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77301. */
  77302. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77303. /**
  77304. * Sets the mesh global Vertex Buffer
  77305. * @param buffer defines the buffer to use
  77306. * @returns the current mesh
  77307. */
  77308. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77309. /**
  77310. * Update a specific associated vertex buffer
  77311. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77312. * - VertexBuffer.PositionKind
  77313. * - VertexBuffer.UVKind
  77314. * - VertexBuffer.UV2Kind
  77315. * - VertexBuffer.UV3Kind
  77316. * - VertexBuffer.UV4Kind
  77317. * - VertexBuffer.UV5Kind
  77318. * - VertexBuffer.UV6Kind
  77319. * - VertexBuffer.ColorKind
  77320. * - VertexBuffer.MatricesIndicesKind
  77321. * - VertexBuffer.MatricesIndicesExtraKind
  77322. * - VertexBuffer.MatricesWeightsKind
  77323. * - VertexBuffer.MatricesWeightsExtraKind
  77324. * @param data defines the data source
  77325. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77326. * @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)
  77327. * @returns the current mesh
  77328. */
  77329. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77330. /**
  77331. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77332. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77333. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77334. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77335. * @returns the current mesh
  77336. */
  77337. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77338. /**
  77339. * Creates a un-shared specific occurence of the geometry for the mesh.
  77340. * @returns the current mesh
  77341. */
  77342. makeGeometryUnique(): Mesh;
  77343. /**
  77344. * Set the index buffer of this mesh
  77345. * @param indices defines the source data
  77346. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77347. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77348. * @returns the current mesh
  77349. */
  77350. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77351. /**
  77352. * Update the current index buffer
  77353. * @param indices defines the source data
  77354. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77355. * @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)
  77356. * @returns the current mesh
  77357. */
  77358. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  77359. /**
  77360. * Invert the geometry to move from a right handed system to a left handed one.
  77361. * @returns the current mesh
  77362. */
  77363. toLeftHanded(): Mesh;
  77364. /** @hidden */
  77365. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77366. /** @hidden */
  77367. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  77368. /**
  77369. * Registers for this mesh a javascript function called just before the rendering process
  77370. * @param func defines the function to call before rendering this mesh
  77371. * @returns the current mesh
  77372. */
  77373. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77374. /**
  77375. * Disposes a previously registered javascript function called before the rendering
  77376. * @param func defines the function to remove
  77377. * @returns the current mesh
  77378. */
  77379. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77380. /**
  77381. * Registers for this mesh a javascript function called just after the rendering is complete
  77382. * @param func defines the function to call after rendering this mesh
  77383. * @returns the current mesh
  77384. */
  77385. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77386. /**
  77387. * Disposes a previously registered javascript function called after the rendering.
  77388. * @param func defines the function to remove
  77389. * @returns the current mesh
  77390. */
  77391. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77392. /** @hidden */
  77393. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77394. /** @hidden */
  77395. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77396. /** @hidden */
  77397. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77398. /** @hidden */
  77399. _rebuild(): void;
  77400. /** @hidden */
  77401. _freeze(): void;
  77402. /** @hidden */
  77403. _unFreeze(): void;
  77404. /**
  77405. * 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
  77406. * @param subMesh defines the subMesh to render
  77407. * @param enableAlphaMode defines if alpha mode can be changed
  77408. * @returns the current mesh
  77409. */
  77410. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77411. private _onBeforeDraw;
  77412. /**
  77413. * Renormalize the mesh and patch it up if there are no weights
  77414. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77415. * However in the case of zero weights then we set just a single influence to 1.
  77416. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77417. */
  77418. cleanMatrixWeights(): void;
  77419. private normalizeSkinFourWeights;
  77420. private normalizeSkinWeightsAndExtra;
  77421. /**
  77422. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77423. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77424. * the user know there was an issue with importing the mesh
  77425. * @returns a validation object with skinned, valid and report string
  77426. */
  77427. validateSkinning(): {
  77428. skinned: boolean;
  77429. valid: boolean;
  77430. report: string;
  77431. };
  77432. /** @hidden */
  77433. _checkDelayState(): Mesh;
  77434. private _queueLoad;
  77435. /**
  77436. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77437. * A mesh is in the frustum if its bounding box intersects the frustum
  77438. * @param frustumPlanes defines the frustum to test
  77439. * @returns true if the mesh is in the frustum planes
  77440. */
  77441. isInFrustum(frustumPlanes: Plane[]): boolean;
  77442. /**
  77443. * Sets the mesh material by the material or multiMaterial `id` property
  77444. * @param id is a string identifying the material or the multiMaterial
  77445. * @returns the current mesh
  77446. */
  77447. setMaterialByID(id: string): Mesh;
  77448. /**
  77449. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77450. * @returns an array of IAnimatable
  77451. */
  77452. getAnimatables(): IAnimatable[];
  77453. /**
  77454. * Modifies the mesh geometry according to the passed transformation matrix.
  77455. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77456. * The mesh normals are modified using the same transformation.
  77457. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77458. * @param transform defines the transform matrix to use
  77459. * @see http://doc.babylonjs.com/resources/baking_transformations
  77460. * @returns the current mesh
  77461. */
  77462. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77463. /**
  77464. * Modifies the mesh geometry according to its own current World Matrix.
  77465. * The mesh World Matrix is then reset.
  77466. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77467. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77468. * @see http://doc.babylonjs.com/resources/baking_transformations
  77469. * @returns the current mesh
  77470. */
  77471. bakeCurrentTransformIntoVertices(): Mesh;
  77472. /** @hidden */
  77473. readonly _positions: Nullable<Vector3[]>;
  77474. /** @hidden */
  77475. _resetPointsArrayCache(): Mesh;
  77476. /** @hidden */
  77477. _generatePointsArray(): boolean;
  77478. /**
  77479. * Returns a new Mesh object generated from the current mesh properties.
  77480. * This method must not get confused with createInstance()
  77481. * @param name is a string, the name given to the new mesh
  77482. * @param newParent can be any Node object (default `null`)
  77483. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77484. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77485. * @returns a new mesh
  77486. */
  77487. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77488. /**
  77489. * Releases resources associated with this mesh.
  77490. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77491. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77492. */
  77493. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77494. /**
  77495. * Modifies the mesh geometry according to a displacement map.
  77496. * 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.
  77497. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77498. * @param url is a string, the URL from the image file is to be downloaded.
  77499. * @param minHeight is the lower limit of the displacement.
  77500. * @param maxHeight is the upper limit of the displacement.
  77501. * @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.
  77502. * @param uvOffset is an optional vector2 used to offset UV.
  77503. * @param uvScale is an optional vector2 used to scale UV.
  77504. * @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.
  77505. * @returns the Mesh.
  77506. */
  77507. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77508. /**
  77509. * Modifies the mesh geometry according to a displacementMap buffer.
  77510. * 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.
  77511. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77512. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77513. * @param heightMapWidth is the width of the buffer image.
  77514. * @param heightMapHeight is the height of the buffer image.
  77515. * @param minHeight is the lower limit of the displacement.
  77516. * @param maxHeight is the upper limit of the displacement.
  77517. * @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.
  77518. * @param uvOffset is an optional vector2 used to offset UV.
  77519. * @param uvScale is an optional vector2 used to scale UV.
  77520. * @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.
  77521. * @returns the Mesh.
  77522. */
  77523. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77524. /**
  77525. * Modify the mesh to get a flat shading rendering.
  77526. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77527. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77528. * @returns current mesh
  77529. */
  77530. convertToFlatShadedMesh(): Mesh;
  77531. /**
  77532. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77533. * In other words, more vertices, no more indices and a single bigger VBO.
  77534. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77535. * @returns current mesh
  77536. */
  77537. convertToUnIndexedMesh(): Mesh;
  77538. /**
  77539. * Inverses facet orientations.
  77540. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77541. * @param flipNormals will also inverts the normals
  77542. * @returns current mesh
  77543. */
  77544. flipFaces(flipNormals?: boolean): Mesh;
  77545. /**
  77546. * Increase the number of facets and hence vertices in a mesh
  77547. * Vertex normals are interpolated from existing vertex normals
  77548. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77549. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  77550. */
  77551. increaseVertices(numberPerEdge: number): void;
  77552. /**
  77553. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  77554. * This will undo any application of covertToFlatShadedMesh
  77555. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77556. */
  77557. forceSharedVertices(): void;
  77558. /** @hidden */
  77559. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77560. /** @hidden */
  77561. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77562. /**
  77563. * Creates a new InstancedMesh object from the mesh model.
  77564. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77565. * @param name defines the name of the new instance
  77566. * @returns a new InstancedMesh
  77567. */
  77568. createInstance(name: string): InstancedMesh;
  77569. /**
  77570. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77571. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77572. * @returns the current mesh
  77573. */
  77574. synchronizeInstances(): Mesh;
  77575. /**
  77576. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77577. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77578. * This should be used together with the simplification to avoid disappearing triangles.
  77579. * @param successCallback an optional success callback to be called after the optimization finished.
  77580. * @returns the current mesh
  77581. */
  77582. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77583. /**
  77584. * Serialize current mesh
  77585. * @param serializationObject defines the object which will receive the serialization data
  77586. */
  77587. serialize(serializationObject: any): void;
  77588. /** @hidden */
  77589. _syncGeometryWithMorphTargetManager(): void;
  77590. /** @hidden */
  77591. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77592. /**
  77593. * Returns a new Mesh object parsed from the source provided.
  77594. * @param parsedMesh is the source
  77595. * @param scene defines the hosting scene
  77596. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77597. * @returns a new Mesh
  77598. */
  77599. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77600. /**
  77601. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77602. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77603. * @param name defines the name of the mesh to create
  77604. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77605. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77606. * @param closePath creates a seam between the first and the last points of each path of the path array
  77607. * @param offset is taken in account only if the `pathArray` is containing a single path
  77608. * @param scene defines the hosting scene
  77609. * @param updatable defines if the mesh must be flagged as updatable
  77610. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77611. * @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)
  77612. * @returns a new Mesh
  77613. */
  77614. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77615. /**
  77616. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77617. * @param name defines the name of the mesh to create
  77618. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77619. * @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
  77620. * @param scene defines the hosting scene
  77621. * @param updatable defines if the mesh must be flagged as updatable
  77622. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77623. * @returns a new Mesh
  77624. */
  77625. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77626. /**
  77627. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77628. * @param name defines the name of the mesh to create
  77629. * @param size sets the size (float) of each box side (default 1)
  77630. * @param scene defines the hosting scene
  77631. * @param updatable defines if the mesh must be flagged as updatable
  77632. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77633. * @returns a new Mesh
  77634. */
  77635. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77636. /**
  77637. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77638. * @param name defines the name of the mesh to create
  77639. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77640. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77641. * @param scene defines the hosting scene
  77642. * @param updatable defines if the mesh must be flagged as updatable
  77643. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77644. * @returns a new Mesh
  77645. */
  77646. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77647. /**
  77648. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  77649. * @param name defines the name of the mesh to create
  77650. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77651. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77652. * @param scene defines the hosting scene
  77653. * @returns a new Mesh
  77654. */
  77655. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  77656. /**
  77657. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77658. * @param name defines the name of the mesh to create
  77659. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77660. * @param diameterTop set the top cap diameter (floats, default 1)
  77661. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77662. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77663. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77664. * @param scene defines the hosting scene
  77665. * @param updatable defines if the mesh must be flagged as updatable
  77666. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77667. * @returns a new Mesh
  77668. */
  77669. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77670. /**
  77671. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77672. * @param name defines the name of the mesh to create
  77673. * @param diameter sets the diameter size (float) of the torus (default 1)
  77674. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77675. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77676. * @param scene defines the hosting scene
  77677. * @param updatable defines if the mesh must be flagged as updatable
  77678. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77679. * @returns a new Mesh
  77680. */
  77681. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77682. /**
  77683. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77684. * @param name defines the name of the mesh to create
  77685. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77686. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77687. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77688. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77689. * @param p the number of windings on X axis (positive integers, default 2)
  77690. * @param q the number of windings on Y axis (positive integers, default 3)
  77691. * @param scene defines the hosting scene
  77692. * @param updatable defines if the mesh must be flagged as updatable
  77693. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77694. * @returns a new Mesh
  77695. */
  77696. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77697. /**
  77698. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77699. * @param name defines the name of the mesh to create
  77700. * @param points is an array successive Vector3
  77701. * @param scene defines the hosting scene
  77702. * @param updatable defines if the mesh must be flagged as updatable
  77703. * @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).
  77704. * @returns a new Mesh
  77705. */
  77706. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77707. /**
  77708. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77709. * @param name defines the name of the mesh to create
  77710. * @param points is an array successive Vector3
  77711. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77712. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77713. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77714. * @param scene defines the hosting scene
  77715. * @param updatable defines if the mesh must be flagged as updatable
  77716. * @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)
  77717. * @returns a new Mesh
  77718. */
  77719. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77720. /**
  77721. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77722. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77723. * 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.
  77724. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77725. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77726. * Remember you can only change the shape positions, not their number when updating a polygon.
  77727. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77728. * @param name defines the name of the mesh to create
  77729. * @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
  77730. * @param scene defines the hosting scene
  77731. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77732. * @param updatable defines if the mesh must be flagged as updatable
  77733. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77734. * @param earcutInjection can be used to inject your own earcut reference
  77735. * @returns a new Mesh
  77736. */
  77737. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77738. /**
  77739. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77740. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77741. * @param name defines the name of the mesh to create
  77742. * @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
  77743. * @param depth defines the height of extrusion
  77744. * @param scene defines the hosting scene
  77745. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77746. * @param updatable defines if the mesh must be flagged as updatable
  77747. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77748. * @param earcutInjection can be used to inject your own earcut reference
  77749. * @returns a new Mesh
  77750. */
  77751. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77752. /**
  77753. * Creates an extruded shape mesh.
  77754. * 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
  77755. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77756. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77757. * @param name defines the name of the mesh to create
  77758. * @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
  77759. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77760. * @param scale is the value to scale the shape
  77761. * @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
  77762. * @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
  77763. * @param scene defines the hosting scene
  77764. * @param updatable defines if the mesh must be flagged as updatable
  77765. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77766. * @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)
  77767. * @returns a new Mesh
  77768. */
  77769. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77770. /**
  77771. * Creates an custom extruded shape mesh.
  77772. * The custom extrusion is a parametric shape.
  77773. * It has no predefined shape. Its final shape will depend on the input parameters.
  77774. * Please consider using the same method from the MeshBuilder class instead
  77775. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77776. * @param name defines the name of the mesh to create
  77777. * @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
  77778. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77779. * @param scaleFunction is a custom Javascript function called on each path point
  77780. * @param rotationFunction is a custom Javascript function called on each path point
  77781. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77782. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77783. * @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
  77784. * @param scene defines the hosting scene
  77785. * @param updatable defines if the mesh must be flagged as updatable
  77786. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77787. * @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)
  77788. * @returns a new Mesh
  77789. */
  77790. 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;
  77791. /**
  77792. * Creates lathe mesh.
  77793. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77794. * Please consider using the same method from the MeshBuilder class instead
  77795. * @param name defines the name of the mesh to create
  77796. * @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
  77797. * @param radius is the radius value of the lathe
  77798. * @param tessellation is the side number of the lathe.
  77799. * @param scene defines the hosting scene
  77800. * @param updatable defines if the mesh must be flagged as updatable
  77801. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77802. * @returns a new Mesh
  77803. */
  77804. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77805. /**
  77806. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77807. * @param name defines the name of the mesh to create
  77808. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77809. * @param scene defines the hosting scene
  77810. * @param updatable defines if the mesh must be flagged as updatable
  77811. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77812. * @returns a new Mesh
  77813. */
  77814. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77815. /**
  77816. * Creates a ground mesh.
  77817. * Please consider using the same method from the MeshBuilder class instead
  77818. * @param name defines the name of the mesh to create
  77819. * @param width set the width of the ground
  77820. * @param height set the height of the ground
  77821. * @param subdivisions sets the number of subdivisions per side
  77822. * @param scene defines the hosting scene
  77823. * @param updatable defines if the mesh must be flagged as updatable
  77824. * @returns a new Mesh
  77825. */
  77826. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77827. /**
  77828. * Creates a tiled ground mesh.
  77829. * Please consider using the same method from the MeshBuilder class instead
  77830. * @param name defines the name of the mesh to create
  77831. * @param xmin set the ground minimum X coordinate
  77832. * @param zmin set the ground minimum Y coordinate
  77833. * @param xmax set the ground maximum X coordinate
  77834. * @param zmax set the ground maximum Z coordinate
  77835. * @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
  77836. * @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
  77837. * @param scene defines the hosting scene
  77838. * @param updatable defines if the mesh must be flagged as updatable
  77839. * @returns a new Mesh
  77840. */
  77841. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77842. w: number;
  77843. h: number;
  77844. }, precision: {
  77845. w: number;
  77846. h: number;
  77847. }, scene: Scene, updatable?: boolean): Mesh;
  77848. /**
  77849. * Creates a ground mesh from a height map.
  77850. * Please consider using the same method from the MeshBuilder class instead
  77851. * @see http://doc.babylonjs.com/babylon101/height_map
  77852. * @param name defines the name of the mesh to create
  77853. * @param url sets the URL of the height map image resource
  77854. * @param width set the ground width size
  77855. * @param height set the ground height size
  77856. * @param subdivisions sets the number of subdivision per side
  77857. * @param minHeight is the minimum altitude on the ground
  77858. * @param maxHeight is the maximum altitude on the ground
  77859. * @param scene defines the hosting scene
  77860. * @param updatable defines if the mesh must be flagged as updatable
  77861. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77862. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77863. * @returns a new Mesh
  77864. */
  77865. 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;
  77866. /**
  77867. * Creates a tube mesh.
  77868. * The tube is a parametric shape.
  77869. * It has no predefined shape. Its final shape will depend on the input parameters.
  77870. * Please consider using the same method from the MeshBuilder class instead
  77871. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77872. * @param name defines the name of the mesh to create
  77873. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77874. * @param radius sets the tube radius size
  77875. * @param tessellation is the number of sides on the tubular surface
  77876. * @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
  77877. * @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
  77878. * @param scene defines the hosting scene
  77879. * @param updatable defines if the mesh must be flagged as updatable
  77880. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77881. * @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)
  77882. * @returns a new Mesh
  77883. */
  77884. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77885. (i: number, distance: number): number;
  77886. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77887. /**
  77888. * Creates a polyhedron mesh.
  77889. * Please consider using the same method from the MeshBuilder class instead.
  77890. * * 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
  77891. * * The parameter `size` (positive float, default 1) sets the polygon size
  77892. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77893. * * 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`
  77894. * * 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
  77895. * * 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)`)
  77896. * * 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
  77897. * * 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
  77898. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77899. * * If you create a double-sided mesh, you can choose what parts of 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
  77900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77901. * @param name defines the name of the mesh to create
  77902. * @param options defines the options used to create the mesh
  77903. * @param scene defines the hosting scene
  77904. * @returns a new Mesh
  77905. */
  77906. static CreatePolyhedron(name: string, options: {
  77907. type?: number;
  77908. size?: number;
  77909. sizeX?: number;
  77910. sizeY?: number;
  77911. sizeZ?: number;
  77912. custom?: any;
  77913. faceUV?: Vector4[];
  77914. faceColors?: Color4[];
  77915. updatable?: boolean;
  77916. sideOrientation?: number;
  77917. }, scene: Scene): Mesh;
  77918. /**
  77919. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77920. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77921. * * 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`)
  77922. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77923. * * 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
  77924. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77925. * * If you create a double-sided mesh, you can choose what parts of 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
  77926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77927. * @param name defines the name of the mesh
  77928. * @param options defines the options used to create the mesh
  77929. * @param scene defines the hosting scene
  77930. * @returns a new Mesh
  77931. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77932. */
  77933. static CreateIcoSphere(name: string, options: {
  77934. radius?: number;
  77935. flat?: boolean;
  77936. subdivisions?: number;
  77937. sideOrientation?: number;
  77938. updatable?: boolean;
  77939. }, scene: Scene): Mesh;
  77940. /**
  77941. * Creates a decal mesh.
  77942. * Please consider using the same method from the MeshBuilder class instead.
  77943. * A decal is a mesh usually applied as a model onto the surface of another mesh
  77944. * @param name defines the name of the mesh
  77945. * @param sourceMesh defines the mesh receiving the decal
  77946. * @param position sets the position of the decal in world coordinates
  77947. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  77948. * @param size sets the decal scaling
  77949. * @param angle sets the angle to rotate the decal
  77950. * @returns a new Mesh
  77951. */
  77952. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  77953. /**
  77954. * Prepare internal position array for software CPU skinning
  77955. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  77956. */
  77957. setPositionsForCPUSkinning(): Float32Array;
  77958. /**
  77959. * Prepare internal normal array for software CPU skinning
  77960. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  77961. */
  77962. setNormalsForCPUSkinning(): Float32Array;
  77963. /**
  77964. * Updates the vertex buffer by applying transformation from the bones
  77965. * @param skeleton defines the skeleton to apply to current mesh
  77966. * @returns the current mesh
  77967. */
  77968. applySkeleton(skeleton: Skeleton): Mesh;
  77969. /**
  77970. * 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
  77971. * @param meshes defines the list of meshes to scan
  77972. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  77973. */
  77974. static MinMax(meshes: AbstractMesh[]): {
  77975. min: Vector3;
  77976. max: Vector3;
  77977. };
  77978. /**
  77979. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  77980. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  77981. * @returns a vector3
  77982. */
  77983. static Center(meshesOrMinMaxVector: {
  77984. min: Vector3;
  77985. max: Vector3;
  77986. } | AbstractMesh[]): Vector3;
  77987. /**
  77988. * Merge the array of meshes into a single mesh for performance reasons.
  77989. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  77990. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  77991. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  77992. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  77993. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  77994. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  77995. * @returns a new mesh
  77996. */
  77997. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  77998. /** @hidden */
  77999. addInstance(instance: InstancedMesh): void;
  78000. /** @hidden */
  78001. removeInstance(instance: InstancedMesh): void;
  78002. }
  78003. }
  78004. declare module BABYLON {
  78005. /**
  78006. * Interface used to define Action
  78007. */
  78008. export interface IAction {
  78009. /**
  78010. * Trigger for the action
  78011. */
  78012. trigger: number;
  78013. /** Options of the trigger */
  78014. triggerOptions: any;
  78015. /**
  78016. * Gets the trigger parameters
  78017. * @returns the trigger parameters
  78018. */
  78019. getTriggerParameter(): any;
  78020. /**
  78021. * Internal only - executes current action event
  78022. * @hidden
  78023. */
  78024. _executeCurrent(evt?: ActionEvent): void;
  78025. /**
  78026. * Serialize placeholder for child classes
  78027. * @param parent of child
  78028. * @returns the serialized object
  78029. */
  78030. serialize(parent: any): any;
  78031. /**
  78032. * Internal only
  78033. * @hidden
  78034. */
  78035. _prepare(): void;
  78036. /**
  78037. * Internal only - manager for action
  78038. * @hidden
  78039. */
  78040. _actionManager: AbstractActionManager;
  78041. /**
  78042. * Adds action to chain of actions, may be a DoNothingAction
  78043. * @param action defines the next action to execute
  78044. * @returns The action passed in
  78045. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78046. */
  78047. then(action: IAction): IAction;
  78048. }
  78049. /**
  78050. * The action to be carried out following a trigger
  78051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78052. */
  78053. export class Action implements IAction {
  78054. /** the trigger, with or without parameters, for the action */
  78055. triggerOptions: any;
  78056. /**
  78057. * Trigger for the action
  78058. */
  78059. trigger: number;
  78060. /**
  78061. * Internal only - manager for action
  78062. * @hidden
  78063. */
  78064. _actionManager: ActionManager;
  78065. private _nextActiveAction;
  78066. private _child;
  78067. private _condition?;
  78068. private _triggerParameter;
  78069. /**
  78070. * An event triggered prior to action being executed.
  78071. */
  78072. onBeforeExecuteObservable: Observable<Action>;
  78073. /**
  78074. * Creates a new Action
  78075. * @param triggerOptions the trigger, with or without parameters, for the action
  78076. * @param condition an optional determinant of action
  78077. */
  78078. constructor(
  78079. /** the trigger, with or without parameters, for the action */
  78080. triggerOptions: any, condition?: Condition);
  78081. /**
  78082. * Internal only
  78083. * @hidden
  78084. */
  78085. _prepare(): void;
  78086. /**
  78087. * Gets the trigger parameters
  78088. * @returns the trigger parameters
  78089. */
  78090. getTriggerParameter(): any;
  78091. /**
  78092. * Internal only - executes current action event
  78093. * @hidden
  78094. */
  78095. _executeCurrent(evt?: ActionEvent): void;
  78096. /**
  78097. * Execute placeholder for child classes
  78098. * @param evt optional action event
  78099. */
  78100. execute(evt?: ActionEvent): void;
  78101. /**
  78102. * Skips to next active action
  78103. */
  78104. skipToNextActiveAction(): void;
  78105. /**
  78106. * Adds action to chain of actions, may be a DoNothingAction
  78107. * @param action defines the next action to execute
  78108. * @returns The action passed in
  78109. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78110. */
  78111. then(action: Action): Action;
  78112. /**
  78113. * Internal only
  78114. * @hidden
  78115. */
  78116. _getProperty(propertyPath: string): string;
  78117. /**
  78118. * Internal only
  78119. * @hidden
  78120. */
  78121. _getEffectiveTarget(target: any, propertyPath: string): any;
  78122. /**
  78123. * Serialize placeholder for child classes
  78124. * @param parent of child
  78125. * @returns the serialized object
  78126. */
  78127. serialize(parent: any): any;
  78128. /**
  78129. * Internal only called by serialize
  78130. * @hidden
  78131. */
  78132. protected _serialize(serializedAction: any, parent?: any): any;
  78133. /**
  78134. * Internal only
  78135. * @hidden
  78136. */
  78137. static _SerializeValueAsString: (value: any) => string;
  78138. /**
  78139. * Internal only
  78140. * @hidden
  78141. */
  78142. static _GetTargetProperty: (target: Scene | Node) => {
  78143. name: string;
  78144. targetType: string;
  78145. value: string;
  78146. };
  78147. }
  78148. }
  78149. declare module BABYLON {
  78150. /**
  78151. * A Condition applied to an Action
  78152. */
  78153. export class Condition {
  78154. /**
  78155. * Internal only - manager for action
  78156. * @hidden
  78157. */
  78158. _actionManager: ActionManager;
  78159. /**
  78160. * Internal only
  78161. * @hidden
  78162. */
  78163. _evaluationId: number;
  78164. /**
  78165. * Internal only
  78166. * @hidden
  78167. */
  78168. _currentResult: boolean;
  78169. /**
  78170. * Creates a new Condition
  78171. * @param actionManager the manager of the action the condition is applied to
  78172. */
  78173. constructor(actionManager: ActionManager);
  78174. /**
  78175. * Check if the current condition is valid
  78176. * @returns a boolean
  78177. */
  78178. isValid(): boolean;
  78179. /**
  78180. * Internal only
  78181. * @hidden
  78182. */
  78183. _getProperty(propertyPath: string): string;
  78184. /**
  78185. * Internal only
  78186. * @hidden
  78187. */
  78188. _getEffectiveTarget(target: any, propertyPath: string): any;
  78189. /**
  78190. * Serialize placeholder for child classes
  78191. * @returns the serialized object
  78192. */
  78193. serialize(): any;
  78194. /**
  78195. * Internal only
  78196. * @hidden
  78197. */
  78198. protected _serialize(serializedCondition: any): any;
  78199. }
  78200. /**
  78201. * Defines specific conditional operators as extensions of Condition
  78202. */
  78203. export class ValueCondition extends Condition {
  78204. /** path to specify the property of the target the conditional operator uses */
  78205. propertyPath: string;
  78206. /** the value compared by the conditional operator against the current value of the property */
  78207. value: any;
  78208. /** the conditional operator, default ValueCondition.IsEqual */
  78209. operator: number;
  78210. /**
  78211. * Internal only
  78212. * @hidden
  78213. */
  78214. private static _IsEqual;
  78215. /**
  78216. * Internal only
  78217. * @hidden
  78218. */
  78219. private static _IsDifferent;
  78220. /**
  78221. * Internal only
  78222. * @hidden
  78223. */
  78224. private static _IsGreater;
  78225. /**
  78226. * Internal only
  78227. * @hidden
  78228. */
  78229. private static _IsLesser;
  78230. /**
  78231. * returns the number for IsEqual
  78232. */
  78233. static readonly IsEqual: number;
  78234. /**
  78235. * Returns the number for IsDifferent
  78236. */
  78237. static readonly IsDifferent: number;
  78238. /**
  78239. * Returns the number for IsGreater
  78240. */
  78241. static readonly IsGreater: number;
  78242. /**
  78243. * Returns the number for IsLesser
  78244. */
  78245. static readonly IsLesser: number;
  78246. /**
  78247. * Internal only The action manager for the condition
  78248. * @hidden
  78249. */
  78250. _actionManager: ActionManager;
  78251. /**
  78252. * Internal only
  78253. * @hidden
  78254. */
  78255. private _target;
  78256. /**
  78257. * Internal only
  78258. * @hidden
  78259. */
  78260. private _effectiveTarget;
  78261. /**
  78262. * Internal only
  78263. * @hidden
  78264. */
  78265. private _property;
  78266. /**
  78267. * Creates a new ValueCondition
  78268. * @param actionManager manager for the action the condition applies to
  78269. * @param target for the action
  78270. * @param propertyPath path to specify the property of the target the conditional operator uses
  78271. * @param value the value compared by the conditional operator against the current value of the property
  78272. * @param operator the conditional operator, default ValueCondition.IsEqual
  78273. */
  78274. constructor(actionManager: ActionManager, target: any,
  78275. /** path to specify the property of the target the conditional operator uses */
  78276. propertyPath: string,
  78277. /** the value compared by the conditional operator against the current value of the property */
  78278. value: any,
  78279. /** the conditional operator, default ValueCondition.IsEqual */
  78280. operator?: number);
  78281. /**
  78282. * Compares the given value with the property value for the specified conditional operator
  78283. * @returns the result of the comparison
  78284. */
  78285. isValid(): boolean;
  78286. /**
  78287. * Serialize the ValueCondition into a JSON compatible object
  78288. * @returns serialization object
  78289. */
  78290. serialize(): any;
  78291. /**
  78292. * Gets the name of the conditional operator for the ValueCondition
  78293. * @param operator the conditional operator
  78294. * @returns the name
  78295. */
  78296. static GetOperatorName(operator: number): string;
  78297. }
  78298. /**
  78299. * Defines a predicate condition as an extension of Condition
  78300. */
  78301. export class PredicateCondition extends Condition {
  78302. /** defines the predicate function used to validate the condition */
  78303. predicate: () => boolean;
  78304. /**
  78305. * Internal only - manager for action
  78306. * @hidden
  78307. */
  78308. _actionManager: ActionManager;
  78309. /**
  78310. * Creates a new PredicateCondition
  78311. * @param actionManager manager for the action the condition applies to
  78312. * @param predicate defines the predicate function used to validate the condition
  78313. */
  78314. constructor(actionManager: ActionManager,
  78315. /** defines the predicate function used to validate the condition */
  78316. predicate: () => boolean);
  78317. /**
  78318. * @returns the validity of the predicate condition
  78319. */
  78320. isValid(): boolean;
  78321. }
  78322. /**
  78323. * Defines a state condition as an extension of Condition
  78324. */
  78325. export class StateCondition extends Condition {
  78326. /** Value to compare with target state */
  78327. value: string;
  78328. /**
  78329. * Internal only - manager for action
  78330. * @hidden
  78331. */
  78332. _actionManager: ActionManager;
  78333. /**
  78334. * Internal only
  78335. * @hidden
  78336. */
  78337. private _target;
  78338. /**
  78339. * Creates a new StateCondition
  78340. * @param actionManager manager for the action the condition applies to
  78341. * @param target of the condition
  78342. * @param value to compare with target state
  78343. */
  78344. constructor(actionManager: ActionManager, target: any,
  78345. /** Value to compare with target state */
  78346. value: string);
  78347. /**
  78348. * Gets a boolean indicating if the current condition is met
  78349. * @returns the validity of the state
  78350. */
  78351. isValid(): boolean;
  78352. /**
  78353. * Serialize the StateCondition into a JSON compatible object
  78354. * @returns serialization object
  78355. */
  78356. serialize(): any;
  78357. }
  78358. }
  78359. declare module BABYLON {
  78360. /**
  78361. * This defines an action responsible to toggle a boolean once triggered.
  78362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78363. */
  78364. export class SwitchBooleanAction extends Action {
  78365. /**
  78366. * The path to the boolean property in the target object
  78367. */
  78368. propertyPath: string;
  78369. private _target;
  78370. private _effectiveTarget;
  78371. private _property;
  78372. /**
  78373. * Instantiate the action
  78374. * @param triggerOptions defines the trigger options
  78375. * @param target defines the object containing the boolean
  78376. * @param propertyPath defines the path to the boolean property in the target object
  78377. * @param condition defines the trigger related conditions
  78378. */
  78379. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78380. /** @hidden */
  78381. _prepare(): void;
  78382. /**
  78383. * Execute the action toggle the boolean value.
  78384. */
  78385. execute(): void;
  78386. /**
  78387. * Serializes the actions and its related information.
  78388. * @param parent defines the object to serialize in
  78389. * @returns the serialized object
  78390. */
  78391. serialize(parent: any): any;
  78392. }
  78393. /**
  78394. * This defines an action responsible to set a the state field of the target
  78395. * to a desired value once triggered.
  78396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78397. */
  78398. export class SetStateAction extends Action {
  78399. /**
  78400. * The value to store in the state field.
  78401. */
  78402. value: string;
  78403. private _target;
  78404. /**
  78405. * Instantiate the action
  78406. * @param triggerOptions defines the trigger options
  78407. * @param target defines the object containing the state property
  78408. * @param value defines the value to store in the state field
  78409. * @param condition defines the trigger related conditions
  78410. */
  78411. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78412. /**
  78413. * Execute the action and store the value on the target state property.
  78414. */
  78415. execute(): void;
  78416. /**
  78417. * Serializes the actions and its related information.
  78418. * @param parent defines the object to serialize in
  78419. * @returns the serialized object
  78420. */
  78421. serialize(parent: any): any;
  78422. }
  78423. /**
  78424. * This defines an action responsible to set a property of the target
  78425. * to a desired value once triggered.
  78426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78427. */
  78428. export class SetValueAction extends Action {
  78429. /**
  78430. * The path of the property to set in the target.
  78431. */
  78432. propertyPath: string;
  78433. /**
  78434. * The value to set in the property
  78435. */
  78436. value: any;
  78437. private _target;
  78438. private _effectiveTarget;
  78439. private _property;
  78440. /**
  78441. * Instantiate the action
  78442. * @param triggerOptions defines the trigger options
  78443. * @param target defines the object containing the property
  78444. * @param propertyPath defines the path of the property to set in the target
  78445. * @param value defines the value to set in the property
  78446. * @param condition defines the trigger related conditions
  78447. */
  78448. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78449. /** @hidden */
  78450. _prepare(): void;
  78451. /**
  78452. * Execute the action and set the targetted property to the desired value.
  78453. */
  78454. execute(): void;
  78455. /**
  78456. * Serializes the actions and its related information.
  78457. * @param parent defines the object to serialize in
  78458. * @returns the serialized object
  78459. */
  78460. serialize(parent: any): any;
  78461. }
  78462. /**
  78463. * This defines an action responsible to increment the target value
  78464. * to a desired value once triggered.
  78465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78466. */
  78467. export class IncrementValueAction extends Action {
  78468. /**
  78469. * The path of the property to increment in the target.
  78470. */
  78471. propertyPath: string;
  78472. /**
  78473. * The value we should increment the property by.
  78474. */
  78475. value: any;
  78476. private _target;
  78477. private _effectiveTarget;
  78478. private _property;
  78479. /**
  78480. * Instantiate the action
  78481. * @param triggerOptions defines the trigger options
  78482. * @param target defines the object containing the property
  78483. * @param propertyPath defines the path of the property to increment in the target
  78484. * @param value defines the value value we should increment the property by
  78485. * @param condition defines the trigger related conditions
  78486. */
  78487. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78488. /** @hidden */
  78489. _prepare(): void;
  78490. /**
  78491. * Execute the action and increment the target of the value amount.
  78492. */
  78493. execute(): void;
  78494. /**
  78495. * Serializes the actions and its related information.
  78496. * @param parent defines the object to serialize in
  78497. * @returns the serialized object
  78498. */
  78499. serialize(parent: any): any;
  78500. }
  78501. /**
  78502. * This defines an action responsible to start an animation once triggered.
  78503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78504. */
  78505. export class PlayAnimationAction extends Action {
  78506. /**
  78507. * Where the animation should start (animation frame)
  78508. */
  78509. from: number;
  78510. /**
  78511. * Where the animation should stop (animation frame)
  78512. */
  78513. to: number;
  78514. /**
  78515. * Define if the animation should loop or stop after the first play.
  78516. */
  78517. loop?: boolean;
  78518. private _target;
  78519. /**
  78520. * Instantiate the action
  78521. * @param triggerOptions defines the trigger options
  78522. * @param target defines the target animation or animation name
  78523. * @param from defines from where the animation should start (animation frame)
  78524. * @param end defines where the animation should stop (animation frame)
  78525. * @param loop defines if the animation should loop or stop after the first play
  78526. * @param condition defines the trigger related conditions
  78527. */
  78528. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78529. /** @hidden */
  78530. _prepare(): void;
  78531. /**
  78532. * Execute the action and play the animation.
  78533. */
  78534. execute(): void;
  78535. /**
  78536. * Serializes the actions and its related information.
  78537. * @param parent defines the object to serialize in
  78538. * @returns the serialized object
  78539. */
  78540. serialize(parent: any): any;
  78541. }
  78542. /**
  78543. * This defines an action responsible to stop an animation once triggered.
  78544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78545. */
  78546. export class StopAnimationAction extends Action {
  78547. private _target;
  78548. /**
  78549. * Instantiate the action
  78550. * @param triggerOptions defines the trigger options
  78551. * @param target defines the target animation or animation name
  78552. * @param condition defines the trigger related conditions
  78553. */
  78554. constructor(triggerOptions: any, target: any, condition?: Condition);
  78555. /** @hidden */
  78556. _prepare(): void;
  78557. /**
  78558. * Execute the action and stop the animation.
  78559. */
  78560. execute(): void;
  78561. /**
  78562. * Serializes the actions and its related information.
  78563. * @param parent defines the object to serialize in
  78564. * @returns the serialized object
  78565. */
  78566. serialize(parent: any): any;
  78567. }
  78568. /**
  78569. * This defines an action responsible that does nothing once triggered.
  78570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78571. */
  78572. export class DoNothingAction extends Action {
  78573. /**
  78574. * Instantiate the action
  78575. * @param triggerOptions defines the trigger options
  78576. * @param condition defines the trigger related conditions
  78577. */
  78578. constructor(triggerOptions?: any, condition?: Condition);
  78579. /**
  78580. * Execute the action and do nothing.
  78581. */
  78582. execute(): void;
  78583. /**
  78584. * Serializes the actions and its related information.
  78585. * @param parent defines the object to serialize in
  78586. * @returns the serialized object
  78587. */
  78588. serialize(parent: any): any;
  78589. }
  78590. /**
  78591. * This defines an action responsible to trigger several actions once triggered.
  78592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78593. */
  78594. export class CombineAction extends Action {
  78595. /**
  78596. * The list of aggregated animations to run.
  78597. */
  78598. children: Action[];
  78599. /**
  78600. * Instantiate the action
  78601. * @param triggerOptions defines the trigger options
  78602. * @param children defines the list of aggregated animations to run
  78603. * @param condition defines the trigger related conditions
  78604. */
  78605. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78606. /** @hidden */
  78607. _prepare(): void;
  78608. /**
  78609. * Execute the action and executes all the aggregated actions.
  78610. */
  78611. execute(evt: ActionEvent): void;
  78612. /**
  78613. * Serializes the actions and its related information.
  78614. * @param parent defines the object to serialize in
  78615. * @returns the serialized object
  78616. */
  78617. serialize(parent: any): any;
  78618. }
  78619. /**
  78620. * This defines an action responsible to run code (external event) once triggered.
  78621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78622. */
  78623. export class ExecuteCodeAction extends Action {
  78624. /**
  78625. * The callback function to run.
  78626. */
  78627. func: (evt: ActionEvent) => void;
  78628. /**
  78629. * Instantiate the action
  78630. * @param triggerOptions defines the trigger options
  78631. * @param func defines the callback function to run
  78632. * @param condition defines the trigger related conditions
  78633. */
  78634. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78635. /**
  78636. * Execute the action and run the attached code.
  78637. */
  78638. execute(evt: ActionEvent): void;
  78639. }
  78640. /**
  78641. * This defines an action responsible to set the parent property of the target once triggered.
  78642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78643. */
  78644. export class SetParentAction extends Action {
  78645. private _parent;
  78646. private _target;
  78647. /**
  78648. * Instantiate the action
  78649. * @param triggerOptions defines the trigger options
  78650. * @param target defines the target containing the parent property
  78651. * @param parent defines from where the animation should start (animation frame)
  78652. * @param condition defines the trigger related conditions
  78653. */
  78654. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78655. /** @hidden */
  78656. _prepare(): void;
  78657. /**
  78658. * Execute the action and set the parent property.
  78659. */
  78660. execute(): void;
  78661. /**
  78662. * Serializes the actions and its related information.
  78663. * @param parent defines the object to serialize in
  78664. * @returns the serialized object
  78665. */
  78666. serialize(parent: any): any;
  78667. }
  78668. }
  78669. declare module BABYLON {
  78670. /**
  78671. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78672. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78674. */
  78675. export class ActionManager extends AbstractActionManager {
  78676. /**
  78677. * Nothing
  78678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78679. */
  78680. static readonly NothingTrigger: number;
  78681. /**
  78682. * On pick
  78683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78684. */
  78685. static readonly OnPickTrigger: number;
  78686. /**
  78687. * On left pick
  78688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78689. */
  78690. static readonly OnLeftPickTrigger: number;
  78691. /**
  78692. * On right pick
  78693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78694. */
  78695. static readonly OnRightPickTrigger: number;
  78696. /**
  78697. * On center pick
  78698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78699. */
  78700. static readonly OnCenterPickTrigger: number;
  78701. /**
  78702. * On pick down
  78703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78704. */
  78705. static readonly OnPickDownTrigger: number;
  78706. /**
  78707. * On double pick
  78708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78709. */
  78710. static readonly OnDoublePickTrigger: number;
  78711. /**
  78712. * On pick up
  78713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78714. */
  78715. static readonly OnPickUpTrigger: number;
  78716. /**
  78717. * On pick out.
  78718. * This trigger will only be raised if you also declared a OnPickDown
  78719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78720. */
  78721. static readonly OnPickOutTrigger: number;
  78722. /**
  78723. * On long press
  78724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78725. */
  78726. static readonly OnLongPressTrigger: number;
  78727. /**
  78728. * On pointer over
  78729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78730. */
  78731. static readonly OnPointerOverTrigger: number;
  78732. /**
  78733. * On pointer out
  78734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78735. */
  78736. static readonly OnPointerOutTrigger: number;
  78737. /**
  78738. * On every frame
  78739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78740. */
  78741. static readonly OnEveryFrameTrigger: number;
  78742. /**
  78743. * On intersection enter
  78744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78745. */
  78746. static readonly OnIntersectionEnterTrigger: number;
  78747. /**
  78748. * On intersection exit
  78749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78750. */
  78751. static readonly OnIntersectionExitTrigger: number;
  78752. /**
  78753. * On key down
  78754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78755. */
  78756. static readonly OnKeyDownTrigger: number;
  78757. /**
  78758. * On key up
  78759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78760. */
  78761. static readonly OnKeyUpTrigger: number;
  78762. private _scene;
  78763. /**
  78764. * Creates a new action manager
  78765. * @param scene defines the hosting scene
  78766. */
  78767. constructor(scene: Scene);
  78768. /**
  78769. * Releases all associated resources
  78770. */
  78771. dispose(): void;
  78772. /**
  78773. * Gets hosting scene
  78774. * @returns the hosting scene
  78775. */
  78776. getScene(): Scene;
  78777. /**
  78778. * Does this action manager handles actions of any of the given triggers
  78779. * @param triggers defines the triggers to be tested
  78780. * @return a boolean indicating whether one (or more) of the triggers is handled
  78781. */
  78782. hasSpecificTriggers(triggers: number[]): boolean;
  78783. /**
  78784. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78785. * speed.
  78786. * @param triggerA defines the trigger to be tested
  78787. * @param triggerB defines the trigger to be tested
  78788. * @return a boolean indicating whether one (or more) of the triggers is handled
  78789. */
  78790. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78791. /**
  78792. * Does this action manager handles actions of a given trigger
  78793. * @param trigger defines the trigger to be tested
  78794. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78795. * @return whether the trigger is handled
  78796. */
  78797. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78798. /**
  78799. * Does this action manager has pointer triggers
  78800. */
  78801. readonly hasPointerTriggers: boolean;
  78802. /**
  78803. * Does this action manager has pick triggers
  78804. */
  78805. readonly hasPickTriggers: boolean;
  78806. /**
  78807. * Registers an action to this action manager
  78808. * @param action defines the action to be registered
  78809. * @return the action amended (prepared) after registration
  78810. */
  78811. registerAction(action: IAction): Nullable<IAction>;
  78812. /**
  78813. * Unregisters an action to this action manager
  78814. * @param action defines the action to be unregistered
  78815. * @return a boolean indicating whether the action has been unregistered
  78816. */
  78817. unregisterAction(action: IAction): Boolean;
  78818. /**
  78819. * Process a specific trigger
  78820. * @param trigger defines the trigger to process
  78821. * @param evt defines the event details to be processed
  78822. */
  78823. processTrigger(trigger: number, evt?: IActionEvent): void;
  78824. /** @hidden */
  78825. _getEffectiveTarget(target: any, propertyPath: string): any;
  78826. /** @hidden */
  78827. _getProperty(propertyPath: string): string;
  78828. /**
  78829. * Serialize this manager to a JSON object
  78830. * @param name defines the property name to store this manager
  78831. * @returns a JSON representation of this manager
  78832. */
  78833. serialize(name: string): any;
  78834. /**
  78835. * Creates a new ActionManager from a JSON data
  78836. * @param parsedActions defines the JSON data to read from
  78837. * @param object defines the hosting mesh
  78838. * @param scene defines the hosting scene
  78839. */
  78840. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78841. /**
  78842. * Get a trigger name by index
  78843. * @param trigger defines the trigger index
  78844. * @returns a trigger name
  78845. */
  78846. static GetTriggerName(trigger: number): string;
  78847. }
  78848. }
  78849. declare module BABYLON {
  78850. /**
  78851. * Class representing a ray with position and direction
  78852. */
  78853. export class Ray {
  78854. /** origin point */
  78855. origin: Vector3;
  78856. /** direction */
  78857. direction: Vector3;
  78858. /** length of the ray */
  78859. length: number;
  78860. private static readonly TmpVector3;
  78861. private _tmpRay;
  78862. /**
  78863. * Creates a new ray
  78864. * @param origin origin point
  78865. * @param direction direction
  78866. * @param length length of the ray
  78867. */
  78868. constructor(
  78869. /** origin point */
  78870. origin: Vector3,
  78871. /** direction */
  78872. direction: Vector3,
  78873. /** length of the ray */
  78874. length?: number);
  78875. /**
  78876. * Checks if the ray intersects a box
  78877. * @param minimum bound of the box
  78878. * @param maximum bound of the box
  78879. * @param intersectionTreshold extra extend to be added to the box in all direction
  78880. * @returns if the box was hit
  78881. */
  78882. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78883. /**
  78884. * Checks if the ray intersects a box
  78885. * @param box the bounding box to check
  78886. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78887. * @returns if the box was hit
  78888. */
  78889. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78890. /**
  78891. * If the ray hits a sphere
  78892. * @param sphere the bounding sphere to check
  78893. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78894. * @returns true if it hits the sphere
  78895. */
  78896. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78897. /**
  78898. * If the ray hits a triange
  78899. * @param vertex0 triangle vertex
  78900. * @param vertex1 triangle vertex
  78901. * @param vertex2 triangle vertex
  78902. * @returns intersection information if hit
  78903. */
  78904. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78905. /**
  78906. * Checks if ray intersects a plane
  78907. * @param plane the plane to check
  78908. * @returns the distance away it was hit
  78909. */
  78910. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78911. /**
  78912. * Checks if ray intersects a mesh
  78913. * @param mesh the mesh to check
  78914. * @param fastCheck if only the bounding box should checked
  78915. * @returns picking info of the intersecton
  78916. */
  78917. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78918. /**
  78919. * Checks if ray intersects a mesh
  78920. * @param meshes the meshes to check
  78921. * @param fastCheck if only the bounding box should checked
  78922. * @param results array to store result in
  78923. * @returns Array of picking infos
  78924. */
  78925. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78926. private _comparePickingInfo;
  78927. private static smallnum;
  78928. private static rayl;
  78929. /**
  78930. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78931. * @param sega the first point of the segment to test the intersection against
  78932. * @param segb the second point of the segment to test the intersection against
  78933. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78934. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78935. */
  78936. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78937. /**
  78938. * Update the ray from viewport position
  78939. * @param x position
  78940. * @param y y position
  78941. * @param viewportWidth viewport width
  78942. * @param viewportHeight viewport height
  78943. * @param world world matrix
  78944. * @param view view matrix
  78945. * @param projection projection matrix
  78946. * @returns this ray updated
  78947. */
  78948. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78949. /**
  78950. * Creates a ray with origin and direction of 0,0,0
  78951. * @returns the new ray
  78952. */
  78953. static Zero(): Ray;
  78954. /**
  78955. * Creates a new ray from screen space and viewport
  78956. * @param x position
  78957. * @param y y position
  78958. * @param viewportWidth viewport width
  78959. * @param viewportHeight viewport height
  78960. * @param world world matrix
  78961. * @param view view matrix
  78962. * @param projection projection matrix
  78963. * @returns new ray
  78964. */
  78965. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78966. /**
  78967. * 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
  78968. * transformed to the given world matrix.
  78969. * @param origin The origin point
  78970. * @param end The end point
  78971. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78972. * @returns the new ray
  78973. */
  78974. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78975. /**
  78976. * Transforms a ray by a matrix
  78977. * @param ray ray to transform
  78978. * @param matrix matrix to apply
  78979. * @returns the resulting new ray
  78980. */
  78981. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78982. /**
  78983. * Transforms a ray by a matrix
  78984. * @param ray ray to transform
  78985. * @param matrix matrix to apply
  78986. * @param result ray to store result in
  78987. */
  78988. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78989. /**
  78990. * Unproject a ray from screen space to object space
  78991. * @param sourceX defines the screen space x coordinate to use
  78992. * @param sourceY defines the screen space y coordinate to use
  78993. * @param viewportWidth defines the current width of the viewport
  78994. * @param viewportHeight defines the current height of the viewport
  78995. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78996. * @param view defines the view matrix to use
  78997. * @param projection defines the projection matrix to use
  78998. */
  78999. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  79000. }
  79001. /**
  79002. * Type used to define predicate used to select faces when a mesh intersection is detected
  79003. */
  79004. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  79005. interface Scene {
  79006. /** @hidden */
  79007. _tempPickingRay: Nullable<Ray>;
  79008. /** @hidden */
  79009. _cachedRayForTransform: Ray;
  79010. /** @hidden */
  79011. _pickWithRayInverseMatrix: Matrix;
  79012. /** @hidden */
  79013. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79014. /** @hidden */
  79015. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79016. }
  79017. }
  79018. declare module BABYLON {
  79019. interface Scene {
  79020. /** @hidden */
  79021. _pointerOverSprite: Nullable<Sprite>;
  79022. /** @hidden */
  79023. _pickedDownSprite: Nullable<Sprite>;
  79024. /** @hidden */
  79025. _tempSpritePickingRay: Nullable<Ray>;
  79026. /**
  79027. * All of the sprite managers added to this scene
  79028. * @see http://doc.babylonjs.com/babylon101/sprites
  79029. */
  79030. spriteManagers: Array<ISpriteManager>;
  79031. /**
  79032. * An event triggered when sprites rendering is about to start
  79033. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79034. */
  79035. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79036. /**
  79037. * An event triggered when sprites rendering is done
  79038. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79039. */
  79040. onAfterSpritesRenderingObservable: Observable<Scene>;
  79041. /** @hidden */
  79042. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79043. /** Launch a ray to try to pick a sprite in the scene
  79044. * @param x position on screen
  79045. * @param y position on screen
  79046. * @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
  79047. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79048. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79049. * @returns a PickingInfo
  79050. */
  79051. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79052. /** Use the given ray to pick a sprite in the scene
  79053. * @param ray The ray (in world space) to use to pick meshes
  79054. * @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
  79055. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79056. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79057. * @returns a PickingInfo
  79058. */
  79059. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79060. /**
  79061. * Force the sprite under the pointer
  79062. * @param sprite defines the sprite to use
  79063. */
  79064. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79065. /**
  79066. * Gets the sprite under the pointer
  79067. * @returns a Sprite or null if no sprite is under the pointer
  79068. */
  79069. getPointerOverSprite(): Nullable<Sprite>;
  79070. }
  79071. /**
  79072. * Defines the sprite scene component responsible to manage sprites
  79073. * in a given scene.
  79074. */
  79075. export class SpriteSceneComponent implements ISceneComponent {
  79076. /**
  79077. * The component name helpfull to identify the component in the list of scene components.
  79078. */
  79079. readonly name: string;
  79080. /**
  79081. * The scene the component belongs to.
  79082. */
  79083. scene: Scene;
  79084. /** @hidden */
  79085. private _spritePredicate;
  79086. /**
  79087. * Creates a new instance of the component for the given scene
  79088. * @param scene Defines the scene to register the component in
  79089. */
  79090. constructor(scene: Scene);
  79091. /**
  79092. * Registers the component in a given scene
  79093. */
  79094. register(): void;
  79095. /**
  79096. * Rebuilds the elements related to this component in case of
  79097. * context lost for instance.
  79098. */
  79099. rebuild(): void;
  79100. /**
  79101. * Disposes the component and the associated ressources.
  79102. */
  79103. dispose(): void;
  79104. private _pickSpriteButKeepRay;
  79105. private _pointerMove;
  79106. private _pointerDown;
  79107. private _pointerUp;
  79108. }
  79109. }
  79110. declare module BABYLON {
  79111. /** @hidden */
  79112. export var fogFragmentDeclaration: {
  79113. name: string;
  79114. shader: string;
  79115. };
  79116. }
  79117. declare module BABYLON {
  79118. /** @hidden */
  79119. export var fogFragment: {
  79120. name: string;
  79121. shader: string;
  79122. };
  79123. }
  79124. declare module BABYLON {
  79125. /** @hidden */
  79126. export var spritesPixelShader: {
  79127. name: string;
  79128. shader: string;
  79129. };
  79130. }
  79131. declare module BABYLON {
  79132. /** @hidden */
  79133. export var fogVertexDeclaration: {
  79134. name: string;
  79135. shader: string;
  79136. };
  79137. }
  79138. declare module BABYLON {
  79139. /** @hidden */
  79140. export var spritesVertexShader: {
  79141. name: string;
  79142. shader: string;
  79143. };
  79144. }
  79145. declare module BABYLON {
  79146. /**
  79147. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79148. */
  79149. export interface ISpriteManager extends IDisposable {
  79150. /**
  79151. * Restricts the camera to viewing objects with the same layerMask.
  79152. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79153. */
  79154. layerMask: number;
  79155. /**
  79156. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79157. */
  79158. isPickable: boolean;
  79159. /**
  79160. * Specifies the rendering group id for this mesh (0 by default)
  79161. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79162. */
  79163. renderingGroupId: number;
  79164. /**
  79165. * Defines the list of sprites managed by the manager.
  79166. */
  79167. sprites: Array<Sprite>;
  79168. /**
  79169. * Tests the intersection of a sprite with a specific ray.
  79170. * @param ray The ray we are sending to test the collision
  79171. * @param camera The camera space we are sending rays in
  79172. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79173. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79174. * @returns picking info or null.
  79175. */
  79176. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79177. /**
  79178. * Renders the list of sprites on screen.
  79179. */
  79180. render(): void;
  79181. }
  79182. /**
  79183. * Class used to manage multiple sprites on the same spritesheet
  79184. * @see http://doc.babylonjs.com/babylon101/sprites
  79185. */
  79186. export class SpriteManager implements ISpriteManager {
  79187. /** defines the manager's name */
  79188. name: string;
  79189. /** Gets the list of sprites */
  79190. sprites: Sprite[];
  79191. /** Gets or sets the rendering group id (0 by default) */
  79192. renderingGroupId: number;
  79193. /** Gets or sets camera layer mask */
  79194. layerMask: number;
  79195. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79196. fogEnabled: boolean;
  79197. /** Gets or sets a boolean indicating if the sprites are pickable */
  79198. isPickable: boolean;
  79199. /** Defines the default width of a cell in the spritesheet */
  79200. cellWidth: number;
  79201. /** Defines the default height of a cell in the spritesheet */
  79202. cellHeight: number;
  79203. /**
  79204. * An event triggered when the manager is disposed.
  79205. */
  79206. onDisposeObservable: Observable<SpriteManager>;
  79207. private _onDisposeObserver;
  79208. /**
  79209. * Callback called when the manager is disposed
  79210. */
  79211. onDispose: () => void;
  79212. private _capacity;
  79213. private _spriteTexture;
  79214. private _epsilon;
  79215. private _scene;
  79216. private _vertexData;
  79217. private _buffer;
  79218. private _vertexBuffers;
  79219. private _indexBuffer;
  79220. private _effectBase;
  79221. private _effectFog;
  79222. /**
  79223. * Gets or sets the spritesheet texture
  79224. */
  79225. texture: Texture;
  79226. /**
  79227. * Creates a new sprite manager
  79228. * @param name defines the manager's name
  79229. * @param imgUrl defines the sprite sheet url
  79230. * @param capacity defines the maximum allowed number of sprites
  79231. * @param cellSize defines the size of a sprite cell
  79232. * @param scene defines the hosting scene
  79233. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79234. * @param samplingMode defines the smapling mode to use with spritesheet
  79235. */
  79236. constructor(
  79237. /** defines the manager's name */
  79238. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  79239. private _appendSpriteVertex;
  79240. /**
  79241. * Intersects the sprites with a ray
  79242. * @param ray defines the ray to intersect with
  79243. * @param camera defines the current active camera
  79244. * @param predicate defines a predicate used to select candidate sprites
  79245. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79246. * @returns null if no hit or a PickingInfo
  79247. */
  79248. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79249. /**
  79250. * Render all child sprites
  79251. */
  79252. render(): void;
  79253. /**
  79254. * Release associated resources
  79255. */
  79256. dispose(): void;
  79257. }
  79258. }
  79259. declare module BABYLON {
  79260. /**
  79261. * Class used to represent a sprite
  79262. * @see http://doc.babylonjs.com/babylon101/sprites
  79263. */
  79264. export class Sprite {
  79265. /** defines the name */
  79266. name: string;
  79267. /** Gets or sets the current world position */
  79268. position: Vector3;
  79269. /** Gets or sets the main color */
  79270. color: Color4;
  79271. /** Gets or sets the width */
  79272. width: number;
  79273. /** Gets or sets the height */
  79274. height: number;
  79275. /** Gets or sets rotation angle */
  79276. angle: number;
  79277. /** Gets or sets the cell index in the sprite sheet */
  79278. cellIndex: number;
  79279. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79280. invertU: number;
  79281. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79282. invertV: number;
  79283. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79284. disposeWhenFinishedAnimating: boolean;
  79285. /** Gets the list of attached animations */
  79286. animations: Animation[];
  79287. /** Gets or sets a boolean indicating if the sprite can be picked */
  79288. isPickable: boolean;
  79289. /**
  79290. * Gets or sets the associated action manager
  79291. */
  79292. actionManager: Nullable<ActionManager>;
  79293. private _animationStarted;
  79294. private _loopAnimation;
  79295. private _fromIndex;
  79296. private _toIndex;
  79297. private _delay;
  79298. private _direction;
  79299. private _manager;
  79300. private _time;
  79301. private _onAnimationEnd;
  79302. /**
  79303. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79304. */
  79305. isVisible: boolean;
  79306. /**
  79307. * Gets or sets the sprite size
  79308. */
  79309. size: number;
  79310. /**
  79311. * Creates a new Sprite
  79312. * @param name defines the name
  79313. * @param manager defines the manager
  79314. */
  79315. constructor(
  79316. /** defines the name */
  79317. name: string, manager: ISpriteManager);
  79318. /**
  79319. * Starts an animation
  79320. * @param from defines the initial key
  79321. * @param to defines the end key
  79322. * @param loop defines if the animation must loop
  79323. * @param delay defines the start delay (in ms)
  79324. * @param onAnimationEnd defines a callback to call when animation ends
  79325. */
  79326. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79327. /** Stops current animation (if any) */
  79328. stopAnimation(): void;
  79329. /** @hidden */
  79330. _animate(deltaTime: number): void;
  79331. /** Release associated resources */
  79332. dispose(): void;
  79333. }
  79334. }
  79335. declare module BABYLON {
  79336. /**
  79337. * Information about the result of picking within a scene
  79338. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79339. */
  79340. export class PickingInfo {
  79341. /** @hidden */
  79342. _pickingUnavailable: boolean;
  79343. /**
  79344. * If the pick collided with an object
  79345. */
  79346. hit: boolean;
  79347. /**
  79348. * Distance away where the pick collided
  79349. */
  79350. distance: number;
  79351. /**
  79352. * The location of pick collision
  79353. */
  79354. pickedPoint: Nullable<Vector3>;
  79355. /**
  79356. * The mesh corresponding the the pick collision
  79357. */
  79358. pickedMesh: Nullable<AbstractMesh>;
  79359. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79360. bu: number;
  79361. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79362. bv: number;
  79363. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79364. faceId: number;
  79365. /** Id of the the submesh that was picked */
  79366. subMeshId: number;
  79367. /** If a sprite was picked, this will be the sprite the pick collided with */
  79368. pickedSprite: Nullable<Sprite>;
  79369. /**
  79370. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79371. */
  79372. originMesh: Nullable<AbstractMesh>;
  79373. /**
  79374. * The ray that was used to perform the picking.
  79375. */
  79376. ray: Nullable<Ray>;
  79377. /**
  79378. * Gets the normal correspodning to the face the pick collided with
  79379. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79380. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79381. * @returns The normal correspodning to the face the pick collided with
  79382. */
  79383. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79384. /**
  79385. * Gets the texture coordinates of where the pick occured
  79386. * @returns the vector containing the coordnates of the texture
  79387. */
  79388. getTextureCoordinates(): Nullable<Vector2>;
  79389. }
  79390. }
  79391. declare module BABYLON {
  79392. /**
  79393. * Gather the list of pointer event types as constants.
  79394. */
  79395. export class PointerEventTypes {
  79396. /**
  79397. * 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.
  79398. */
  79399. static readonly POINTERDOWN: number;
  79400. /**
  79401. * The pointerup event is fired when a pointer is no longer active.
  79402. */
  79403. static readonly POINTERUP: number;
  79404. /**
  79405. * The pointermove event is fired when a pointer changes coordinates.
  79406. */
  79407. static readonly POINTERMOVE: number;
  79408. /**
  79409. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79410. */
  79411. static readonly POINTERWHEEL: number;
  79412. /**
  79413. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79414. */
  79415. static readonly POINTERPICK: number;
  79416. /**
  79417. * The pointertap event is fired when a the object has been touched and released without drag.
  79418. */
  79419. static readonly POINTERTAP: number;
  79420. /**
  79421. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79422. */
  79423. static readonly POINTERDOUBLETAP: number;
  79424. }
  79425. /**
  79426. * Base class of pointer info types.
  79427. */
  79428. export class PointerInfoBase {
  79429. /**
  79430. * Defines the type of event (PointerEventTypes)
  79431. */
  79432. type: number;
  79433. /**
  79434. * Defines the related dom event
  79435. */
  79436. event: PointerEvent | MouseWheelEvent;
  79437. /**
  79438. * Instantiates the base class of pointers info.
  79439. * @param type Defines the type of event (PointerEventTypes)
  79440. * @param event Defines the related dom event
  79441. */
  79442. constructor(
  79443. /**
  79444. * Defines the type of event (PointerEventTypes)
  79445. */
  79446. type: number,
  79447. /**
  79448. * Defines the related dom event
  79449. */
  79450. event: PointerEvent | MouseWheelEvent);
  79451. }
  79452. /**
  79453. * This class is used to store pointer related info for the onPrePointerObservable event.
  79454. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79455. */
  79456. export class PointerInfoPre extends PointerInfoBase {
  79457. /**
  79458. * Ray from a pointer if availible (eg. 6dof controller)
  79459. */
  79460. ray: Nullable<Ray>;
  79461. /**
  79462. * Defines the local position of the pointer on the canvas.
  79463. */
  79464. localPosition: Vector2;
  79465. /**
  79466. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79467. */
  79468. skipOnPointerObservable: boolean;
  79469. /**
  79470. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79471. * @param type Defines the type of event (PointerEventTypes)
  79472. * @param event Defines the related dom event
  79473. * @param localX Defines the local x coordinates of the pointer when the event occured
  79474. * @param localY Defines the local y coordinates of the pointer when the event occured
  79475. */
  79476. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79477. }
  79478. /**
  79479. * This type contains all the data related to a pointer event in Babylon.js.
  79480. * 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.
  79481. */
  79482. export class PointerInfo extends PointerInfoBase {
  79483. /**
  79484. * Defines the picking info associated to the info (if any)\
  79485. */
  79486. pickInfo: Nullable<PickingInfo>;
  79487. /**
  79488. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79489. * @param type Defines the type of event (PointerEventTypes)
  79490. * @param event Defines the related dom event
  79491. * @param pickInfo Defines the picking info associated to the info (if any)\
  79492. */
  79493. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79494. /**
  79495. * Defines the picking info associated to the info (if any)\
  79496. */
  79497. pickInfo: Nullable<PickingInfo>);
  79498. }
  79499. /**
  79500. * Data relating to a touch event on the screen.
  79501. */
  79502. export interface PointerTouch {
  79503. /**
  79504. * X coordinate of touch.
  79505. */
  79506. x: number;
  79507. /**
  79508. * Y coordinate of touch.
  79509. */
  79510. y: number;
  79511. /**
  79512. * Id of touch. Unique for each finger.
  79513. */
  79514. pointerId: number;
  79515. /**
  79516. * Event type passed from DOM.
  79517. */
  79518. type: any;
  79519. }
  79520. }
  79521. declare module BABYLON {
  79522. /**
  79523. * Manage the mouse inputs to control the movement of a free camera.
  79524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79525. */
  79526. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79527. /**
  79528. * Define if touch is enabled in the mouse input
  79529. */
  79530. touchEnabled: boolean;
  79531. /**
  79532. * Defines the camera the input is attached to.
  79533. */
  79534. camera: FreeCamera;
  79535. /**
  79536. * Defines the buttons associated with the input to handle camera move.
  79537. */
  79538. buttons: number[];
  79539. /**
  79540. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79541. */
  79542. angularSensibility: number;
  79543. private _pointerInput;
  79544. private _onMouseMove;
  79545. private _observer;
  79546. private previousPosition;
  79547. /**
  79548. * Observable for when a pointer move event occurs containing the move offset
  79549. */
  79550. onPointerMovedObservable: Observable<{
  79551. offsetX: number;
  79552. offsetY: number;
  79553. }>;
  79554. /**
  79555. * @hidden
  79556. * If the camera should be rotated automatically based on pointer movement
  79557. */
  79558. _allowCameraRotation: boolean;
  79559. /**
  79560. * Manage the mouse inputs to control the movement of a free camera.
  79561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79562. * @param touchEnabled Defines if touch is enabled or not
  79563. */
  79564. constructor(
  79565. /**
  79566. * Define if touch is enabled in the mouse input
  79567. */
  79568. touchEnabled?: boolean);
  79569. /**
  79570. * Attach the input controls to a specific dom element to get the input from.
  79571. * @param element Defines the element the controls should be listened from
  79572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79573. */
  79574. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79575. /**
  79576. * Called on JS contextmenu event.
  79577. * Override this method to provide functionality.
  79578. */
  79579. protected onContextMenu(evt: PointerEvent): void;
  79580. /**
  79581. * Detach the current controls from the specified dom element.
  79582. * @param element Defines the element to stop listening the inputs from
  79583. */
  79584. detachControl(element: Nullable<HTMLElement>): void;
  79585. /**
  79586. * Gets the class name of the current intput.
  79587. * @returns the class name
  79588. */
  79589. getClassName(): string;
  79590. /**
  79591. * Get the friendly name associated with the input class.
  79592. * @returns the input friendly name
  79593. */
  79594. getSimpleName(): string;
  79595. }
  79596. }
  79597. declare module BABYLON {
  79598. /**
  79599. * Manage the touch inputs to control the movement of a free camera.
  79600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79601. */
  79602. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79603. /**
  79604. * Defines the camera the input is attached to.
  79605. */
  79606. camera: FreeCamera;
  79607. /**
  79608. * Defines the touch sensibility for rotation.
  79609. * The higher the faster.
  79610. */
  79611. touchAngularSensibility: number;
  79612. /**
  79613. * Defines the touch sensibility for move.
  79614. * The higher the faster.
  79615. */
  79616. touchMoveSensibility: number;
  79617. private _offsetX;
  79618. private _offsetY;
  79619. private _pointerPressed;
  79620. private _pointerInput;
  79621. private _observer;
  79622. private _onLostFocus;
  79623. /**
  79624. * Attach the input controls to a specific dom element to get the input from.
  79625. * @param element Defines the element the controls should be listened from
  79626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79627. */
  79628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79629. /**
  79630. * Detach the current controls from the specified dom element.
  79631. * @param element Defines the element to stop listening the inputs from
  79632. */
  79633. detachControl(element: Nullable<HTMLElement>): void;
  79634. /**
  79635. * Update the current camera state depending on the inputs that have been used this frame.
  79636. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79637. */
  79638. checkInputs(): void;
  79639. /**
  79640. * Gets the class name of the current intput.
  79641. * @returns the class name
  79642. */
  79643. getClassName(): string;
  79644. /**
  79645. * Get the friendly name associated with the input class.
  79646. * @returns the input friendly name
  79647. */
  79648. getSimpleName(): string;
  79649. }
  79650. }
  79651. declare module BABYLON {
  79652. /**
  79653. * Default Inputs manager for the FreeCamera.
  79654. * It groups all the default supported inputs for ease of use.
  79655. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79656. */
  79657. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79658. /**
  79659. * @hidden
  79660. */
  79661. _mouseInput: Nullable<FreeCameraMouseInput>;
  79662. /**
  79663. * Instantiates a new FreeCameraInputsManager.
  79664. * @param camera Defines the camera the inputs belong to
  79665. */
  79666. constructor(camera: FreeCamera);
  79667. /**
  79668. * Add keyboard input support to the input manager.
  79669. * @returns the current input manager
  79670. */
  79671. addKeyboard(): FreeCameraInputsManager;
  79672. /**
  79673. * Add mouse input support to the input manager.
  79674. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79675. * @returns the current input manager
  79676. */
  79677. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79678. /**
  79679. * Removes the mouse input support from the manager
  79680. * @returns the current input manager
  79681. */
  79682. removeMouse(): FreeCameraInputsManager;
  79683. /**
  79684. * Add touch input support to the input manager.
  79685. * @returns the current input manager
  79686. */
  79687. addTouch(): FreeCameraInputsManager;
  79688. /**
  79689. * Remove all attached input methods from a camera
  79690. */
  79691. clear(): void;
  79692. }
  79693. }
  79694. declare module BABYLON {
  79695. /**
  79696. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79697. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79698. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79699. */
  79700. export class FreeCamera extends TargetCamera {
  79701. /**
  79702. * Define the collision ellipsoid of the camera.
  79703. * This is helpful to simulate a camera body like the player body around the camera
  79704. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79705. */
  79706. ellipsoid: Vector3;
  79707. /**
  79708. * Define an offset for the position of the ellipsoid around the camera.
  79709. * This can be helpful to determine the center of the body near the gravity center of the body
  79710. * instead of its head.
  79711. */
  79712. ellipsoidOffset: Vector3;
  79713. /**
  79714. * Enable or disable collisions of the camera with the rest of the scene objects.
  79715. */
  79716. checkCollisions: boolean;
  79717. /**
  79718. * Enable or disable gravity on the camera.
  79719. */
  79720. applyGravity: boolean;
  79721. /**
  79722. * Define the input manager associated to the camera.
  79723. */
  79724. inputs: FreeCameraInputsManager;
  79725. /**
  79726. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79727. * Higher values reduce sensitivity.
  79728. */
  79729. /**
  79730. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79731. * Higher values reduce sensitivity.
  79732. */
  79733. angularSensibility: number;
  79734. /**
  79735. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79736. */
  79737. keysUp: number[];
  79738. /**
  79739. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79740. */
  79741. keysDown: number[];
  79742. /**
  79743. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79744. */
  79745. keysLeft: number[];
  79746. /**
  79747. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79748. */
  79749. keysRight: number[];
  79750. /**
  79751. * Event raised when the camera collide with a mesh in the scene.
  79752. */
  79753. onCollide: (collidedMesh: AbstractMesh) => void;
  79754. private _collider;
  79755. private _needMoveForGravity;
  79756. private _oldPosition;
  79757. private _diffPosition;
  79758. private _newPosition;
  79759. /** @hidden */
  79760. _localDirection: Vector3;
  79761. /** @hidden */
  79762. _transformedDirection: Vector3;
  79763. /**
  79764. * Instantiates a Free Camera.
  79765. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79766. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79767. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79768. * @param name Define the name of the camera in the scene
  79769. * @param position Define the start position of the camera in the scene
  79770. * @param scene Define the scene the camera belongs to
  79771. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79772. */
  79773. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79774. /**
  79775. * Attached controls to the current camera.
  79776. * @param element Defines the element the controls should be listened from
  79777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79778. */
  79779. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79780. /**
  79781. * Detach the current controls from the camera.
  79782. * The camera will stop reacting to inputs.
  79783. * @param element Defines the element to stop listening the inputs from
  79784. */
  79785. detachControl(element: HTMLElement): void;
  79786. private _collisionMask;
  79787. /**
  79788. * Define a collision mask to limit the list of object the camera can collide with
  79789. */
  79790. collisionMask: number;
  79791. /** @hidden */
  79792. _collideWithWorld(displacement: Vector3): void;
  79793. private _onCollisionPositionChange;
  79794. /** @hidden */
  79795. _checkInputs(): void;
  79796. /** @hidden */
  79797. _decideIfNeedsToMove(): boolean;
  79798. /** @hidden */
  79799. _updatePosition(): void;
  79800. /**
  79801. * Destroy the camera and release the current resources hold by it.
  79802. */
  79803. dispose(): void;
  79804. /**
  79805. * Gets the current object class name.
  79806. * @return the class name
  79807. */
  79808. getClassName(): string;
  79809. }
  79810. }
  79811. declare module BABYLON {
  79812. /**
  79813. * Represents a gamepad control stick position
  79814. */
  79815. export class StickValues {
  79816. /**
  79817. * The x component of the control stick
  79818. */
  79819. x: number;
  79820. /**
  79821. * The y component of the control stick
  79822. */
  79823. y: number;
  79824. /**
  79825. * Initializes the gamepad x and y control stick values
  79826. * @param x The x component of the gamepad control stick value
  79827. * @param y The y component of the gamepad control stick value
  79828. */
  79829. constructor(
  79830. /**
  79831. * The x component of the control stick
  79832. */
  79833. x: number,
  79834. /**
  79835. * The y component of the control stick
  79836. */
  79837. y: number);
  79838. }
  79839. /**
  79840. * An interface which manages callbacks for gamepad button changes
  79841. */
  79842. export interface GamepadButtonChanges {
  79843. /**
  79844. * Called when a gamepad has been changed
  79845. */
  79846. changed: boolean;
  79847. /**
  79848. * Called when a gamepad press event has been triggered
  79849. */
  79850. pressChanged: boolean;
  79851. /**
  79852. * Called when a touch event has been triggered
  79853. */
  79854. touchChanged: boolean;
  79855. /**
  79856. * Called when a value has changed
  79857. */
  79858. valueChanged: boolean;
  79859. }
  79860. /**
  79861. * Represents a gamepad
  79862. */
  79863. export class Gamepad {
  79864. /**
  79865. * The id of the gamepad
  79866. */
  79867. id: string;
  79868. /**
  79869. * The index of the gamepad
  79870. */
  79871. index: number;
  79872. /**
  79873. * The browser gamepad
  79874. */
  79875. browserGamepad: any;
  79876. /**
  79877. * Specifies what type of gamepad this represents
  79878. */
  79879. type: number;
  79880. private _leftStick;
  79881. private _rightStick;
  79882. /** @hidden */
  79883. _isConnected: boolean;
  79884. private _leftStickAxisX;
  79885. private _leftStickAxisY;
  79886. private _rightStickAxisX;
  79887. private _rightStickAxisY;
  79888. /**
  79889. * Triggered when the left control stick has been changed
  79890. */
  79891. private _onleftstickchanged;
  79892. /**
  79893. * Triggered when the right control stick has been changed
  79894. */
  79895. private _onrightstickchanged;
  79896. /**
  79897. * Represents a gamepad controller
  79898. */
  79899. static GAMEPAD: number;
  79900. /**
  79901. * Represents a generic controller
  79902. */
  79903. static GENERIC: number;
  79904. /**
  79905. * Represents an XBox controller
  79906. */
  79907. static XBOX: number;
  79908. /**
  79909. * Represents a pose-enabled controller
  79910. */
  79911. static POSE_ENABLED: number;
  79912. /**
  79913. * Specifies whether the left control stick should be Y-inverted
  79914. */
  79915. protected _invertLeftStickY: boolean;
  79916. /**
  79917. * Specifies if the gamepad has been connected
  79918. */
  79919. readonly isConnected: boolean;
  79920. /**
  79921. * Initializes the gamepad
  79922. * @param id The id of the gamepad
  79923. * @param index The index of the gamepad
  79924. * @param browserGamepad The browser gamepad
  79925. * @param leftStickX The x component of the left joystick
  79926. * @param leftStickY The y component of the left joystick
  79927. * @param rightStickX The x component of the right joystick
  79928. * @param rightStickY The y component of the right joystick
  79929. */
  79930. constructor(
  79931. /**
  79932. * The id of the gamepad
  79933. */
  79934. id: string,
  79935. /**
  79936. * The index of the gamepad
  79937. */
  79938. index: number,
  79939. /**
  79940. * The browser gamepad
  79941. */
  79942. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79943. /**
  79944. * Callback triggered when the left joystick has changed
  79945. * @param callback
  79946. */
  79947. onleftstickchanged(callback: (values: StickValues) => void): void;
  79948. /**
  79949. * Callback triggered when the right joystick has changed
  79950. * @param callback
  79951. */
  79952. onrightstickchanged(callback: (values: StickValues) => void): void;
  79953. /**
  79954. * Gets the left joystick
  79955. */
  79956. /**
  79957. * Sets the left joystick values
  79958. */
  79959. leftStick: StickValues;
  79960. /**
  79961. * Gets the right joystick
  79962. */
  79963. /**
  79964. * Sets the right joystick value
  79965. */
  79966. rightStick: StickValues;
  79967. /**
  79968. * Updates the gamepad joystick positions
  79969. */
  79970. update(): void;
  79971. /**
  79972. * Disposes the gamepad
  79973. */
  79974. dispose(): void;
  79975. }
  79976. /**
  79977. * Represents a generic gamepad
  79978. */
  79979. export class GenericPad extends Gamepad {
  79980. private _buttons;
  79981. private _onbuttondown;
  79982. private _onbuttonup;
  79983. /**
  79984. * Observable triggered when a button has been pressed
  79985. */
  79986. onButtonDownObservable: Observable<number>;
  79987. /**
  79988. * Observable triggered when a button has been released
  79989. */
  79990. onButtonUpObservable: Observable<number>;
  79991. /**
  79992. * Callback triggered when a button has been pressed
  79993. * @param callback Called when a button has been pressed
  79994. */
  79995. onbuttondown(callback: (buttonPressed: number) => void): void;
  79996. /**
  79997. * Callback triggered when a button has been released
  79998. * @param callback Called when a button has been released
  79999. */
  80000. onbuttonup(callback: (buttonReleased: number) => void): void;
  80001. /**
  80002. * Initializes the generic gamepad
  80003. * @param id The id of the generic gamepad
  80004. * @param index The index of the generic gamepad
  80005. * @param browserGamepad The browser gamepad
  80006. */
  80007. constructor(id: string, index: number, browserGamepad: any);
  80008. private _setButtonValue;
  80009. /**
  80010. * Updates the generic gamepad
  80011. */
  80012. update(): void;
  80013. /**
  80014. * Disposes the generic gamepad
  80015. */
  80016. dispose(): void;
  80017. }
  80018. }
  80019. declare module BABYLON {
  80020. /**
  80021. * Defines the types of pose enabled controllers that are supported
  80022. */
  80023. export enum PoseEnabledControllerType {
  80024. /**
  80025. * HTC Vive
  80026. */
  80027. VIVE = 0,
  80028. /**
  80029. * Oculus Rift
  80030. */
  80031. OCULUS = 1,
  80032. /**
  80033. * Windows mixed reality
  80034. */
  80035. WINDOWS = 2,
  80036. /**
  80037. * Samsung gear VR
  80038. */
  80039. GEAR_VR = 3,
  80040. /**
  80041. * Google Daydream
  80042. */
  80043. DAYDREAM = 4,
  80044. /**
  80045. * Generic
  80046. */
  80047. GENERIC = 5
  80048. }
  80049. /**
  80050. * Defines the MutableGamepadButton interface for the state of a gamepad button
  80051. */
  80052. export interface MutableGamepadButton {
  80053. /**
  80054. * Value of the button/trigger
  80055. */
  80056. value: number;
  80057. /**
  80058. * If the button/trigger is currently touched
  80059. */
  80060. touched: boolean;
  80061. /**
  80062. * If the button/trigger is currently pressed
  80063. */
  80064. pressed: boolean;
  80065. }
  80066. /**
  80067. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80068. * @hidden
  80069. */
  80070. export interface ExtendedGamepadButton extends GamepadButton {
  80071. /**
  80072. * If the button/trigger is currently pressed
  80073. */
  80074. readonly pressed: boolean;
  80075. /**
  80076. * If the button/trigger is currently touched
  80077. */
  80078. readonly touched: boolean;
  80079. /**
  80080. * Value of the button/trigger
  80081. */
  80082. readonly value: number;
  80083. }
  80084. /** @hidden */
  80085. export interface _GamePadFactory {
  80086. /**
  80087. * Returns wether or not the current gamepad can be created for this type of controller.
  80088. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80089. * @returns true if it can be created, otherwise false
  80090. */
  80091. canCreate(gamepadInfo: any): boolean;
  80092. /**
  80093. * Creates a new instance of the Gamepad.
  80094. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80095. * @returns the new gamepad instance
  80096. */
  80097. create(gamepadInfo: any): Gamepad;
  80098. }
  80099. /**
  80100. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80101. */
  80102. export class PoseEnabledControllerHelper {
  80103. /** @hidden */
  80104. static _ControllerFactories: _GamePadFactory[];
  80105. /** @hidden */
  80106. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80107. /**
  80108. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80109. * @param vrGamepad the gamepad to initialized
  80110. * @returns a vr controller of the type the gamepad identified as
  80111. */
  80112. static InitiateController(vrGamepad: any): Gamepad;
  80113. }
  80114. /**
  80115. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80116. */
  80117. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80118. private _deviceRoomPosition;
  80119. private _deviceRoomRotationQuaternion;
  80120. /**
  80121. * The device position in babylon space
  80122. */
  80123. devicePosition: Vector3;
  80124. /**
  80125. * The device rotation in babylon space
  80126. */
  80127. deviceRotationQuaternion: Quaternion;
  80128. /**
  80129. * The scale factor of the device in babylon space
  80130. */
  80131. deviceScaleFactor: number;
  80132. /**
  80133. * (Likely devicePosition should be used instead) The device position in its room space
  80134. */
  80135. position: Vector3;
  80136. /**
  80137. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80138. */
  80139. rotationQuaternion: Quaternion;
  80140. /**
  80141. * The type of controller (Eg. Windows mixed reality)
  80142. */
  80143. controllerType: PoseEnabledControllerType;
  80144. protected _calculatedPosition: Vector3;
  80145. private _calculatedRotation;
  80146. /**
  80147. * The raw pose from the device
  80148. */
  80149. rawPose: DevicePose;
  80150. private _trackPosition;
  80151. private _maxRotationDistFromHeadset;
  80152. private _draggedRoomRotation;
  80153. /**
  80154. * @hidden
  80155. */
  80156. _disableTrackPosition(fixedPosition: Vector3): void;
  80157. /**
  80158. * Internal, the mesh attached to the controller
  80159. * @hidden
  80160. */
  80161. _mesh: Nullable<AbstractMesh>;
  80162. private _poseControlledCamera;
  80163. private _leftHandSystemQuaternion;
  80164. /**
  80165. * Internal, matrix used to convert room space to babylon space
  80166. * @hidden
  80167. */
  80168. _deviceToWorld: Matrix;
  80169. /**
  80170. * Node to be used when casting a ray from the controller
  80171. * @hidden
  80172. */
  80173. _pointingPoseNode: Nullable<TransformNode>;
  80174. /**
  80175. * Name of the child mesh that can be used to cast a ray from the controller
  80176. */
  80177. static readonly POINTING_POSE: string;
  80178. /**
  80179. * Creates a new PoseEnabledController from a gamepad
  80180. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80181. */
  80182. constructor(browserGamepad: any);
  80183. private _workingMatrix;
  80184. /**
  80185. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80186. */
  80187. update(): void;
  80188. /**
  80189. * Updates only the pose device and mesh without doing any button event checking
  80190. */
  80191. protected _updatePoseAndMesh(): void;
  80192. /**
  80193. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80194. * @param poseData raw pose fromthe device
  80195. */
  80196. updateFromDevice(poseData: DevicePose): void;
  80197. /**
  80198. * @hidden
  80199. */
  80200. _meshAttachedObservable: Observable<AbstractMesh>;
  80201. /**
  80202. * Attaches a mesh to the controller
  80203. * @param mesh the mesh to be attached
  80204. */
  80205. attachToMesh(mesh: AbstractMesh): void;
  80206. /**
  80207. * Attaches the controllers mesh to a camera
  80208. * @param camera the camera the mesh should be attached to
  80209. */
  80210. attachToPoseControlledCamera(camera: TargetCamera): void;
  80211. /**
  80212. * Disposes of the controller
  80213. */
  80214. dispose(): void;
  80215. /**
  80216. * The mesh that is attached to the controller
  80217. */
  80218. readonly mesh: Nullable<AbstractMesh>;
  80219. /**
  80220. * Gets the ray of the controller in the direction the controller is pointing
  80221. * @param length the length the resulting ray should be
  80222. * @returns a ray in the direction the controller is pointing
  80223. */
  80224. getForwardRay(length?: number): Ray;
  80225. }
  80226. }
  80227. declare module BABYLON {
  80228. /**
  80229. * Defines the WebVRController object that represents controllers tracked in 3D space
  80230. */
  80231. export abstract class WebVRController extends PoseEnabledController {
  80232. /**
  80233. * Internal, the default controller model for the controller
  80234. */
  80235. protected _defaultModel: AbstractMesh;
  80236. /**
  80237. * Fired when the trigger state has changed
  80238. */
  80239. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80240. /**
  80241. * Fired when the main button state has changed
  80242. */
  80243. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80244. /**
  80245. * Fired when the secondary button state has changed
  80246. */
  80247. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80248. /**
  80249. * Fired when the pad state has changed
  80250. */
  80251. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80252. /**
  80253. * Fired when controllers stick values have changed
  80254. */
  80255. onPadValuesChangedObservable: Observable<StickValues>;
  80256. /**
  80257. * Array of button availible on the controller
  80258. */
  80259. protected _buttons: Array<MutableGamepadButton>;
  80260. private _onButtonStateChange;
  80261. /**
  80262. * Fired when a controller button's state has changed
  80263. * @param callback the callback containing the button that was modified
  80264. */
  80265. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80266. /**
  80267. * X and Y axis corresponding to the controllers joystick
  80268. */
  80269. pad: StickValues;
  80270. /**
  80271. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80272. */
  80273. hand: string;
  80274. /**
  80275. * The default controller model for the controller
  80276. */
  80277. readonly defaultModel: AbstractMesh;
  80278. /**
  80279. * Creates a new WebVRController from a gamepad
  80280. * @param vrGamepad the gamepad that the WebVRController should be created from
  80281. */
  80282. constructor(vrGamepad: any);
  80283. /**
  80284. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80285. */
  80286. update(): void;
  80287. /**
  80288. * Function to be called when a button is modified
  80289. */
  80290. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80291. /**
  80292. * Loads a mesh and attaches it to the controller
  80293. * @param scene the scene the mesh should be added to
  80294. * @param meshLoaded callback for when the mesh has been loaded
  80295. */
  80296. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80297. private _setButtonValue;
  80298. private _changes;
  80299. private _checkChanges;
  80300. /**
  80301. * Disposes of th webVRCOntroller
  80302. */
  80303. dispose(): void;
  80304. }
  80305. }
  80306. declare module BABYLON {
  80307. /**
  80308. * The HemisphericLight simulates the ambient environment light,
  80309. * so the passed direction is the light reflection direction, not the incoming direction.
  80310. */
  80311. export class HemisphericLight extends Light {
  80312. /**
  80313. * The groundColor is the light in the opposite direction to the one specified during creation.
  80314. * 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.
  80315. */
  80316. groundColor: Color3;
  80317. /**
  80318. * The light reflection direction, not the incoming direction.
  80319. */
  80320. direction: Vector3;
  80321. /**
  80322. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80323. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80324. * The HemisphericLight can't cast shadows.
  80325. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80326. * @param name The friendly name of the light
  80327. * @param direction The direction of the light reflection
  80328. * @param scene The scene the light belongs to
  80329. */
  80330. constructor(name: string, direction: Vector3, scene: Scene);
  80331. protected _buildUniformLayout(): void;
  80332. /**
  80333. * Returns the string "HemisphericLight".
  80334. * @return The class name
  80335. */
  80336. getClassName(): string;
  80337. /**
  80338. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80339. * Returns the updated direction.
  80340. * @param target The target the direction should point to
  80341. * @return The computed direction
  80342. */
  80343. setDirectionToTarget(target: Vector3): Vector3;
  80344. /**
  80345. * Returns the shadow generator associated to the light.
  80346. * @returns Always null for hemispheric lights because it does not support shadows.
  80347. */
  80348. getShadowGenerator(): Nullable<IShadowGenerator>;
  80349. /**
  80350. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80351. * @param effect The effect to update
  80352. * @param lightIndex The index of the light in the effect to update
  80353. * @returns The hemispheric light
  80354. */
  80355. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80356. /**
  80357. * Computes the world matrix of the node
  80358. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80359. * @param useWasUpdatedFlag defines a reserved property
  80360. * @returns the world matrix
  80361. */
  80362. computeWorldMatrix(): Matrix;
  80363. /**
  80364. * Returns the integer 3.
  80365. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80366. */
  80367. getTypeID(): number;
  80368. /**
  80369. * Prepares the list of defines specific to the light type.
  80370. * @param defines the list of defines
  80371. * @param lightIndex defines the index of the light for the effect
  80372. */
  80373. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80374. }
  80375. }
  80376. declare module BABYLON {
  80377. /** @hidden */
  80378. export var vrMultiviewToSingleviewPixelShader: {
  80379. name: string;
  80380. shader: string;
  80381. };
  80382. }
  80383. declare module BABYLON {
  80384. /**
  80385. * Renders to multiple views with a single draw call
  80386. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80387. */
  80388. export class MultiviewRenderTarget extends RenderTargetTexture {
  80389. /**
  80390. * Creates a multiview render target
  80391. * @param scene scene used with the render target
  80392. * @param size the size of the render target (used for each view)
  80393. */
  80394. constructor(scene: Scene, size?: number | {
  80395. width: number;
  80396. height: number;
  80397. } | {
  80398. ratio: number;
  80399. });
  80400. /**
  80401. * @hidden
  80402. * @param faceIndex the face index, if its a cube texture
  80403. */
  80404. _bindFrameBuffer(faceIndex?: number): void;
  80405. /**
  80406. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80407. * @returns the view count
  80408. */
  80409. getViewCount(): number;
  80410. }
  80411. }
  80412. declare module BABYLON {
  80413. interface Engine {
  80414. /**
  80415. * Creates a new multiview render target
  80416. * @param width defines the width of the texture
  80417. * @param height defines the height of the texture
  80418. * @returns the created multiview texture
  80419. */
  80420. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80421. /**
  80422. * Binds a multiview framebuffer to be drawn to
  80423. * @param multiviewTexture texture to bind
  80424. */
  80425. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80426. }
  80427. interface Camera {
  80428. /**
  80429. * @hidden
  80430. * 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)
  80431. */
  80432. _useMultiviewToSingleView: boolean;
  80433. /**
  80434. * @hidden
  80435. * 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)
  80436. */
  80437. _multiviewTexture: Nullable<RenderTargetTexture>;
  80438. /**
  80439. * @hidden
  80440. * ensures the multiview texture of the camera exists and has the specified width/height
  80441. * @param width height to set on the multiview texture
  80442. * @param height width to set on the multiview texture
  80443. */
  80444. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80445. }
  80446. interface Scene {
  80447. /** @hidden */
  80448. _transformMatrixR: Matrix;
  80449. /** @hidden */
  80450. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80451. /** @hidden */
  80452. _createMultiviewUbo(): void;
  80453. /** @hidden */
  80454. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80455. /** @hidden */
  80456. _renderMultiviewToSingleView(camera: Camera): void;
  80457. }
  80458. }
  80459. declare module BABYLON {
  80460. /**
  80461. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80462. * This will not be used for webXR as it supports displaying texture arrays directly
  80463. */
  80464. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80465. /**
  80466. * Initializes a VRMultiviewToSingleview
  80467. * @param name name of the post process
  80468. * @param camera camera to be applied to
  80469. * @param scaleFactor scaling factor to the size of the output texture
  80470. */
  80471. constructor(name: string, camera: Camera, scaleFactor: number);
  80472. }
  80473. }
  80474. declare module BABYLON {
  80475. interface Engine {
  80476. /** @hidden */
  80477. _vrDisplay: any;
  80478. /** @hidden */
  80479. _vrSupported: boolean;
  80480. /** @hidden */
  80481. _oldSize: Size;
  80482. /** @hidden */
  80483. _oldHardwareScaleFactor: number;
  80484. /** @hidden */
  80485. _vrExclusivePointerMode: boolean;
  80486. /** @hidden */
  80487. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80488. /** @hidden */
  80489. _onVRDisplayPointerRestricted: () => void;
  80490. /** @hidden */
  80491. _onVRDisplayPointerUnrestricted: () => void;
  80492. /** @hidden */
  80493. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80494. /** @hidden */
  80495. _onVrDisplayDisconnect: Nullable<() => void>;
  80496. /** @hidden */
  80497. _onVrDisplayPresentChange: Nullable<() => void>;
  80498. /**
  80499. * Observable signaled when VR display mode changes
  80500. */
  80501. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80502. /**
  80503. * Observable signaled when VR request present is complete
  80504. */
  80505. onVRRequestPresentComplete: Observable<boolean>;
  80506. /**
  80507. * Observable signaled when VR request present starts
  80508. */
  80509. onVRRequestPresentStart: Observable<Engine>;
  80510. /**
  80511. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80512. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80513. */
  80514. isInVRExclusivePointerMode: boolean;
  80515. /**
  80516. * Gets a boolean indicating if a webVR device was detected
  80517. * @returns true if a webVR device was detected
  80518. */
  80519. isVRDevicePresent(): boolean;
  80520. /**
  80521. * Gets the current webVR device
  80522. * @returns the current webVR device (or null)
  80523. */
  80524. getVRDevice(): any;
  80525. /**
  80526. * Initializes a webVR display and starts listening to display change events
  80527. * The onVRDisplayChangedObservable will be notified upon these changes
  80528. * @returns A promise containing a VRDisplay and if vr is supported
  80529. */
  80530. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80531. /** @hidden */
  80532. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80533. /**
  80534. * Call this function to switch to webVR mode
  80535. * Will do nothing if webVR is not supported or if there is no webVR device
  80536. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80537. */
  80538. enableVR(): void;
  80539. /** @hidden */
  80540. _onVRFullScreenTriggered(): void;
  80541. }
  80542. }
  80543. declare module BABYLON {
  80544. /**
  80545. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80546. * IMPORTANT!! The data is right-hand data.
  80547. * @export
  80548. * @interface DevicePose
  80549. */
  80550. export interface DevicePose {
  80551. /**
  80552. * The position of the device, values in array are [x,y,z].
  80553. */
  80554. readonly position: Nullable<Float32Array>;
  80555. /**
  80556. * The linearVelocity of the device, values in array are [x,y,z].
  80557. */
  80558. readonly linearVelocity: Nullable<Float32Array>;
  80559. /**
  80560. * The linearAcceleration of the device, values in array are [x,y,z].
  80561. */
  80562. readonly linearAcceleration: Nullable<Float32Array>;
  80563. /**
  80564. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80565. */
  80566. readonly orientation: Nullable<Float32Array>;
  80567. /**
  80568. * The angularVelocity of the device, values in array are [x,y,z].
  80569. */
  80570. readonly angularVelocity: Nullable<Float32Array>;
  80571. /**
  80572. * The angularAcceleration of the device, values in array are [x,y,z].
  80573. */
  80574. readonly angularAcceleration: Nullable<Float32Array>;
  80575. }
  80576. /**
  80577. * Interface representing a pose controlled object in Babylon.
  80578. * A pose controlled object has both regular pose values as well as pose values
  80579. * from an external device such as a VR head mounted display
  80580. */
  80581. export interface PoseControlled {
  80582. /**
  80583. * The position of the object in babylon space.
  80584. */
  80585. position: Vector3;
  80586. /**
  80587. * The rotation quaternion of the object in babylon space.
  80588. */
  80589. rotationQuaternion: Quaternion;
  80590. /**
  80591. * The position of the device in babylon space.
  80592. */
  80593. devicePosition?: Vector3;
  80594. /**
  80595. * The rotation quaternion of the device in babylon space.
  80596. */
  80597. deviceRotationQuaternion: Quaternion;
  80598. /**
  80599. * The raw pose coming from the device.
  80600. */
  80601. rawPose: Nullable<DevicePose>;
  80602. /**
  80603. * The scale of the device to be used when translating from device space to babylon space.
  80604. */
  80605. deviceScaleFactor: number;
  80606. /**
  80607. * Updates the poseControlled values based on the input device pose.
  80608. * @param poseData the pose data to update the object with
  80609. */
  80610. updateFromDevice(poseData: DevicePose): void;
  80611. }
  80612. /**
  80613. * Set of options to customize the webVRCamera
  80614. */
  80615. export interface WebVROptions {
  80616. /**
  80617. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80618. */
  80619. trackPosition?: boolean;
  80620. /**
  80621. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80622. */
  80623. positionScale?: number;
  80624. /**
  80625. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80626. */
  80627. displayName?: string;
  80628. /**
  80629. * Should the native controller meshes be initialized. (default: true)
  80630. */
  80631. controllerMeshes?: boolean;
  80632. /**
  80633. * Creating a default HemiLight only on controllers. (default: true)
  80634. */
  80635. defaultLightingOnControllers?: boolean;
  80636. /**
  80637. * If you don't want to use the default VR button of the helper. (default: false)
  80638. */
  80639. useCustomVRButton?: boolean;
  80640. /**
  80641. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80642. */
  80643. customVRButton?: HTMLButtonElement;
  80644. /**
  80645. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80646. */
  80647. rayLength?: number;
  80648. /**
  80649. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80650. */
  80651. defaultHeight?: number;
  80652. /**
  80653. * If multiview should be used if availible (default: false)
  80654. */
  80655. useMultiview?: boolean;
  80656. }
  80657. /**
  80658. * This represents a WebVR camera.
  80659. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80660. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80661. */
  80662. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80663. private webVROptions;
  80664. /**
  80665. * @hidden
  80666. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80667. */
  80668. _vrDevice: any;
  80669. /**
  80670. * The rawPose of the vrDevice.
  80671. */
  80672. rawPose: Nullable<DevicePose>;
  80673. private _onVREnabled;
  80674. private _specsVersion;
  80675. private _attached;
  80676. private _frameData;
  80677. protected _descendants: Array<Node>;
  80678. private _deviceRoomPosition;
  80679. /** @hidden */
  80680. _deviceRoomRotationQuaternion: Quaternion;
  80681. private _standingMatrix;
  80682. /**
  80683. * Represents device position in babylon space.
  80684. */
  80685. devicePosition: Vector3;
  80686. /**
  80687. * Represents device rotation in babylon space.
  80688. */
  80689. deviceRotationQuaternion: Quaternion;
  80690. /**
  80691. * The scale of the device to be used when translating from device space to babylon space.
  80692. */
  80693. deviceScaleFactor: number;
  80694. private _deviceToWorld;
  80695. private _worldToDevice;
  80696. /**
  80697. * References to the webVR controllers for the vrDevice.
  80698. */
  80699. controllers: Array<WebVRController>;
  80700. /**
  80701. * Emits an event when a controller is attached.
  80702. */
  80703. onControllersAttachedObservable: Observable<WebVRController[]>;
  80704. /**
  80705. * Emits an event when a controller's mesh has been loaded;
  80706. */
  80707. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80708. /**
  80709. * Emits an event when the HMD's pose has been updated.
  80710. */
  80711. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80712. private _poseSet;
  80713. /**
  80714. * If the rig cameras be used as parent instead of this camera.
  80715. */
  80716. rigParenting: boolean;
  80717. private _lightOnControllers;
  80718. private _defaultHeight?;
  80719. /**
  80720. * Instantiates a WebVRFreeCamera.
  80721. * @param name The name of the WebVRFreeCamera
  80722. * @param position The starting anchor position for the camera
  80723. * @param scene The scene the camera belongs to
  80724. * @param webVROptions a set of customizable options for the webVRCamera
  80725. */
  80726. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80727. /**
  80728. * Gets the device distance from the ground in meters.
  80729. * @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.
  80730. */
  80731. deviceDistanceToRoomGround(): number;
  80732. /**
  80733. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80734. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80735. */
  80736. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80737. /**
  80738. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80739. * @returns A promise with a boolean set to if the standing matrix is supported.
  80740. */
  80741. useStandingMatrixAsync(): Promise<boolean>;
  80742. /**
  80743. * Disposes the camera
  80744. */
  80745. dispose(): void;
  80746. /**
  80747. * Gets a vrController by name.
  80748. * @param name The name of the controller to retreive
  80749. * @returns the controller matching the name specified or null if not found
  80750. */
  80751. getControllerByName(name: string): Nullable<WebVRController>;
  80752. private _leftController;
  80753. /**
  80754. * The controller corresponding to the users left hand.
  80755. */
  80756. readonly leftController: Nullable<WebVRController>;
  80757. private _rightController;
  80758. /**
  80759. * The controller corresponding to the users right hand.
  80760. */
  80761. readonly rightController: Nullable<WebVRController>;
  80762. /**
  80763. * Casts a ray forward from the vrCamera's gaze.
  80764. * @param length Length of the ray (default: 100)
  80765. * @returns the ray corresponding to the gaze
  80766. */
  80767. getForwardRay(length?: number): Ray;
  80768. /**
  80769. * @hidden
  80770. * Updates the camera based on device's frame data
  80771. */
  80772. _checkInputs(): void;
  80773. /**
  80774. * Updates the poseControlled values based on the input device pose.
  80775. * @param poseData Pose coming from the device
  80776. */
  80777. updateFromDevice(poseData: DevicePose): void;
  80778. private _htmlElementAttached;
  80779. private _detachIfAttached;
  80780. /**
  80781. * WebVR's attach control will start broadcasting frames to the device.
  80782. * Note that in certain browsers (chrome for example) this function must be called
  80783. * within a user-interaction callback. Example:
  80784. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80785. *
  80786. * @param element html element to attach the vrDevice to
  80787. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80788. */
  80789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80790. /**
  80791. * Detaches the camera from the html element and disables VR
  80792. *
  80793. * @param element html element to detach from
  80794. */
  80795. detachControl(element: HTMLElement): void;
  80796. /**
  80797. * @returns the name of this class
  80798. */
  80799. getClassName(): string;
  80800. /**
  80801. * Calls resetPose on the vrDisplay
  80802. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80803. */
  80804. resetToCurrentRotation(): void;
  80805. /**
  80806. * @hidden
  80807. * Updates the rig cameras (left and right eye)
  80808. */
  80809. _updateRigCameras(): void;
  80810. private _workingVector;
  80811. private _oneVector;
  80812. private _workingMatrix;
  80813. private updateCacheCalled;
  80814. private _correctPositionIfNotTrackPosition;
  80815. /**
  80816. * @hidden
  80817. * Updates the cached values of the camera
  80818. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80819. */
  80820. _updateCache(ignoreParentClass?: boolean): void;
  80821. /**
  80822. * @hidden
  80823. * Get current device position in babylon world
  80824. */
  80825. _computeDevicePosition(): void;
  80826. /**
  80827. * Updates the current device position and rotation in the babylon world
  80828. */
  80829. update(): void;
  80830. /**
  80831. * @hidden
  80832. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80833. * @returns an identity matrix
  80834. */
  80835. _getViewMatrix(): Matrix;
  80836. private _tmpMatrix;
  80837. /**
  80838. * This function is called by the two RIG cameras.
  80839. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80840. * @hidden
  80841. */
  80842. _getWebVRViewMatrix(): Matrix;
  80843. /** @hidden */
  80844. _getWebVRProjectionMatrix(): Matrix;
  80845. private _onGamepadConnectedObserver;
  80846. private _onGamepadDisconnectedObserver;
  80847. private _updateCacheWhenTrackingDisabledObserver;
  80848. /**
  80849. * Initializes the controllers and their meshes
  80850. */
  80851. initControllers(): void;
  80852. }
  80853. }
  80854. declare module BABYLON {
  80855. /**
  80856. * Size options for a post process
  80857. */
  80858. export type PostProcessOptions = {
  80859. width: number;
  80860. height: number;
  80861. };
  80862. /**
  80863. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80864. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80865. */
  80866. export class PostProcess {
  80867. /** Name of the PostProcess. */
  80868. name: string;
  80869. /**
  80870. * Gets or sets the unique id of the post process
  80871. */
  80872. uniqueId: number;
  80873. /**
  80874. * Width of the texture to apply the post process on
  80875. */
  80876. width: number;
  80877. /**
  80878. * Height of the texture to apply the post process on
  80879. */
  80880. height: number;
  80881. /**
  80882. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80883. * @hidden
  80884. */
  80885. _outputTexture: Nullable<InternalTexture>;
  80886. /**
  80887. * Sampling mode used by the shader
  80888. * See https://doc.babylonjs.com/classes/3.1/texture
  80889. */
  80890. renderTargetSamplingMode: number;
  80891. /**
  80892. * Clear color to use when screen clearing
  80893. */
  80894. clearColor: Color4;
  80895. /**
  80896. * If the buffer needs to be cleared before applying the post process. (default: true)
  80897. * Should be set to false if shader will overwrite all previous pixels.
  80898. */
  80899. autoClear: boolean;
  80900. /**
  80901. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80902. */
  80903. alphaMode: number;
  80904. /**
  80905. * Sets the setAlphaBlendConstants of the babylon engine
  80906. */
  80907. alphaConstants: Color4;
  80908. /**
  80909. * Animations to be used for the post processing
  80910. */
  80911. animations: Animation[];
  80912. /**
  80913. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80914. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80915. */
  80916. enablePixelPerfectMode: boolean;
  80917. /**
  80918. * Force the postprocess to be applied without taking in account viewport
  80919. */
  80920. forceFullscreenViewport: boolean;
  80921. /**
  80922. * List of inspectable custom properties (used by the Inspector)
  80923. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80924. */
  80925. inspectableCustomProperties: IInspectable[];
  80926. /**
  80927. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80928. *
  80929. * | Value | Type | Description |
  80930. * | ----- | ----------------------------------- | ----------- |
  80931. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80932. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80933. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80934. *
  80935. */
  80936. scaleMode: number;
  80937. /**
  80938. * Force textures to be a power of two (default: false)
  80939. */
  80940. alwaysForcePOT: boolean;
  80941. private _samples;
  80942. /**
  80943. * Number of sample textures (default: 1)
  80944. */
  80945. samples: number;
  80946. /**
  80947. * Modify the scale of the post process to be the same as the viewport (default: false)
  80948. */
  80949. adaptScaleToCurrentViewport: boolean;
  80950. private _camera;
  80951. private _scene;
  80952. private _engine;
  80953. private _options;
  80954. private _reusable;
  80955. private _textureType;
  80956. /**
  80957. * Smart array of input and output textures for the post process.
  80958. * @hidden
  80959. */
  80960. _textures: SmartArray<InternalTexture>;
  80961. /**
  80962. * The index in _textures that corresponds to the output texture.
  80963. * @hidden
  80964. */
  80965. _currentRenderTextureInd: number;
  80966. private _effect;
  80967. private _samplers;
  80968. private _fragmentUrl;
  80969. private _vertexUrl;
  80970. private _parameters;
  80971. private _scaleRatio;
  80972. protected _indexParameters: any;
  80973. private _shareOutputWithPostProcess;
  80974. private _texelSize;
  80975. private _forcedOutputTexture;
  80976. /**
  80977. * Returns the fragment url or shader name used in the post process.
  80978. * @returns the fragment url or name in the shader store.
  80979. */
  80980. getEffectName(): string;
  80981. /**
  80982. * An event triggered when the postprocess is activated.
  80983. */
  80984. onActivateObservable: Observable<Camera>;
  80985. private _onActivateObserver;
  80986. /**
  80987. * A function that is added to the onActivateObservable
  80988. */
  80989. onActivate: Nullable<(camera: Camera) => void>;
  80990. /**
  80991. * An event triggered when the postprocess changes its size.
  80992. */
  80993. onSizeChangedObservable: Observable<PostProcess>;
  80994. private _onSizeChangedObserver;
  80995. /**
  80996. * A function that is added to the onSizeChangedObservable
  80997. */
  80998. onSizeChanged: (postProcess: PostProcess) => void;
  80999. /**
  81000. * An event triggered when the postprocess applies its effect.
  81001. */
  81002. onApplyObservable: Observable<Effect>;
  81003. private _onApplyObserver;
  81004. /**
  81005. * A function that is added to the onApplyObservable
  81006. */
  81007. onApply: (effect: Effect) => void;
  81008. /**
  81009. * An event triggered before rendering the postprocess
  81010. */
  81011. onBeforeRenderObservable: Observable<Effect>;
  81012. private _onBeforeRenderObserver;
  81013. /**
  81014. * A function that is added to the onBeforeRenderObservable
  81015. */
  81016. onBeforeRender: (effect: Effect) => void;
  81017. /**
  81018. * An event triggered after rendering the postprocess
  81019. */
  81020. onAfterRenderObservable: Observable<Effect>;
  81021. private _onAfterRenderObserver;
  81022. /**
  81023. * A function that is added to the onAfterRenderObservable
  81024. */
  81025. onAfterRender: (efect: Effect) => void;
  81026. /**
  81027. * 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
  81028. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81029. */
  81030. inputTexture: InternalTexture;
  81031. /**
  81032. * Gets the camera which post process is applied to.
  81033. * @returns The camera the post process is applied to.
  81034. */
  81035. getCamera(): Camera;
  81036. /**
  81037. * Gets the texel size of the postprocess.
  81038. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81039. */
  81040. readonly texelSize: Vector2;
  81041. /**
  81042. * Creates a new instance PostProcess
  81043. * @param name The name of the PostProcess.
  81044. * @param fragmentUrl The url of the fragment shader to be used.
  81045. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81046. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81047. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81048. * @param camera The camera to apply the render pass to.
  81049. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81050. * @param engine The engine which the post process will be applied. (default: current engine)
  81051. * @param reusable If the post process can be reused on the same frame. (default: false)
  81052. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81053. * @param textureType Type of textures used when performing the post process. (default: 0)
  81054. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81055. * @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
  81056. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81057. */
  81058. constructor(
  81059. /** Name of the PostProcess. */
  81060. 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);
  81061. /**
  81062. * Gets a string idenfifying the name of the class
  81063. * @returns "PostProcess" string
  81064. */
  81065. getClassName(): string;
  81066. /**
  81067. * Gets the engine which this post process belongs to.
  81068. * @returns The engine the post process was enabled with.
  81069. */
  81070. getEngine(): Engine;
  81071. /**
  81072. * The effect that is created when initializing the post process.
  81073. * @returns The created effect corresponding the the postprocess.
  81074. */
  81075. getEffect(): Effect;
  81076. /**
  81077. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81078. * @param postProcess The post process to share the output with.
  81079. * @returns This post process.
  81080. */
  81081. shareOutputWith(postProcess: PostProcess): PostProcess;
  81082. /**
  81083. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81084. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81085. */
  81086. useOwnOutput(): void;
  81087. /**
  81088. * Updates the effect with the current post process compile time values and recompiles the shader.
  81089. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81090. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81091. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81092. * @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
  81093. * @param onCompiled Called when the shader has been compiled.
  81094. * @param onError Called if there is an error when compiling a shader.
  81095. */
  81096. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81097. /**
  81098. * The post process is reusable if it can be used multiple times within one frame.
  81099. * @returns If the post process is reusable
  81100. */
  81101. isReusable(): boolean;
  81102. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81103. markTextureDirty(): void;
  81104. /**
  81105. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81106. * 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.
  81107. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81108. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81109. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81110. * @returns The target texture that was bound to be written to.
  81111. */
  81112. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81113. /**
  81114. * If the post process is supported.
  81115. */
  81116. readonly isSupported: boolean;
  81117. /**
  81118. * The aspect ratio of the output texture.
  81119. */
  81120. readonly aspectRatio: number;
  81121. /**
  81122. * Get a value indicating if the post-process is ready to be used
  81123. * @returns true if the post-process is ready (shader is compiled)
  81124. */
  81125. isReady(): boolean;
  81126. /**
  81127. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81128. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81129. */
  81130. apply(): Nullable<Effect>;
  81131. private _disposeTextures;
  81132. /**
  81133. * Disposes the post process.
  81134. * @param camera The camera to dispose the post process on.
  81135. */
  81136. dispose(camera?: Camera): void;
  81137. }
  81138. }
  81139. declare module BABYLON {
  81140. /** @hidden */
  81141. export var kernelBlurVaryingDeclaration: {
  81142. name: string;
  81143. shader: string;
  81144. };
  81145. }
  81146. declare module BABYLON {
  81147. /** @hidden */
  81148. export var kernelBlurFragment: {
  81149. name: string;
  81150. shader: string;
  81151. };
  81152. }
  81153. declare module BABYLON {
  81154. /** @hidden */
  81155. export var kernelBlurFragment2: {
  81156. name: string;
  81157. shader: string;
  81158. };
  81159. }
  81160. declare module BABYLON {
  81161. /** @hidden */
  81162. export var kernelBlurPixelShader: {
  81163. name: string;
  81164. shader: string;
  81165. };
  81166. }
  81167. declare module BABYLON {
  81168. /** @hidden */
  81169. export var kernelBlurVertex: {
  81170. name: string;
  81171. shader: string;
  81172. };
  81173. }
  81174. declare module BABYLON {
  81175. /** @hidden */
  81176. export var kernelBlurVertexShader: {
  81177. name: string;
  81178. shader: string;
  81179. };
  81180. }
  81181. declare module BABYLON {
  81182. /**
  81183. * The Blur Post Process which blurs an image based on a kernel and direction.
  81184. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81185. */
  81186. export class BlurPostProcess extends PostProcess {
  81187. /** The direction in which to blur the image. */
  81188. direction: Vector2;
  81189. private blockCompilation;
  81190. protected _kernel: number;
  81191. protected _idealKernel: number;
  81192. protected _packedFloat: boolean;
  81193. private _staticDefines;
  81194. /**
  81195. * Sets the length in pixels of the blur sample region
  81196. */
  81197. /**
  81198. * Gets the length in pixels of the blur sample region
  81199. */
  81200. kernel: number;
  81201. /**
  81202. * Sets wether or not the blur needs to unpack/repack floats
  81203. */
  81204. /**
  81205. * Gets wether or not the blur is unpacking/repacking floats
  81206. */
  81207. packedFloat: boolean;
  81208. /**
  81209. * Creates a new instance BlurPostProcess
  81210. * @param name The name of the effect.
  81211. * @param direction The direction in which to blur the image.
  81212. * @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.
  81213. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81214. * @param camera The camera to apply the render pass to.
  81215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81216. * @param engine The engine which the post process will be applied. (default: current engine)
  81217. * @param reusable If the post process can be reused on the same frame. (default: false)
  81218. * @param textureType Type of textures used when performing the post process. (default: 0)
  81219. * @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)
  81220. */
  81221. constructor(name: string,
  81222. /** The direction in which to blur the image. */
  81223. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81224. /**
  81225. * Updates the effect with the current post process compile time values and recompiles the shader.
  81226. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81227. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81228. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81229. * @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
  81230. * @param onCompiled Called when the shader has been compiled.
  81231. * @param onError Called if there is an error when compiling a shader.
  81232. */
  81233. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81234. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81235. /**
  81236. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81237. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81238. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81239. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81240. * The gaps between physical kernels are compensated for in the weighting of the samples
  81241. * @param idealKernel Ideal blur kernel.
  81242. * @return Nearest best kernel.
  81243. */
  81244. protected _nearestBestKernel(idealKernel: number): number;
  81245. /**
  81246. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81247. * @param x The point on the Gaussian distribution to sample.
  81248. * @return the value of the Gaussian function at x.
  81249. */
  81250. protected _gaussianWeight(x: number): number;
  81251. /**
  81252. * Generates a string that can be used as a floating point number in GLSL.
  81253. * @param x Value to print.
  81254. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81255. * @return GLSL float string.
  81256. */
  81257. protected _glslFloat(x: number, decimalFigures?: number): string;
  81258. }
  81259. }
  81260. declare module BABYLON {
  81261. /**
  81262. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81263. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81264. * You can then easily use it as a reflectionTexture on a flat surface.
  81265. * In case the surface is not a plane, please consider relying on reflection probes.
  81266. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81267. */
  81268. export class MirrorTexture extends RenderTargetTexture {
  81269. private scene;
  81270. /**
  81271. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81272. * 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.
  81273. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81274. */
  81275. mirrorPlane: Plane;
  81276. /**
  81277. * Define the blur ratio used to blur the reflection if needed.
  81278. */
  81279. blurRatio: number;
  81280. /**
  81281. * Define the adaptive blur kernel used to blur the reflection if needed.
  81282. * This will autocompute the closest best match for the `blurKernel`
  81283. */
  81284. adaptiveBlurKernel: number;
  81285. /**
  81286. * Define the blur kernel used to blur the reflection if needed.
  81287. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81288. */
  81289. blurKernel: number;
  81290. /**
  81291. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81292. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81293. */
  81294. blurKernelX: number;
  81295. /**
  81296. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81297. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81298. */
  81299. blurKernelY: number;
  81300. private _autoComputeBlurKernel;
  81301. protected _onRatioRescale(): void;
  81302. private _updateGammaSpace;
  81303. private _imageProcessingConfigChangeObserver;
  81304. private _transformMatrix;
  81305. private _mirrorMatrix;
  81306. private _savedViewMatrix;
  81307. private _blurX;
  81308. private _blurY;
  81309. private _adaptiveBlurKernel;
  81310. private _blurKernelX;
  81311. private _blurKernelY;
  81312. private _blurRatio;
  81313. /**
  81314. * Instantiates a Mirror Texture.
  81315. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81316. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81317. * You can then easily use it as a reflectionTexture on a flat surface.
  81318. * In case the surface is not a plane, please consider relying on reflection probes.
  81319. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81320. * @param name
  81321. * @param size
  81322. * @param scene
  81323. * @param generateMipMaps
  81324. * @param type
  81325. * @param samplingMode
  81326. * @param generateDepthBuffer
  81327. */
  81328. constructor(name: string, size: number | {
  81329. width: number;
  81330. height: number;
  81331. } | {
  81332. ratio: number;
  81333. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81334. private _preparePostProcesses;
  81335. /**
  81336. * Clone the mirror texture.
  81337. * @returns the cloned texture
  81338. */
  81339. clone(): MirrorTexture;
  81340. /**
  81341. * Serialize the texture to a JSON representation you could use in Parse later on
  81342. * @returns the serialized JSON representation
  81343. */
  81344. serialize(): any;
  81345. /**
  81346. * Dispose the texture and release its associated resources.
  81347. */
  81348. dispose(): void;
  81349. }
  81350. }
  81351. declare module BABYLON {
  81352. /**
  81353. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81354. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81355. */
  81356. export class Texture extends BaseTexture {
  81357. /** @hidden */
  81358. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81359. /** @hidden */
  81360. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81361. /** @hidden */
  81362. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81363. /** nearest is mag = nearest and min = nearest and mip = linear */
  81364. static readonly NEAREST_SAMPLINGMODE: number;
  81365. /** nearest is mag = nearest and min = nearest and mip = linear */
  81366. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81367. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81368. static readonly BILINEAR_SAMPLINGMODE: number;
  81369. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81370. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81371. /** Trilinear is mag = linear and min = linear and mip = linear */
  81372. static readonly TRILINEAR_SAMPLINGMODE: number;
  81373. /** Trilinear is mag = linear and min = linear and mip = linear */
  81374. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81375. /** mag = nearest and min = nearest and mip = nearest */
  81376. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81377. /** mag = nearest and min = linear and mip = nearest */
  81378. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81379. /** mag = nearest and min = linear and mip = linear */
  81380. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81381. /** mag = nearest and min = linear and mip = none */
  81382. static readonly NEAREST_LINEAR: number;
  81383. /** mag = nearest and min = nearest and mip = none */
  81384. static readonly NEAREST_NEAREST: number;
  81385. /** mag = linear and min = nearest and mip = nearest */
  81386. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81387. /** mag = linear and min = nearest and mip = linear */
  81388. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81389. /** mag = linear and min = linear and mip = none */
  81390. static readonly LINEAR_LINEAR: number;
  81391. /** mag = linear and min = nearest and mip = none */
  81392. static readonly LINEAR_NEAREST: number;
  81393. /** Explicit coordinates mode */
  81394. static readonly EXPLICIT_MODE: number;
  81395. /** Spherical coordinates mode */
  81396. static readonly SPHERICAL_MODE: number;
  81397. /** Planar coordinates mode */
  81398. static readonly PLANAR_MODE: number;
  81399. /** Cubic coordinates mode */
  81400. static readonly CUBIC_MODE: number;
  81401. /** Projection coordinates mode */
  81402. static readonly PROJECTION_MODE: number;
  81403. /** Inverse Cubic coordinates mode */
  81404. static readonly SKYBOX_MODE: number;
  81405. /** Inverse Cubic coordinates mode */
  81406. static readonly INVCUBIC_MODE: number;
  81407. /** Equirectangular coordinates mode */
  81408. static readonly EQUIRECTANGULAR_MODE: number;
  81409. /** Equirectangular Fixed coordinates mode */
  81410. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81411. /** Equirectangular Fixed Mirrored coordinates mode */
  81412. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81413. /** Texture is not repeating outside of 0..1 UVs */
  81414. static readonly CLAMP_ADDRESSMODE: number;
  81415. /** Texture is repeating outside of 0..1 UVs */
  81416. static readonly WRAP_ADDRESSMODE: number;
  81417. /** Texture is repeating and mirrored */
  81418. static readonly MIRROR_ADDRESSMODE: number;
  81419. /**
  81420. * 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
  81421. */
  81422. static UseSerializedUrlIfAny: boolean;
  81423. /**
  81424. * Define the url of the texture.
  81425. */
  81426. url: Nullable<string>;
  81427. /**
  81428. * Define an offset on the texture to offset the u coordinates of the UVs
  81429. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81430. */
  81431. uOffset: number;
  81432. /**
  81433. * Define an offset on the texture to offset the v coordinates of the UVs
  81434. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81435. */
  81436. vOffset: number;
  81437. /**
  81438. * Define an offset on the texture to scale the u coordinates of the UVs
  81439. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81440. */
  81441. uScale: number;
  81442. /**
  81443. * Define an offset on the texture to scale the v coordinates of the UVs
  81444. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81445. */
  81446. vScale: number;
  81447. /**
  81448. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81449. * @see http://doc.babylonjs.com/how_to/more_materials
  81450. */
  81451. uAng: number;
  81452. /**
  81453. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81454. * @see http://doc.babylonjs.com/how_to/more_materials
  81455. */
  81456. vAng: number;
  81457. /**
  81458. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81459. * @see http://doc.babylonjs.com/how_to/more_materials
  81460. */
  81461. wAng: number;
  81462. /**
  81463. * Defines the center of rotation (U)
  81464. */
  81465. uRotationCenter: number;
  81466. /**
  81467. * Defines the center of rotation (V)
  81468. */
  81469. vRotationCenter: number;
  81470. /**
  81471. * Defines the center of rotation (W)
  81472. */
  81473. wRotationCenter: number;
  81474. /**
  81475. * Are mip maps generated for this texture or not.
  81476. */
  81477. readonly noMipmap: boolean;
  81478. /**
  81479. * List of inspectable custom properties (used by the Inspector)
  81480. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81481. */
  81482. inspectableCustomProperties: Nullable<IInspectable[]>;
  81483. private _noMipmap;
  81484. /** @hidden */
  81485. _invertY: boolean;
  81486. private _rowGenerationMatrix;
  81487. private _cachedTextureMatrix;
  81488. private _projectionModeMatrix;
  81489. private _t0;
  81490. private _t1;
  81491. private _t2;
  81492. private _cachedUOffset;
  81493. private _cachedVOffset;
  81494. private _cachedUScale;
  81495. private _cachedVScale;
  81496. private _cachedUAng;
  81497. private _cachedVAng;
  81498. private _cachedWAng;
  81499. private _cachedProjectionMatrixId;
  81500. private _cachedCoordinatesMode;
  81501. /** @hidden */
  81502. protected _initialSamplingMode: number;
  81503. /** @hidden */
  81504. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  81505. private _deleteBuffer;
  81506. protected _format: Nullable<number>;
  81507. private _delayedOnLoad;
  81508. private _delayedOnError;
  81509. /**
  81510. * Observable triggered once the texture has been loaded.
  81511. */
  81512. onLoadObservable: Observable<Texture>;
  81513. protected _isBlocking: boolean;
  81514. /**
  81515. * Is the texture preventing material to render while loading.
  81516. * If false, a default texture will be used instead of the loading one during the preparation step.
  81517. */
  81518. isBlocking: boolean;
  81519. /**
  81520. * Get the current sampling mode associated with the texture.
  81521. */
  81522. readonly samplingMode: number;
  81523. /**
  81524. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81525. */
  81526. readonly invertY: boolean;
  81527. /**
  81528. * Instantiates a new texture.
  81529. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81530. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81531. * @param url define the url of the picture to load as a texture
  81532. * @param scene define the scene the texture will belong to
  81533. * @param noMipmap define if the texture will require mip maps or not
  81534. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81535. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81536. * @param onLoad define a callback triggered when the texture has been loaded
  81537. * @param onError define a callback triggered when an error occurred during the loading session
  81538. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81539. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81540. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81541. */
  81542. 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);
  81543. /**
  81544. * Update the url (and optional buffer) of this texture if url was null during construction.
  81545. * @param url the url of the texture
  81546. * @param buffer the buffer of the texture (defaults to null)
  81547. * @param onLoad callback called when the texture is loaded (defaults to null)
  81548. */
  81549. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81550. /**
  81551. * Finish the loading sequence of a texture flagged as delayed load.
  81552. * @hidden
  81553. */
  81554. delayLoad(): void;
  81555. private _prepareRowForTextureGeneration;
  81556. /**
  81557. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81558. * @returns the transform matrix of the texture.
  81559. */
  81560. getTextureMatrix(): Matrix;
  81561. /**
  81562. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81563. * @returns The reflection texture transform
  81564. */
  81565. getReflectionTextureMatrix(): Matrix;
  81566. /**
  81567. * Clones the texture.
  81568. * @returns the cloned texture
  81569. */
  81570. clone(): Texture;
  81571. /**
  81572. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81573. * @returns The JSON representation of the texture
  81574. */
  81575. serialize(): any;
  81576. /**
  81577. * Get the current class name of the texture useful for serialization or dynamic coding.
  81578. * @returns "Texture"
  81579. */
  81580. getClassName(): string;
  81581. /**
  81582. * Dispose the texture and release its associated resources.
  81583. */
  81584. dispose(): void;
  81585. /**
  81586. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81587. * @param parsedTexture Define the JSON representation of the texture
  81588. * @param scene Define the scene the parsed texture should be instantiated in
  81589. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81590. * @returns The parsed texture if successful
  81591. */
  81592. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81593. /**
  81594. * Creates a texture from its base 64 representation.
  81595. * @param data Define the base64 payload without the data: prefix
  81596. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81597. * @param scene Define the scene the texture should belong to
  81598. * @param noMipmap Forces the texture to not create mip map information if true
  81599. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81600. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81601. * @param onLoad define a callback triggered when the texture has been loaded
  81602. * @param onError define a callback triggered when an error occurred during the loading session
  81603. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81604. * @returns the created texture
  81605. */
  81606. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81607. /**
  81608. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81609. * @param data Define the base64 payload without the data: prefix
  81610. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81611. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81612. * @param scene Define the scene the texture should belong to
  81613. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81614. * @param noMipmap Forces the texture to not create mip map information if true
  81615. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81616. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81617. * @param onLoad define a callback triggered when the texture has been loaded
  81618. * @param onError define a callback triggered when an error occurred during the loading session
  81619. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81620. * @returns the created texture
  81621. */
  81622. 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;
  81623. }
  81624. }
  81625. declare module BABYLON {
  81626. /**
  81627. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81628. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81629. */
  81630. export class PostProcessManager {
  81631. private _scene;
  81632. private _indexBuffer;
  81633. private _vertexBuffers;
  81634. /**
  81635. * Creates a new instance PostProcess
  81636. * @param scene The scene that the post process is associated with.
  81637. */
  81638. constructor(scene: Scene);
  81639. private _prepareBuffers;
  81640. private _buildIndexBuffer;
  81641. /**
  81642. * Rebuilds the vertex buffers of the manager.
  81643. * @hidden
  81644. */
  81645. _rebuild(): void;
  81646. /**
  81647. * Prepares a frame to be run through a post process.
  81648. * @param sourceTexture The input texture to the post procesess. (default: null)
  81649. * @param postProcesses An array of post processes to be run. (default: null)
  81650. * @returns True if the post processes were able to be run.
  81651. * @hidden
  81652. */
  81653. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81654. /**
  81655. * Manually render a set of post processes to a texture.
  81656. * @param postProcesses An array of post processes to be run.
  81657. * @param targetTexture The target texture to render to.
  81658. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81659. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81660. * @param lodLevel defines which lod of the texture to render to
  81661. */
  81662. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81663. /**
  81664. * Finalize the result of the output of the postprocesses.
  81665. * @param doNotPresent If true the result will not be displayed to the screen.
  81666. * @param targetTexture The target texture to render to.
  81667. * @param faceIndex The index of the face to bind the target texture to.
  81668. * @param postProcesses The array of post processes to render.
  81669. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81670. * @hidden
  81671. */
  81672. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81673. /**
  81674. * Disposes of the post process manager.
  81675. */
  81676. dispose(): void;
  81677. }
  81678. }
  81679. declare module BABYLON {
  81680. interface AbstractScene {
  81681. /**
  81682. * The list of procedural textures added to the scene
  81683. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81684. */
  81685. proceduralTextures: Array<ProceduralTexture>;
  81686. }
  81687. /**
  81688. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81689. * in a given scene.
  81690. */
  81691. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81692. /**
  81693. * The component name helpfull to identify the component in the list of scene components.
  81694. */
  81695. readonly name: string;
  81696. /**
  81697. * The scene the component belongs to.
  81698. */
  81699. scene: Scene;
  81700. /**
  81701. * Creates a new instance of the component for the given scene
  81702. * @param scene Defines the scene to register the component in
  81703. */
  81704. constructor(scene: Scene);
  81705. /**
  81706. * Registers the component in a given scene
  81707. */
  81708. register(): void;
  81709. /**
  81710. * Rebuilds the elements related to this component in case of
  81711. * context lost for instance.
  81712. */
  81713. rebuild(): void;
  81714. /**
  81715. * Disposes the component and the associated ressources.
  81716. */
  81717. dispose(): void;
  81718. private _beforeClear;
  81719. }
  81720. }
  81721. declare module BABYLON {
  81722. interface Engine {
  81723. /**
  81724. * Creates a new render target cube texture
  81725. * @param size defines the size of the texture
  81726. * @param options defines the options used to create the texture
  81727. * @returns a new render target cube texture stored in an InternalTexture
  81728. */
  81729. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81730. }
  81731. }
  81732. declare module BABYLON {
  81733. /** @hidden */
  81734. export var proceduralVertexShader: {
  81735. name: string;
  81736. shader: string;
  81737. };
  81738. }
  81739. declare module BABYLON {
  81740. /**
  81741. * 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.
  81742. * This is the base class of any Procedural texture and contains most of the shareable code.
  81743. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81744. */
  81745. export class ProceduralTexture extends Texture {
  81746. isCube: boolean;
  81747. /**
  81748. * Define if the texture is enabled or not (disabled texture will not render)
  81749. */
  81750. isEnabled: boolean;
  81751. /**
  81752. * Define if the texture must be cleared before rendering (default is true)
  81753. */
  81754. autoClear: boolean;
  81755. /**
  81756. * Callback called when the texture is generated
  81757. */
  81758. onGenerated: () => void;
  81759. /**
  81760. * Event raised when the texture is generated
  81761. */
  81762. onGeneratedObservable: Observable<ProceduralTexture>;
  81763. /** @hidden */
  81764. _generateMipMaps: boolean;
  81765. /** @hidden **/
  81766. _effect: Effect;
  81767. /** @hidden */
  81768. _textures: {
  81769. [key: string]: Texture;
  81770. };
  81771. private _size;
  81772. private _currentRefreshId;
  81773. private _refreshRate;
  81774. private _vertexBuffers;
  81775. private _indexBuffer;
  81776. private _uniforms;
  81777. private _samplers;
  81778. private _fragment;
  81779. private _floats;
  81780. private _ints;
  81781. private _floatsArrays;
  81782. private _colors3;
  81783. private _colors4;
  81784. private _vectors2;
  81785. private _vectors3;
  81786. private _matrices;
  81787. private _fallbackTexture;
  81788. private _fallbackTextureUsed;
  81789. private _engine;
  81790. private _cachedDefines;
  81791. private _contentUpdateId;
  81792. private _contentData;
  81793. /**
  81794. * Instantiates a new procedural texture.
  81795. * 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.
  81796. * This is the base class of any Procedural texture and contains most of the shareable code.
  81797. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81798. * @param name Define the name of the texture
  81799. * @param size Define the size of the texture to create
  81800. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81801. * @param scene Define the scene the texture belongs to
  81802. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81803. * @param generateMipMaps Define if the texture should creates mip maps or not
  81804. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81805. */
  81806. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81807. /**
  81808. * The effect that is created when initializing the post process.
  81809. * @returns The created effect corresponding the the postprocess.
  81810. */
  81811. getEffect(): Effect;
  81812. /**
  81813. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81814. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81815. */
  81816. getContent(): Nullable<ArrayBufferView>;
  81817. private _createIndexBuffer;
  81818. /** @hidden */
  81819. _rebuild(): void;
  81820. /**
  81821. * Resets the texture in order to recreate its associated resources.
  81822. * This can be called in case of context loss
  81823. */
  81824. reset(): void;
  81825. protected _getDefines(): string;
  81826. /**
  81827. * Is the texture ready to be used ? (rendered at least once)
  81828. * @returns true if ready, otherwise, false.
  81829. */
  81830. isReady(): boolean;
  81831. /**
  81832. * Resets the refresh counter of the texture and start bak from scratch.
  81833. * Could be useful to regenerate the texture if it is setup to render only once.
  81834. */
  81835. resetRefreshCounter(): void;
  81836. /**
  81837. * Set the fragment shader to use in order to render the texture.
  81838. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81839. */
  81840. setFragment(fragment: any): void;
  81841. /**
  81842. * Define the refresh rate of the texture or the rendering frequency.
  81843. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81844. */
  81845. refreshRate: number;
  81846. /** @hidden */
  81847. _shouldRender(): boolean;
  81848. /**
  81849. * Get the size the texture is rendering at.
  81850. * @returns the size (texture is always squared)
  81851. */
  81852. getRenderSize(): number;
  81853. /**
  81854. * Resize the texture to new value.
  81855. * @param size Define the new size the texture should have
  81856. * @param generateMipMaps Define whether the new texture should create mip maps
  81857. */
  81858. resize(size: number, generateMipMaps: boolean): void;
  81859. private _checkUniform;
  81860. /**
  81861. * Set a texture in the shader program used to render.
  81862. * @param name Define the name of the uniform samplers as defined in the shader
  81863. * @param texture Define the texture to bind to this sampler
  81864. * @return the texture itself allowing "fluent" like uniform updates
  81865. */
  81866. setTexture(name: string, texture: Texture): ProceduralTexture;
  81867. /**
  81868. * Set a float in the shader.
  81869. * @param name Define the name of the uniform as defined in the shader
  81870. * @param value Define the value to give to the uniform
  81871. * @return the texture itself allowing "fluent" like uniform updates
  81872. */
  81873. setFloat(name: string, value: number): ProceduralTexture;
  81874. /**
  81875. * Set a int in the shader.
  81876. * @param name Define the name of the uniform as defined in the shader
  81877. * @param value Define the value to give to the uniform
  81878. * @return the texture itself allowing "fluent" like uniform updates
  81879. */
  81880. setInt(name: string, value: number): ProceduralTexture;
  81881. /**
  81882. * Set an array of floats in the shader.
  81883. * @param name Define the name of the uniform as defined in the shader
  81884. * @param value Define the value to give to the uniform
  81885. * @return the texture itself allowing "fluent" like uniform updates
  81886. */
  81887. setFloats(name: string, value: number[]): ProceduralTexture;
  81888. /**
  81889. * Set a vec3 in the shader from a Color3.
  81890. * @param name Define the name of the uniform as defined in the shader
  81891. * @param value Define the value to give to the uniform
  81892. * @return the texture itself allowing "fluent" like uniform updates
  81893. */
  81894. setColor3(name: string, value: Color3): ProceduralTexture;
  81895. /**
  81896. * Set a vec4 in the shader from a Color4.
  81897. * @param name Define the name of the uniform as defined in the shader
  81898. * @param value Define the value to give to the uniform
  81899. * @return the texture itself allowing "fluent" like uniform updates
  81900. */
  81901. setColor4(name: string, value: Color4): ProceduralTexture;
  81902. /**
  81903. * Set a vec2 in the shader from a Vector2.
  81904. * @param name Define the name of the uniform as defined in the shader
  81905. * @param value Define the value to give to the uniform
  81906. * @return the texture itself allowing "fluent" like uniform updates
  81907. */
  81908. setVector2(name: string, value: Vector2): ProceduralTexture;
  81909. /**
  81910. * Set a vec3 in the shader from a Vector3.
  81911. * @param name Define the name of the uniform as defined in the shader
  81912. * @param value Define the value to give to the uniform
  81913. * @return the texture itself allowing "fluent" like uniform updates
  81914. */
  81915. setVector3(name: string, value: Vector3): ProceduralTexture;
  81916. /**
  81917. * Set a mat4 in the shader from a MAtrix.
  81918. * @param name Define the name of the uniform as defined in the shader
  81919. * @param value Define the value to give to the uniform
  81920. * @return the texture itself allowing "fluent" like uniform updates
  81921. */
  81922. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81923. /**
  81924. * Render the texture to its associated render target.
  81925. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81926. */
  81927. render(useCameraPostProcess?: boolean): void;
  81928. /**
  81929. * Clone the texture.
  81930. * @returns the cloned texture
  81931. */
  81932. clone(): ProceduralTexture;
  81933. /**
  81934. * Dispose the texture and release its asoociated resources.
  81935. */
  81936. dispose(): void;
  81937. }
  81938. }
  81939. declare module BABYLON {
  81940. /**
  81941. * This represents the base class for particle system in Babylon.
  81942. * 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.
  81943. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81944. * @example https://doc.babylonjs.com/babylon101/particles
  81945. */
  81946. export class BaseParticleSystem {
  81947. /**
  81948. * Source color is added to the destination color without alpha affecting the result
  81949. */
  81950. static BLENDMODE_ONEONE: number;
  81951. /**
  81952. * Blend current color and particle color using particle’s alpha
  81953. */
  81954. static BLENDMODE_STANDARD: number;
  81955. /**
  81956. * Add current color and particle color multiplied by particle’s alpha
  81957. */
  81958. static BLENDMODE_ADD: number;
  81959. /**
  81960. * Multiply current color with particle color
  81961. */
  81962. static BLENDMODE_MULTIPLY: number;
  81963. /**
  81964. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81965. */
  81966. static BLENDMODE_MULTIPLYADD: number;
  81967. /**
  81968. * List of animations used by the particle system.
  81969. */
  81970. animations: Animation[];
  81971. /**
  81972. * The id of the Particle system.
  81973. */
  81974. id: string;
  81975. /**
  81976. * The friendly name of the Particle system.
  81977. */
  81978. name: string;
  81979. /**
  81980. * The rendering group used by the Particle system to chose when to render.
  81981. */
  81982. renderingGroupId: number;
  81983. /**
  81984. * The emitter represents the Mesh or position we are attaching the particle system to.
  81985. */
  81986. emitter: Nullable<AbstractMesh | Vector3>;
  81987. /**
  81988. * The maximum number of particles to emit per frame
  81989. */
  81990. emitRate: number;
  81991. /**
  81992. * If you want to launch only a few particles at once, that can be done, as well.
  81993. */
  81994. manualEmitCount: number;
  81995. /**
  81996. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81997. */
  81998. updateSpeed: number;
  81999. /**
  82000. * The amount of time the particle system is running (depends of the overall update speed).
  82001. */
  82002. targetStopDuration: number;
  82003. /**
  82004. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82005. */
  82006. disposeOnStop: boolean;
  82007. /**
  82008. * Minimum power of emitting particles.
  82009. */
  82010. minEmitPower: number;
  82011. /**
  82012. * Maximum power of emitting particles.
  82013. */
  82014. maxEmitPower: number;
  82015. /**
  82016. * Minimum life time of emitting particles.
  82017. */
  82018. minLifeTime: number;
  82019. /**
  82020. * Maximum life time of emitting particles.
  82021. */
  82022. maxLifeTime: number;
  82023. /**
  82024. * Minimum Size of emitting particles.
  82025. */
  82026. minSize: number;
  82027. /**
  82028. * Maximum Size of emitting particles.
  82029. */
  82030. maxSize: number;
  82031. /**
  82032. * Minimum scale of emitting particles on X axis.
  82033. */
  82034. minScaleX: number;
  82035. /**
  82036. * Maximum scale of emitting particles on X axis.
  82037. */
  82038. maxScaleX: number;
  82039. /**
  82040. * Minimum scale of emitting particles on Y axis.
  82041. */
  82042. minScaleY: number;
  82043. /**
  82044. * Maximum scale of emitting particles on Y axis.
  82045. */
  82046. maxScaleY: number;
  82047. /**
  82048. * Gets or sets the minimal initial rotation in radians.
  82049. */
  82050. minInitialRotation: number;
  82051. /**
  82052. * Gets or sets the maximal initial rotation in radians.
  82053. */
  82054. maxInitialRotation: number;
  82055. /**
  82056. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82057. */
  82058. minAngularSpeed: number;
  82059. /**
  82060. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82061. */
  82062. maxAngularSpeed: number;
  82063. /**
  82064. * The texture used to render each particle. (this can be a spritesheet)
  82065. */
  82066. particleTexture: Nullable<Texture>;
  82067. /**
  82068. * The layer mask we are rendering the particles through.
  82069. */
  82070. layerMask: number;
  82071. /**
  82072. * This can help using your own shader to render the particle system.
  82073. * The according effect will be created
  82074. */
  82075. customShader: any;
  82076. /**
  82077. * By default particle system starts as soon as they are created. This prevents the
  82078. * automatic start to happen and let you decide when to start emitting particles.
  82079. */
  82080. preventAutoStart: boolean;
  82081. private _noiseTexture;
  82082. /**
  82083. * Gets or sets a texture used to add random noise to particle positions
  82084. */
  82085. noiseTexture: Nullable<ProceduralTexture>;
  82086. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82087. noiseStrength: Vector3;
  82088. /**
  82089. * Callback triggered when the particle animation is ending.
  82090. */
  82091. onAnimationEnd: Nullable<() => void>;
  82092. /**
  82093. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82094. */
  82095. blendMode: number;
  82096. /**
  82097. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82098. * to override the particles.
  82099. */
  82100. forceDepthWrite: boolean;
  82101. /** 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 */
  82102. preWarmCycles: number;
  82103. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82104. preWarmStepOffset: number;
  82105. /**
  82106. * 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)
  82107. */
  82108. spriteCellChangeSpeed: number;
  82109. /**
  82110. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82111. */
  82112. startSpriteCellID: number;
  82113. /**
  82114. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82115. */
  82116. endSpriteCellID: number;
  82117. /**
  82118. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82119. */
  82120. spriteCellWidth: number;
  82121. /**
  82122. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82123. */
  82124. spriteCellHeight: number;
  82125. /**
  82126. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82127. */
  82128. spriteRandomStartCell: boolean;
  82129. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82130. translationPivot: Vector2;
  82131. /** @hidden */
  82132. protected _isAnimationSheetEnabled: boolean;
  82133. /**
  82134. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82135. */
  82136. beginAnimationOnStart: boolean;
  82137. /**
  82138. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82139. */
  82140. beginAnimationFrom: number;
  82141. /**
  82142. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82143. */
  82144. beginAnimationTo: number;
  82145. /**
  82146. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82147. */
  82148. beginAnimationLoop: boolean;
  82149. /**
  82150. * Gets or sets a world offset applied to all particles
  82151. */
  82152. worldOffset: Vector3;
  82153. /**
  82154. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82155. */
  82156. isAnimationSheetEnabled: boolean;
  82157. /**
  82158. * Get hosting scene
  82159. * @returns the scene
  82160. */
  82161. getScene(): Scene;
  82162. /**
  82163. * You can use gravity if you want to give an orientation to your particles.
  82164. */
  82165. gravity: Vector3;
  82166. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82167. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82168. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82169. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82170. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82171. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82172. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82173. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82174. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82175. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82176. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82177. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82178. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82179. /**
  82180. * Defines the delay in milliseconds before starting the system (0 by default)
  82181. */
  82182. startDelay: number;
  82183. /**
  82184. * Gets the current list of drag gradients.
  82185. * You must use addDragGradient and removeDragGradient to udpate this list
  82186. * @returns the list of drag gradients
  82187. */
  82188. getDragGradients(): Nullable<Array<FactorGradient>>;
  82189. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82190. limitVelocityDamping: number;
  82191. /**
  82192. * Gets the current list of limit velocity gradients.
  82193. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82194. * @returns the list of limit velocity gradients
  82195. */
  82196. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82197. /**
  82198. * Gets the current list of color gradients.
  82199. * You must use addColorGradient and removeColorGradient to udpate this list
  82200. * @returns the list of color gradients
  82201. */
  82202. getColorGradients(): Nullable<Array<ColorGradient>>;
  82203. /**
  82204. * Gets the current list of size gradients.
  82205. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82206. * @returns the list of size gradients
  82207. */
  82208. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82209. /**
  82210. * Gets the current list of color remap gradients.
  82211. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82212. * @returns the list of color remap gradients
  82213. */
  82214. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82215. /**
  82216. * Gets the current list of alpha remap gradients.
  82217. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82218. * @returns the list of alpha remap gradients
  82219. */
  82220. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82221. /**
  82222. * Gets the current list of life time gradients.
  82223. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82224. * @returns the list of life time gradients
  82225. */
  82226. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82227. /**
  82228. * Gets the current list of angular speed gradients.
  82229. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82230. * @returns the list of angular speed gradients
  82231. */
  82232. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82233. /**
  82234. * Gets the current list of velocity gradients.
  82235. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82236. * @returns the list of velocity gradients
  82237. */
  82238. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82239. /**
  82240. * Gets the current list of start size gradients.
  82241. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82242. * @returns the list of start size gradients
  82243. */
  82244. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82245. /**
  82246. * Gets the current list of emit rate gradients.
  82247. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82248. * @returns the list of emit rate gradients
  82249. */
  82250. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82251. /**
  82252. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82253. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82254. */
  82255. direction1: Vector3;
  82256. /**
  82257. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82258. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82259. */
  82260. direction2: Vector3;
  82261. /**
  82262. * 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.
  82263. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82264. */
  82265. minEmitBox: Vector3;
  82266. /**
  82267. * 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.
  82268. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82269. */
  82270. maxEmitBox: Vector3;
  82271. /**
  82272. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82273. */
  82274. color1: Color4;
  82275. /**
  82276. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82277. */
  82278. color2: Color4;
  82279. /**
  82280. * Color the particle will have at the end of its lifetime
  82281. */
  82282. colorDead: Color4;
  82283. /**
  82284. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82285. */
  82286. textureMask: Color4;
  82287. /**
  82288. * The particle emitter type defines the emitter used by the particle system.
  82289. * It can be for example box, sphere, or cone...
  82290. */
  82291. particleEmitterType: IParticleEmitterType;
  82292. /** @hidden */
  82293. _isSubEmitter: boolean;
  82294. /**
  82295. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82296. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82297. */
  82298. billboardMode: number;
  82299. protected _isBillboardBased: boolean;
  82300. /**
  82301. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82302. */
  82303. isBillboardBased: boolean;
  82304. /**
  82305. * The scene the particle system belongs to.
  82306. */
  82307. protected _scene: Scene;
  82308. /**
  82309. * Local cache of defines for image processing.
  82310. */
  82311. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82312. /**
  82313. * Default configuration related to image processing available in the standard Material.
  82314. */
  82315. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82316. /**
  82317. * Gets the image processing configuration used either in this material.
  82318. */
  82319. /**
  82320. * Sets the Default image processing configuration used either in the this material.
  82321. *
  82322. * If sets to null, the scene one is in use.
  82323. */
  82324. imageProcessingConfiguration: ImageProcessingConfiguration;
  82325. /**
  82326. * Attaches a new image processing configuration to the Standard Material.
  82327. * @param configuration
  82328. */
  82329. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82330. /** @hidden */
  82331. protected _reset(): void;
  82332. /** @hidden */
  82333. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82334. /**
  82335. * Instantiates a particle system.
  82336. * 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.
  82337. * @param name The name of the particle system
  82338. */
  82339. constructor(name: string);
  82340. /**
  82341. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82342. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82343. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82344. * @returns the emitter
  82345. */
  82346. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82347. /**
  82348. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82349. * @param radius The radius of the hemisphere to emit from
  82350. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82351. * @returns the emitter
  82352. */
  82353. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82354. /**
  82355. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82356. * @param radius The radius of the sphere to emit from
  82357. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82358. * @returns the emitter
  82359. */
  82360. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82361. /**
  82362. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82363. * @param radius The radius of the sphere to emit from
  82364. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82365. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82366. * @returns the emitter
  82367. */
  82368. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82369. /**
  82370. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82371. * @param radius The radius of the emission cylinder
  82372. * @param height The height of the emission cylinder
  82373. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82374. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82375. * @returns the emitter
  82376. */
  82377. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82378. /**
  82379. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82380. * @param radius The radius of the cylinder to emit from
  82381. * @param height The height of the emission cylinder
  82382. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82383. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82384. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82385. * @returns the emitter
  82386. */
  82387. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82388. /**
  82389. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82390. * @param radius The radius of the cone to emit from
  82391. * @param angle The base angle of the cone
  82392. * @returns the emitter
  82393. */
  82394. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82395. /**
  82396. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82397. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82398. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82399. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82400. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82401. * @returns the emitter
  82402. */
  82403. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82404. }
  82405. }
  82406. declare module BABYLON {
  82407. /**
  82408. * Type of sub emitter
  82409. */
  82410. export enum SubEmitterType {
  82411. /**
  82412. * Attached to the particle over it's lifetime
  82413. */
  82414. ATTACHED = 0,
  82415. /**
  82416. * Created when the particle dies
  82417. */
  82418. END = 1
  82419. }
  82420. /**
  82421. * Sub emitter class used to emit particles from an existing particle
  82422. */
  82423. export class SubEmitter {
  82424. /**
  82425. * the particle system to be used by the sub emitter
  82426. */
  82427. particleSystem: ParticleSystem;
  82428. /**
  82429. * Type of the submitter (Default: END)
  82430. */
  82431. type: SubEmitterType;
  82432. /**
  82433. * 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)
  82434. * Note: This only is supported when using an emitter of type Mesh
  82435. */
  82436. inheritDirection: boolean;
  82437. /**
  82438. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82439. */
  82440. inheritedVelocityAmount: number;
  82441. /**
  82442. * Creates a sub emitter
  82443. * @param particleSystem the particle system to be used by the sub emitter
  82444. */
  82445. constructor(
  82446. /**
  82447. * the particle system to be used by the sub emitter
  82448. */
  82449. particleSystem: ParticleSystem);
  82450. /**
  82451. * Clones the sub emitter
  82452. * @returns the cloned sub emitter
  82453. */
  82454. clone(): SubEmitter;
  82455. /**
  82456. * Serialize current object to a JSON object
  82457. * @returns the serialized object
  82458. */
  82459. serialize(): any;
  82460. /** @hidden */
  82461. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82462. /**
  82463. * Creates a new SubEmitter from a serialized JSON version
  82464. * @param serializationObject defines the JSON object to read from
  82465. * @param scene defines the hosting scene
  82466. * @param rootUrl defines the rootUrl for data loading
  82467. * @returns a new SubEmitter
  82468. */
  82469. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82470. /** Release associated resources */
  82471. dispose(): void;
  82472. }
  82473. }
  82474. declare module BABYLON {
  82475. /** @hidden */
  82476. export var imageProcessingDeclaration: {
  82477. name: string;
  82478. shader: string;
  82479. };
  82480. }
  82481. declare module BABYLON {
  82482. /** @hidden */
  82483. export var imageProcessingFunctions: {
  82484. name: string;
  82485. shader: string;
  82486. };
  82487. }
  82488. declare module BABYLON {
  82489. /** @hidden */
  82490. export var particlesPixelShader: {
  82491. name: string;
  82492. shader: string;
  82493. };
  82494. }
  82495. declare module BABYLON {
  82496. /** @hidden */
  82497. export var particlesVertexShader: {
  82498. name: string;
  82499. shader: string;
  82500. };
  82501. }
  82502. declare module BABYLON {
  82503. /**
  82504. * This represents a particle system in Babylon.
  82505. * 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.
  82506. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82507. * @example https://doc.babylonjs.com/babylon101/particles
  82508. */
  82509. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82510. /**
  82511. * Billboard mode will only apply to Y axis
  82512. */
  82513. static readonly BILLBOARDMODE_Y: number;
  82514. /**
  82515. * Billboard mode will apply to all axes
  82516. */
  82517. static readonly BILLBOARDMODE_ALL: number;
  82518. /**
  82519. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82520. */
  82521. static readonly BILLBOARDMODE_STRETCHED: number;
  82522. /**
  82523. * This function can be defined to provide custom update for active particles.
  82524. * This function will be called instead of regular update (age, position, color, etc.).
  82525. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82526. */
  82527. updateFunction: (particles: Particle[]) => void;
  82528. private _emitterWorldMatrix;
  82529. /**
  82530. * This function can be defined to specify initial direction for every new particle.
  82531. * It by default use the emitterType defined function
  82532. */
  82533. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82534. /**
  82535. * This function can be defined to specify initial position for every new particle.
  82536. * It by default use the emitterType defined function
  82537. */
  82538. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82539. /**
  82540. * @hidden
  82541. */
  82542. _inheritedVelocityOffset: Vector3;
  82543. /**
  82544. * An event triggered when the system is disposed
  82545. */
  82546. onDisposeObservable: Observable<ParticleSystem>;
  82547. private _onDisposeObserver;
  82548. /**
  82549. * Sets a callback that will be triggered when the system is disposed
  82550. */
  82551. onDispose: () => void;
  82552. private _particles;
  82553. private _epsilon;
  82554. private _capacity;
  82555. private _stockParticles;
  82556. private _newPartsExcess;
  82557. private _vertexData;
  82558. private _vertexBuffer;
  82559. private _vertexBuffers;
  82560. private _spriteBuffer;
  82561. private _indexBuffer;
  82562. private _effect;
  82563. private _customEffect;
  82564. private _cachedDefines;
  82565. private _scaledColorStep;
  82566. private _colorDiff;
  82567. private _scaledDirection;
  82568. private _scaledGravity;
  82569. private _currentRenderId;
  82570. private _alive;
  82571. private _useInstancing;
  82572. private _started;
  82573. private _stopped;
  82574. private _actualFrame;
  82575. private _scaledUpdateSpeed;
  82576. private _vertexBufferSize;
  82577. /** @hidden */
  82578. _currentEmitRateGradient: Nullable<FactorGradient>;
  82579. /** @hidden */
  82580. _currentEmitRate1: number;
  82581. /** @hidden */
  82582. _currentEmitRate2: number;
  82583. /** @hidden */
  82584. _currentStartSizeGradient: Nullable<FactorGradient>;
  82585. /** @hidden */
  82586. _currentStartSize1: number;
  82587. /** @hidden */
  82588. _currentStartSize2: number;
  82589. private readonly _rawTextureWidth;
  82590. private _rampGradientsTexture;
  82591. private _useRampGradients;
  82592. /** Gets or sets a boolean indicating that ramp gradients must be used
  82593. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82594. */
  82595. useRampGradients: boolean;
  82596. /**
  82597. * 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.
  82598. * 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: [])
  82599. */
  82600. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82601. private _subEmitters;
  82602. /**
  82603. * @hidden
  82604. * If the particle systems emitter should be disposed when the particle system is disposed
  82605. */
  82606. _disposeEmitterOnDispose: boolean;
  82607. /**
  82608. * The current active Sub-systems, this property is used by the root particle system only.
  82609. */
  82610. activeSubSystems: Array<ParticleSystem>;
  82611. private _rootParticleSystem;
  82612. /**
  82613. * Gets the current list of active particles
  82614. */
  82615. readonly particles: Particle[];
  82616. /**
  82617. * Returns the string "ParticleSystem"
  82618. * @returns a string containing the class name
  82619. */
  82620. getClassName(): string;
  82621. /**
  82622. * Instantiates a particle system.
  82623. * 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.
  82624. * @param name The name of the particle system
  82625. * @param capacity The max number of particles alive at the same time
  82626. * @param scene The scene the particle system belongs to
  82627. * @param customEffect a custom effect used to change the way particles are rendered by default
  82628. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82629. * @param epsilon Offset used to render the particles
  82630. */
  82631. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82632. private _addFactorGradient;
  82633. private _removeFactorGradient;
  82634. /**
  82635. * Adds a new life time gradient
  82636. * @param gradient defines the gradient to use (between 0 and 1)
  82637. * @param factor defines the life time factor to affect to the specified gradient
  82638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82639. * @returns the current particle system
  82640. */
  82641. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82642. /**
  82643. * Remove a specific life time gradient
  82644. * @param gradient defines the gradient to remove
  82645. * @returns the current particle system
  82646. */
  82647. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82648. /**
  82649. * Adds a new size gradient
  82650. * @param gradient defines the gradient to use (between 0 and 1)
  82651. * @param factor defines the size factor to affect to the specified gradient
  82652. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82653. * @returns the current particle system
  82654. */
  82655. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82656. /**
  82657. * Remove a specific size gradient
  82658. * @param gradient defines the gradient to remove
  82659. * @returns the current particle system
  82660. */
  82661. removeSizeGradient(gradient: number): IParticleSystem;
  82662. /**
  82663. * Adds a new color remap gradient
  82664. * @param gradient defines the gradient to use (between 0 and 1)
  82665. * @param min defines the color remap minimal range
  82666. * @param max defines the color remap maximal range
  82667. * @returns the current particle system
  82668. */
  82669. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82670. /**
  82671. * Remove a specific color remap gradient
  82672. * @param gradient defines the gradient to remove
  82673. * @returns the current particle system
  82674. */
  82675. removeColorRemapGradient(gradient: number): IParticleSystem;
  82676. /**
  82677. * Adds a new alpha remap gradient
  82678. * @param gradient defines the gradient to use (between 0 and 1)
  82679. * @param min defines the alpha remap minimal range
  82680. * @param max defines the alpha remap maximal range
  82681. * @returns the current particle system
  82682. */
  82683. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82684. /**
  82685. * Remove a specific alpha remap gradient
  82686. * @param gradient defines the gradient to remove
  82687. * @returns the current particle system
  82688. */
  82689. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82690. /**
  82691. * Adds a new angular speed gradient
  82692. * @param gradient defines the gradient to use (between 0 and 1)
  82693. * @param factor defines the angular speed to affect to the specified gradient
  82694. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82695. * @returns the current particle system
  82696. */
  82697. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82698. /**
  82699. * Remove a specific angular speed gradient
  82700. * @param gradient defines the gradient to remove
  82701. * @returns the current particle system
  82702. */
  82703. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82704. /**
  82705. * Adds a new velocity gradient
  82706. * @param gradient defines the gradient to use (between 0 and 1)
  82707. * @param factor defines the velocity to affect to the specified gradient
  82708. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82709. * @returns the current particle system
  82710. */
  82711. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82712. /**
  82713. * Remove a specific velocity gradient
  82714. * @param gradient defines the gradient to remove
  82715. * @returns the current particle system
  82716. */
  82717. removeVelocityGradient(gradient: number): IParticleSystem;
  82718. /**
  82719. * Adds a new limit velocity gradient
  82720. * @param gradient defines the gradient to use (between 0 and 1)
  82721. * @param factor defines the limit velocity value to affect to the specified gradient
  82722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82723. * @returns the current particle system
  82724. */
  82725. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82726. /**
  82727. * Remove a specific limit velocity gradient
  82728. * @param gradient defines the gradient to remove
  82729. * @returns the current particle system
  82730. */
  82731. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82732. /**
  82733. * Adds a new drag gradient
  82734. * @param gradient defines the gradient to use (between 0 and 1)
  82735. * @param factor defines the drag value to affect to the specified gradient
  82736. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82737. * @returns the current particle system
  82738. */
  82739. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82740. /**
  82741. * Remove a specific drag gradient
  82742. * @param gradient defines the gradient to remove
  82743. * @returns the current particle system
  82744. */
  82745. removeDragGradient(gradient: number): IParticleSystem;
  82746. /**
  82747. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82748. * @param gradient defines the gradient to use (between 0 and 1)
  82749. * @param factor defines the emit rate value to affect to the specified gradient
  82750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82751. * @returns the current particle system
  82752. */
  82753. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82754. /**
  82755. * Remove a specific emit rate gradient
  82756. * @param gradient defines the gradient to remove
  82757. * @returns the current particle system
  82758. */
  82759. removeEmitRateGradient(gradient: number): IParticleSystem;
  82760. /**
  82761. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82762. * @param gradient defines the gradient to use (between 0 and 1)
  82763. * @param factor defines the start size value to affect to the specified gradient
  82764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82765. * @returns the current particle system
  82766. */
  82767. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82768. /**
  82769. * Remove a specific start size gradient
  82770. * @param gradient defines the gradient to remove
  82771. * @returns the current particle system
  82772. */
  82773. removeStartSizeGradient(gradient: number): IParticleSystem;
  82774. private _createRampGradientTexture;
  82775. /**
  82776. * Gets the current list of ramp gradients.
  82777. * You must use addRampGradient and removeRampGradient to udpate this list
  82778. * @returns the list of ramp gradients
  82779. */
  82780. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82781. /**
  82782. * Adds a new ramp gradient used to remap particle colors
  82783. * @param gradient defines the gradient to use (between 0 and 1)
  82784. * @param color defines the color to affect to the specified gradient
  82785. * @returns the current particle system
  82786. */
  82787. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82788. /**
  82789. * Remove a specific ramp gradient
  82790. * @param gradient defines the gradient to remove
  82791. * @returns the current particle system
  82792. */
  82793. removeRampGradient(gradient: number): ParticleSystem;
  82794. /**
  82795. * Adds a new color gradient
  82796. * @param gradient defines the gradient to use (between 0 and 1)
  82797. * @param color1 defines the color to affect to the specified gradient
  82798. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82799. * @returns this particle system
  82800. */
  82801. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82802. /**
  82803. * Remove a specific color gradient
  82804. * @param gradient defines the gradient to remove
  82805. * @returns this particle system
  82806. */
  82807. removeColorGradient(gradient: number): IParticleSystem;
  82808. private _fetchR;
  82809. protected _reset(): void;
  82810. private _resetEffect;
  82811. private _createVertexBuffers;
  82812. private _createIndexBuffer;
  82813. /**
  82814. * Gets the maximum number of particles active at the same time.
  82815. * @returns The max number of active particles.
  82816. */
  82817. getCapacity(): number;
  82818. /**
  82819. * Gets whether there are still active particles in the system.
  82820. * @returns True if it is alive, otherwise false.
  82821. */
  82822. isAlive(): boolean;
  82823. /**
  82824. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82825. * @returns True if it has been started, otherwise false.
  82826. */
  82827. isStarted(): boolean;
  82828. private _prepareSubEmitterInternalArray;
  82829. /**
  82830. * Starts the particle system and begins to emit
  82831. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82832. */
  82833. start(delay?: number): void;
  82834. /**
  82835. * Stops the particle system.
  82836. * @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.
  82837. */
  82838. stop(stopSubEmitters?: boolean): void;
  82839. /**
  82840. * Remove all active particles
  82841. */
  82842. reset(): void;
  82843. /**
  82844. * @hidden (for internal use only)
  82845. */
  82846. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82847. /**
  82848. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82849. * Its lifetime will start back at 0.
  82850. */
  82851. recycleParticle: (particle: Particle) => void;
  82852. private _stopSubEmitters;
  82853. private _createParticle;
  82854. private _removeFromRoot;
  82855. private _emitFromParticle;
  82856. private _update;
  82857. /** @hidden */
  82858. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82859. /** @hidden */
  82860. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82861. /** @hidden */
  82862. private _getEffect;
  82863. /**
  82864. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82865. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82866. */
  82867. animate(preWarmOnly?: boolean): void;
  82868. private _appendParticleVertices;
  82869. /**
  82870. * Rebuilds the particle system.
  82871. */
  82872. rebuild(): void;
  82873. /**
  82874. * Is this system ready to be used/rendered
  82875. * @return true if the system is ready
  82876. */
  82877. isReady(): boolean;
  82878. private _render;
  82879. /**
  82880. * Renders the particle system in its current state.
  82881. * @returns the current number of particles
  82882. */
  82883. render(): number;
  82884. /**
  82885. * Disposes the particle system and free the associated resources
  82886. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82887. */
  82888. dispose(disposeTexture?: boolean): void;
  82889. /**
  82890. * Clones the particle system.
  82891. * @param name The name of the cloned object
  82892. * @param newEmitter The new emitter to use
  82893. * @returns the cloned particle system
  82894. */
  82895. clone(name: string, newEmitter: any): ParticleSystem;
  82896. /**
  82897. * Serializes the particle system to a JSON object.
  82898. * @returns the JSON object
  82899. */
  82900. serialize(): any;
  82901. /** @hidden */
  82902. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82903. /** @hidden */
  82904. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82905. /**
  82906. * Parses a JSON object to create a particle system.
  82907. * @param parsedParticleSystem The JSON object to parse
  82908. * @param scene The scene to create the particle system in
  82909. * @param rootUrl The root url to use to load external dependencies like texture
  82910. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82911. * @returns the Parsed particle system
  82912. */
  82913. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82914. }
  82915. }
  82916. declare module BABYLON {
  82917. /**
  82918. * A particle represents one of the element emitted by a particle system.
  82919. * This is mainly define by its coordinates, direction, velocity and age.
  82920. */
  82921. export class Particle {
  82922. /**
  82923. * The particle system the particle belongs to.
  82924. */
  82925. particleSystem: ParticleSystem;
  82926. private static _Count;
  82927. /**
  82928. * Unique ID of the particle
  82929. */
  82930. id: number;
  82931. /**
  82932. * The world position of the particle in the scene.
  82933. */
  82934. position: Vector3;
  82935. /**
  82936. * The world direction of the particle in the scene.
  82937. */
  82938. direction: Vector3;
  82939. /**
  82940. * The color of the particle.
  82941. */
  82942. color: Color4;
  82943. /**
  82944. * The color change of the particle per step.
  82945. */
  82946. colorStep: Color4;
  82947. /**
  82948. * Defines how long will the life of the particle be.
  82949. */
  82950. lifeTime: number;
  82951. /**
  82952. * The current age of the particle.
  82953. */
  82954. age: number;
  82955. /**
  82956. * The current size of the particle.
  82957. */
  82958. size: number;
  82959. /**
  82960. * The current scale of the particle.
  82961. */
  82962. scale: Vector2;
  82963. /**
  82964. * The current angle of the particle.
  82965. */
  82966. angle: number;
  82967. /**
  82968. * Defines how fast is the angle changing.
  82969. */
  82970. angularSpeed: number;
  82971. /**
  82972. * Defines the cell index used by the particle to be rendered from a sprite.
  82973. */
  82974. cellIndex: number;
  82975. /**
  82976. * The information required to support color remapping
  82977. */
  82978. remapData: Vector4;
  82979. /** @hidden */
  82980. _randomCellOffset?: number;
  82981. /** @hidden */
  82982. _initialDirection: Nullable<Vector3>;
  82983. /** @hidden */
  82984. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82985. /** @hidden */
  82986. _initialStartSpriteCellID: number;
  82987. /** @hidden */
  82988. _initialEndSpriteCellID: number;
  82989. /** @hidden */
  82990. _currentColorGradient: Nullable<ColorGradient>;
  82991. /** @hidden */
  82992. _currentColor1: Color4;
  82993. /** @hidden */
  82994. _currentColor2: Color4;
  82995. /** @hidden */
  82996. _currentSizeGradient: Nullable<FactorGradient>;
  82997. /** @hidden */
  82998. _currentSize1: number;
  82999. /** @hidden */
  83000. _currentSize2: number;
  83001. /** @hidden */
  83002. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83003. /** @hidden */
  83004. _currentAngularSpeed1: number;
  83005. /** @hidden */
  83006. _currentAngularSpeed2: number;
  83007. /** @hidden */
  83008. _currentVelocityGradient: Nullable<FactorGradient>;
  83009. /** @hidden */
  83010. _currentVelocity1: number;
  83011. /** @hidden */
  83012. _currentVelocity2: number;
  83013. /** @hidden */
  83014. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83015. /** @hidden */
  83016. _currentLimitVelocity1: number;
  83017. /** @hidden */
  83018. _currentLimitVelocity2: number;
  83019. /** @hidden */
  83020. _currentDragGradient: Nullable<FactorGradient>;
  83021. /** @hidden */
  83022. _currentDrag1: number;
  83023. /** @hidden */
  83024. _currentDrag2: number;
  83025. /** @hidden */
  83026. _randomNoiseCoordinates1: Vector3;
  83027. /** @hidden */
  83028. _randomNoiseCoordinates2: Vector3;
  83029. /**
  83030. * Creates a new instance Particle
  83031. * @param particleSystem the particle system the particle belongs to
  83032. */
  83033. constructor(
  83034. /**
  83035. * The particle system the particle belongs to.
  83036. */
  83037. particleSystem: ParticleSystem);
  83038. private updateCellInfoFromSystem;
  83039. /**
  83040. * Defines how the sprite cell index is updated for the particle
  83041. */
  83042. updateCellIndex(): void;
  83043. /** @hidden */
  83044. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83045. /** @hidden */
  83046. _inheritParticleInfoToSubEmitters(): void;
  83047. /** @hidden */
  83048. _reset(): void;
  83049. /**
  83050. * Copy the properties of particle to another one.
  83051. * @param other the particle to copy the information to.
  83052. */
  83053. copyTo(other: Particle): void;
  83054. }
  83055. }
  83056. declare module BABYLON {
  83057. /**
  83058. * Particle emitter represents a volume emitting particles.
  83059. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83060. */
  83061. export interface IParticleEmitterType {
  83062. /**
  83063. * Called by the particle System when the direction is computed for the created particle.
  83064. * @param worldMatrix is the world matrix of the particle system
  83065. * @param directionToUpdate is the direction vector to update with the result
  83066. * @param particle is the particle we are computed the direction for
  83067. */
  83068. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83069. /**
  83070. * Called by the particle System when the position is computed for the created particle.
  83071. * @param worldMatrix is the world matrix of the particle system
  83072. * @param positionToUpdate is the position vector to update with the result
  83073. * @param particle is the particle we are computed the position for
  83074. */
  83075. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83076. /**
  83077. * Clones the current emitter and returns a copy of it
  83078. * @returns the new emitter
  83079. */
  83080. clone(): IParticleEmitterType;
  83081. /**
  83082. * Called by the GPUParticleSystem to setup the update shader
  83083. * @param effect defines the update shader
  83084. */
  83085. applyToShader(effect: Effect): void;
  83086. /**
  83087. * Returns a string to use to update the GPU particles update shader
  83088. * @returns the effect defines string
  83089. */
  83090. getEffectDefines(): string;
  83091. /**
  83092. * Returns a string representing the class name
  83093. * @returns a string containing the class name
  83094. */
  83095. getClassName(): string;
  83096. /**
  83097. * Serializes the particle system to a JSON object.
  83098. * @returns the JSON object
  83099. */
  83100. serialize(): any;
  83101. /**
  83102. * Parse properties from a JSON object
  83103. * @param serializationObject defines the JSON object
  83104. */
  83105. parse(serializationObject: any): void;
  83106. }
  83107. }
  83108. declare module BABYLON {
  83109. /**
  83110. * Particle emitter emitting particles from the inside of a box.
  83111. * It emits the particles randomly between 2 given directions.
  83112. */
  83113. export class BoxParticleEmitter implements IParticleEmitterType {
  83114. /**
  83115. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83116. */
  83117. direction1: Vector3;
  83118. /**
  83119. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83120. */
  83121. direction2: Vector3;
  83122. /**
  83123. * 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.
  83124. */
  83125. minEmitBox: Vector3;
  83126. /**
  83127. * 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.
  83128. */
  83129. maxEmitBox: Vector3;
  83130. /**
  83131. * Creates a new instance BoxParticleEmitter
  83132. */
  83133. constructor();
  83134. /**
  83135. * Called by the particle System when the direction is computed for the created particle.
  83136. * @param worldMatrix is the world matrix of the particle system
  83137. * @param directionToUpdate is the direction vector to update with the result
  83138. * @param particle is the particle we are computed the direction for
  83139. */
  83140. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83141. /**
  83142. * Called by the particle System when the position is computed for the created particle.
  83143. * @param worldMatrix is the world matrix of the particle system
  83144. * @param positionToUpdate is the position vector to update with the result
  83145. * @param particle is the particle we are computed the position for
  83146. */
  83147. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83148. /**
  83149. * Clones the current emitter and returns a copy of it
  83150. * @returns the new emitter
  83151. */
  83152. clone(): BoxParticleEmitter;
  83153. /**
  83154. * Called by the GPUParticleSystem to setup the update shader
  83155. * @param effect defines the update shader
  83156. */
  83157. applyToShader(effect: Effect): void;
  83158. /**
  83159. * Returns a string to use to update the GPU particles update shader
  83160. * @returns a string containng the defines string
  83161. */
  83162. getEffectDefines(): string;
  83163. /**
  83164. * Returns the string "BoxParticleEmitter"
  83165. * @returns a string containing the class name
  83166. */
  83167. getClassName(): string;
  83168. /**
  83169. * Serializes the particle system to a JSON object.
  83170. * @returns the JSON object
  83171. */
  83172. serialize(): any;
  83173. /**
  83174. * Parse properties from a JSON object
  83175. * @param serializationObject defines the JSON object
  83176. */
  83177. parse(serializationObject: any): void;
  83178. }
  83179. }
  83180. declare module BABYLON {
  83181. /**
  83182. * Particle emitter emitting particles from the inside of a cone.
  83183. * It emits the particles alongside the cone volume from the base to the particle.
  83184. * The emission direction might be randomized.
  83185. */
  83186. export class ConeParticleEmitter implements IParticleEmitterType {
  83187. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83188. directionRandomizer: number;
  83189. private _radius;
  83190. private _angle;
  83191. private _height;
  83192. /**
  83193. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83194. */
  83195. radiusRange: number;
  83196. /**
  83197. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83198. */
  83199. heightRange: number;
  83200. /**
  83201. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83202. */
  83203. emitFromSpawnPointOnly: boolean;
  83204. /**
  83205. * Gets or sets the radius of the emission cone
  83206. */
  83207. radius: number;
  83208. /**
  83209. * Gets or sets the angle of the emission cone
  83210. */
  83211. angle: number;
  83212. private _buildHeight;
  83213. /**
  83214. * Creates a new instance ConeParticleEmitter
  83215. * @param radius the radius of the emission cone (1 by default)
  83216. * @param angle the cone base angle (PI by default)
  83217. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83218. */
  83219. constructor(radius?: number, angle?: number,
  83220. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83221. directionRandomizer?: number);
  83222. /**
  83223. * Called by the particle System when the direction is computed for the created particle.
  83224. * @param worldMatrix is the world matrix of the particle system
  83225. * @param directionToUpdate is the direction vector to update with the result
  83226. * @param particle is the particle we are computed the direction for
  83227. */
  83228. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83229. /**
  83230. * Called by the particle System when the position is computed for the created particle.
  83231. * @param worldMatrix is the world matrix of the particle system
  83232. * @param positionToUpdate is the position vector to update with the result
  83233. * @param particle is the particle we are computed the position for
  83234. */
  83235. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83236. /**
  83237. * Clones the current emitter and returns a copy of it
  83238. * @returns the new emitter
  83239. */
  83240. clone(): ConeParticleEmitter;
  83241. /**
  83242. * Called by the GPUParticleSystem to setup the update shader
  83243. * @param effect defines the update shader
  83244. */
  83245. applyToShader(effect: Effect): void;
  83246. /**
  83247. * Returns a string to use to update the GPU particles update shader
  83248. * @returns a string containng the defines string
  83249. */
  83250. getEffectDefines(): string;
  83251. /**
  83252. * Returns the string "ConeParticleEmitter"
  83253. * @returns a string containing the class name
  83254. */
  83255. getClassName(): string;
  83256. /**
  83257. * Serializes the particle system to a JSON object.
  83258. * @returns the JSON object
  83259. */
  83260. serialize(): any;
  83261. /**
  83262. * Parse properties from a JSON object
  83263. * @param serializationObject defines the JSON object
  83264. */
  83265. parse(serializationObject: any): void;
  83266. }
  83267. }
  83268. declare module BABYLON {
  83269. /**
  83270. * Particle emitter emitting particles from the inside of a cylinder.
  83271. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83272. */
  83273. export class CylinderParticleEmitter implements IParticleEmitterType {
  83274. /**
  83275. * The radius of the emission cylinder.
  83276. */
  83277. radius: number;
  83278. /**
  83279. * The height of the emission cylinder.
  83280. */
  83281. height: number;
  83282. /**
  83283. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83284. */
  83285. radiusRange: number;
  83286. /**
  83287. * How much to randomize the particle direction [0-1].
  83288. */
  83289. directionRandomizer: number;
  83290. /**
  83291. * Creates a new instance CylinderParticleEmitter
  83292. * @param radius the radius of the emission cylinder (1 by default)
  83293. * @param height the height of the emission cylinder (1 by default)
  83294. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83295. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83296. */
  83297. constructor(
  83298. /**
  83299. * The radius of the emission cylinder.
  83300. */
  83301. radius?: number,
  83302. /**
  83303. * The height of the emission cylinder.
  83304. */
  83305. height?: number,
  83306. /**
  83307. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83308. */
  83309. radiusRange?: number,
  83310. /**
  83311. * How much to randomize the particle direction [0-1].
  83312. */
  83313. directionRandomizer?: number);
  83314. /**
  83315. * Called by the particle System when the direction is computed for the created particle.
  83316. * @param worldMatrix is the world matrix of the particle system
  83317. * @param directionToUpdate is the direction vector to update with the result
  83318. * @param particle is the particle we are computed the direction for
  83319. */
  83320. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83321. /**
  83322. * Called by the particle System when the position is computed for the created particle.
  83323. * @param worldMatrix is the world matrix of the particle system
  83324. * @param positionToUpdate is the position vector to update with the result
  83325. * @param particle is the particle we are computed the position for
  83326. */
  83327. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83328. /**
  83329. * Clones the current emitter and returns a copy of it
  83330. * @returns the new emitter
  83331. */
  83332. clone(): CylinderParticleEmitter;
  83333. /**
  83334. * Called by the GPUParticleSystem to setup the update shader
  83335. * @param effect defines the update shader
  83336. */
  83337. applyToShader(effect: Effect): void;
  83338. /**
  83339. * Returns a string to use to update the GPU particles update shader
  83340. * @returns a string containng the defines string
  83341. */
  83342. getEffectDefines(): string;
  83343. /**
  83344. * Returns the string "CylinderParticleEmitter"
  83345. * @returns a string containing the class name
  83346. */
  83347. getClassName(): string;
  83348. /**
  83349. * Serializes the particle system to a JSON object.
  83350. * @returns the JSON object
  83351. */
  83352. serialize(): any;
  83353. /**
  83354. * Parse properties from a JSON object
  83355. * @param serializationObject defines the JSON object
  83356. */
  83357. parse(serializationObject: any): void;
  83358. }
  83359. /**
  83360. * Particle emitter emitting particles from the inside of a cylinder.
  83361. * It emits the particles randomly between two vectors.
  83362. */
  83363. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83364. /**
  83365. * The min limit of the emission direction.
  83366. */
  83367. direction1: Vector3;
  83368. /**
  83369. * The max limit of the emission direction.
  83370. */
  83371. direction2: Vector3;
  83372. /**
  83373. * Creates a new instance CylinderDirectedParticleEmitter
  83374. * @param radius the radius of the emission cylinder (1 by default)
  83375. * @param height the height of the emission cylinder (1 by default)
  83376. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83377. * @param direction1 the min limit of the emission direction (up vector by default)
  83378. * @param direction2 the max limit of the emission direction (up vector by default)
  83379. */
  83380. constructor(radius?: number, height?: number, radiusRange?: number,
  83381. /**
  83382. * The min limit of the emission direction.
  83383. */
  83384. direction1?: Vector3,
  83385. /**
  83386. * The max limit of the emission direction.
  83387. */
  83388. direction2?: Vector3);
  83389. /**
  83390. * Called by the particle System when the direction is computed for the created particle.
  83391. * @param worldMatrix is the world matrix of the particle system
  83392. * @param directionToUpdate is the direction vector to update with the result
  83393. * @param particle is the particle we are computed the direction for
  83394. */
  83395. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83396. /**
  83397. * Clones the current emitter and returns a copy of it
  83398. * @returns the new emitter
  83399. */
  83400. clone(): CylinderDirectedParticleEmitter;
  83401. /**
  83402. * Called by the GPUParticleSystem to setup the update shader
  83403. * @param effect defines the update shader
  83404. */
  83405. applyToShader(effect: Effect): void;
  83406. /**
  83407. * Returns a string to use to update the GPU particles update shader
  83408. * @returns a string containng the defines string
  83409. */
  83410. getEffectDefines(): string;
  83411. /**
  83412. * Returns the string "CylinderDirectedParticleEmitter"
  83413. * @returns a string containing the class name
  83414. */
  83415. getClassName(): string;
  83416. /**
  83417. * Serializes the particle system to a JSON object.
  83418. * @returns the JSON object
  83419. */
  83420. serialize(): any;
  83421. /**
  83422. * Parse properties from a JSON object
  83423. * @param serializationObject defines the JSON object
  83424. */
  83425. parse(serializationObject: any): void;
  83426. }
  83427. }
  83428. declare module BABYLON {
  83429. /**
  83430. * Particle emitter emitting particles from the inside of a hemisphere.
  83431. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83432. */
  83433. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83434. /**
  83435. * The radius of the emission hemisphere.
  83436. */
  83437. radius: number;
  83438. /**
  83439. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83440. */
  83441. radiusRange: number;
  83442. /**
  83443. * How much to randomize the particle direction [0-1].
  83444. */
  83445. directionRandomizer: number;
  83446. /**
  83447. * Creates a new instance HemisphericParticleEmitter
  83448. * @param radius the radius of the emission hemisphere (1 by default)
  83449. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83450. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83451. */
  83452. constructor(
  83453. /**
  83454. * The radius of the emission hemisphere.
  83455. */
  83456. radius?: number,
  83457. /**
  83458. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83459. */
  83460. radiusRange?: number,
  83461. /**
  83462. * How much to randomize the particle direction [0-1].
  83463. */
  83464. directionRandomizer?: number);
  83465. /**
  83466. * Called by the particle System when the direction is computed for the created particle.
  83467. * @param worldMatrix is the world matrix of the particle system
  83468. * @param directionToUpdate is the direction vector to update with the result
  83469. * @param particle is the particle we are computed the direction for
  83470. */
  83471. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83472. /**
  83473. * Called by the particle System when the position is computed for the created particle.
  83474. * @param worldMatrix is the world matrix of the particle system
  83475. * @param positionToUpdate is the position vector to update with the result
  83476. * @param particle is the particle we are computed the position for
  83477. */
  83478. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83479. /**
  83480. * Clones the current emitter and returns a copy of it
  83481. * @returns the new emitter
  83482. */
  83483. clone(): HemisphericParticleEmitter;
  83484. /**
  83485. * Called by the GPUParticleSystem to setup the update shader
  83486. * @param effect defines the update shader
  83487. */
  83488. applyToShader(effect: Effect): void;
  83489. /**
  83490. * Returns a string to use to update the GPU particles update shader
  83491. * @returns a string containng the defines string
  83492. */
  83493. getEffectDefines(): string;
  83494. /**
  83495. * Returns the string "HemisphericParticleEmitter"
  83496. * @returns a string containing the class name
  83497. */
  83498. getClassName(): string;
  83499. /**
  83500. * Serializes the particle system to a JSON object.
  83501. * @returns the JSON object
  83502. */
  83503. serialize(): any;
  83504. /**
  83505. * Parse properties from a JSON object
  83506. * @param serializationObject defines the JSON object
  83507. */
  83508. parse(serializationObject: any): void;
  83509. }
  83510. }
  83511. declare module BABYLON {
  83512. /**
  83513. * Particle emitter emitting particles from a point.
  83514. * It emits the particles randomly between 2 given directions.
  83515. */
  83516. export class PointParticleEmitter implements IParticleEmitterType {
  83517. /**
  83518. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83519. */
  83520. direction1: Vector3;
  83521. /**
  83522. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83523. */
  83524. direction2: Vector3;
  83525. /**
  83526. * Creates a new instance PointParticleEmitter
  83527. */
  83528. constructor();
  83529. /**
  83530. * Called by the particle System when the direction is computed for the created particle.
  83531. * @param worldMatrix is the world matrix of the particle system
  83532. * @param directionToUpdate is the direction vector to update with the result
  83533. * @param particle is the particle we are computed the direction for
  83534. */
  83535. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83536. /**
  83537. * Called by the particle System when the position is computed for the created particle.
  83538. * @param worldMatrix is the world matrix of the particle system
  83539. * @param positionToUpdate is the position vector to update with the result
  83540. * @param particle is the particle we are computed the position for
  83541. */
  83542. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83543. /**
  83544. * Clones the current emitter and returns a copy of it
  83545. * @returns the new emitter
  83546. */
  83547. clone(): PointParticleEmitter;
  83548. /**
  83549. * Called by the GPUParticleSystem to setup the update shader
  83550. * @param effect defines the update shader
  83551. */
  83552. applyToShader(effect: Effect): void;
  83553. /**
  83554. * Returns a string to use to update the GPU particles update shader
  83555. * @returns a string containng the defines string
  83556. */
  83557. getEffectDefines(): string;
  83558. /**
  83559. * Returns the string "PointParticleEmitter"
  83560. * @returns a string containing the class name
  83561. */
  83562. getClassName(): string;
  83563. /**
  83564. * Serializes the particle system to a JSON object.
  83565. * @returns the JSON object
  83566. */
  83567. serialize(): any;
  83568. /**
  83569. * Parse properties from a JSON object
  83570. * @param serializationObject defines the JSON object
  83571. */
  83572. parse(serializationObject: any): void;
  83573. }
  83574. }
  83575. declare module BABYLON {
  83576. /**
  83577. * Particle emitter emitting particles from the inside of a sphere.
  83578. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83579. */
  83580. export class SphereParticleEmitter implements IParticleEmitterType {
  83581. /**
  83582. * The radius of the emission sphere.
  83583. */
  83584. radius: number;
  83585. /**
  83586. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83587. */
  83588. radiusRange: number;
  83589. /**
  83590. * How much to randomize the particle direction [0-1].
  83591. */
  83592. directionRandomizer: number;
  83593. /**
  83594. * Creates a new instance SphereParticleEmitter
  83595. * @param radius the radius of the emission sphere (1 by default)
  83596. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83597. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83598. */
  83599. constructor(
  83600. /**
  83601. * The radius of the emission sphere.
  83602. */
  83603. radius?: number,
  83604. /**
  83605. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83606. */
  83607. radiusRange?: number,
  83608. /**
  83609. * How much to randomize the particle direction [0-1].
  83610. */
  83611. directionRandomizer?: number);
  83612. /**
  83613. * Called by the particle System when the direction is computed for the created particle.
  83614. * @param worldMatrix is the world matrix of the particle system
  83615. * @param directionToUpdate is the direction vector to update with the result
  83616. * @param particle is the particle we are computed the direction for
  83617. */
  83618. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83619. /**
  83620. * Called by the particle System when the position is computed for the created particle.
  83621. * @param worldMatrix is the world matrix of the particle system
  83622. * @param positionToUpdate is the position vector to update with the result
  83623. * @param particle is the particle we are computed the position for
  83624. */
  83625. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83626. /**
  83627. * Clones the current emitter and returns a copy of it
  83628. * @returns the new emitter
  83629. */
  83630. clone(): SphereParticleEmitter;
  83631. /**
  83632. * Called by the GPUParticleSystem to setup the update shader
  83633. * @param effect defines the update shader
  83634. */
  83635. applyToShader(effect: Effect): void;
  83636. /**
  83637. * Returns a string to use to update the GPU particles update shader
  83638. * @returns a string containng the defines string
  83639. */
  83640. getEffectDefines(): string;
  83641. /**
  83642. * Returns the string "SphereParticleEmitter"
  83643. * @returns a string containing the class name
  83644. */
  83645. getClassName(): string;
  83646. /**
  83647. * Serializes the particle system to a JSON object.
  83648. * @returns the JSON object
  83649. */
  83650. serialize(): any;
  83651. /**
  83652. * Parse properties from a JSON object
  83653. * @param serializationObject defines the JSON object
  83654. */
  83655. parse(serializationObject: any): void;
  83656. }
  83657. /**
  83658. * Particle emitter emitting particles from the inside of a sphere.
  83659. * It emits the particles randomly between two vectors.
  83660. */
  83661. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83662. /**
  83663. * The min limit of the emission direction.
  83664. */
  83665. direction1: Vector3;
  83666. /**
  83667. * The max limit of the emission direction.
  83668. */
  83669. direction2: Vector3;
  83670. /**
  83671. * Creates a new instance SphereDirectedParticleEmitter
  83672. * @param radius the radius of the emission sphere (1 by default)
  83673. * @param direction1 the min limit of the emission direction (up vector by default)
  83674. * @param direction2 the max limit of the emission direction (up vector by default)
  83675. */
  83676. constructor(radius?: number,
  83677. /**
  83678. * The min limit of the emission direction.
  83679. */
  83680. direction1?: Vector3,
  83681. /**
  83682. * The max limit of the emission direction.
  83683. */
  83684. direction2?: Vector3);
  83685. /**
  83686. * Called by the particle System when the direction is computed for the created particle.
  83687. * @param worldMatrix is the world matrix of the particle system
  83688. * @param directionToUpdate is the direction vector to update with the result
  83689. * @param particle is the particle we are computed the direction for
  83690. */
  83691. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83692. /**
  83693. * Clones the current emitter and returns a copy of it
  83694. * @returns the new emitter
  83695. */
  83696. clone(): SphereDirectedParticleEmitter;
  83697. /**
  83698. * Called by the GPUParticleSystem to setup the update shader
  83699. * @param effect defines the update shader
  83700. */
  83701. applyToShader(effect: Effect): void;
  83702. /**
  83703. * Returns a string to use to update the GPU particles update shader
  83704. * @returns a string containng the defines string
  83705. */
  83706. getEffectDefines(): string;
  83707. /**
  83708. * Returns the string "SphereDirectedParticleEmitter"
  83709. * @returns a string containing the class name
  83710. */
  83711. getClassName(): string;
  83712. /**
  83713. * Serializes the particle system to a JSON object.
  83714. * @returns the JSON object
  83715. */
  83716. serialize(): any;
  83717. /**
  83718. * Parse properties from a JSON object
  83719. * @param serializationObject defines the JSON object
  83720. */
  83721. parse(serializationObject: any): void;
  83722. }
  83723. }
  83724. declare module BABYLON {
  83725. /**
  83726. * Interface representing a particle system in Babylon.js.
  83727. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83728. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83729. */
  83730. export interface IParticleSystem {
  83731. /**
  83732. * List of animations used by the particle system.
  83733. */
  83734. animations: Animation[];
  83735. /**
  83736. * The id of the Particle system.
  83737. */
  83738. id: string;
  83739. /**
  83740. * The name of the Particle system.
  83741. */
  83742. name: string;
  83743. /**
  83744. * The emitter represents the Mesh or position we are attaching the particle system to.
  83745. */
  83746. emitter: Nullable<AbstractMesh | Vector3>;
  83747. /**
  83748. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83749. */
  83750. isBillboardBased: boolean;
  83751. /**
  83752. * The rendering group used by the Particle system to chose when to render.
  83753. */
  83754. renderingGroupId: number;
  83755. /**
  83756. * The layer mask we are rendering the particles through.
  83757. */
  83758. layerMask: number;
  83759. /**
  83760. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83761. */
  83762. updateSpeed: number;
  83763. /**
  83764. * The amount of time the particle system is running (depends of the overall update speed).
  83765. */
  83766. targetStopDuration: number;
  83767. /**
  83768. * The texture used to render each particle. (this can be a spritesheet)
  83769. */
  83770. particleTexture: Nullable<Texture>;
  83771. /**
  83772. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83773. */
  83774. blendMode: number;
  83775. /**
  83776. * Minimum life time of emitting particles.
  83777. */
  83778. minLifeTime: number;
  83779. /**
  83780. * Maximum life time of emitting particles.
  83781. */
  83782. maxLifeTime: number;
  83783. /**
  83784. * Minimum Size of emitting particles.
  83785. */
  83786. minSize: number;
  83787. /**
  83788. * Maximum Size of emitting particles.
  83789. */
  83790. maxSize: number;
  83791. /**
  83792. * Minimum scale of emitting particles on X axis.
  83793. */
  83794. minScaleX: number;
  83795. /**
  83796. * Maximum scale of emitting particles on X axis.
  83797. */
  83798. maxScaleX: number;
  83799. /**
  83800. * Minimum scale of emitting particles on Y axis.
  83801. */
  83802. minScaleY: number;
  83803. /**
  83804. * Maximum scale of emitting particles on Y axis.
  83805. */
  83806. maxScaleY: number;
  83807. /**
  83808. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83809. */
  83810. color1: Color4;
  83811. /**
  83812. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83813. */
  83814. color2: Color4;
  83815. /**
  83816. * Color the particle will have at the end of its lifetime.
  83817. */
  83818. colorDead: Color4;
  83819. /**
  83820. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83821. */
  83822. emitRate: number;
  83823. /**
  83824. * You can use gravity if you want to give an orientation to your particles.
  83825. */
  83826. gravity: Vector3;
  83827. /**
  83828. * Minimum power of emitting particles.
  83829. */
  83830. minEmitPower: number;
  83831. /**
  83832. * Maximum power of emitting particles.
  83833. */
  83834. maxEmitPower: number;
  83835. /**
  83836. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83837. */
  83838. minAngularSpeed: number;
  83839. /**
  83840. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83841. */
  83842. maxAngularSpeed: number;
  83843. /**
  83844. * Gets or sets the minimal initial rotation in radians.
  83845. */
  83846. minInitialRotation: number;
  83847. /**
  83848. * Gets or sets the maximal initial rotation in radians.
  83849. */
  83850. maxInitialRotation: number;
  83851. /**
  83852. * The particle emitter type defines the emitter used by the particle system.
  83853. * It can be for example box, sphere, or cone...
  83854. */
  83855. particleEmitterType: Nullable<IParticleEmitterType>;
  83856. /**
  83857. * Defines the delay in milliseconds before starting the system (0 by default)
  83858. */
  83859. startDelay: number;
  83860. /**
  83861. * 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
  83862. */
  83863. preWarmCycles: number;
  83864. /**
  83865. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83866. */
  83867. preWarmStepOffset: number;
  83868. /**
  83869. * 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)
  83870. */
  83871. spriteCellChangeSpeed: number;
  83872. /**
  83873. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83874. */
  83875. startSpriteCellID: number;
  83876. /**
  83877. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83878. */
  83879. endSpriteCellID: number;
  83880. /**
  83881. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83882. */
  83883. spriteCellWidth: number;
  83884. /**
  83885. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83886. */
  83887. spriteCellHeight: number;
  83888. /**
  83889. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83890. */
  83891. spriteRandomStartCell: boolean;
  83892. /**
  83893. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83894. */
  83895. isAnimationSheetEnabled: boolean;
  83896. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83897. translationPivot: Vector2;
  83898. /**
  83899. * Gets or sets a texture used to add random noise to particle positions
  83900. */
  83901. noiseTexture: Nullable<BaseTexture>;
  83902. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83903. noiseStrength: Vector3;
  83904. /**
  83905. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83906. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83907. */
  83908. billboardMode: number;
  83909. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83910. limitVelocityDamping: number;
  83911. /**
  83912. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83913. */
  83914. beginAnimationOnStart: boolean;
  83915. /**
  83916. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83917. */
  83918. beginAnimationFrom: number;
  83919. /**
  83920. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83921. */
  83922. beginAnimationTo: number;
  83923. /**
  83924. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83925. */
  83926. beginAnimationLoop: boolean;
  83927. /**
  83928. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83929. */
  83930. disposeOnStop: boolean;
  83931. /**
  83932. * Gets the maximum number of particles active at the same time.
  83933. * @returns The max number of active particles.
  83934. */
  83935. getCapacity(): number;
  83936. /**
  83937. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83938. * @returns True if it has been started, otherwise false.
  83939. */
  83940. isStarted(): boolean;
  83941. /**
  83942. * Animates the particle system for this frame.
  83943. */
  83944. animate(): void;
  83945. /**
  83946. * Renders the particle system in its current state.
  83947. * @returns the current number of particles
  83948. */
  83949. render(): number;
  83950. /**
  83951. * Dispose the particle system and frees its associated resources.
  83952. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83953. */
  83954. dispose(disposeTexture?: boolean): void;
  83955. /**
  83956. * Clones the particle system.
  83957. * @param name The name of the cloned object
  83958. * @param newEmitter The new emitter to use
  83959. * @returns the cloned particle system
  83960. */
  83961. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83962. /**
  83963. * Serializes the particle system to a JSON object.
  83964. * @returns the JSON object
  83965. */
  83966. serialize(): any;
  83967. /**
  83968. * Rebuild the particle system
  83969. */
  83970. rebuild(): void;
  83971. /**
  83972. * Starts the particle system and begins to emit
  83973. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83974. */
  83975. start(delay?: number): void;
  83976. /**
  83977. * Stops the particle system.
  83978. */
  83979. stop(): void;
  83980. /**
  83981. * Remove all active particles
  83982. */
  83983. reset(): void;
  83984. /**
  83985. * Is this system ready to be used/rendered
  83986. * @return true if the system is ready
  83987. */
  83988. isReady(): boolean;
  83989. /**
  83990. * Adds a new color gradient
  83991. * @param gradient defines the gradient to use (between 0 and 1)
  83992. * @param color1 defines the color to affect to the specified gradient
  83993. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83994. * @returns the current particle system
  83995. */
  83996. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83997. /**
  83998. * Remove a specific color gradient
  83999. * @param gradient defines the gradient to remove
  84000. * @returns the current particle system
  84001. */
  84002. removeColorGradient(gradient: number): IParticleSystem;
  84003. /**
  84004. * Adds a new size gradient
  84005. * @param gradient defines the gradient to use (between 0 and 1)
  84006. * @param factor defines the size factor to affect to the specified gradient
  84007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84008. * @returns the current particle system
  84009. */
  84010. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84011. /**
  84012. * Remove a specific size gradient
  84013. * @param gradient defines the gradient to remove
  84014. * @returns the current particle system
  84015. */
  84016. removeSizeGradient(gradient: number): IParticleSystem;
  84017. /**
  84018. * Gets the current list of color gradients.
  84019. * You must use addColorGradient and removeColorGradient to udpate this list
  84020. * @returns the list of color gradients
  84021. */
  84022. getColorGradients(): Nullable<Array<ColorGradient>>;
  84023. /**
  84024. * Gets the current list of size gradients.
  84025. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84026. * @returns the list of size gradients
  84027. */
  84028. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84029. /**
  84030. * Gets the current list of angular speed gradients.
  84031. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84032. * @returns the list of angular speed gradients
  84033. */
  84034. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84035. /**
  84036. * Adds a new angular speed gradient
  84037. * @param gradient defines the gradient to use (between 0 and 1)
  84038. * @param factor defines the angular speed to affect to the specified gradient
  84039. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84040. * @returns the current particle system
  84041. */
  84042. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84043. /**
  84044. * Remove a specific angular speed gradient
  84045. * @param gradient defines the gradient to remove
  84046. * @returns the current particle system
  84047. */
  84048. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84049. /**
  84050. * Gets the current list of velocity gradients.
  84051. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84052. * @returns the list of velocity gradients
  84053. */
  84054. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84055. /**
  84056. * Adds a new velocity gradient
  84057. * @param gradient defines the gradient to use (between 0 and 1)
  84058. * @param factor defines the velocity to affect to the specified gradient
  84059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84060. * @returns the current particle system
  84061. */
  84062. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84063. /**
  84064. * Remove a specific velocity gradient
  84065. * @param gradient defines the gradient to remove
  84066. * @returns the current particle system
  84067. */
  84068. removeVelocityGradient(gradient: number): IParticleSystem;
  84069. /**
  84070. * Gets the current list of limit velocity gradients.
  84071. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84072. * @returns the list of limit velocity gradients
  84073. */
  84074. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84075. /**
  84076. * Adds a new limit velocity gradient
  84077. * @param gradient defines the gradient to use (between 0 and 1)
  84078. * @param factor defines the limit velocity to affect to the specified gradient
  84079. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84080. * @returns the current particle system
  84081. */
  84082. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84083. /**
  84084. * Remove a specific limit velocity gradient
  84085. * @param gradient defines the gradient to remove
  84086. * @returns the current particle system
  84087. */
  84088. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84089. /**
  84090. * Adds a new drag gradient
  84091. * @param gradient defines the gradient to use (between 0 and 1)
  84092. * @param factor defines the drag to affect to the specified gradient
  84093. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84094. * @returns the current particle system
  84095. */
  84096. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84097. /**
  84098. * Remove a specific drag gradient
  84099. * @param gradient defines the gradient to remove
  84100. * @returns the current particle system
  84101. */
  84102. removeDragGradient(gradient: number): IParticleSystem;
  84103. /**
  84104. * Gets the current list of drag gradients.
  84105. * You must use addDragGradient and removeDragGradient to udpate this list
  84106. * @returns the list of drag gradients
  84107. */
  84108. getDragGradients(): Nullable<Array<FactorGradient>>;
  84109. /**
  84110. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84111. * @param gradient defines the gradient to use (between 0 and 1)
  84112. * @param factor defines the emit rate to affect to the specified gradient
  84113. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84114. * @returns the current particle system
  84115. */
  84116. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84117. /**
  84118. * Remove a specific emit rate gradient
  84119. * @param gradient defines the gradient to remove
  84120. * @returns the current particle system
  84121. */
  84122. removeEmitRateGradient(gradient: number): IParticleSystem;
  84123. /**
  84124. * Gets the current list of emit rate gradients.
  84125. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84126. * @returns the list of emit rate gradients
  84127. */
  84128. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84129. /**
  84130. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84131. * @param gradient defines the gradient to use (between 0 and 1)
  84132. * @param factor defines the start size to affect to the specified gradient
  84133. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84134. * @returns the current particle system
  84135. */
  84136. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84137. /**
  84138. * Remove a specific start size gradient
  84139. * @param gradient defines the gradient to remove
  84140. * @returns the current particle system
  84141. */
  84142. removeStartSizeGradient(gradient: number): IParticleSystem;
  84143. /**
  84144. * Gets the current list of start size gradients.
  84145. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84146. * @returns the list of start size gradients
  84147. */
  84148. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84149. /**
  84150. * Adds a new life time gradient
  84151. * @param gradient defines the gradient to use (between 0 and 1)
  84152. * @param factor defines the life time factor to affect to the specified gradient
  84153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84154. * @returns the current particle system
  84155. */
  84156. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84157. /**
  84158. * Remove a specific life time gradient
  84159. * @param gradient defines the gradient to remove
  84160. * @returns the current particle system
  84161. */
  84162. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84163. /**
  84164. * Gets the current list of life time gradients.
  84165. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84166. * @returns the list of life time gradients
  84167. */
  84168. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84169. /**
  84170. * Gets the current list of color gradients.
  84171. * You must use addColorGradient and removeColorGradient to udpate this list
  84172. * @returns the list of color gradients
  84173. */
  84174. getColorGradients(): Nullable<Array<ColorGradient>>;
  84175. /**
  84176. * Adds a new ramp gradient used to remap particle colors
  84177. * @param gradient defines the gradient to use (between 0 and 1)
  84178. * @param color defines the color to affect to the specified gradient
  84179. * @returns the current particle system
  84180. */
  84181. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84182. /**
  84183. * Gets the current list of ramp gradients.
  84184. * You must use addRampGradient and removeRampGradient to udpate this list
  84185. * @returns the list of ramp gradients
  84186. */
  84187. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84188. /** Gets or sets a boolean indicating that ramp gradients must be used
  84189. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84190. */
  84191. useRampGradients: boolean;
  84192. /**
  84193. * Adds a new color remap gradient
  84194. * @param gradient defines the gradient to use (between 0 and 1)
  84195. * @param min defines the color remap minimal range
  84196. * @param max defines the color remap maximal range
  84197. * @returns the current particle system
  84198. */
  84199. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84200. /**
  84201. * Gets the current list of color remap gradients.
  84202. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84203. * @returns the list of color remap gradients
  84204. */
  84205. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84206. /**
  84207. * Adds a new alpha remap gradient
  84208. * @param gradient defines the gradient to use (between 0 and 1)
  84209. * @param min defines the alpha remap minimal range
  84210. * @param max defines the alpha remap maximal range
  84211. * @returns the current particle system
  84212. */
  84213. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84214. /**
  84215. * Gets the current list of alpha remap gradients.
  84216. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84217. * @returns the list of alpha remap gradients
  84218. */
  84219. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84220. /**
  84221. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84222. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84223. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84224. * @returns the emitter
  84225. */
  84226. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84227. /**
  84228. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84229. * @param radius The radius of the hemisphere to emit from
  84230. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84231. * @returns the emitter
  84232. */
  84233. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84234. /**
  84235. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84236. * @param radius The radius of the sphere to emit from
  84237. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84238. * @returns the emitter
  84239. */
  84240. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84241. /**
  84242. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84243. * @param radius The radius of the sphere to emit from
  84244. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84245. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84246. * @returns the emitter
  84247. */
  84248. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84249. /**
  84250. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84251. * @param radius The radius of the emission cylinder
  84252. * @param height The height of the emission cylinder
  84253. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84254. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84255. * @returns the emitter
  84256. */
  84257. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84258. /**
  84259. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84260. * @param radius The radius of the cylinder to emit from
  84261. * @param height The height of the emission cylinder
  84262. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84263. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84264. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84265. * @returns the emitter
  84266. */
  84267. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84268. /**
  84269. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84270. * @param radius The radius of the cone to emit from
  84271. * @param angle The base angle of the cone
  84272. * @returns the emitter
  84273. */
  84274. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84275. /**
  84276. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84277. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84278. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84279. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84280. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84281. * @returns the emitter
  84282. */
  84283. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84284. /**
  84285. * Get hosting scene
  84286. * @returns the scene
  84287. */
  84288. getScene(): Scene;
  84289. }
  84290. }
  84291. declare module BABYLON {
  84292. /** @hidden */
  84293. export var linePixelShader: {
  84294. name: string;
  84295. shader: string;
  84296. };
  84297. }
  84298. declare module BABYLON {
  84299. /** @hidden */
  84300. export var lineVertexShader: {
  84301. name: string;
  84302. shader: string;
  84303. };
  84304. }
  84305. declare module BABYLON {
  84306. interface AbstractMesh {
  84307. /**
  84308. * Gets the edgesRenderer associated with the mesh
  84309. */
  84310. edgesRenderer: Nullable<EdgesRenderer>;
  84311. }
  84312. interface LinesMesh {
  84313. /**
  84314. * Enables the edge rendering mode on the mesh.
  84315. * This mode makes the mesh edges visible
  84316. * @param epsilon defines the maximal distance between two angles to detect a face
  84317. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84318. * @returns the currentAbstractMesh
  84319. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84320. */
  84321. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84322. }
  84323. interface InstancedLinesMesh {
  84324. /**
  84325. * Enables the edge rendering mode on the mesh.
  84326. * This mode makes the mesh edges visible
  84327. * @param epsilon defines the maximal distance between two angles to detect a face
  84328. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84329. * @returns the current InstancedLinesMesh
  84330. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84331. */
  84332. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84333. }
  84334. /**
  84335. * Defines the minimum contract an Edges renderer should follow.
  84336. */
  84337. export interface IEdgesRenderer extends IDisposable {
  84338. /**
  84339. * Gets or sets a boolean indicating if the edgesRenderer is active
  84340. */
  84341. isEnabled: boolean;
  84342. /**
  84343. * Renders the edges of the attached mesh,
  84344. */
  84345. render(): void;
  84346. /**
  84347. * Checks wether or not the edges renderer is ready to render.
  84348. * @return true if ready, otherwise false.
  84349. */
  84350. isReady(): boolean;
  84351. }
  84352. /**
  84353. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  84354. */
  84355. export class EdgesRenderer implements IEdgesRenderer {
  84356. /**
  84357. * Define the size of the edges with an orthographic camera
  84358. */
  84359. edgesWidthScalerForOrthographic: number;
  84360. /**
  84361. * Define the size of the edges with a perspective camera
  84362. */
  84363. edgesWidthScalerForPerspective: number;
  84364. protected _source: AbstractMesh;
  84365. protected _linesPositions: number[];
  84366. protected _linesNormals: number[];
  84367. protected _linesIndices: number[];
  84368. protected _epsilon: number;
  84369. protected _indicesCount: number;
  84370. protected _lineShader: ShaderMaterial;
  84371. protected _ib: DataBuffer;
  84372. protected _buffers: {
  84373. [key: string]: Nullable<VertexBuffer>;
  84374. };
  84375. protected _checkVerticesInsteadOfIndices: boolean;
  84376. private _meshRebuildObserver;
  84377. private _meshDisposeObserver;
  84378. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84379. isEnabled: boolean;
  84380. /**
  84381. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84382. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84383. * @param source Mesh used to create edges
  84384. * @param epsilon sum of angles in adjacency to check for edge
  84385. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84386. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84387. */
  84388. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84389. protected _prepareRessources(): void;
  84390. /** @hidden */
  84391. _rebuild(): void;
  84392. /**
  84393. * Releases the required resources for the edges renderer
  84394. */
  84395. dispose(): void;
  84396. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84397. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84398. /**
  84399. * Checks if the pair of p0 and p1 is en edge
  84400. * @param faceIndex
  84401. * @param edge
  84402. * @param faceNormals
  84403. * @param p0
  84404. * @param p1
  84405. * @private
  84406. */
  84407. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84408. /**
  84409. * push line into the position, normal and index buffer
  84410. * @protected
  84411. */
  84412. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84413. /**
  84414. * Generates lines edges from adjacencjes
  84415. * @private
  84416. */
  84417. _generateEdgesLines(): void;
  84418. /**
  84419. * Checks wether or not the edges renderer is ready to render.
  84420. * @return true if ready, otherwise false.
  84421. */
  84422. isReady(): boolean;
  84423. /**
  84424. * Renders the edges of the attached mesh,
  84425. */
  84426. render(): void;
  84427. }
  84428. /**
  84429. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84430. */
  84431. export class LineEdgesRenderer extends EdgesRenderer {
  84432. /**
  84433. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84434. * @param source LineMesh used to generate edges
  84435. * @param epsilon not important (specified angle for edge detection)
  84436. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84437. */
  84438. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84439. /**
  84440. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84441. */
  84442. _generateEdgesLines(): void;
  84443. }
  84444. }
  84445. declare module BABYLON {
  84446. /**
  84447. * This represents the object necessary to create a rendering group.
  84448. * This is exclusively used and created by the rendering manager.
  84449. * To modify the behavior, you use the available helpers in your scene or meshes.
  84450. * @hidden
  84451. */
  84452. export class RenderingGroup {
  84453. index: number;
  84454. private static _zeroVector;
  84455. private _scene;
  84456. private _opaqueSubMeshes;
  84457. private _transparentSubMeshes;
  84458. private _alphaTestSubMeshes;
  84459. private _depthOnlySubMeshes;
  84460. private _particleSystems;
  84461. private _spriteManagers;
  84462. private _opaqueSortCompareFn;
  84463. private _alphaTestSortCompareFn;
  84464. private _transparentSortCompareFn;
  84465. private _renderOpaque;
  84466. private _renderAlphaTest;
  84467. private _renderTransparent;
  84468. /** @hidden */
  84469. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84470. onBeforeTransparentRendering: () => void;
  84471. /**
  84472. * Set the opaque sort comparison function.
  84473. * If null the sub meshes will be render in the order they were created
  84474. */
  84475. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84476. /**
  84477. * Set the alpha test sort comparison function.
  84478. * If null the sub meshes will be render in the order they were created
  84479. */
  84480. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84481. /**
  84482. * Set the transparent sort comparison function.
  84483. * If null the sub meshes will be render in the order they were created
  84484. */
  84485. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84486. /**
  84487. * Creates a new rendering group.
  84488. * @param index The rendering group index
  84489. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84490. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84491. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84492. */
  84493. 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>);
  84494. /**
  84495. * Render all the sub meshes contained in the group.
  84496. * @param customRenderFunction Used to override the default render behaviour of the group.
  84497. * @returns true if rendered some submeshes.
  84498. */
  84499. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84500. /**
  84501. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84502. * @param subMeshes The submeshes to render
  84503. */
  84504. private renderOpaqueSorted;
  84505. /**
  84506. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84507. * @param subMeshes The submeshes to render
  84508. */
  84509. private renderAlphaTestSorted;
  84510. /**
  84511. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84512. * @param subMeshes The submeshes to render
  84513. */
  84514. private renderTransparentSorted;
  84515. /**
  84516. * Renders the submeshes in a specified order.
  84517. * @param subMeshes The submeshes to sort before render
  84518. * @param sortCompareFn The comparison function use to sort
  84519. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84520. * @param transparent Specifies to activate blending if true
  84521. */
  84522. private static renderSorted;
  84523. /**
  84524. * Renders the submeshes in the order they were dispatched (no sort applied).
  84525. * @param subMeshes The submeshes to render
  84526. */
  84527. private static renderUnsorted;
  84528. /**
  84529. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84530. * are rendered back to front if in the same alpha index.
  84531. *
  84532. * @param a The first submesh
  84533. * @param b The second submesh
  84534. * @returns The result of the comparison
  84535. */
  84536. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84537. /**
  84538. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84539. * are rendered back to front.
  84540. *
  84541. * @param a The first submesh
  84542. * @param b The second submesh
  84543. * @returns The result of the comparison
  84544. */
  84545. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84546. /**
  84547. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84548. * are rendered front to back (prevent overdraw).
  84549. *
  84550. * @param a The first submesh
  84551. * @param b The second submesh
  84552. * @returns The result of the comparison
  84553. */
  84554. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84555. /**
  84556. * Resets the different lists of submeshes to prepare a new frame.
  84557. */
  84558. prepare(): void;
  84559. dispose(): void;
  84560. /**
  84561. * Inserts the submesh in its correct queue depending on its material.
  84562. * @param subMesh The submesh to dispatch
  84563. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84564. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84565. */
  84566. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84567. dispatchSprites(spriteManager: ISpriteManager): void;
  84568. dispatchParticles(particleSystem: IParticleSystem): void;
  84569. private _renderParticles;
  84570. private _renderSprites;
  84571. }
  84572. }
  84573. declare module BABYLON {
  84574. /**
  84575. * Interface describing the different options available in the rendering manager
  84576. * regarding Auto Clear between groups.
  84577. */
  84578. export interface IRenderingManagerAutoClearSetup {
  84579. /**
  84580. * Defines whether or not autoclear is enable.
  84581. */
  84582. autoClear: boolean;
  84583. /**
  84584. * Defines whether or not to autoclear the depth buffer.
  84585. */
  84586. depth: boolean;
  84587. /**
  84588. * Defines whether or not to autoclear the stencil buffer.
  84589. */
  84590. stencil: boolean;
  84591. }
  84592. /**
  84593. * This class is used by the onRenderingGroupObservable
  84594. */
  84595. export class RenderingGroupInfo {
  84596. /**
  84597. * The Scene that being rendered
  84598. */
  84599. scene: Scene;
  84600. /**
  84601. * The camera currently used for the rendering pass
  84602. */
  84603. camera: Nullable<Camera>;
  84604. /**
  84605. * The ID of the renderingGroup being processed
  84606. */
  84607. renderingGroupId: number;
  84608. }
  84609. /**
  84610. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84611. * It is enable to manage the different groups as well as the different necessary sort functions.
  84612. * This should not be used directly aside of the few static configurations
  84613. */
  84614. export class RenderingManager {
  84615. /**
  84616. * The max id used for rendering groups (not included)
  84617. */
  84618. static MAX_RENDERINGGROUPS: number;
  84619. /**
  84620. * The min id used for rendering groups (included)
  84621. */
  84622. static MIN_RENDERINGGROUPS: number;
  84623. /**
  84624. * Used to globally prevent autoclearing scenes.
  84625. */
  84626. static AUTOCLEAR: boolean;
  84627. /**
  84628. * @hidden
  84629. */
  84630. _useSceneAutoClearSetup: boolean;
  84631. private _scene;
  84632. private _renderingGroups;
  84633. private _depthStencilBufferAlreadyCleaned;
  84634. private _autoClearDepthStencil;
  84635. private _customOpaqueSortCompareFn;
  84636. private _customAlphaTestSortCompareFn;
  84637. private _customTransparentSortCompareFn;
  84638. private _renderingGroupInfo;
  84639. /**
  84640. * Instantiates a new rendering group for a particular scene
  84641. * @param scene Defines the scene the groups belongs to
  84642. */
  84643. constructor(scene: Scene);
  84644. private _clearDepthStencilBuffer;
  84645. /**
  84646. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84647. * @hidden
  84648. */
  84649. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84650. /**
  84651. * Resets the different information of the group to prepare a new frame
  84652. * @hidden
  84653. */
  84654. reset(): void;
  84655. /**
  84656. * Dispose and release the group and its associated resources.
  84657. * @hidden
  84658. */
  84659. dispose(): void;
  84660. /**
  84661. * Clear the info related to rendering groups preventing retention points during dispose.
  84662. */
  84663. freeRenderingGroups(): void;
  84664. private _prepareRenderingGroup;
  84665. /**
  84666. * Add a sprite manager to the rendering manager in order to render it this frame.
  84667. * @param spriteManager Define the sprite manager to render
  84668. */
  84669. dispatchSprites(spriteManager: ISpriteManager): void;
  84670. /**
  84671. * Add a particle system to the rendering manager in order to render it this frame.
  84672. * @param particleSystem Define the particle system to render
  84673. */
  84674. dispatchParticles(particleSystem: IParticleSystem): void;
  84675. /**
  84676. * Add a submesh to the manager in order to render it this frame
  84677. * @param subMesh The submesh to dispatch
  84678. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84679. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84680. */
  84681. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84682. /**
  84683. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84684. * This allowed control for front to back rendering or reversly depending of the special needs.
  84685. *
  84686. * @param renderingGroupId The rendering group id corresponding to its index
  84687. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84688. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84689. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84690. */
  84691. 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;
  84692. /**
  84693. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84694. *
  84695. * @param renderingGroupId The rendering group id corresponding to its index
  84696. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84697. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84698. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84699. */
  84700. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84701. /**
  84702. * Gets the current auto clear configuration for one rendering group of the rendering
  84703. * manager.
  84704. * @param index the rendering group index to get the information for
  84705. * @returns The auto clear setup for the requested rendering group
  84706. */
  84707. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84708. }
  84709. }
  84710. declare module BABYLON {
  84711. /**
  84712. * This Helps creating a texture that will be created from a camera in your scene.
  84713. * It is basically a dynamic texture that could be used to create special effects for instance.
  84714. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84715. */
  84716. export class RenderTargetTexture extends Texture {
  84717. isCube: boolean;
  84718. /**
  84719. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84720. */
  84721. static readonly REFRESHRATE_RENDER_ONCE: number;
  84722. /**
  84723. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84724. */
  84725. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84726. /**
  84727. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84728. * the central point of your effect and can save a lot of performances.
  84729. */
  84730. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84731. /**
  84732. * Use this predicate to dynamically define the list of mesh you want to render.
  84733. * If set, the renderList property will be overwritten.
  84734. */
  84735. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84736. private _renderList;
  84737. /**
  84738. * Use this list to define the list of mesh you want to render.
  84739. */
  84740. renderList: Nullable<Array<AbstractMesh>>;
  84741. private _hookArray;
  84742. /**
  84743. * Define if particles should be rendered in your texture.
  84744. */
  84745. renderParticles: boolean;
  84746. /**
  84747. * Define if sprites should be rendered in your texture.
  84748. */
  84749. renderSprites: boolean;
  84750. /**
  84751. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84752. */
  84753. coordinatesMode: number;
  84754. /**
  84755. * Define the camera used to render the texture.
  84756. */
  84757. activeCamera: Nullable<Camera>;
  84758. /**
  84759. * Override the render function of the texture with your own one.
  84760. */
  84761. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84762. /**
  84763. * Define if camera post processes should be use while rendering the texture.
  84764. */
  84765. useCameraPostProcesses: boolean;
  84766. /**
  84767. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84768. */
  84769. ignoreCameraViewport: boolean;
  84770. private _postProcessManager;
  84771. private _postProcesses;
  84772. private _resizeObserver;
  84773. /**
  84774. * An event triggered when the texture is unbind.
  84775. */
  84776. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84777. /**
  84778. * An event triggered when the texture is unbind.
  84779. */
  84780. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84781. private _onAfterUnbindObserver;
  84782. /**
  84783. * Set a after unbind callback in the texture.
  84784. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84785. */
  84786. onAfterUnbind: () => void;
  84787. /**
  84788. * An event triggered before rendering the texture
  84789. */
  84790. onBeforeRenderObservable: Observable<number>;
  84791. private _onBeforeRenderObserver;
  84792. /**
  84793. * Set a before render callback in the texture.
  84794. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84795. */
  84796. onBeforeRender: (faceIndex: number) => void;
  84797. /**
  84798. * An event triggered after rendering the texture
  84799. */
  84800. onAfterRenderObservable: Observable<number>;
  84801. private _onAfterRenderObserver;
  84802. /**
  84803. * Set a after render callback in the texture.
  84804. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84805. */
  84806. onAfterRender: (faceIndex: number) => void;
  84807. /**
  84808. * An event triggered after the texture clear
  84809. */
  84810. onClearObservable: Observable<Engine>;
  84811. private _onClearObserver;
  84812. /**
  84813. * Set a clear callback in the texture.
  84814. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84815. */
  84816. onClear: (Engine: Engine) => void;
  84817. /**
  84818. * Define the clear color of the Render Target if it should be different from the scene.
  84819. */
  84820. clearColor: Color4;
  84821. protected _size: number | {
  84822. width: number;
  84823. height: number;
  84824. };
  84825. protected _initialSizeParameter: number | {
  84826. width: number;
  84827. height: number;
  84828. } | {
  84829. ratio: number;
  84830. };
  84831. protected _sizeRatio: Nullable<number>;
  84832. /** @hidden */
  84833. _generateMipMaps: boolean;
  84834. protected _renderingManager: RenderingManager;
  84835. /** @hidden */
  84836. _waitingRenderList: string[];
  84837. protected _doNotChangeAspectRatio: boolean;
  84838. protected _currentRefreshId: number;
  84839. protected _refreshRate: number;
  84840. protected _textureMatrix: Matrix;
  84841. protected _samples: number;
  84842. protected _renderTargetOptions: RenderTargetCreationOptions;
  84843. /**
  84844. * Gets render target creation options that were used.
  84845. */
  84846. readonly renderTargetOptions: RenderTargetCreationOptions;
  84847. protected _engine: Engine;
  84848. protected _onRatioRescale(): void;
  84849. /**
  84850. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84851. * It must define where the camera used to render the texture is set
  84852. */
  84853. boundingBoxPosition: Vector3;
  84854. private _boundingBoxSize;
  84855. /**
  84856. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84857. * When defined, the cubemap will switch to local mode
  84858. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84859. * @example https://www.babylonjs-playground.com/#RNASML
  84860. */
  84861. boundingBoxSize: Vector3;
  84862. /**
  84863. * In case the RTT has been created with a depth texture, get the associated
  84864. * depth texture.
  84865. * Otherwise, return null.
  84866. */
  84867. depthStencilTexture: Nullable<InternalTexture>;
  84868. /**
  84869. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84870. * or used a shadow, depth texture...
  84871. * @param name The friendly name of the texture
  84872. * @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)
  84873. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84874. * @param generateMipMaps True if mip maps need to be generated after render.
  84875. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84876. * @param type The type of the buffer in the RTT (int, half float, float...)
  84877. * @param isCube True if a cube texture needs to be created
  84878. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84879. * @param generateDepthBuffer True to generate a depth buffer
  84880. * @param generateStencilBuffer True to generate a stencil buffer
  84881. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84882. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84883. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84884. */
  84885. constructor(name: string, size: number | {
  84886. width: number;
  84887. height: number;
  84888. } | {
  84889. ratio: number;
  84890. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84891. /**
  84892. * Creates a depth stencil texture.
  84893. * This is only available in WebGL 2 or with the depth texture extension available.
  84894. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84895. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84896. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84897. */
  84898. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84899. private _processSizeParameter;
  84900. /**
  84901. * Define the number of samples to use in case of MSAA.
  84902. * It defaults to one meaning no MSAA has been enabled.
  84903. */
  84904. samples: number;
  84905. /**
  84906. * Resets the refresh counter of the texture and start bak from scratch.
  84907. * Could be useful to regenerate the texture if it is setup to render only once.
  84908. */
  84909. resetRefreshCounter(): void;
  84910. /**
  84911. * Define the refresh rate of the texture or the rendering frequency.
  84912. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84913. */
  84914. refreshRate: number;
  84915. /**
  84916. * Adds a post process to the render target rendering passes.
  84917. * @param postProcess define the post process to add
  84918. */
  84919. addPostProcess(postProcess: PostProcess): void;
  84920. /**
  84921. * Clear all the post processes attached to the render target
  84922. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84923. */
  84924. clearPostProcesses(dispose?: boolean): void;
  84925. /**
  84926. * Remove one of the post process from the list of attached post processes to the texture
  84927. * @param postProcess define the post process to remove from the list
  84928. */
  84929. removePostProcess(postProcess: PostProcess): void;
  84930. /** @hidden */
  84931. _shouldRender(): boolean;
  84932. /**
  84933. * Gets the actual render size of the texture.
  84934. * @returns the width of the render size
  84935. */
  84936. getRenderSize(): number;
  84937. /**
  84938. * Gets the actual render width of the texture.
  84939. * @returns the width of the render size
  84940. */
  84941. getRenderWidth(): number;
  84942. /**
  84943. * Gets the actual render height of the texture.
  84944. * @returns the height of the render size
  84945. */
  84946. getRenderHeight(): number;
  84947. /**
  84948. * Get if the texture can be rescaled or not.
  84949. */
  84950. readonly canRescale: boolean;
  84951. /**
  84952. * Resize the texture using a ratio.
  84953. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84954. */
  84955. scale(ratio: number): void;
  84956. /**
  84957. * Get the texture reflection matrix used to rotate/transform the reflection.
  84958. * @returns the reflection matrix
  84959. */
  84960. getReflectionTextureMatrix(): Matrix;
  84961. /**
  84962. * Resize the texture to a new desired size.
  84963. * Be carrefull as it will recreate all the data in the new texture.
  84964. * @param size Define the new size. It can be:
  84965. * - a number for squared texture,
  84966. * - an object containing { width: number, height: number }
  84967. * - or an object containing a ratio { ratio: number }
  84968. */
  84969. resize(size: number | {
  84970. width: number;
  84971. height: number;
  84972. } | {
  84973. ratio: number;
  84974. }): void;
  84975. /**
  84976. * Renders all the objects from the render list into the texture.
  84977. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84978. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84979. */
  84980. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84981. private _bestReflectionRenderTargetDimension;
  84982. /**
  84983. * @hidden
  84984. * @param faceIndex face index to bind to if this is a cubetexture
  84985. */
  84986. _bindFrameBuffer(faceIndex?: number): void;
  84987. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84988. private renderToTarget;
  84989. /**
  84990. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84991. * This allowed control for front to back rendering or reversly depending of the special needs.
  84992. *
  84993. * @param renderingGroupId The rendering group id corresponding to its index
  84994. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84995. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84996. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84997. */
  84998. 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;
  84999. /**
  85000. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85001. *
  85002. * @param renderingGroupId The rendering group id corresponding to its index
  85003. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85004. */
  85005. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85006. /**
  85007. * Clones the texture.
  85008. * @returns the cloned texture
  85009. */
  85010. clone(): RenderTargetTexture;
  85011. /**
  85012. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85013. * @returns The JSON representation of the texture
  85014. */
  85015. serialize(): any;
  85016. /**
  85017. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85018. */
  85019. disposeFramebufferObjects(): void;
  85020. /**
  85021. * Dispose the texture and release its associated resources.
  85022. */
  85023. dispose(): void;
  85024. /** @hidden */
  85025. _rebuild(): void;
  85026. /**
  85027. * Clear the info related to rendering groups preventing retention point in material dispose.
  85028. */
  85029. freeRenderingGroups(): void;
  85030. /**
  85031. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85032. * @returns the view count
  85033. */
  85034. getViewCount(): number;
  85035. }
  85036. }
  85037. declare module BABYLON {
  85038. /**
  85039. * Base class for the main features of a material in Babylon.js
  85040. */
  85041. export class Material implements IAnimatable {
  85042. /**
  85043. * Returns the triangle fill mode
  85044. */
  85045. static readonly TriangleFillMode: number;
  85046. /**
  85047. * Returns the wireframe mode
  85048. */
  85049. static readonly WireFrameFillMode: number;
  85050. /**
  85051. * Returns the point fill mode
  85052. */
  85053. static readonly PointFillMode: number;
  85054. /**
  85055. * Returns the point list draw mode
  85056. */
  85057. static readonly PointListDrawMode: number;
  85058. /**
  85059. * Returns the line list draw mode
  85060. */
  85061. static readonly LineListDrawMode: number;
  85062. /**
  85063. * Returns the line loop draw mode
  85064. */
  85065. static readonly LineLoopDrawMode: number;
  85066. /**
  85067. * Returns the line strip draw mode
  85068. */
  85069. static readonly LineStripDrawMode: number;
  85070. /**
  85071. * Returns the triangle strip draw mode
  85072. */
  85073. static readonly TriangleStripDrawMode: number;
  85074. /**
  85075. * Returns the triangle fan draw mode
  85076. */
  85077. static readonly TriangleFanDrawMode: number;
  85078. /**
  85079. * Stores the clock-wise side orientation
  85080. */
  85081. static readonly ClockWiseSideOrientation: number;
  85082. /**
  85083. * Stores the counter clock-wise side orientation
  85084. */
  85085. static readonly CounterClockWiseSideOrientation: number;
  85086. /**
  85087. * The dirty texture flag value
  85088. */
  85089. static readonly TextureDirtyFlag: number;
  85090. /**
  85091. * The dirty light flag value
  85092. */
  85093. static readonly LightDirtyFlag: number;
  85094. /**
  85095. * The dirty fresnel flag value
  85096. */
  85097. static readonly FresnelDirtyFlag: number;
  85098. /**
  85099. * The dirty attribute flag value
  85100. */
  85101. static readonly AttributesDirtyFlag: number;
  85102. /**
  85103. * The dirty misc flag value
  85104. */
  85105. static readonly MiscDirtyFlag: number;
  85106. /**
  85107. * The all dirty flag value
  85108. */
  85109. static readonly AllDirtyFlag: number;
  85110. /**
  85111. * The ID of the material
  85112. */
  85113. id: string;
  85114. /**
  85115. * Gets or sets the unique id of the material
  85116. */
  85117. uniqueId: number;
  85118. /**
  85119. * The name of the material
  85120. */
  85121. name: string;
  85122. /**
  85123. * Gets or sets user defined metadata
  85124. */
  85125. metadata: any;
  85126. /**
  85127. * For internal use only. Please do not use.
  85128. */
  85129. reservedDataStore: any;
  85130. /**
  85131. * Specifies if the ready state should be checked on each call
  85132. */
  85133. checkReadyOnEveryCall: boolean;
  85134. /**
  85135. * Specifies if the ready state should be checked once
  85136. */
  85137. checkReadyOnlyOnce: boolean;
  85138. /**
  85139. * The state of the material
  85140. */
  85141. state: string;
  85142. /**
  85143. * The alpha value of the material
  85144. */
  85145. protected _alpha: number;
  85146. /**
  85147. * List of inspectable custom properties (used by the Inspector)
  85148. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85149. */
  85150. inspectableCustomProperties: IInspectable[];
  85151. /**
  85152. * Sets the alpha value of the material
  85153. */
  85154. /**
  85155. * Gets the alpha value of the material
  85156. */
  85157. alpha: number;
  85158. /**
  85159. * Specifies if back face culling is enabled
  85160. */
  85161. protected _backFaceCulling: boolean;
  85162. /**
  85163. * Sets the back-face culling state
  85164. */
  85165. /**
  85166. * Gets the back-face culling state
  85167. */
  85168. backFaceCulling: boolean;
  85169. /**
  85170. * Stores the value for side orientation
  85171. */
  85172. sideOrientation: number;
  85173. /**
  85174. * Callback triggered when the material is compiled
  85175. */
  85176. onCompiled: Nullable<(effect: Effect) => void>;
  85177. /**
  85178. * Callback triggered when an error occurs
  85179. */
  85180. onError: Nullable<(effect: Effect, errors: string) => void>;
  85181. /**
  85182. * Callback triggered to get the render target textures
  85183. */
  85184. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85185. /**
  85186. * Gets a boolean indicating that current material needs to register RTT
  85187. */
  85188. readonly hasRenderTargetTextures: boolean;
  85189. /**
  85190. * Specifies if the material should be serialized
  85191. */
  85192. doNotSerialize: boolean;
  85193. /**
  85194. * @hidden
  85195. */
  85196. _storeEffectOnSubMeshes: boolean;
  85197. /**
  85198. * Stores the animations for the material
  85199. */
  85200. animations: Nullable<Array<Animation>>;
  85201. /**
  85202. * An event triggered when the material is disposed
  85203. */
  85204. onDisposeObservable: Observable<Material>;
  85205. /**
  85206. * An observer which watches for dispose events
  85207. */
  85208. private _onDisposeObserver;
  85209. private _onUnBindObservable;
  85210. /**
  85211. * Called during a dispose event
  85212. */
  85213. onDispose: () => void;
  85214. private _onBindObservable;
  85215. /**
  85216. * An event triggered when the material is bound
  85217. */
  85218. readonly onBindObservable: Observable<AbstractMesh>;
  85219. /**
  85220. * An observer which watches for bind events
  85221. */
  85222. private _onBindObserver;
  85223. /**
  85224. * Called during a bind event
  85225. */
  85226. onBind: (Mesh: AbstractMesh) => void;
  85227. /**
  85228. * An event triggered when the material is unbound
  85229. */
  85230. readonly onUnBindObservable: Observable<Material>;
  85231. /**
  85232. * Stores the value of the alpha mode
  85233. */
  85234. private _alphaMode;
  85235. /**
  85236. * Sets the value of the alpha mode.
  85237. *
  85238. * | Value | Type | Description |
  85239. * | --- | --- | --- |
  85240. * | 0 | ALPHA_DISABLE | |
  85241. * | 1 | ALPHA_ADD | |
  85242. * | 2 | ALPHA_COMBINE | |
  85243. * | 3 | ALPHA_SUBTRACT | |
  85244. * | 4 | ALPHA_MULTIPLY | |
  85245. * | 5 | ALPHA_MAXIMIZED | |
  85246. * | 6 | ALPHA_ONEONE | |
  85247. * | 7 | ALPHA_PREMULTIPLIED | |
  85248. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  85249. * | 9 | ALPHA_INTERPOLATE | |
  85250. * | 10 | ALPHA_SCREENMODE | |
  85251. *
  85252. */
  85253. /**
  85254. * Gets the value of the alpha mode
  85255. */
  85256. alphaMode: number;
  85257. /**
  85258. * Stores the state of the need depth pre-pass value
  85259. */
  85260. private _needDepthPrePass;
  85261. /**
  85262. * Sets the need depth pre-pass value
  85263. */
  85264. /**
  85265. * Gets the depth pre-pass value
  85266. */
  85267. needDepthPrePass: boolean;
  85268. /**
  85269. * Specifies if depth writing should be disabled
  85270. */
  85271. disableDepthWrite: boolean;
  85272. /**
  85273. * Specifies if depth writing should be forced
  85274. */
  85275. forceDepthWrite: boolean;
  85276. /**
  85277. * Specifies if there should be a separate pass for culling
  85278. */
  85279. separateCullingPass: boolean;
  85280. /**
  85281. * Stores the state specifing if fog should be enabled
  85282. */
  85283. private _fogEnabled;
  85284. /**
  85285. * Sets the state for enabling fog
  85286. */
  85287. /**
  85288. * Gets the value of the fog enabled state
  85289. */
  85290. fogEnabled: boolean;
  85291. /**
  85292. * Stores the size of points
  85293. */
  85294. pointSize: number;
  85295. /**
  85296. * Stores the z offset value
  85297. */
  85298. zOffset: number;
  85299. /**
  85300. * Gets a value specifying if wireframe mode is enabled
  85301. */
  85302. /**
  85303. * Sets the state of wireframe mode
  85304. */
  85305. wireframe: boolean;
  85306. /**
  85307. * Gets the value specifying if point clouds are enabled
  85308. */
  85309. /**
  85310. * Sets the state of point cloud mode
  85311. */
  85312. pointsCloud: boolean;
  85313. /**
  85314. * Gets the material fill mode
  85315. */
  85316. /**
  85317. * Sets the material fill mode
  85318. */
  85319. fillMode: number;
  85320. /**
  85321. * @hidden
  85322. * Stores the effects for the material
  85323. */
  85324. _effect: Nullable<Effect>;
  85325. /**
  85326. * @hidden
  85327. * Specifies if the material was previously ready
  85328. */
  85329. _wasPreviouslyReady: boolean;
  85330. /**
  85331. * Specifies if uniform buffers should be used
  85332. */
  85333. private _useUBO;
  85334. /**
  85335. * Stores a reference to the scene
  85336. */
  85337. private _scene;
  85338. /**
  85339. * Stores the fill mode state
  85340. */
  85341. private _fillMode;
  85342. /**
  85343. * Specifies if the depth write state should be cached
  85344. */
  85345. private _cachedDepthWriteState;
  85346. /**
  85347. * Stores the uniform buffer
  85348. */
  85349. protected _uniformBuffer: UniformBuffer;
  85350. /** @hidden */
  85351. _indexInSceneMaterialArray: number;
  85352. /** @hidden */
  85353. meshMap: Nullable<{
  85354. [id: string]: AbstractMesh | undefined;
  85355. }>;
  85356. /**
  85357. * Creates a material instance
  85358. * @param name defines the name of the material
  85359. * @param scene defines the scene to reference
  85360. * @param doNotAdd specifies if the material should be added to the scene
  85361. */
  85362. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  85363. /**
  85364. * Returns a string representation of the current material
  85365. * @param fullDetails defines a boolean indicating which levels of logging is desired
  85366. * @returns a string with material information
  85367. */
  85368. toString(fullDetails?: boolean): string;
  85369. /**
  85370. * Gets the class name of the material
  85371. * @returns a string with the class name of the material
  85372. */
  85373. getClassName(): string;
  85374. /**
  85375. * Specifies if updates for the material been locked
  85376. */
  85377. readonly isFrozen: boolean;
  85378. /**
  85379. * Locks updates for the material
  85380. */
  85381. freeze(): void;
  85382. /**
  85383. * Unlocks updates for the material
  85384. */
  85385. unfreeze(): void;
  85386. /**
  85387. * Specifies if the material is ready to be used
  85388. * @param mesh defines the mesh to check
  85389. * @param useInstances specifies if instances should be used
  85390. * @returns a boolean indicating if the material is ready to be used
  85391. */
  85392. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85393. /**
  85394. * Specifies that the submesh is ready to be used
  85395. * @param mesh defines the mesh to check
  85396. * @param subMesh defines which submesh to check
  85397. * @param useInstances specifies that instances should be used
  85398. * @returns a boolean indicating that the submesh is ready or not
  85399. */
  85400. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85401. /**
  85402. * Returns the material effect
  85403. * @returns the effect associated with the material
  85404. */
  85405. getEffect(): Nullable<Effect>;
  85406. /**
  85407. * Returns the current scene
  85408. * @returns a Scene
  85409. */
  85410. getScene(): Scene;
  85411. /**
  85412. * Specifies if the material will require alpha blending
  85413. * @returns a boolean specifying if alpha blending is needed
  85414. */
  85415. needAlphaBlending(): boolean;
  85416. /**
  85417. * Specifies if the mesh will require alpha blending
  85418. * @param mesh defines the mesh to check
  85419. * @returns a boolean specifying if alpha blending is needed for the mesh
  85420. */
  85421. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85422. /**
  85423. * Specifies if this material should be rendered in alpha test mode
  85424. * @returns a boolean specifying if an alpha test is needed.
  85425. */
  85426. needAlphaTesting(): boolean;
  85427. /**
  85428. * Gets the texture used for the alpha test
  85429. * @returns the texture to use for alpha testing
  85430. */
  85431. getAlphaTestTexture(): Nullable<BaseTexture>;
  85432. /**
  85433. * Marks the material to indicate that it needs to be re-calculated
  85434. */
  85435. markDirty(): void;
  85436. /** @hidden */
  85437. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85438. /**
  85439. * Binds the material to the mesh
  85440. * @param world defines the world transformation matrix
  85441. * @param mesh defines the mesh to bind the material to
  85442. */
  85443. bind(world: Matrix, mesh?: Mesh): void;
  85444. /**
  85445. * Binds the submesh to the material
  85446. * @param world defines the world transformation matrix
  85447. * @param mesh defines the mesh containing the submesh
  85448. * @param subMesh defines the submesh to bind the material to
  85449. */
  85450. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85451. /**
  85452. * Binds the world matrix to the material
  85453. * @param world defines the world transformation matrix
  85454. */
  85455. bindOnlyWorldMatrix(world: Matrix): void;
  85456. /**
  85457. * Binds the scene's uniform buffer to the effect.
  85458. * @param effect defines the effect to bind to the scene uniform buffer
  85459. * @param sceneUbo defines the uniform buffer storing scene data
  85460. */
  85461. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85462. /**
  85463. * Binds the view matrix to the effect
  85464. * @param effect defines the effect to bind the view matrix to
  85465. */
  85466. bindView(effect: Effect): void;
  85467. /**
  85468. * Binds the view projection matrix to the effect
  85469. * @param effect defines the effect to bind the view projection matrix to
  85470. */
  85471. bindViewProjection(effect: Effect): void;
  85472. /**
  85473. * Specifies if material alpha testing should be turned on for the mesh
  85474. * @param mesh defines the mesh to check
  85475. */
  85476. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85477. /**
  85478. * Processes to execute after binding the material to a mesh
  85479. * @param mesh defines the rendered mesh
  85480. */
  85481. protected _afterBind(mesh?: Mesh): void;
  85482. /**
  85483. * Unbinds the material from the mesh
  85484. */
  85485. unbind(): void;
  85486. /**
  85487. * Gets the active textures from the material
  85488. * @returns an array of textures
  85489. */
  85490. getActiveTextures(): BaseTexture[];
  85491. /**
  85492. * Specifies if the material uses a texture
  85493. * @param texture defines the texture to check against the material
  85494. * @returns a boolean specifying if the material uses the texture
  85495. */
  85496. hasTexture(texture: BaseTexture): boolean;
  85497. /**
  85498. * Makes a duplicate of the material, and gives it a new name
  85499. * @param name defines the new name for the duplicated material
  85500. * @returns the cloned material
  85501. */
  85502. clone(name: string): Nullable<Material>;
  85503. /**
  85504. * Gets the meshes bound to the material
  85505. * @returns an array of meshes bound to the material
  85506. */
  85507. getBindedMeshes(): AbstractMesh[];
  85508. /**
  85509. * Force shader compilation
  85510. * @param mesh defines the mesh associated with this material
  85511. * @param onCompiled defines a function to execute once the material is compiled
  85512. * @param options defines the options to configure the compilation
  85513. */
  85514. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85515. clipPlane: boolean;
  85516. }>): void;
  85517. /**
  85518. * Force shader compilation
  85519. * @param mesh defines the mesh that will use this material
  85520. * @param options defines additional options for compiling the shaders
  85521. * @returns a promise that resolves when the compilation completes
  85522. */
  85523. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85524. clipPlane: boolean;
  85525. }>): Promise<void>;
  85526. private static readonly _AllDirtyCallBack;
  85527. private static readonly _ImageProcessingDirtyCallBack;
  85528. private static readonly _TextureDirtyCallBack;
  85529. private static readonly _FresnelDirtyCallBack;
  85530. private static readonly _MiscDirtyCallBack;
  85531. private static readonly _LightsDirtyCallBack;
  85532. private static readonly _AttributeDirtyCallBack;
  85533. private static _FresnelAndMiscDirtyCallBack;
  85534. private static _TextureAndMiscDirtyCallBack;
  85535. private static readonly _DirtyCallbackArray;
  85536. private static readonly _RunDirtyCallBacks;
  85537. /**
  85538. * Marks a define in the material to indicate that it needs to be re-computed
  85539. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85540. */
  85541. markAsDirty(flag: number): void;
  85542. /**
  85543. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85544. * @param func defines a function which checks material defines against the submeshes
  85545. */
  85546. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85547. /**
  85548. * Indicates that we need to re-calculated for all submeshes
  85549. */
  85550. protected _markAllSubMeshesAsAllDirty(): void;
  85551. /**
  85552. * Indicates that image processing needs to be re-calculated for all submeshes
  85553. */
  85554. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85555. /**
  85556. * Indicates that textures need to be re-calculated for all submeshes
  85557. */
  85558. protected _markAllSubMeshesAsTexturesDirty(): void;
  85559. /**
  85560. * Indicates that fresnel needs to be re-calculated for all submeshes
  85561. */
  85562. protected _markAllSubMeshesAsFresnelDirty(): void;
  85563. /**
  85564. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85565. */
  85566. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85567. /**
  85568. * Indicates that lights need to be re-calculated for all submeshes
  85569. */
  85570. protected _markAllSubMeshesAsLightsDirty(): void;
  85571. /**
  85572. * Indicates that attributes need to be re-calculated for all submeshes
  85573. */
  85574. protected _markAllSubMeshesAsAttributesDirty(): void;
  85575. /**
  85576. * Indicates that misc needs to be re-calculated for all submeshes
  85577. */
  85578. protected _markAllSubMeshesAsMiscDirty(): void;
  85579. /**
  85580. * Indicates that textures and misc need to be re-calculated for all submeshes
  85581. */
  85582. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85583. /**
  85584. * Disposes the material
  85585. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85586. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85587. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85588. */
  85589. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85590. /** @hidden */
  85591. private releaseVertexArrayObject;
  85592. /**
  85593. * Serializes this material
  85594. * @returns the serialized material object
  85595. */
  85596. serialize(): any;
  85597. /**
  85598. * Creates a material from parsed material data
  85599. * @param parsedMaterial defines parsed material data
  85600. * @param scene defines the hosting scene
  85601. * @param rootUrl defines the root URL to use to load textures
  85602. * @returns a new material
  85603. */
  85604. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85605. }
  85606. }
  85607. declare module BABYLON {
  85608. /**
  85609. * Base class for submeshes
  85610. */
  85611. export class BaseSubMesh {
  85612. /** @hidden */
  85613. _materialDefines: Nullable<MaterialDefines>;
  85614. /** @hidden */
  85615. _materialEffect: Nullable<Effect>;
  85616. /**
  85617. * Gets associated effect
  85618. */
  85619. readonly effect: Nullable<Effect>;
  85620. /**
  85621. * Sets associated effect (effect used to render this submesh)
  85622. * @param effect defines the effect to associate with
  85623. * @param defines defines the set of defines used to compile this effect
  85624. */
  85625. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85626. }
  85627. /**
  85628. * Defines a subdivision inside a mesh
  85629. */
  85630. export class SubMesh extends BaseSubMesh implements ICullable {
  85631. /** the material index to use */
  85632. materialIndex: number;
  85633. /** vertex index start */
  85634. verticesStart: number;
  85635. /** vertices count */
  85636. verticesCount: number;
  85637. /** index start */
  85638. indexStart: number;
  85639. /** indices count */
  85640. indexCount: number;
  85641. /** @hidden */
  85642. _linesIndexCount: number;
  85643. private _mesh;
  85644. private _renderingMesh;
  85645. private _boundingInfo;
  85646. private _linesIndexBuffer;
  85647. /** @hidden */
  85648. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85649. /** @hidden */
  85650. _trianglePlanes: Plane[];
  85651. /** @hidden */
  85652. _lastColliderTransformMatrix: Nullable<Matrix>;
  85653. /** @hidden */
  85654. _renderId: number;
  85655. /** @hidden */
  85656. _alphaIndex: number;
  85657. /** @hidden */
  85658. _distanceToCamera: number;
  85659. /** @hidden */
  85660. _id: number;
  85661. private _currentMaterial;
  85662. /**
  85663. * Add a new submesh to a mesh
  85664. * @param materialIndex defines the material index to use
  85665. * @param verticesStart defines vertex index start
  85666. * @param verticesCount defines vertices count
  85667. * @param indexStart defines index start
  85668. * @param indexCount defines indices count
  85669. * @param mesh defines the parent mesh
  85670. * @param renderingMesh defines an optional rendering mesh
  85671. * @param createBoundingBox defines if bounding box should be created for this submesh
  85672. * @returns the new submesh
  85673. */
  85674. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85675. /**
  85676. * Creates a new submesh
  85677. * @param materialIndex defines the material index to use
  85678. * @param verticesStart defines vertex index start
  85679. * @param verticesCount defines vertices count
  85680. * @param indexStart defines index start
  85681. * @param indexCount defines indices count
  85682. * @param mesh defines the parent mesh
  85683. * @param renderingMesh defines an optional rendering mesh
  85684. * @param createBoundingBox defines if bounding box should be created for this submesh
  85685. */
  85686. constructor(
  85687. /** the material index to use */
  85688. materialIndex: number,
  85689. /** vertex index start */
  85690. verticesStart: number,
  85691. /** vertices count */
  85692. verticesCount: number,
  85693. /** index start */
  85694. indexStart: number,
  85695. /** indices count */
  85696. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85697. /**
  85698. * Returns true if this submesh covers the entire parent mesh
  85699. * @ignorenaming
  85700. */
  85701. readonly IsGlobal: boolean;
  85702. /**
  85703. * Returns the submesh BoudingInfo object
  85704. * @returns current bounding info (or mesh's one if the submesh is global)
  85705. */
  85706. getBoundingInfo(): BoundingInfo;
  85707. /**
  85708. * Sets the submesh BoundingInfo
  85709. * @param boundingInfo defines the new bounding info to use
  85710. * @returns the SubMesh
  85711. */
  85712. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85713. /**
  85714. * Returns the mesh of the current submesh
  85715. * @return the parent mesh
  85716. */
  85717. getMesh(): AbstractMesh;
  85718. /**
  85719. * Returns the rendering mesh of the submesh
  85720. * @returns the rendering mesh (could be different from parent mesh)
  85721. */
  85722. getRenderingMesh(): Mesh;
  85723. /**
  85724. * Returns the submesh material
  85725. * @returns null or the current material
  85726. */
  85727. getMaterial(): Nullable<Material>;
  85728. /**
  85729. * Sets a new updated BoundingInfo object to the submesh
  85730. * @param data defines an optional position array to use to determine the bounding info
  85731. * @returns the SubMesh
  85732. */
  85733. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85734. /** @hidden */
  85735. _checkCollision(collider: Collider): boolean;
  85736. /**
  85737. * Updates the submesh BoundingInfo
  85738. * @param world defines the world matrix to use to update the bounding info
  85739. * @returns the submesh
  85740. */
  85741. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85742. /**
  85743. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85744. * @param frustumPlanes defines the frustum planes
  85745. * @returns true if the submesh is intersecting with the frustum
  85746. */
  85747. isInFrustum(frustumPlanes: Plane[]): boolean;
  85748. /**
  85749. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85750. * @param frustumPlanes defines the frustum planes
  85751. * @returns true if the submesh is inside the frustum
  85752. */
  85753. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85754. /**
  85755. * Renders the submesh
  85756. * @param enableAlphaMode defines if alpha needs to be used
  85757. * @returns the submesh
  85758. */
  85759. render(enableAlphaMode: boolean): SubMesh;
  85760. /**
  85761. * @hidden
  85762. */
  85763. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85764. /**
  85765. * Checks if the submesh intersects with a ray
  85766. * @param ray defines the ray to test
  85767. * @returns true is the passed ray intersects the submesh bounding box
  85768. */
  85769. canIntersects(ray: Ray): boolean;
  85770. /**
  85771. * Intersects current submesh with a ray
  85772. * @param ray defines the ray to test
  85773. * @param positions defines mesh's positions array
  85774. * @param indices defines mesh's indices array
  85775. * @param fastCheck defines if only bounding info should be used
  85776. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85777. * @returns intersection info or null if no intersection
  85778. */
  85779. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85780. /** @hidden */
  85781. private _intersectLines;
  85782. /** @hidden */
  85783. private _intersectUnIndexedLines;
  85784. /** @hidden */
  85785. private _intersectTriangles;
  85786. /** @hidden */
  85787. private _intersectUnIndexedTriangles;
  85788. /** @hidden */
  85789. _rebuild(): void;
  85790. /**
  85791. * Creates a new submesh from the passed mesh
  85792. * @param newMesh defines the new hosting mesh
  85793. * @param newRenderingMesh defines an optional rendering mesh
  85794. * @returns the new submesh
  85795. */
  85796. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85797. /**
  85798. * Release associated resources
  85799. */
  85800. dispose(): void;
  85801. /**
  85802. * Gets the class name
  85803. * @returns the string "SubMesh".
  85804. */
  85805. getClassName(): string;
  85806. /**
  85807. * Creates a new submesh from indices data
  85808. * @param materialIndex the index of the main mesh material
  85809. * @param startIndex the index where to start the copy in the mesh indices array
  85810. * @param indexCount the number of indices to copy then from the startIndex
  85811. * @param mesh the main mesh to create the submesh from
  85812. * @param renderingMesh the optional rendering mesh
  85813. * @returns a new submesh
  85814. */
  85815. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85816. }
  85817. }
  85818. declare module BABYLON {
  85819. /**
  85820. * Class used to store geometry data (vertex buffers + index buffer)
  85821. */
  85822. export class Geometry implements IGetSetVerticesData {
  85823. /**
  85824. * Gets or sets the ID of the geometry
  85825. */
  85826. id: string;
  85827. /**
  85828. * Gets or sets the unique ID of the geometry
  85829. */
  85830. uniqueId: number;
  85831. /**
  85832. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85833. */
  85834. delayLoadState: number;
  85835. /**
  85836. * Gets the file containing the data to load when running in delay load state
  85837. */
  85838. delayLoadingFile: Nullable<string>;
  85839. /**
  85840. * Callback called when the geometry is updated
  85841. */
  85842. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85843. private _scene;
  85844. private _engine;
  85845. private _meshes;
  85846. private _totalVertices;
  85847. /** @hidden */
  85848. _indices: IndicesArray;
  85849. /** @hidden */
  85850. _vertexBuffers: {
  85851. [key: string]: VertexBuffer;
  85852. };
  85853. private _isDisposed;
  85854. private _extend;
  85855. private _boundingBias;
  85856. /** @hidden */
  85857. _delayInfo: Array<string>;
  85858. private _indexBuffer;
  85859. private _indexBufferIsUpdatable;
  85860. /** @hidden */
  85861. _boundingInfo: Nullable<BoundingInfo>;
  85862. /** @hidden */
  85863. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85864. /** @hidden */
  85865. _softwareSkinningFrameId: number;
  85866. private _vertexArrayObjects;
  85867. private _updatable;
  85868. /** @hidden */
  85869. _positions: Nullable<Vector3[]>;
  85870. /**
  85871. * 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
  85872. */
  85873. /**
  85874. * 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
  85875. */
  85876. boundingBias: Vector2;
  85877. /**
  85878. * Static function used to attach a new empty geometry to a mesh
  85879. * @param mesh defines the mesh to attach the geometry to
  85880. * @returns the new Geometry
  85881. */
  85882. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85883. /**
  85884. * Creates a new geometry
  85885. * @param id defines the unique ID
  85886. * @param scene defines the hosting scene
  85887. * @param vertexData defines the VertexData used to get geometry data
  85888. * @param updatable defines if geometry must be updatable (false by default)
  85889. * @param mesh defines the mesh that will be associated with the geometry
  85890. */
  85891. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85892. /**
  85893. * Gets the current extend of the geometry
  85894. */
  85895. readonly extend: {
  85896. minimum: Vector3;
  85897. maximum: Vector3;
  85898. };
  85899. /**
  85900. * Gets the hosting scene
  85901. * @returns the hosting Scene
  85902. */
  85903. getScene(): Scene;
  85904. /**
  85905. * Gets the hosting engine
  85906. * @returns the hosting Engine
  85907. */
  85908. getEngine(): Engine;
  85909. /**
  85910. * Defines if the geometry is ready to use
  85911. * @returns true if the geometry is ready to be used
  85912. */
  85913. isReady(): boolean;
  85914. /**
  85915. * Gets a value indicating that the geometry should not be serialized
  85916. */
  85917. readonly doNotSerialize: boolean;
  85918. /** @hidden */
  85919. _rebuild(): void;
  85920. /**
  85921. * Affects all geometry data in one call
  85922. * @param vertexData defines the geometry data
  85923. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85924. */
  85925. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85926. /**
  85927. * Set specific vertex data
  85928. * @param kind defines the data kind (Position, normal, etc...)
  85929. * @param data defines the vertex data to use
  85930. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85931. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85932. */
  85933. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85934. /**
  85935. * Removes a specific vertex data
  85936. * @param kind defines the data kind (Position, normal, etc...)
  85937. */
  85938. removeVerticesData(kind: string): void;
  85939. /**
  85940. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85941. * @param buffer defines the vertex buffer to use
  85942. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85943. */
  85944. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85945. /**
  85946. * Update a specific vertex buffer
  85947. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85948. * It will do nothing if the buffer is not updatable
  85949. * @param kind defines the data kind (Position, normal, etc...)
  85950. * @param data defines the data to use
  85951. * @param offset defines the offset in the target buffer where to store the data
  85952. * @param useBytes set to true if the offset is in bytes
  85953. */
  85954. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85955. /**
  85956. * Update a specific vertex buffer
  85957. * This function will create a new buffer if the current one is not updatable
  85958. * @param kind defines the data kind (Position, normal, etc...)
  85959. * @param data defines the data to use
  85960. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85961. */
  85962. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85963. private _updateBoundingInfo;
  85964. /** @hidden */
  85965. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85966. /**
  85967. * Gets total number of vertices
  85968. * @returns the total number of vertices
  85969. */
  85970. getTotalVertices(): number;
  85971. /**
  85972. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85973. * @param kind defines the data kind (Position, normal, etc...)
  85974. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85975. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85976. * @returns a float array containing vertex data
  85977. */
  85978. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85979. /**
  85980. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85981. * @param kind defines the data kind (Position, normal, etc...)
  85982. * @returns true if the vertex buffer with the specified kind is updatable
  85983. */
  85984. isVertexBufferUpdatable(kind: string): boolean;
  85985. /**
  85986. * Gets a specific vertex buffer
  85987. * @param kind defines the data kind (Position, normal, etc...)
  85988. * @returns a VertexBuffer
  85989. */
  85990. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85991. /**
  85992. * Returns all vertex buffers
  85993. * @return an object holding all vertex buffers indexed by kind
  85994. */
  85995. getVertexBuffers(): Nullable<{
  85996. [key: string]: VertexBuffer;
  85997. }>;
  85998. /**
  85999. * Gets a boolean indicating if specific vertex buffer is present
  86000. * @param kind defines the data kind (Position, normal, etc...)
  86001. * @returns true if data is present
  86002. */
  86003. isVerticesDataPresent(kind: string): boolean;
  86004. /**
  86005. * Gets a list of all attached data kinds (Position, normal, etc...)
  86006. * @returns a list of string containing all kinds
  86007. */
  86008. getVerticesDataKinds(): string[];
  86009. /**
  86010. * Update index buffer
  86011. * @param indices defines the indices to store in the index buffer
  86012. * @param offset defines the offset in the target buffer where to store the data
  86013. * @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)
  86014. */
  86015. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  86016. /**
  86017. * Creates a new index buffer
  86018. * @param indices defines the indices to store in the index buffer
  86019. * @param totalVertices defines the total number of vertices (could be null)
  86020. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86021. */
  86022. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86023. /**
  86024. * Return the total number of indices
  86025. * @returns the total number of indices
  86026. */
  86027. getTotalIndices(): number;
  86028. /**
  86029. * Gets the index buffer array
  86030. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86031. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86032. * @returns the index buffer array
  86033. */
  86034. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86035. /**
  86036. * Gets the index buffer
  86037. * @return the index buffer
  86038. */
  86039. getIndexBuffer(): Nullable<DataBuffer>;
  86040. /** @hidden */
  86041. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86042. /**
  86043. * Release the associated resources for a specific mesh
  86044. * @param mesh defines the source mesh
  86045. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86046. */
  86047. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86048. /**
  86049. * Apply current geometry to a given mesh
  86050. * @param mesh defines the mesh to apply geometry to
  86051. */
  86052. applyToMesh(mesh: Mesh): void;
  86053. private _updateExtend;
  86054. private _applyToMesh;
  86055. private notifyUpdate;
  86056. /**
  86057. * Load the geometry if it was flagged as delay loaded
  86058. * @param scene defines the hosting scene
  86059. * @param onLoaded defines a callback called when the geometry is loaded
  86060. */
  86061. load(scene: Scene, onLoaded?: () => void): void;
  86062. private _queueLoad;
  86063. /**
  86064. * Invert the geometry to move from a right handed system to a left handed one.
  86065. */
  86066. toLeftHanded(): void;
  86067. /** @hidden */
  86068. _resetPointsArrayCache(): void;
  86069. /** @hidden */
  86070. _generatePointsArray(): boolean;
  86071. /**
  86072. * Gets a value indicating if the geometry is disposed
  86073. * @returns true if the geometry was disposed
  86074. */
  86075. isDisposed(): boolean;
  86076. private _disposeVertexArrayObjects;
  86077. /**
  86078. * Free all associated resources
  86079. */
  86080. dispose(): void;
  86081. /**
  86082. * Clone the current geometry into a new geometry
  86083. * @param id defines the unique ID of the new geometry
  86084. * @returns a new geometry object
  86085. */
  86086. copy(id: string): Geometry;
  86087. /**
  86088. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86089. * @return a JSON representation of the current geometry data (without the vertices data)
  86090. */
  86091. serialize(): any;
  86092. private toNumberArray;
  86093. /**
  86094. * Serialize all vertices data into a JSON oject
  86095. * @returns a JSON representation of the current geometry data
  86096. */
  86097. serializeVerticeData(): any;
  86098. /**
  86099. * Extracts a clone of a mesh geometry
  86100. * @param mesh defines the source mesh
  86101. * @param id defines the unique ID of the new geometry object
  86102. * @returns the new geometry object
  86103. */
  86104. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86105. /**
  86106. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86107. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86108. * Be aware Math.random() could cause collisions, but:
  86109. * "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"
  86110. * @returns a string containing a new GUID
  86111. */
  86112. static RandomId(): string;
  86113. /** @hidden */
  86114. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86115. private static _CleanMatricesWeights;
  86116. /**
  86117. * Create a new geometry from persisted data (Using .babylon file format)
  86118. * @param parsedVertexData defines the persisted data
  86119. * @param scene defines the hosting scene
  86120. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86121. * @returns the new geometry object
  86122. */
  86123. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  86124. }
  86125. }
  86126. declare module BABYLON {
  86127. /**
  86128. * Define an interface for all classes that will get and set the data on vertices
  86129. */
  86130. export interface IGetSetVerticesData {
  86131. /**
  86132. * Gets a boolean indicating if specific vertex data is present
  86133. * @param kind defines the vertex data kind to use
  86134. * @returns true is data kind is present
  86135. */
  86136. isVerticesDataPresent(kind: string): boolean;
  86137. /**
  86138. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86139. * @param kind defines the data kind (Position, normal, etc...)
  86140. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86141. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86142. * @returns a float array containing vertex data
  86143. */
  86144. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86145. /**
  86146. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86147. * @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.
  86148. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86149. * @returns the indices array or an empty array if the mesh has no geometry
  86150. */
  86151. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86152. /**
  86153. * Set specific vertex data
  86154. * @param kind defines the data kind (Position, normal, etc...)
  86155. * @param data defines the vertex data to use
  86156. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86157. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86158. */
  86159. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  86160. /**
  86161. * Update a specific associated vertex buffer
  86162. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86163. * - VertexBuffer.PositionKind
  86164. * - VertexBuffer.UVKind
  86165. * - VertexBuffer.UV2Kind
  86166. * - VertexBuffer.UV3Kind
  86167. * - VertexBuffer.UV4Kind
  86168. * - VertexBuffer.UV5Kind
  86169. * - VertexBuffer.UV6Kind
  86170. * - VertexBuffer.ColorKind
  86171. * - VertexBuffer.MatricesIndicesKind
  86172. * - VertexBuffer.MatricesIndicesExtraKind
  86173. * - VertexBuffer.MatricesWeightsKind
  86174. * - VertexBuffer.MatricesWeightsExtraKind
  86175. * @param data defines the data source
  86176. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86177. * @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)
  86178. */
  86179. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  86180. /**
  86181. * Creates a new index buffer
  86182. * @param indices defines the indices to store in the index buffer
  86183. * @param totalVertices defines the total number of vertices (could be null)
  86184. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86185. */
  86186. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  86187. }
  86188. /**
  86189. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86190. */
  86191. export class VertexData {
  86192. /**
  86193. * Mesh side orientation : usually the external or front surface
  86194. */
  86195. static readonly FRONTSIDE: number;
  86196. /**
  86197. * Mesh side orientation : usually the internal or back surface
  86198. */
  86199. static readonly BACKSIDE: number;
  86200. /**
  86201. * Mesh side orientation : both internal and external or front and back surfaces
  86202. */
  86203. static readonly DOUBLESIDE: number;
  86204. /**
  86205. * Mesh side orientation : by default, `FRONTSIDE`
  86206. */
  86207. static readonly DEFAULTSIDE: number;
  86208. /**
  86209. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  86210. */
  86211. positions: Nullable<FloatArray>;
  86212. /**
  86213. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  86214. */
  86215. normals: Nullable<FloatArray>;
  86216. /**
  86217. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  86218. */
  86219. tangents: Nullable<FloatArray>;
  86220. /**
  86221. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86222. */
  86223. uvs: Nullable<FloatArray>;
  86224. /**
  86225. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86226. */
  86227. uvs2: Nullable<FloatArray>;
  86228. /**
  86229. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86230. */
  86231. uvs3: Nullable<FloatArray>;
  86232. /**
  86233. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86234. */
  86235. uvs4: Nullable<FloatArray>;
  86236. /**
  86237. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86238. */
  86239. uvs5: Nullable<FloatArray>;
  86240. /**
  86241. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86242. */
  86243. uvs6: Nullable<FloatArray>;
  86244. /**
  86245. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  86246. */
  86247. colors: Nullable<FloatArray>;
  86248. /**
  86249. * 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).
  86250. */
  86251. matricesIndices: Nullable<FloatArray>;
  86252. /**
  86253. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  86254. */
  86255. matricesWeights: Nullable<FloatArray>;
  86256. /**
  86257. * An array extending the number of possible indices
  86258. */
  86259. matricesIndicesExtra: Nullable<FloatArray>;
  86260. /**
  86261. * An array extending the number of possible weights when the number of indices is extended
  86262. */
  86263. matricesWeightsExtra: Nullable<FloatArray>;
  86264. /**
  86265. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  86266. */
  86267. indices: Nullable<IndicesArray>;
  86268. /**
  86269. * Uses the passed data array to set the set the values for the specified kind of data
  86270. * @param data a linear array of floating numbers
  86271. * @param kind the type of data that is being set, eg positions, colors etc
  86272. */
  86273. set(data: FloatArray, kind: string): void;
  86274. /**
  86275. * Associates the vertexData to the passed Mesh.
  86276. * Sets it as updatable or not (default `false`)
  86277. * @param mesh the mesh the vertexData is applied to
  86278. * @param updatable when used and having the value true allows new data to update the vertexData
  86279. * @returns the VertexData
  86280. */
  86281. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  86282. /**
  86283. * Associates the vertexData to the passed Geometry.
  86284. * Sets it as updatable or not (default `false`)
  86285. * @param geometry the geometry the vertexData is applied to
  86286. * @param updatable when used and having the value true allows new data to update the vertexData
  86287. * @returns VertexData
  86288. */
  86289. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  86290. /**
  86291. * Updates the associated mesh
  86292. * @param mesh the mesh to be updated
  86293. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86294. * @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
  86295. * @returns VertexData
  86296. */
  86297. updateMesh(mesh: Mesh): VertexData;
  86298. /**
  86299. * Updates the associated geometry
  86300. * @param geometry the geometry to be updated
  86301. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86302. * @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
  86303. * @returns VertexData.
  86304. */
  86305. updateGeometry(geometry: Geometry): VertexData;
  86306. private _applyTo;
  86307. private _update;
  86308. /**
  86309. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86310. * @param matrix the transforming matrix
  86311. * @returns the VertexData
  86312. */
  86313. transform(matrix: Matrix): VertexData;
  86314. /**
  86315. * Merges the passed VertexData into the current one
  86316. * @param other the VertexData to be merged into the current one
  86317. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  86318. * @returns the modified VertexData
  86319. */
  86320. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  86321. private _mergeElement;
  86322. private _validate;
  86323. /**
  86324. * Serializes the VertexData
  86325. * @returns a serialized object
  86326. */
  86327. serialize(): any;
  86328. /**
  86329. * Extracts the vertexData from a mesh
  86330. * @param mesh the mesh from which to extract the VertexData
  86331. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  86332. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86333. * @returns the object VertexData associated to the passed mesh
  86334. */
  86335. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86336. /**
  86337. * Extracts the vertexData from the geometry
  86338. * @param geometry the geometry from which to extract the VertexData
  86339. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  86340. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86341. * @returns the object VertexData associated to the passed mesh
  86342. */
  86343. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86344. private static _ExtractFrom;
  86345. /**
  86346. * Creates the VertexData for a Ribbon
  86347. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  86348. * * pathArray array of paths, each of which an array of successive Vector3
  86349. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  86350. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  86351. * * 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
  86352. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86353. * * 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)
  86354. * * 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)
  86355. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  86356. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  86357. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  86358. * @returns the VertexData of the ribbon
  86359. */
  86360. static CreateRibbon(options: {
  86361. pathArray: Vector3[][];
  86362. closeArray?: boolean;
  86363. closePath?: boolean;
  86364. offset?: number;
  86365. sideOrientation?: number;
  86366. frontUVs?: Vector4;
  86367. backUVs?: Vector4;
  86368. invertUV?: boolean;
  86369. uvs?: Vector2[];
  86370. colors?: Color4[];
  86371. }): VertexData;
  86372. /**
  86373. * Creates the VertexData for a box
  86374. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86375. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86376. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86377. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86378. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86379. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86380. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86381. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86382. * * 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)
  86383. * * 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)
  86384. * @returns the VertexData of the box
  86385. */
  86386. static CreateBox(options: {
  86387. size?: number;
  86388. width?: number;
  86389. height?: number;
  86390. depth?: number;
  86391. faceUV?: Vector4[];
  86392. faceColors?: Color4[];
  86393. sideOrientation?: number;
  86394. frontUVs?: Vector4;
  86395. backUVs?: Vector4;
  86396. }): VertexData;
  86397. /**
  86398. * Creates the VertexData for a tiled box
  86399. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86400. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86401. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86402. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86403. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86404. * @returns the VertexData of the box
  86405. */
  86406. static CreateTiledBox(options: {
  86407. pattern?: number;
  86408. width?: number;
  86409. height?: number;
  86410. depth?: number;
  86411. tileSize?: number;
  86412. tileWidth?: number;
  86413. tileHeight?: number;
  86414. alignHorizontal?: number;
  86415. alignVertical?: number;
  86416. faceUV?: Vector4[];
  86417. faceColors?: Color4[];
  86418. sideOrientation?: number;
  86419. }): VertexData;
  86420. /**
  86421. * Creates the VertexData for a tiled plane
  86422. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86423. * * pattern a limited pattern arrangement depending on the number
  86424. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86425. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86426. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86427. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86428. * * 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)
  86429. * * 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)
  86430. * @returns the VertexData of the tiled plane
  86431. */
  86432. static CreateTiledPlane(options: {
  86433. pattern?: number;
  86434. tileSize?: number;
  86435. tileWidth?: number;
  86436. tileHeight?: number;
  86437. size?: number;
  86438. width?: number;
  86439. height?: number;
  86440. alignHorizontal?: number;
  86441. alignVertical?: number;
  86442. sideOrientation?: number;
  86443. frontUVs?: Vector4;
  86444. backUVs?: Vector4;
  86445. }): VertexData;
  86446. /**
  86447. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86448. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86449. * * segments sets the number of horizontal strips optional, default 32
  86450. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86451. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86452. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86453. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86454. * * 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
  86455. * * 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
  86456. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86457. * * 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)
  86458. * * 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)
  86459. * @returns the VertexData of the ellipsoid
  86460. */
  86461. static CreateSphere(options: {
  86462. segments?: number;
  86463. diameter?: number;
  86464. diameterX?: number;
  86465. diameterY?: number;
  86466. diameterZ?: number;
  86467. arc?: number;
  86468. slice?: number;
  86469. sideOrientation?: number;
  86470. frontUVs?: Vector4;
  86471. backUVs?: Vector4;
  86472. }): VertexData;
  86473. /**
  86474. * Creates the VertexData for a cylinder, cone or prism
  86475. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86476. * * height sets the height (y direction) of the cylinder, optional, default 2
  86477. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86478. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86479. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86480. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86481. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86482. * * 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
  86483. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86484. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86485. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86486. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86487. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86488. * * 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)
  86489. * * 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)
  86490. * @returns the VertexData of the cylinder, cone or prism
  86491. */
  86492. static CreateCylinder(options: {
  86493. height?: number;
  86494. diameterTop?: number;
  86495. diameterBottom?: number;
  86496. diameter?: number;
  86497. tessellation?: number;
  86498. subdivisions?: number;
  86499. arc?: number;
  86500. faceColors?: Color4[];
  86501. faceUV?: Vector4[];
  86502. hasRings?: boolean;
  86503. enclose?: boolean;
  86504. sideOrientation?: number;
  86505. frontUVs?: Vector4;
  86506. backUVs?: Vector4;
  86507. }): VertexData;
  86508. /**
  86509. * Creates the VertexData for a torus
  86510. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86511. * * diameter the diameter of the torus, optional default 1
  86512. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86513. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86514. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86515. * * 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)
  86516. * * 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)
  86517. * @returns the VertexData of the torus
  86518. */
  86519. static CreateTorus(options: {
  86520. diameter?: number;
  86521. thickness?: number;
  86522. tessellation?: number;
  86523. sideOrientation?: number;
  86524. frontUVs?: Vector4;
  86525. backUVs?: Vector4;
  86526. }): VertexData;
  86527. /**
  86528. * Creates the VertexData of the LineSystem
  86529. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86530. * - lines an array of lines, each line being an array of successive Vector3
  86531. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86532. * @returns the VertexData of the LineSystem
  86533. */
  86534. static CreateLineSystem(options: {
  86535. lines: Vector3[][];
  86536. colors?: Nullable<Color4[][]>;
  86537. }): VertexData;
  86538. /**
  86539. * Create the VertexData for a DashedLines
  86540. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86541. * - points an array successive Vector3
  86542. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86543. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86544. * - dashNb the intended total number of dashes, optional, default 200
  86545. * @returns the VertexData for the DashedLines
  86546. */
  86547. static CreateDashedLines(options: {
  86548. points: Vector3[];
  86549. dashSize?: number;
  86550. gapSize?: number;
  86551. dashNb?: number;
  86552. }): VertexData;
  86553. /**
  86554. * Creates the VertexData for a Ground
  86555. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86556. * - width the width (x direction) of the ground, optional, default 1
  86557. * - height the height (z direction) of the ground, optional, default 1
  86558. * - subdivisions the number of subdivisions per side, optional, default 1
  86559. * @returns the VertexData of the Ground
  86560. */
  86561. static CreateGround(options: {
  86562. width?: number;
  86563. height?: number;
  86564. subdivisions?: number;
  86565. subdivisionsX?: number;
  86566. subdivisionsY?: number;
  86567. }): VertexData;
  86568. /**
  86569. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86570. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86571. * * xmin the ground minimum X coordinate, optional, default -1
  86572. * * zmin the ground minimum Z coordinate, optional, default -1
  86573. * * xmax the ground maximum X coordinate, optional, default 1
  86574. * * zmax the ground maximum Z coordinate, optional, default 1
  86575. * * 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}
  86576. * * 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}
  86577. * @returns the VertexData of the TiledGround
  86578. */
  86579. static CreateTiledGround(options: {
  86580. xmin: number;
  86581. zmin: number;
  86582. xmax: number;
  86583. zmax: number;
  86584. subdivisions?: {
  86585. w: number;
  86586. h: number;
  86587. };
  86588. precision?: {
  86589. w: number;
  86590. h: number;
  86591. };
  86592. }): VertexData;
  86593. /**
  86594. * Creates the VertexData of the Ground designed from a heightmap
  86595. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86596. * * width the width (x direction) of the ground
  86597. * * height the height (z direction) of the ground
  86598. * * subdivisions the number of subdivisions per side
  86599. * * minHeight the minimum altitude on the ground, optional, default 0
  86600. * * maxHeight the maximum altitude on the ground, optional default 1
  86601. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86602. * * buffer the array holding the image color data
  86603. * * bufferWidth the width of image
  86604. * * bufferHeight the height of image
  86605. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86606. * @returns the VertexData of the Ground designed from a heightmap
  86607. */
  86608. static CreateGroundFromHeightMap(options: {
  86609. width: number;
  86610. height: number;
  86611. subdivisions: number;
  86612. minHeight: number;
  86613. maxHeight: number;
  86614. colorFilter: Color3;
  86615. buffer: Uint8Array;
  86616. bufferWidth: number;
  86617. bufferHeight: number;
  86618. alphaFilter: number;
  86619. }): VertexData;
  86620. /**
  86621. * Creates the VertexData for a Plane
  86622. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86623. * * size sets the width and height of the plane to the value of size, optional default 1
  86624. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86625. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86626. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86627. * * 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)
  86628. * * 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)
  86629. * @returns the VertexData of the box
  86630. */
  86631. static CreatePlane(options: {
  86632. size?: number;
  86633. width?: number;
  86634. height?: number;
  86635. sideOrientation?: number;
  86636. frontUVs?: Vector4;
  86637. backUVs?: Vector4;
  86638. }): VertexData;
  86639. /**
  86640. * Creates the VertexData of the Disc or regular Polygon
  86641. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86642. * * radius the radius of the disc, optional default 0.5
  86643. * * tessellation the number of polygon sides, optional, default 64
  86644. * * 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
  86645. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86646. * * 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)
  86647. * * 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)
  86648. * @returns the VertexData of the box
  86649. */
  86650. static CreateDisc(options: {
  86651. radius?: number;
  86652. tessellation?: number;
  86653. arc?: number;
  86654. sideOrientation?: number;
  86655. frontUVs?: Vector4;
  86656. backUVs?: Vector4;
  86657. }): VertexData;
  86658. /**
  86659. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86660. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86661. * @param polygon a mesh built from polygonTriangulation.build()
  86662. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86663. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86664. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86665. * @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)
  86666. * @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)
  86667. * @returns the VertexData of the Polygon
  86668. */
  86669. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86670. /**
  86671. * Creates the VertexData of the IcoSphere
  86672. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86673. * * radius the radius of the IcoSphere, optional default 1
  86674. * * radiusX allows stretching in the x direction, optional, default radius
  86675. * * radiusY allows stretching in the y direction, optional, default radius
  86676. * * radiusZ allows stretching in the z direction, optional, default radius
  86677. * * flat when true creates a flat shaded mesh, optional, default true
  86678. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86679. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86680. * * 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)
  86681. * * 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)
  86682. * @returns the VertexData of the IcoSphere
  86683. */
  86684. static CreateIcoSphere(options: {
  86685. radius?: number;
  86686. radiusX?: number;
  86687. radiusY?: number;
  86688. radiusZ?: number;
  86689. flat?: boolean;
  86690. subdivisions?: number;
  86691. sideOrientation?: number;
  86692. frontUVs?: Vector4;
  86693. backUVs?: Vector4;
  86694. }): VertexData;
  86695. /**
  86696. * Creates the VertexData for a Polyhedron
  86697. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86698. * * type provided types are:
  86699. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86700. * * 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)
  86701. * * size the size of the IcoSphere, optional default 1
  86702. * * sizeX allows stretching in the x direction, optional, default size
  86703. * * sizeY allows stretching in the y direction, optional, default size
  86704. * * sizeZ allows stretching in the z direction, optional, default size
  86705. * * 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
  86706. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86707. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86708. * * flat when true creates a flat shaded mesh, optional, default true
  86709. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86710. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86711. * * 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)
  86712. * * 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)
  86713. * @returns the VertexData of the Polyhedron
  86714. */
  86715. static CreatePolyhedron(options: {
  86716. type?: number;
  86717. size?: number;
  86718. sizeX?: number;
  86719. sizeY?: number;
  86720. sizeZ?: number;
  86721. custom?: any;
  86722. faceUV?: Vector4[];
  86723. faceColors?: Color4[];
  86724. flat?: boolean;
  86725. sideOrientation?: number;
  86726. frontUVs?: Vector4;
  86727. backUVs?: Vector4;
  86728. }): VertexData;
  86729. /**
  86730. * Creates the VertexData for a TorusKnot
  86731. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86732. * * radius the radius of the torus knot, optional, default 2
  86733. * * tube the thickness of the tube, optional, default 0.5
  86734. * * radialSegments the number of sides on each tube segments, optional, default 32
  86735. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86736. * * p the number of windings around the z axis, optional, default 2
  86737. * * q the number of windings around the x axis, optional, default 3
  86738. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86739. * * 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)
  86740. * * 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)
  86741. * @returns the VertexData of the Torus Knot
  86742. */
  86743. static CreateTorusKnot(options: {
  86744. radius?: number;
  86745. tube?: number;
  86746. radialSegments?: number;
  86747. tubularSegments?: number;
  86748. p?: number;
  86749. q?: number;
  86750. sideOrientation?: number;
  86751. frontUVs?: Vector4;
  86752. backUVs?: Vector4;
  86753. }): VertexData;
  86754. /**
  86755. * Compute normals for given positions and indices
  86756. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86757. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86758. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86759. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86760. * * facetNormals : optional array of facet normals (vector3)
  86761. * * facetPositions : optional array of facet positions (vector3)
  86762. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86763. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86764. * * bInfo : optional bounding info, required for facetPartitioning computation
  86765. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86766. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86767. * * useRightHandedSystem: optional boolean to for right handed system computation
  86768. * * depthSort : optional boolean to enable the facet depth sort computation
  86769. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86770. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86771. */
  86772. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86773. facetNormals?: any;
  86774. facetPositions?: any;
  86775. facetPartitioning?: any;
  86776. ratio?: number;
  86777. bInfo?: any;
  86778. bbSize?: Vector3;
  86779. subDiv?: any;
  86780. useRightHandedSystem?: boolean;
  86781. depthSort?: boolean;
  86782. distanceTo?: Vector3;
  86783. depthSortedFacets?: any;
  86784. }): void;
  86785. /** @hidden */
  86786. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86787. /**
  86788. * Applies VertexData created from the imported parameters to the geometry
  86789. * @param parsedVertexData the parsed data from an imported file
  86790. * @param geometry the geometry to apply the VertexData to
  86791. */
  86792. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86793. }
  86794. }
  86795. declare module BABYLON {
  86796. /**
  86797. * Class containing static functions to help procedurally build meshes
  86798. */
  86799. export class DiscBuilder {
  86800. /**
  86801. * Creates a plane polygonal mesh. By default, this is a disc
  86802. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86803. * * 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
  86804. * * 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
  86805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86806. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  86807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86808. * @param name defines the name of the mesh
  86809. * @param options defines the options used to create the mesh
  86810. * @param scene defines the hosting scene
  86811. * @returns the plane polygonal mesh
  86812. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86813. */
  86814. static CreateDisc(name: string, options: {
  86815. radius?: number;
  86816. tessellation?: number;
  86817. arc?: number;
  86818. updatable?: boolean;
  86819. sideOrientation?: number;
  86820. frontUVs?: Vector4;
  86821. backUVs?: Vector4;
  86822. }, scene?: Nullable<Scene>): Mesh;
  86823. }
  86824. }
  86825. declare module BABYLON {
  86826. /**
  86827. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86828. *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.
  86829. * The SPS is also a particle system. It provides some methods to manage the particles.
  86830. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86831. *
  86832. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86833. */
  86834. export class SolidParticleSystem implements IDisposable {
  86835. /**
  86836. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86837. * Example : var p = SPS.particles[i];
  86838. */
  86839. particles: SolidParticle[];
  86840. /**
  86841. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86842. */
  86843. nbParticles: number;
  86844. /**
  86845. * If the particles must ever face the camera (default false). Useful for planar particles.
  86846. */
  86847. billboard: boolean;
  86848. /**
  86849. * Recompute normals when adding a shape
  86850. */
  86851. recomputeNormals: boolean;
  86852. /**
  86853. * This a counter ofr your own usage. It's not set by any SPS functions.
  86854. */
  86855. counter: number;
  86856. /**
  86857. * The SPS name. This name is also given to the underlying mesh.
  86858. */
  86859. name: string;
  86860. /**
  86861. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86862. */
  86863. mesh: Mesh;
  86864. /**
  86865. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86866. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86867. */
  86868. vars: any;
  86869. /**
  86870. * This array is populated when the SPS is set as 'pickable'.
  86871. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86872. * Each element of this array is an object `{idx: int, faceId: int}`.
  86873. * `idx` is the picked particle index in the `SPS.particles` array
  86874. * `faceId` is the picked face index counted within this particle.
  86875. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86876. */
  86877. pickedParticles: {
  86878. idx: number;
  86879. faceId: number;
  86880. }[];
  86881. /**
  86882. * This array is populated when `enableDepthSort` is set to true.
  86883. * Each element of this array is an instance of the class DepthSortedParticle.
  86884. */
  86885. depthSortedParticles: DepthSortedParticle[];
  86886. /**
  86887. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86888. * @hidden
  86889. */
  86890. _bSphereOnly: boolean;
  86891. /**
  86892. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86893. * @hidden
  86894. */
  86895. _bSphereRadiusFactor: number;
  86896. private _scene;
  86897. private _positions;
  86898. private _indices;
  86899. private _normals;
  86900. private _colors;
  86901. private _uvs;
  86902. private _indices32;
  86903. private _positions32;
  86904. private _normals32;
  86905. private _fixedNormal32;
  86906. private _colors32;
  86907. private _uvs32;
  86908. private _index;
  86909. private _updatable;
  86910. private _pickable;
  86911. private _isVisibilityBoxLocked;
  86912. private _alwaysVisible;
  86913. private _depthSort;
  86914. private _shapeCounter;
  86915. private _copy;
  86916. private _color;
  86917. private _computeParticleColor;
  86918. private _computeParticleTexture;
  86919. private _computeParticleRotation;
  86920. private _computeParticleVertex;
  86921. private _computeBoundingBox;
  86922. private _depthSortParticles;
  86923. private _camera;
  86924. private _mustUnrotateFixedNormals;
  86925. private _particlesIntersect;
  86926. private _needs32Bits;
  86927. /**
  86928. * Creates a SPS (Solid Particle System) object.
  86929. * @param name (String) is the SPS name, this will be the underlying mesh name.
  86930. * @param scene (Scene) is the scene in which the SPS is added.
  86931. * @param options defines the options of the sps e.g.
  86932. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  86933. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  86934. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  86935. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  86936. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  86937. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  86938. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  86939. */
  86940. constructor(name: string, scene: Scene, options?: {
  86941. updatable?: boolean;
  86942. isPickable?: boolean;
  86943. enableDepthSort?: boolean;
  86944. particleIntersection?: boolean;
  86945. boundingSphereOnly?: boolean;
  86946. bSphereRadiusFactor?: number;
  86947. });
  86948. /**
  86949. * Builds the SPS underlying mesh. Returns a standard Mesh.
  86950. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  86951. * @returns the created mesh
  86952. */
  86953. buildMesh(): Mesh;
  86954. /**
  86955. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  86956. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  86957. * Thus the particles generated from `digest()` have their property `position` set yet.
  86958. * @param mesh ( Mesh ) is the mesh to be digested
  86959. * @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
  86960. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  86961. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  86962. * @returns the current SPS
  86963. */
  86964. digest(mesh: Mesh, options?: {
  86965. facetNb?: number;
  86966. number?: number;
  86967. delta?: number;
  86968. }): SolidParticleSystem;
  86969. private _unrotateFixedNormals;
  86970. private _resetCopy;
  86971. private _meshBuilder;
  86972. private _posToShape;
  86973. private _uvsToShapeUV;
  86974. private _addParticle;
  86975. /**
  86976. * Adds some particles to the SPS from the model shape. Returns the shape id.
  86977. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  86978. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  86979. * @param nb (positive integer) the number of particles to be created from this model
  86980. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  86981. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  86982. * @returns the number of shapes in the system
  86983. */
  86984. addShape(mesh: Mesh, nb: number, options?: {
  86985. positionFunction?: any;
  86986. vertexFunction?: any;
  86987. }): number;
  86988. private _rebuildParticle;
  86989. /**
  86990. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  86991. * @returns the SPS.
  86992. */
  86993. rebuildMesh(): SolidParticleSystem;
  86994. /**
  86995. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  86996. * This method calls `updateParticle()` for each particle of the SPS.
  86997. * For an animated SPS, it is usually called within the render loop.
  86998. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  86999. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  87000. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  87001. * @returns the SPS.
  87002. */
  87003. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  87004. /**
  87005. * Disposes the SPS.
  87006. */
  87007. dispose(): void;
  87008. /**
  87009. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  87010. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87011. * @returns the SPS.
  87012. */
  87013. refreshVisibleSize(): SolidParticleSystem;
  87014. /**
  87015. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  87016. * @param size the size (float) of the visibility box
  87017. * note : this doesn't lock the SPS mesh bounding box.
  87018. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87019. */
  87020. setVisibilityBox(size: number): void;
  87021. /**
  87022. * Gets whether the SPS as always visible or not
  87023. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87024. */
  87025. /**
  87026. * Sets the SPS as always visible or not
  87027. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87028. */
  87029. isAlwaysVisible: boolean;
  87030. /**
  87031. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  87032. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87033. */
  87034. /**
  87035. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  87036. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87037. */
  87038. isVisibilityBoxLocked: boolean;
  87039. /**
  87040. * Tells to `setParticles()` to compute the particle rotations or not.
  87041. * Default value : true. The SPS is faster when it's set to false.
  87042. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  87043. */
  87044. /**
  87045. * Gets if `setParticles()` computes the particle rotations or not.
  87046. * Default value : true. The SPS is faster when it's set to false.
  87047. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  87048. */
  87049. computeParticleRotation: boolean;
  87050. /**
  87051. * Tells to `setParticles()` to compute the particle colors or not.
  87052. * Default value : true. The SPS is faster when it's set to false.
  87053. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  87054. */
  87055. /**
  87056. * Gets if `setParticles()` computes the particle colors or not.
  87057. * Default value : true. The SPS is faster when it's set to false.
  87058. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  87059. */
  87060. computeParticleColor: boolean;
  87061. /**
  87062. * Gets if `setParticles()` computes the particle textures or not.
  87063. * Default value : true. The SPS is faster when it's set to false.
  87064. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  87065. */
  87066. computeParticleTexture: boolean;
  87067. /**
  87068. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  87069. * Default value : false. The SPS is faster when it's set to false.
  87070. * Note : the particle custom vertex positions aren't stored values.
  87071. */
  87072. /**
  87073. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  87074. * Default value : false. The SPS is faster when it's set to false.
  87075. * Note : the particle custom vertex positions aren't stored values.
  87076. */
  87077. computeParticleVertex: boolean;
  87078. /**
  87079. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  87080. */
  87081. /**
  87082. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  87083. */
  87084. computeBoundingBox: boolean;
  87085. /**
  87086. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  87087. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  87088. * Default : `true`
  87089. */
  87090. /**
  87091. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  87092. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  87093. * Default : `true`
  87094. */
  87095. depthSortParticles: boolean;
  87096. /**
  87097. * This function does nothing. It may be overwritten to set all the particle first values.
  87098. * The SPS doesn't call this function, you may have to call it by your own.
  87099. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87100. */
  87101. initParticles(): void;
  87102. /**
  87103. * This function does nothing. It may be overwritten to recycle a particle.
  87104. * The SPS doesn't call this function, you may have to call it by your own.
  87105. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87106. * @param particle The particle to recycle
  87107. * @returns the recycled particle
  87108. */
  87109. recycleParticle(particle: SolidParticle): SolidParticle;
  87110. /**
  87111. * Updates a particle : this function should be overwritten by the user.
  87112. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  87113. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87114. * @example : just set a particle position or velocity and recycle conditions
  87115. * @param particle The particle to update
  87116. * @returns the updated particle
  87117. */
  87118. updateParticle(particle: SolidParticle): SolidParticle;
  87119. /**
  87120. * Updates a vertex of a particle : it can be overwritten by the user.
  87121. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  87122. * @param particle the current particle
  87123. * @param vertex the current index of the current particle
  87124. * @param pt the index of the current vertex in the particle shape
  87125. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  87126. * @example : just set a vertex particle position
  87127. * @returns the updated vertex
  87128. */
  87129. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  87130. /**
  87131. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  87132. * This does nothing and may be overwritten by the user.
  87133. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87134. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87135. * @param update the boolean update value actually passed to setParticles()
  87136. */
  87137. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  87138. /**
  87139. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  87140. * This will be passed three parameters.
  87141. * This does nothing and may be overwritten by the user.
  87142. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87143. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87144. * @param update the boolean update value actually passed to setParticles()
  87145. */
  87146. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  87147. }
  87148. }
  87149. declare module BABYLON {
  87150. /**
  87151. * Represents one particle of a solid particle system.
  87152. */
  87153. export class SolidParticle {
  87154. /**
  87155. * particle global index
  87156. */
  87157. idx: number;
  87158. /**
  87159. * The color of the particle
  87160. */
  87161. color: Nullable<Color4>;
  87162. /**
  87163. * The world space position of the particle.
  87164. */
  87165. position: Vector3;
  87166. /**
  87167. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  87168. */
  87169. rotation: Vector3;
  87170. /**
  87171. * The world space rotation quaternion of the particle.
  87172. */
  87173. rotationQuaternion: Nullable<Quaternion>;
  87174. /**
  87175. * The scaling of the particle.
  87176. */
  87177. scaling: Vector3;
  87178. /**
  87179. * The uvs of the particle.
  87180. */
  87181. uvs: Vector4;
  87182. /**
  87183. * The current speed of the particle.
  87184. */
  87185. velocity: Vector3;
  87186. /**
  87187. * The pivot point in the particle local space.
  87188. */
  87189. pivot: Vector3;
  87190. /**
  87191. * Must the particle be translated from its pivot point in its local space ?
  87192. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  87193. * Default : false
  87194. */
  87195. translateFromPivot: boolean;
  87196. /**
  87197. * Is the particle active or not ?
  87198. */
  87199. alive: boolean;
  87200. /**
  87201. * Is the particle visible or not ?
  87202. */
  87203. isVisible: boolean;
  87204. /**
  87205. * Index of this particle in the global "positions" array (Internal use)
  87206. * @hidden
  87207. */
  87208. _pos: number;
  87209. /**
  87210. * @hidden Index of this particle in the global "indices" array (Internal use)
  87211. */
  87212. _ind: number;
  87213. /**
  87214. * @hidden ModelShape of this particle (Internal use)
  87215. */
  87216. _model: ModelShape;
  87217. /**
  87218. * ModelShape id of this particle
  87219. */
  87220. shapeId: number;
  87221. /**
  87222. * Index of the particle in its shape id (Internal use)
  87223. */
  87224. idxInShape: number;
  87225. /**
  87226. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  87227. */
  87228. _modelBoundingInfo: BoundingInfo;
  87229. /**
  87230. * @hidden Particle BoundingInfo object (Internal use)
  87231. */
  87232. _boundingInfo: BoundingInfo;
  87233. /**
  87234. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  87235. */
  87236. _sps: SolidParticleSystem;
  87237. /**
  87238. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  87239. */
  87240. _stillInvisible: boolean;
  87241. /**
  87242. * @hidden Last computed particle rotation matrix
  87243. */
  87244. _rotationMatrix: number[];
  87245. /**
  87246. * Parent particle Id, if any.
  87247. * Default null.
  87248. */
  87249. parentId: Nullable<number>;
  87250. /**
  87251. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  87252. * The possible values are :
  87253. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87254. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87255. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87256. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87257. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87258. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  87259. * */
  87260. cullingStrategy: number;
  87261. /**
  87262. * @hidden Internal global position in the SPS.
  87263. */
  87264. _globalPosition: Vector3;
  87265. /**
  87266. * Creates a Solid Particle object.
  87267. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  87268. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  87269. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  87270. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  87271. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  87272. * @param shapeId (integer) is the model shape identifier in the SPS.
  87273. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  87274. * @param sps defines the sps it is associated to
  87275. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  87276. */
  87277. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  87278. /**
  87279. * Legacy support, changed scale to scaling
  87280. */
  87281. /**
  87282. * Legacy support, changed scale to scaling
  87283. */
  87284. scale: Vector3;
  87285. /**
  87286. * Legacy support, changed quaternion to rotationQuaternion
  87287. */
  87288. /**
  87289. * Legacy support, changed quaternion to rotationQuaternion
  87290. */
  87291. quaternion: Nullable<Quaternion>;
  87292. /**
  87293. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  87294. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  87295. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  87296. * @returns true if it intersects
  87297. */
  87298. intersectsMesh(target: Mesh | SolidParticle): boolean;
  87299. /**
  87300. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  87301. * A particle is in the frustum if its bounding box intersects the frustum
  87302. * @param frustumPlanes defines the frustum to test
  87303. * @returns true if the particle is in the frustum planes
  87304. */
  87305. isInFrustum(frustumPlanes: Plane[]): boolean;
  87306. /**
  87307. * get the rotation matrix of the particle
  87308. * @hidden
  87309. */
  87310. getRotationMatrix(m: Matrix): void;
  87311. }
  87312. /**
  87313. * Represents the shape of the model used by one particle of a solid particle system.
  87314. * SPS internal tool, don't use it manually.
  87315. */
  87316. export class ModelShape {
  87317. /**
  87318. * The shape id
  87319. * @hidden
  87320. */
  87321. shapeID: number;
  87322. /**
  87323. * flat array of model positions (internal use)
  87324. * @hidden
  87325. */
  87326. _shape: Vector3[];
  87327. /**
  87328. * flat array of model UVs (internal use)
  87329. * @hidden
  87330. */
  87331. _shapeUV: number[];
  87332. /**
  87333. * length of the shape in the model indices array (internal use)
  87334. * @hidden
  87335. */
  87336. _indicesLength: number;
  87337. /**
  87338. * Custom position function (internal use)
  87339. * @hidden
  87340. */
  87341. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  87342. /**
  87343. * Custom vertex function (internal use)
  87344. * @hidden
  87345. */
  87346. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  87347. /**
  87348. * 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.
  87349. * SPS internal tool, don't use it manually.
  87350. * @hidden
  87351. */
  87352. 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>);
  87353. }
  87354. /**
  87355. * Represents a Depth Sorted Particle in the solid particle system.
  87356. */
  87357. export class DepthSortedParticle {
  87358. /**
  87359. * Index of the particle in the "indices" array
  87360. */
  87361. ind: number;
  87362. /**
  87363. * Length of the particle shape in the "indices" array
  87364. */
  87365. indicesLength: number;
  87366. /**
  87367. * Squared distance from the particle to the camera
  87368. */
  87369. sqDistance: number;
  87370. }
  87371. }
  87372. declare module BABYLON {
  87373. /**
  87374. * @hidden
  87375. */
  87376. export class _MeshCollisionData {
  87377. _checkCollisions: boolean;
  87378. _collisionMask: number;
  87379. _collisionGroup: number;
  87380. _collider: Nullable<Collider>;
  87381. _oldPositionForCollisions: Vector3;
  87382. _diffPositionForCollisions: Vector3;
  87383. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  87384. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  87385. }
  87386. }
  87387. declare module BABYLON {
  87388. /** @hidden */
  87389. class _FacetDataStorage {
  87390. facetPositions: Vector3[];
  87391. facetNormals: Vector3[];
  87392. facetPartitioning: number[][];
  87393. facetNb: number;
  87394. partitioningSubdivisions: number;
  87395. partitioningBBoxRatio: number;
  87396. facetDataEnabled: boolean;
  87397. facetParameters: any;
  87398. bbSize: Vector3;
  87399. subDiv: {
  87400. max: number;
  87401. X: number;
  87402. Y: number;
  87403. Z: number;
  87404. };
  87405. facetDepthSort: boolean;
  87406. facetDepthSortEnabled: boolean;
  87407. depthSortedIndices: IndicesArray;
  87408. depthSortedFacets: {
  87409. ind: number;
  87410. sqDistance: number;
  87411. }[];
  87412. facetDepthSortFunction: (f1: {
  87413. ind: number;
  87414. sqDistance: number;
  87415. }, f2: {
  87416. ind: number;
  87417. sqDistance: number;
  87418. }) => number;
  87419. facetDepthSortFrom: Vector3;
  87420. facetDepthSortOrigin: Vector3;
  87421. invertedMatrix: Matrix;
  87422. }
  87423. /**
  87424. * @hidden
  87425. **/
  87426. class _InternalAbstractMeshDataInfo {
  87427. _hasVertexAlpha: boolean;
  87428. _useVertexColors: boolean;
  87429. _numBoneInfluencers: number;
  87430. _applyFog: boolean;
  87431. _receiveShadows: boolean;
  87432. _facetData: _FacetDataStorage;
  87433. _visibility: number;
  87434. _skeleton: Nullable<Skeleton>;
  87435. _layerMask: number;
  87436. _computeBonesUsingShaders: boolean;
  87437. _isActive: boolean;
  87438. _onlyForInstances: boolean;
  87439. _isActiveIntermediate: boolean;
  87440. _onlyForInstancesIntermediate: boolean;
  87441. }
  87442. /**
  87443. * Class used to store all common mesh properties
  87444. */
  87445. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  87446. /** No occlusion */
  87447. static OCCLUSION_TYPE_NONE: number;
  87448. /** Occlusion set to optimisitic */
  87449. static OCCLUSION_TYPE_OPTIMISTIC: number;
  87450. /** Occlusion set to strict */
  87451. static OCCLUSION_TYPE_STRICT: number;
  87452. /** Use an accurante occlusion algorithm */
  87453. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  87454. /** Use a conservative occlusion algorithm */
  87455. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  87456. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  87457. * Test order :
  87458. * Is the bounding sphere outside the frustum ?
  87459. * If not, are the bounding box vertices outside the frustum ?
  87460. * It not, then the cullable object is in the frustum.
  87461. */
  87462. static readonly CULLINGSTRATEGY_STANDARD: number;
  87463. /** Culling strategy : Bounding Sphere Only.
  87464. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  87465. * It's also less accurate than the standard because some not visible objects can still be selected.
  87466. * Test : is the bounding sphere outside the frustum ?
  87467. * If not, then the cullable object is in the frustum.
  87468. */
  87469. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  87470. /** Culling strategy : Optimistic Inclusion.
  87471. * This in an inclusion test first, then the standard exclusion test.
  87472. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  87473. * 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.
  87474. * Anyway, it's as accurate as the standard strategy.
  87475. * Test :
  87476. * Is the cullable object bounding sphere center in the frustum ?
  87477. * If not, apply the default culling strategy.
  87478. */
  87479. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  87480. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  87481. * This in an inclusion test first, then the bounding sphere only exclusion test.
  87482. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  87483. * 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.
  87484. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  87485. * Test :
  87486. * Is the cullable object bounding sphere center in the frustum ?
  87487. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  87488. */
  87489. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  87490. /**
  87491. * No billboard
  87492. */
  87493. static readonly BILLBOARDMODE_NONE: number;
  87494. /** Billboard on X axis */
  87495. static readonly BILLBOARDMODE_X: number;
  87496. /** Billboard on Y axis */
  87497. static readonly BILLBOARDMODE_Y: number;
  87498. /** Billboard on Z axis */
  87499. static readonly BILLBOARDMODE_Z: number;
  87500. /** Billboard on all axes */
  87501. static readonly BILLBOARDMODE_ALL: number;
  87502. /** @hidden */
  87503. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  87504. /**
  87505. * The culling strategy to use to check whether the mesh must be rendered or not.
  87506. * This value can be changed at any time and will be used on the next render mesh selection.
  87507. * The possible values are :
  87508. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87509. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87510. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87511. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87512. * Please read each static variable documentation to get details about the culling process.
  87513. * */
  87514. cullingStrategy: number;
  87515. /**
  87516. * Gets the number of facets in the mesh
  87517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87518. */
  87519. readonly facetNb: number;
  87520. /**
  87521. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  87522. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87523. */
  87524. partitioningSubdivisions: number;
  87525. /**
  87526. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  87527. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  87528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87529. */
  87530. partitioningBBoxRatio: number;
  87531. /**
  87532. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  87533. * Works only for updatable meshes.
  87534. * Doesn't work with multi-materials
  87535. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87536. */
  87537. mustDepthSortFacets: boolean;
  87538. /**
  87539. * The location (Vector3) where the facet depth sort must be computed from.
  87540. * By default, the active camera position.
  87541. * Used only when facet depth sort is enabled
  87542. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87543. */
  87544. facetDepthSortFrom: Vector3;
  87545. /**
  87546. * gets a boolean indicating if facetData is enabled
  87547. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87548. */
  87549. readonly isFacetDataEnabled: boolean;
  87550. /** @hidden */
  87551. _updateNonUniformScalingState(value: boolean): boolean;
  87552. /**
  87553. * An event triggered when this mesh collides with another one
  87554. */
  87555. onCollideObservable: Observable<AbstractMesh>;
  87556. /** Set a function to call when this mesh collides with another one */
  87557. onCollide: () => void;
  87558. /**
  87559. * An event triggered when the collision's position changes
  87560. */
  87561. onCollisionPositionChangeObservable: Observable<Vector3>;
  87562. /** Set a function to call when the collision's position changes */
  87563. onCollisionPositionChange: () => void;
  87564. /**
  87565. * An event triggered when material is changed
  87566. */
  87567. onMaterialChangedObservable: Observable<AbstractMesh>;
  87568. /**
  87569. * Gets or sets the orientation for POV movement & rotation
  87570. */
  87571. definedFacingForward: boolean;
  87572. /** @hidden */
  87573. _occlusionQuery: Nullable<WebGLQuery>;
  87574. /** @hidden */
  87575. _renderingGroup: Nullable<RenderingGroup>;
  87576. /**
  87577. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87578. */
  87579. /**
  87580. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87581. */
  87582. visibility: number;
  87583. /** Gets or sets the alpha index used to sort transparent meshes
  87584. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  87585. */
  87586. alphaIndex: number;
  87587. /**
  87588. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  87589. */
  87590. isVisible: boolean;
  87591. /**
  87592. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  87593. */
  87594. isPickable: boolean;
  87595. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  87596. showSubMeshesBoundingBox: boolean;
  87597. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  87598. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  87599. */
  87600. isBlocker: boolean;
  87601. /**
  87602. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  87603. */
  87604. enablePointerMoveEvents: boolean;
  87605. /**
  87606. * Specifies the rendering group id for this mesh (0 by default)
  87607. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  87608. */
  87609. renderingGroupId: number;
  87610. private _material;
  87611. /** Gets or sets current material */
  87612. material: Nullable<Material>;
  87613. /**
  87614. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  87615. * @see http://doc.babylonjs.com/babylon101/shadows
  87616. */
  87617. receiveShadows: boolean;
  87618. /** Defines color to use when rendering outline */
  87619. outlineColor: Color3;
  87620. /** Define width to use when rendering outline */
  87621. outlineWidth: number;
  87622. /** Defines color to use when rendering overlay */
  87623. overlayColor: Color3;
  87624. /** Defines alpha to use when rendering overlay */
  87625. overlayAlpha: number;
  87626. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  87627. hasVertexAlpha: boolean;
  87628. /** 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) */
  87629. useVertexColors: boolean;
  87630. /**
  87631. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  87632. */
  87633. computeBonesUsingShaders: boolean;
  87634. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  87635. numBoneInfluencers: number;
  87636. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  87637. applyFog: boolean;
  87638. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  87639. useOctreeForRenderingSelection: boolean;
  87640. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  87641. useOctreeForPicking: boolean;
  87642. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  87643. useOctreeForCollisions: boolean;
  87644. /**
  87645. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  87646. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  87647. */
  87648. layerMask: number;
  87649. /**
  87650. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  87651. */
  87652. alwaysSelectAsActiveMesh: boolean;
  87653. /**
  87654. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  87655. */
  87656. doNotSyncBoundingInfo: boolean;
  87657. /**
  87658. * Gets or sets the current action manager
  87659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87660. */
  87661. actionManager: Nullable<AbstractActionManager>;
  87662. private _meshCollisionData;
  87663. /**
  87664. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  87665. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87666. */
  87667. ellipsoid: Vector3;
  87668. /**
  87669. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  87670. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87671. */
  87672. ellipsoidOffset: Vector3;
  87673. /**
  87674. * Gets or sets a collision mask used to mask collisions (default is -1).
  87675. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87676. */
  87677. collisionMask: number;
  87678. /**
  87679. * Gets or sets the current collision group mask (-1 by default).
  87680. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87681. */
  87682. collisionGroup: number;
  87683. /**
  87684. * Defines edge width used when edgesRenderer is enabled
  87685. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87686. */
  87687. edgesWidth: number;
  87688. /**
  87689. * Defines edge color used when edgesRenderer is enabled
  87690. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87691. */
  87692. edgesColor: Color4;
  87693. /** @hidden */
  87694. _edgesRenderer: Nullable<IEdgesRenderer>;
  87695. /** @hidden */
  87696. _masterMesh: Nullable<AbstractMesh>;
  87697. /** @hidden */
  87698. _boundingInfo: Nullable<BoundingInfo>;
  87699. /** @hidden */
  87700. _renderId: number;
  87701. /**
  87702. * Gets or sets the list of subMeshes
  87703. * @see http://doc.babylonjs.com/how_to/multi_materials
  87704. */
  87705. subMeshes: SubMesh[];
  87706. /** @hidden */
  87707. _intersectionsInProgress: AbstractMesh[];
  87708. /** @hidden */
  87709. _unIndexed: boolean;
  87710. /** @hidden */
  87711. _lightSources: Light[];
  87712. /** Gets the list of lights affecting that mesh */
  87713. readonly lightSources: Light[];
  87714. /** @hidden */
  87715. readonly _positions: Nullable<Vector3[]>;
  87716. /** @hidden */
  87717. _waitingData: {
  87718. lods: Nullable<any>;
  87719. actions: Nullable<any>;
  87720. freezeWorldMatrix: Nullable<boolean>;
  87721. };
  87722. /** @hidden */
  87723. _bonesTransformMatrices: Nullable<Float32Array>;
  87724. /**
  87725. * Gets or sets a skeleton to apply skining transformations
  87726. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87727. */
  87728. skeleton: Nullable<Skeleton>;
  87729. /**
  87730. * An event triggered when the mesh is rebuilt.
  87731. */
  87732. onRebuildObservable: Observable<AbstractMesh>;
  87733. /**
  87734. * Creates a new AbstractMesh
  87735. * @param name defines the name of the mesh
  87736. * @param scene defines the hosting scene
  87737. */
  87738. constructor(name: string, scene?: Nullable<Scene>);
  87739. /**
  87740. * Returns the string "AbstractMesh"
  87741. * @returns "AbstractMesh"
  87742. */
  87743. getClassName(): string;
  87744. /**
  87745. * Gets a string representation of the current mesh
  87746. * @param fullDetails defines a boolean indicating if full details must be included
  87747. * @returns a string representation of the current mesh
  87748. */
  87749. toString(fullDetails?: boolean): string;
  87750. /**
  87751. * @hidden
  87752. */
  87753. protected _getEffectiveParent(): Nullable<Node>;
  87754. /** @hidden */
  87755. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87756. /** @hidden */
  87757. _rebuild(): void;
  87758. /** @hidden */
  87759. _resyncLightSources(): void;
  87760. /** @hidden */
  87761. _resyncLighSource(light: Light): void;
  87762. /** @hidden */
  87763. _unBindEffect(): void;
  87764. /** @hidden */
  87765. _removeLightSource(light: Light): void;
  87766. private _markSubMeshesAsDirty;
  87767. /** @hidden */
  87768. _markSubMeshesAsLightDirty(): void;
  87769. /** @hidden */
  87770. _markSubMeshesAsAttributesDirty(): void;
  87771. /** @hidden */
  87772. _markSubMeshesAsMiscDirty(): void;
  87773. /**
  87774. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87775. */
  87776. scaling: Vector3;
  87777. /**
  87778. * Returns true if the mesh is blocked. Implemented by child classes
  87779. */
  87780. readonly isBlocked: boolean;
  87781. /**
  87782. * Returns the mesh itself by default. Implemented by child classes
  87783. * @param camera defines the camera to use to pick the right LOD level
  87784. * @returns the currentAbstractMesh
  87785. */
  87786. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87787. /**
  87788. * Returns 0 by default. Implemented by child classes
  87789. * @returns an integer
  87790. */
  87791. getTotalVertices(): number;
  87792. /**
  87793. * Returns a positive integer : the total number of indices in this mesh geometry.
  87794. * @returns the numner of indices or zero if the mesh has no geometry.
  87795. */
  87796. getTotalIndices(): number;
  87797. /**
  87798. * Returns null by default. Implemented by child classes
  87799. * @returns null
  87800. */
  87801. getIndices(): Nullable<IndicesArray>;
  87802. /**
  87803. * Returns the array of the requested vertex data kind. Implemented by child classes
  87804. * @param kind defines the vertex data kind to use
  87805. * @returns null
  87806. */
  87807. getVerticesData(kind: string): Nullable<FloatArray>;
  87808. /**
  87809. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87810. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87811. * Note that a new underlying VertexBuffer object is created each call.
  87812. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87813. * @param kind defines vertex data kind:
  87814. * * VertexBuffer.PositionKind
  87815. * * VertexBuffer.UVKind
  87816. * * VertexBuffer.UV2Kind
  87817. * * VertexBuffer.UV3Kind
  87818. * * VertexBuffer.UV4Kind
  87819. * * VertexBuffer.UV5Kind
  87820. * * VertexBuffer.UV6Kind
  87821. * * VertexBuffer.ColorKind
  87822. * * VertexBuffer.MatricesIndicesKind
  87823. * * VertexBuffer.MatricesIndicesExtraKind
  87824. * * VertexBuffer.MatricesWeightsKind
  87825. * * VertexBuffer.MatricesWeightsExtraKind
  87826. * @param data defines the data source
  87827. * @param updatable defines if the data must be flagged as updatable (or static)
  87828. * @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
  87829. * @returns the current mesh
  87830. */
  87831. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87832. /**
  87833. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87834. * If the mesh has no geometry, it is simply returned as it is.
  87835. * @param kind defines vertex data kind:
  87836. * * VertexBuffer.PositionKind
  87837. * * VertexBuffer.UVKind
  87838. * * VertexBuffer.UV2Kind
  87839. * * VertexBuffer.UV3Kind
  87840. * * VertexBuffer.UV4Kind
  87841. * * VertexBuffer.UV5Kind
  87842. * * VertexBuffer.UV6Kind
  87843. * * VertexBuffer.ColorKind
  87844. * * VertexBuffer.MatricesIndicesKind
  87845. * * VertexBuffer.MatricesIndicesExtraKind
  87846. * * VertexBuffer.MatricesWeightsKind
  87847. * * VertexBuffer.MatricesWeightsExtraKind
  87848. * @param data defines the data source
  87849. * @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
  87850. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87851. * @returns the current mesh
  87852. */
  87853. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87854. /**
  87855. * Sets the mesh indices,
  87856. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87857. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87858. * @param totalVertices Defines the total number of vertices
  87859. * @returns the current mesh
  87860. */
  87861. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87862. /**
  87863. * Gets a boolean indicating if specific vertex data is present
  87864. * @param kind defines the vertex data kind to use
  87865. * @returns true is data kind is present
  87866. */
  87867. isVerticesDataPresent(kind: string): boolean;
  87868. /**
  87869. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  87870. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  87871. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  87872. * @returns a BoundingInfo
  87873. */
  87874. getBoundingInfo(): BoundingInfo;
  87875. /**
  87876. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87877. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87878. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87879. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87880. * @returns the current mesh
  87881. */
  87882. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  87883. /**
  87884. * Overwrite the current bounding info
  87885. * @param boundingInfo defines the new bounding info
  87886. * @returns the current mesh
  87887. */
  87888. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87889. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87890. readonly useBones: boolean;
  87891. /** @hidden */
  87892. _preActivate(): void;
  87893. /** @hidden */
  87894. _preActivateForIntermediateRendering(renderId: number): void;
  87895. /** @hidden */
  87896. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87897. /** @hidden */
  87898. _postActivate(): void;
  87899. /** @hidden */
  87900. _freeze(): void;
  87901. /** @hidden */
  87902. _unFreeze(): void;
  87903. /**
  87904. * Gets the current world matrix
  87905. * @returns a Matrix
  87906. */
  87907. getWorldMatrix(): Matrix;
  87908. /** @hidden */
  87909. _getWorldMatrixDeterminant(): number;
  87910. /**
  87911. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87912. */
  87913. readonly isAnInstance: boolean;
  87914. /**
  87915. * Perform relative position change from the point of view of behind the front of the mesh.
  87916. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87917. * Supports definition of mesh facing forward or backward
  87918. * @param amountRight defines the distance on the right axis
  87919. * @param amountUp defines the distance on the up axis
  87920. * @param amountForward defines the distance on the forward axis
  87921. * @returns the current mesh
  87922. */
  87923. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87924. /**
  87925. * Calculate relative position change from the point of view of behind the front of the mesh.
  87926. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87927. * Supports definition of mesh facing forward or backward
  87928. * @param amountRight defines the distance on the right axis
  87929. * @param amountUp defines the distance on the up axis
  87930. * @param amountForward defines the distance on the forward axis
  87931. * @returns the new displacement vector
  87932. */
  87933. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  87934. /**
  87935. * Perform relative rotation change from the point of view of behind the front of the mesh.
  87936. * Supports definition of mesh facing forward or backward
  87937. * @param flipBack defines the flip
  87938. * @param twirlClockwise defines the twirl
  87939. * @param tiltRight defines the tilt
  87940. * @returns the current mesh
  87941. */
  87942. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  87943. /**
  87944. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  87945. * Supports definition of mesh facing forward or backward.
  87946. * @param flipBack defines the flip
  87947. * @param twirlClockwise defines the twirl
  87948. * @param tiltRight defines the tilt
  87949. * @returns the new rotation vector
  87950. */
  87951. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  87952. /**
  87953. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87954. * This means the mesh underlying bounding box and sphere are recomputed.
  87955. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87956. * @returns the current mesh
  87957. */
  87958. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  87959. /** @hidden */
  87960. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  87961. /** @hidden */
  87962. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  87963. /** @hidden */
  87964. _updateBoundingInfo(): AbstractMesh;
  87965. /** @hidden */
  87966. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  87967. /** @hidden */
  87968. protected _afterComputeWorldMatrix(): void;
  87969. /** @hidden */
  87970. readonly _effectiveMesh: AbstractMesh;
  87971. /**
  87972. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87973. * A mesh is in the frustum if its bounding box intersects the frustum
  87974. * @param frustumPlanes defines the frustum to test
  87975. * @returns true if the mesh is in the frustum planes
  87976. */
  87977. isInFrustum(frustumPlanes: Plane[]): boolean;
  87978. /**
  87979. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  87980. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  87981. * @param frustumPlanes defines the frustum to test
  87982. * @returns true if the mesh is completely in the frustum planes
  87983. */
  87984. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87985. /**
  87986. * True if the mesh intersects another mesh or a SolidParticle object
  87987. * @param mesh defines a target mesh or SolidParticle to test
  87988. * @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)
  87989. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  87990. * @returns true if there is an intersection
  87991. */
  87992. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  87993. /**
  87994. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  87995. * @param point defines the point to test
  87996. * @returns true if there is an intersection
  87997. */
  87998. intersectsPoint(point: Vector3): boolean;
  87999. /**
  88000. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  88001. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88002. */
  88003. checkCollisions: boolean;
  88004. /**
  88005. * Gets Collider object used to compute collisions (not physics)
  88006. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88007. */
  88008. readonly collider: Nullable<Collider>;
  88009. /**
  88010. * Move the mesh using collision engine
  88011. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88012. * @param displacement defines the requested displacement vector
  88013. * @returns the current mesh
  88014. */
  88015. moveWithCollisions(displacement: Vector3): AbstractMesh;
  88016. private _onCollisionPositionChange;
  88017. /** @hidden */
  88018. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  88019. /** @hidden */
  88020. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  88021. /** @hidden */
  88022. _checkCollision(collider: Collider): AbstractMesh;
  88023. /** @hidden */
  88024. _generatePointsArray(): boolean;
  88025. /**
  88026. * Checks if the passed Ray intersects with the mesh
  88027. * @param ray defines the ray to use
  88028. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  88029. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  88030. * @returns the picking info
  88031. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88032. */
  88033. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  88034. /**
  88035. * Clones the current mesh
  88036. * @param name defines the mesh name
  88037. * @param newParent defines the new mesh parent
  88038. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  88039. * @returns the new mesh
  88040. */
  88041. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88042. /**
  88043. * Disposes all the submeshes of the current meshnp
  88044. * @returns the current mesh
  88045. */
  88046. releaseSubMeshes(): AbstractMesh;
  88047. /**
  88048. * Releases resources associated with this abstract mesh.
  88049. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88050. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88051. */
  88052. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88053. /**
  88054. * Adds the passed mesh as a child to the current mesh
  88055. * @param mesh defines the child mesh
  88056. * @returns the current mesh
  88057. */
  88058. addChild(mesh: AbstractMesh): AbstractMesh;
  88059. /**
  88060. * Removes the passed mesh from the current mesh children list
  88061. * @param mesh defines the child mesh
  88062. * @returns the current mesh
  88063. */
  88064. removeChild(mesh: AbstractMesh): AbstractMesh;
  88065. /** @hidden */
  88066. private _initFacetData;
  88067. /**
  88068. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  88069. * This method can be called within the render loop.
  88070. * 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
  88071. * @returns the current mesh
  88072. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88073. */
  88074. updateFacetData(): AbstractMesh;
  88075. /**
  88076. * Returns the facetLocalNormals array.
  88077. * The normals are expressed in the mesh local spac
  88078. * @returns an array of Vector3
  88079. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88080. */
  88081. getFacetLocalNormals(): Vector3[];
  88082. /**
  88083. * Returns the facetLocalPositions array.
  88084. * The facet positions are expressed in the mesh local space
  88085. * @returns an array of Vector3
  88086. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88087. */
  88088. getFacetLocalPositions(): Vector3[];
  88089. /**
  88090. * Returns the facetLocalPartioning array
  88091. * @returns an array of array of numbers
  88092. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88093. */
  88094. getFacetLocalPartitioning(): number[][];
  88095. /**
  88096. * Returns the i-th facet position in the world system.
  88097. * This method allocates a new Vector3 per call
  88098. * @param i defines the facet index
  88099. * @returns a new Vector3
  88100. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88101. */
  88102. getFacetPosition(i: number): Vector3;
  88103. /**
  88104. * Sets the reference Vector3 with the i-th facet position in the world system
  88105. * @param i defines the facet index
  88106. * @param ref defines the target vector
  88107. * @returns the current mesh
  88108. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88109. */
  88110. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  88111. /**
  88112. * Returns the i-th facet normal in the world system.
  88113. * This method allocates a new Vector3 per call
  88114. * @param i defines the facet index
  88115. * @returns a new Vector3
  88116. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88117. */
  88118. getFacetNormal(i: number): Vector3;
  88119. /**
  88120. * Sets the reference Vector3 with the i-th facet normal in the world system
  88121. * @param i defines the facet index
  88122. * @param ref defines the target vector
  88123. * @returns the current mesh
  88124. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88125. */
  88126. getFacetNormalToRef(i: number, ref: Vector3): this;
  88127. /**
  88128. * 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)
  88129. * @param x defines x coordinate
  88130. * @param y defines y coordinate
  88131. * @param z defines z coordinate
  88132. * @returns the array of facet indexes
  88133. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88134. */
  88135. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  88136. /**
  88137. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  88138. * @param projected sets as the (x,y,z) world projection on the facet
  88139. * @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
  88140. * @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
  88141. * @param x defines x coordinate
  88142. * @param y defines y coordinate
  88143. * @param z defines z coordinate
  88144. * @returns the face index if found (or null instead)
  88145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88146. */
  88147. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  88148. /**
  88149. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  88150. * @param projected sets as the (x,y,z) local projection on the facet
  88151. * @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
  88152. * @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
  88153. * @param x defines x coordinate
  88154. * @param y defines y coordinate
  88155. * @param z defines z coordinate
  88156. * @returns the face index if found (or null instead)
  88157. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88158. */
  88159. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  88160. /**
  88161. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  88162. * @returns the parameters
  88163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88164. */
  88165. getFacetDataParameters(): any;
  88166. /**
  88167. * Disables the feature FacetData and frees the related memory
  88168. * @returns the current mesh
  88169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88170. */
  88171. disableFacetData(): AbstractMesh;
  88172. /**
  88173. * Updates the AbstractMesh indices array
  88174. * @param indices defines the data source
  88175. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88176. * @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)
  88177. * @returns the current mesh
  88178. */
  88179. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  88180. /**
  88181. * Creates new normals data for the mesh
  88182. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  88183. * @returns the current mesh
  88184. */
  88185. createNormals(updatable: boolean): AbstractMesh;
  88186. /**
  88187. * Align the mesh with a normal
  88188. * @param normal defines the normal to use
  88189. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  88190. * @returns the current mesh
  88191. */
  88192. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  88193. /** @hidden */
  88194. _checkOcclusionQuery(): boolean;
  88195. /**
  88196. * Disables the mesh edge rendering mode
  88197. * @returns the currentAbstractMesh
  88198. */
  88199. disableEdgesRendering(): AbstractMesh;
  88200. /**
  88201. * Enables the edge rendering mode on the mesh.
  88202. * This mode makes the mesh edges visible
  88203. * @param epsilon defines the maximal distance between two angles to detect a face
  88204. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88205. * @returns the currentAbstractMesh
  88206. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88207. */
  88208. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88209. }
  88210. }
  88211. declare module BABYLON {
  88212. /**
  88213. * Interface used to define ActionEvent
  88214. */
  88215. export interface IActionEvent {
  88216. /** The mesh or sprite that triggered the action */
  88217. source: any;
  88218. /** The X mouse cursor position at the time of the event */
  88219. pointerX: number;
  88220. /** The Y mouse cursor position at the time of the event */
  88221. pointerY: number;
  88222. /** The mesh that is currently pointed at (can be null) */
  88223. meshUnderPointer: Nullable<AbstractMesh>;
  88224. /** the original (browser) event that triggered the ActionEvent */
  88225. sourceEvent?: any;
  88226. /** additional data for the event */
  88227. additionalData?: any;
  88228. }
  88229. /**
  88230. * ActionEvent is the event being sent when an action is triggered.
  88231. */
  88232. export class ActionEvent implements IActionEvent {
  88233. /** The mesh or sprite that triggered the action */
  88234. source: any;
  88235. /** The X mouse cursor position at the time of the event */
  88236. pointerX: number;
  88237. /** The Y mouse cursor position at the time of the event */
  88238. pointerY: number;
  88239. /** The mesh that is currently pointed at (can be null) */
  88240. meshUnderPointer: Nullable<AbstractMesh>;
  88241. /** the original (browser) event that triggered the ActionEvent */
  88242. sourceEvent?: any;
  88243. /** additional data for the event */
  88244. additionalData?: any;
  88245. /**
  88246. * Creates a new ActionEvent
  88247. * @param source The mesh or sprite that triggered the action
  88248. * @param pointerX The X mouse cursor position at the time of the event
  88249. * @param pointerY The Y mouse cursor position at the time of the event
  88250. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  88251. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  88252. * @param additionalData additional data for the event
  88253. */
  88254. constructor(
  88255. /** The mesh or sprite that triggered the action */
  88256. source: any,
  88257. /** The X mouse cursor position at the time of the event */
  88258. pointerX: number,
  88259. /** The Y mouse cursor position at the time of the event */
  88260. pointerY: number,
  88261. /** The mesh that is currently pointed at (can be null) */
  88262. meshUnderPointer: Nullable<AbstractMesh>,
  88263. /** the original (browser) event that triggered the ActionEvent */
  88264. sourceEvent?: any,
  88265. /** additional data for the event */
  88266. additionalData?: any);
  88267. /**
  88268. * Helper function to auto-create an ActionEvent from a source mesh.
  88269. * @param source The source mesh that triggered the event
  88270. * @param evt The original (browser) event
  88271. * @param additionalData additional data for the event
  88272. * @returns the new ActionEvent
  88273. */
  88274. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  88275. /**
  88276. * Helper function to auto-create an ActionEvent from a source sprite
  88277. * @param source The source sprite that triggered the event
  88278. * @param scene Scene associated with the sprite
  88279. * @param evt The original (browser) event
  88280. * @param additionalData additional data for the event
  88281. * @returns the new ActionEvent
  88282. */
  88283. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  88284. /**
  88285. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  88286. * @param scene the scene where the event occurred
  88287. * @param evt The original (browser) event
  88288. * @returns the new ActionEvent
  88289. */
  88290. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  88291. /**
  88292. * Helper function to auto-create an ActionEvent from a primitive
  88293. * @param prim defines the target primitive
  88294. * @param pointerPos defines the pointer position
  88295. * @param evt The original (browser) event
  88296. * @param additionalData additional data for the event
  88297. * @returns the new ActionEvent
  88298. */
  88299. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  88300. }
  88301. }
  88302. declare module BABYLON {
  88303. /**
  88304. * Abstract class used to decouple action Manager from scene and meshes.
  88305. * Do not instantiate.
  88306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  88307. */
  88308. export abstract class AbstractActionManager implements IDisposable {
  88309. /** Gets the list of active triggers */
  88310. static Triggers: {
  88311. [key: string]: number;
  88312. };
  88313. /** Gets the cursor to use when hovering items */
  88314. hoverCursor: string;
  88315. /** Gets the list of actions */
  88316. actions: IAction[];
  88317. /**
  88318. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  88319. */
  88320. isRecursive: boolean;
  88321. /**
  88322. * Releases all associated resources
  88323. */
  88324. abstract dispose(): void;
  88325. /**
  88326. * Does this action manager has pointer triggers
  88327. */
  88328. abstract readonly hasPointerTriggers: boolean;
  88329. /**
  88330. * Does this action manager has pick triggers
  88331. */
  88332. abstract readonly hasPickTriggers: boolean;
  88333. /**
  88334. * Process a specific trigger
  88335. * @param trigger defines the trigger to process
  88336. * @param evt defines the event details to be processed
  88337. */
  88338. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  88339. /**
  88340. * Does this action manager handles actions of any of the given triggers
  88341. * @param triggers defines the triggers to be tested
  88342. * @return a boolean indicating whether one (or more) of the triggers is handled
  88343. */
  88344. abstract hasSpecificTriggers(triggers: number[]): boolean;
  88345. /**
  88346. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88347. * speed.
  88348. * @param triggerA defines the trigger to be tested
  88349. * @param triggerB defines the trigger to be tested
  88350. * @return a boolean indicating whether one (or more) of the triggers is handled
  88351. */
  88352. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88353. /**
  88354. * Does this action manager handles actions of a given trigger
  88355. * @param trigger defines the trigger to be tested
  88356. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88357. * @return whether the trigger is handled
  88358. */
  88359. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88360. /**
  88361. * Serialize this manager to a JSON object
  88362. * @param name defines the property name to store this manager
  88363. * @returns a JSON representation of this manager
  88364. */
  88365. abstract serialize(name: string): any;
  88366. /**
  88367. * Registers an action to this action manager
  88368. * @param action defines the action to be registered
  88369. * @return the action amended (prepared) after registration
  88370. */
  88371. abstract registerAction(action: IAction): Nullable<IAction>;
  88372. /**
  88373. * Unregisters an action to this action manager
  88374. * @param action defines the action to be unregistered
  88375. * @return a boolean indicating whether the action has been unregistered
  88376. */
  88377. abstract unregisterAction(action: IAction): Boolean;
  88378. /**
  88379. * Does exist one action manager with at least one trigger
  88380. **/
  88381. static readonly HasTriggers: boolean;
  88382. /**
  88383. * Does exist one action manager with at least one pick trigger
  88384. **/
  88385. static readonly HasPickTriggers: boolean;
  88386. /**
  88387. * Does exist one action manager that handles actions of a given trigger
  88388. * @param trigger defines the trigger to be tested
  88389. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  88390. **/
  88391. static HasSpecificTrigger(trigger: number): boolean;
  88392. }
  88393. }
  88394. declare module BABYLON {
  88395. /**
  88396. * Defines how a node can be built from a string name.
  88397. */
  88398. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  88399. /**
  88400. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  88401. */
  88402. export class Node implements IBehaviorAware<Node> {
  88403. /** @hidden */
  88404. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  88405. private static _NodeConstructors;
  88406. /**
  88407. * Add a new node constructor
  88408. * @param type defines the type name of the node to construct
  88409. * @param constructorFunc defines the constructor function
  88410. */
  88411. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  88412. /**
  88413. * Returns a node constructor based on type name
  88414. * @param type defines the type name
  88415. * @param name defines the new node name
  88416. * @param scene defines the hosting scene
  88417. * @param options defines optional options to transmit to constructors
  88418. * @returns the new constructor or null
  88419. */
  88420. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  88421. /**
  88422. * Gets or sets the name of the node
  88423. */
  88424. name: string;
  88425. /**
  88426. * Gets or sets the id of the node
  88427. */
  88428. id: string;
  88429. /**
  88430. * Gets or sets the unique id of the node
  88431. */
  88432. uniqueId: number;
  88433. /**
  88434. * Gets or sets a string used to store user defined state for the node
  88435. */
  88436. state: string;
  88437. /**
  88438. * Gets or sets an object used to store user defined information for the node
  88439. */
  88440. metadata: any;
  88441. /**
  88442. * For internal use only. Please do not use.
  88443. */
  88444. reservedDataStore: any;
  88445. /**
  88446. * List of inspectable custom properties (used by the Inspector)
  88447. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88448. */
  88449. inspectableCustomProperties: IInspectable[];
  88450. /**
  88451. * Gets or sets a boolean used to define if the node must be serialized
  88452. */
  88453. doNotSerialize: boolean;
  88454. /** @hidden */
  88455. _isDisposed: boolean;
  88456. /**
  88457. * Gets a list of Animations associated with the node
  88458. */
  88459. animations: Animation[];
  88460. protected _ranges: {
  88461. [name: string]: Nullable<AnimationRange>;
  88462. };
  88463. /**
  88464. * Callback raised when the node is ready to be used
  88465. */
  88466. onReady: Nullable<(node: Node) => void>;
  88467. private _isEnabled;
  88468. private _isParentEnabled;
  88469. private _isReady;
  88470. /** @hidden */
  88471. _currentRenderId: number;
  88472. private _parentUpdateId;
  88473. /** @hidden */
  88474. _childUpdateId: number;
  88475. /** @hidden */
  88476. _waitingParentId: Nullable<string>;
  88477. /** @hidden */
  88478. _scene: Scene;
  88479. /** @hidden */
  88480. _cache: any;
  88481. private _parentNode;
  88482. private _children;
  88483. /** @hidden */
  88484. _worldMatrix: Matrix;
  88485. /** @hidden */
  88486. _worldMatrixDeterminant: number;
  88487. /** @hidden */
  88488. _worldMatrixDeterminantIsDirty: boolean;
  88489. /** @hidden */
  88490. private _sceneRootNodesIndex;
  88491. /**
  88492. * Gets a boolean indicating if the node has been disposed
  88493. * @returns true if the node was disposed
  88494. */
  88495. isDisposed(): boolean;
  88496. /**
  88497. * Gets or sets the parent of the node (without keeping the current position in the scene)
  88498. * @see https://doc.babylonjs.com/how_to/parenting
  88499. */
  88500. parent: Nullable<Node>;
  88501. private addToSceneRootNodes;
  88502. private removeFromSceneRootNodes;
  88503. private _animationPropertiesOverride;
  88504. /**
  88505. * Gets or sets the animation properties override
  88506. */
  88507. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88508. /**
  88509. * Gets a string idenfifying the name of the class
  88510. * @returns "Node" string
  88511. */
  88512. getClassName(): string;
  88513. /** @hidden */
  88514. readonly _isNode: boolean;
  88515. /**
  88516. * An event triggered when the mesh is disposed
  88517. */
  88518. onDisposeObservable: Observable<Node>;
  88519. private _onDisposeObserver;
  88520. /**
  88521. * Sets a callback that will be raised when the node will be disposed
  88522. */
  88523. onDispose: () => void;
  88524. /**
  88525. * Creates a new Node
  88526. * @param name the name and id to be given to this node
  88527. * @param scene the scene this node will be added to
  88528. * @param addToRootNodes the node will be added to scene.rootNodes
  88529. */
  88530. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  88531. /**
  88532. * Gets the scene of the node
  88533. * @returns a scene
  88534. */
  88535. getScene(): Scene;
  88536. /**
  88537. * Gets the engine of the node
  88538. * @returns a Engine
  88539. */
  88540. getEngine(): Engine;
  88541. private _behaviors;
  88542. /**
  88543. * Attach a behavior to the node
  88544. * @see http://doc.babylonjs.com/features/behaviour
  88545. * @param behavior defines the behavior to attach
  88546. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  88547. * @returns the current Node
  88548. */
  88549. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  88550. /**
  88551. * Remove an attached behavior
  88552. * @see http://doc.babylonjs.com/features/behaviour
  88553. * @param behavior defines the behavior to attach
  88554. * @returns the current Node
  88555. */
  88556. removeBehavior(behavior: Behavior<Node>): Node;
  88557. /**
  88558. * Gets the list of attached behaviors
  88559. * @see http://doc.babylonjs.com/features/behaviour
  88560. */
  88561. readonly behaviors: Behavior<Node>[];
  88562. /**
  88563. * Gets an attached behavior by name
  88564. * @param name defines the name of the behavior to look for
  88565. * @see http://doc.babylonjs.com/features/behaviour
  88566. * @returns null if behavior was not found else the requested behavior
  88567. */
  88568. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  88569. /**
  88570. * Returns the latest update of the World matrix
  88571. * @returns a Matrix
  88572. */
  88573. getWorldMatrix(): Matrix;
  88574. /** @hidden */
  88575. _getWorldMatrixDeterminant(): number;
  88576. /**
  88577. * Returns directly the latest state of the mesh World matrix.
  88578. * A Matrix is returned.
  88579. */
  88580. readonly worldMatrixFromCache: Matrix;
  88581. /** @hidden */
  88582. _initCache(): void;
  88583. /** @hidden */
  88584. updateCache(force?: boolean): void;
  88585. /** @hidden */
  88586. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  88587. /** @hidden */
  88588. _updateCache(ignoreParentClass?: boolean): void;
  88589. /** @hidden */
  88590. _isSynchronized(): boolean;
  88591. /** @hidden */
  88592. _markSyncedWithParent(): void;
  88593. /** @hidden */
  88594. isSynchronizedWithParent(): boolean;
  88595. /** @hidden */
  88596. isSynchronized(): boolean;
  88597. /**
  88598. * Is this node ready to be used/rendered
  88599. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88600. * @return true if the node is ready
  88601. */
  88602. isReady(completeCheck?: boolean): boolean;
  88603. /**
  88604. * Is this node enabled?
  88605. * 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
  88606. * @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
  88607. * @return whether this node (and its parent) is enabled
  88608. */
  88609. isEnabled(checkAncestors?: boolean): boolean;
  88610. /** @hidden */
  88611. protected _syncParentEnabledState(): void;
  88612. /**
  88613. * Set the enabled state of this node
  88614. * @param value defines the new enabled state
  88615. */
  88616. setEnabled(value: boolean): void;
  88617. /**
  88618. * Is this node a descendant of the given node?
  88619. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  88620. * @param ancestor defines the parent node to inspect
  88621. * @returns a boolean indicating if this node is a descendant of the given node
  88622. */
  88623. isDescendantOf(ancestor: Node): boolean;
  88624. /** @hidden */
  88625. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  88626. /**
  88627. * Will return all nodes that have this node as ascendant
  88628. * @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
  88629. * @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
  88630. * @return all children nodes of all types
  88631. */
  88632. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  88633. /**
  88634. * Get all child-meshes of this node
  88635. * @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)
  88636. * @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
  88637. * @returns an array of AbstractMesh
  88638. */
  88639. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  88640. /**
  88641. * Get all direct children of this node
  88642. * @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
  88643. * @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)
  88644. * @returns an array of Node
  88645. */
  88646. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  88647. /** @hidden */
  88648. _setReady(state: boolean): void;
  88649. /**
  88650. * Get an animation by name
  88651. * @param name defines the name of the animation to look for
  88652. * @returns null if not found else the requested animation
  88653. */
  88654. getAnimationByName(name: string): Nullable<Animation>;
  88655. /**
  88656. * Creates an animation range for this node
  88657. * @param name defines the name of the range
  88658. * @param from defines the starting key
  88659. * @param to defines the end key
  88660. */
  88661. createAnimationRange(name: string, from: number, to: number): void;
  88662. /**
  88663. * Delete a specific animation range
  88664. * @param name defines the name of the range to delete
  88665. * @param deleteFrames defines if animation frames from the range must be deleted as well
  88666. */
  88667. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88668. /**
  88669. * Get an animation range by name
  88670. * @param name defines the name of the animation range to look for
  88671. * @returns null if not found else the requested animation range
  88672. */
  88673. getAnimationRange(name: string): Nullable<AnimationRange>;
  88674. /**
  88675. * Gets the list of all animation ranges defined on this node
  88676. * @returns an array
  88677. */
  88678. getAnimationRanges(): Nullable<AnimationRange>[];
  88679. /**
  88680. * Will start the animation sequence
  88681. * @param name defines the range frames for animation sequence
  88682. * @param loop defines if the animation should loop (false by default)
  88683. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  88684. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  88685. * @returns the object created for this animation. If range does not exist, it will return null
  88686. */
  88687. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88688. /**
  88689. * Serialize animation ranges into a JSON compatible object
  88690. * @returns serialization object
  88691. */
  88692. serializeAnimationRanges(): any;
  88693. /**
  88694. * Computes the world matrix of the node
  88695. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88696. * @returns the world matrix
  88697. */
  88698. computeWorldMatrix(force?: boolean): Matrix;
  88699. /**
  88700. * Releases resources associated with this node.
  88701. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88702. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88703. */
  88704. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88705. /**
  88706. * Parse animation range data from a serialization object and store them into a given node
  88707. * @param node defines where to store the animation ranges
  88708. * @param parsedNode defines the serialization object to read data from
  88709. * @param scene defines the hosting scene
  88710. */
  88711. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88712. /**
  88713. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88714. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88715. * @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
  88716. * @returns the new bounding vectors
  88717. */
  88718. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88719. min: Vector3;
  88720. max: Vector3;
  88721. };
  88722. }
  88723. }
  88724. declare module BABYLON {
  88725. /**
  88726. * @hidden
  88727. */
  88728. export class _IAnimationState {
  88729. key: number;
  88730. repeatCount: number;
  88731. workValue?: any;
  88732. loopMode?: number;
  88733. offsetValue?: any;
  88734. highLimitValue?: any;
  88735. }
  88736. /**
  88737. * Class used to store any kind of animation
  88738. */
  88739. export class Animation {
  88740. /**Name of the animation */
  88741. name: string;
  88742. /**Property to animate */
  88743. targetProperty: string;
  88744. /**The frames per second of the animation */
  88745. framePerSecond: number;
  88746. /**The data type of the animation */
  88747. dataType: number;
  88748. /**The loop mode of the animation */
  88749. loopMode?: number | undefined;
  88750. /**Specifies if blending should be enabled */
  88751. enableBlending?: boolean | undefined;
  88752. /**
  88753. * Use matrix interpolation instead of using direct key value when animating matrices
  88754. */
  88755. static AllowMatricesInterpolation: boolean;
  88756. /**
  88757. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88758. */
  88759. static AllowMatrixDecomposeForInterpolation: boolean;
  88760. /**
  88761. * Stores the key frames of the animation
  88762. */
  88763. private _keys;
  88764. /**
  88765. * Stores the easing function of the animation
  88766. */
  88767. private _easingFunction;
  88768. /**
  88769. * @hidden Internal use only
  88770. */
  88771. _runtimeAnimations: RuntimeAnimation[];
  88772. /**
  88773. * The set of event that will be linked to this animation
  88774. */
  88775. private _events;
  88776. /**
  88777. * Stores an array of target property paths
  88778. */
  88779. targetPropertyPath: string[];
  88780. /**
  88781. * Stores the blending speed of the animation
  88782. */
  88783. blendingSpeed: number;
  88784. /**
  88785. * Stores the animation ranges for the animation
  88786. */
  88787. private _ranges;
  88788. /**
  88789. * @hidden Internal use
  88790. */
  88791. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88792. /**
  88793. * Sets up an animation
  88794. * @param property The property to animate
  88795. * @param animationType The animation type to apply
  88796. * @param framePerSecond The frames per second of the animation
  88797. * @param easingFunction The easing function used in the animation
  88798. * @returns The created animation
  88799. */
  88800. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88801. /**
  88802. * Create and start an animation on a node
  88803. * @param name defines the name of the global animation that will be run on all nodes
  88804. * @param node defines the root node where the animation will take place
  88805. * @param targetProperty defines property to animate
  88806. * @param framePerSecond defines the number of frame per second yo use
  88807. * @param totalFrame defines the number of frames in total
  88808. * @param from defines the initial value
  88809. * @param to defines the final value
  88810. * @param loopMode defines which loop mode you want to use (off by default)
  88811. * @param easingFunction defines the easing function to use (linear by default)
  88812. * @param onAnimationEnd defines the callback to call when animation end
  88813. * @returns the animatable created for this animation
  88814. */
  88815. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88816. /**
  88817. * Create and start an animation on a node and its descendants
  88818. * @param name defines the name of the global animation that will be run on all nodes
  88819. * @param node defines the root node where the animation will take place
  88820. * @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
  88821. * @param targetProperty defines property to animate
  88822. * @param framePerSecond defines the number of frame per second to use
  88823. * @param totalFrame defines the number of frames in total
  88824. * @param from defines the initial value
  88825. * @param to defines the final value
  88826. * @param loopMode defines which loop mode you want to use (off by default)
  88827. * @param easingFunction defines the easing function to use (linear by default)
  88828. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88829. * @returns the list of animatables created for all nodes
  88830. * @example https://www.babylonjs-playground.com/#MH0VLI
  88831. */
  88832. 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[]>;
  88833. /**
  88834. * Creates a new animation, merges it with the existing animations and starts it
  88835. * @param name Name of the animation
  88836. * @param node Node which contains the scene that begins the animations
  88837. * @param targetProperty Specifies which property to animate
  88838. * @param framePerSecond The frames per second of the animation
  88839. * @param totalFrame The total number of frames
  88840. * @param from The frame at the beginning of the animation
  88841. * @param to The frame at the end of the animation
  88842. * @param loopMode Specifies the loop mode of the animation
  88843. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88844. * @param onAnimationEnd Callback to run once the animation is complete
  88845. * @returns Nullable animation
  88846. */
  88847. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88848. /**
  88849. * Transition property of an host to the target Value
  88850. * @param property The property to transition
  88851. * @param targetValue The target Value of the property
  88852. * @param host The object where the property to animate belongs
  88853. * @param scene Scene used to run the animation
  88854. * @param frameRate Framerate (in frame/s) to use
  88855. * @param transition The transition type we want to use
  88856. * @param duration The duration of the animation, in milliseconds
  88857. * @param onAnimationEnd Callback trigger at the end of the animation
  88858. * @returns Nullable animation
  88859. */
  88860. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88861. /**
  88862. * Return the array of runtime animations currently using this animation
  88863. */
  88864. readonly runtimeAnimations: RuntimeAnimation[];
  88865. /**
  88866. * Specifies if any of the runtime animations are currently running
  88867. */
  88868. readonly hasRunningRuntimeAnimations: boolean;
  88869. /**
  88870. * Initializes the animation
  88871. * @param name Name of the animation
  88872. * @param targetProperty Property to animate
  88873. * @param framePerSecond The frames per second of the animation
  88874. * @param dataType The data type of the animation
  88875. * @param loopMode The loop mode of the animation
  88876. * @param enableBlending Specifies if blending should be enabled
  88877. */
  88878. constructor(
  88879. /**Name of the animation */
  88880. name: string,
  88881. /**Property to animate */
  88882. targetProperty: string,
  88883. /**The frames per second of the animation */
  88884. framePerSecond: number,
  88885. /**The data type of the animation */
  88886. dataType: number,
  88887. /**The loop mode of the animation */
  88888. loopMode?: number | undefined,
  88889. /**Specifies if blending should be enabled */
  88890. enableBlending?: boolean | undefined);
  88891. /**
  88892. * Converts the animation to a string
  88893. * @param fullDetails support for multiple levels of logging within scene loading
  88894. * @returns String form of the animation
  88895. */
  88896. toString(fullDetails?: boolean): string;
  88897. /**
  88898. * Add an event to this animation
  88899. * @param event Event to add
  88900. */
  88901. addEvent(event: AnimationEvent): void;
  88902. /**
  88903. * Remove all events found at the given frame
  88904. * @param frame The frame to remove events from
  88905. */
  88906. removeEvents(frame: number): void;
  88907. /**
  88908. * Retrieves all the events from the animation
  88909. * @returns Events from the animation
  88910. */
  88911. getEvents(): AnimationEvent[];
  88912. /**
  88913. * Creates an animation range
  88914. * @param name Name of the animation range
  88915. * @param from Starting frame of the animation range
  88916. * @param to Ending frame of the animation
  88917. */
  88918. createRange(name: string, from: number, to: number): void;
  88919. /**
  88920. * Deletes an animation range by name
  88921. * @param name Name of the animation range to delete
  88922. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88923. */
  88924. deleteRange(name: string, deleteFrames?: boolean): void;
  88925. /**
  88926. * Gets the animation range by name, or null if not defined
  88927. * @param name Name of the animation range
  88928. * @returns Nullable animation range
  88929. */
  88930. getRange(name: string): Nullable<AnimationRange>;
  88931. /**
  88932. * Gets the key frames from the animation
  88933. * @returns The key frames of the animation
  88934. */
  88935. getKeys(): Array<IAnimationKey>;
  88936. /**
  88937. * Gets the highest frame rate of the animation
  88938. * @returns Highest frame rate of the animation
  88939. */
  88940. getHighestFrame(): number;
  88941. /**
  88942. * Gets the easing function of the animation
  88943. * @returns Easing function of the animation
  88944. */
  88945. getEasingFunction(): IEasingFunction;
  88946. /**
  88947. * Sets the easing function of the animation
  88948. * @param easingFunction A custom mathematical formula for animation
  88949. */
  88950. setEasingFunction(easingFunction: EasingFunction): void;
  88951. /**
  88952. * Interpolates a scalar linearly
  88953. * @param startValue Start value of the animation curve
  88954. * @param endValue End value of the animation curve
  88955. * @param gradient Scalar amount to interpolate
  88956. * @returns Interpolated scalar value
  88957. */
  88958. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  88959. /**
  88960. * Interpolates a scalar cubically
  88961. * @param startValue Start value of the animation curve
  88962. * @param outTangent End tangent of the animation
  88963. * @param endValue End value of the animation curve
  88964. * @param inTangent Start tangent of the animation curve
  88965. * @param gradient Scalar amount to interpolate
  88966. * @returns Interpolated scalar value
  88967. */
  88968. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  88969. /**
  88970. * Interpolates a quaternion using a spherical linear interpolation
  88971. * @param startValue Start value of the animation curve
  88972. * @param endValue End value of the animation curve
  88973. * @param gradient Scalar amount to interpolate
  88974. * @returns Interpolated quaternion value
  88975. */
  88976. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  88977. /**
  88978. * Interpolates a quaternion cubically
  88979. * @param startValue Start value of the animation curve
  88980. * @param outTangent End tangent of the animation curve
  88981. * @param endValue End value of the animation curve
  88982. * @param inTangent Start tangent of the animation curve
  88983. * @param gradient Scalar amount to interpolate
  88984. * @returns Interpolated quaternion value
  88985. */
  88986. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  88987. /**
  88988. * Interpolates a Vector3 linearl
  88989. * @param startValue Start value of the animation curve
  88990. * @param endValue End value of the animation curve
  88991. * @param gradient Scalar amount to interpolate
  88992. * @returns Interpolated scalar value
  88993. */
  88994. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  88995. /**
  88996. * Interpolates a Vector3 cubically
  88997. * @param startValue Start value of the animation curve
  88998. * @param outTangent End tangent of the animation
  88999. * @param endValue End value of the animation curve
  89000. * @param inTangent Start tangent of the animation curve
  89001. * @param gradient Scalar amount to interpolate
  89002. * @returns InterpolatedVector3 value
  89003. */
  89004. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  89005. /**
  89006. * Interpolates a Vector2 linearly
  89007. * @param startValue Start value of the animation curve
  89008. * @param endValue End value of the animation curve
  89009. * @param gradient Scalar amount to interpolate
  89010. * @returns Interpolated Vector2 value
  89011. */
  89012. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  89013. /**
  89014. * Interpolates a Vector2 cubically
  89015. * @param startValue Start value of the animation curve
  89016. * @param outTangent End tangent of the animation
  89017. * @param endValue End value of the animation curve
  89018. * @param inTangent Start tangent of the animation curve
  89019. * @param gradient Scalar amount to interpolate
  89020. * @returns Interpolated Vector2 value
  89021. */
  89022. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  89023. /**
  89024. * Interpolates a size linearly
  89025. * @param startValue Start value of the animation curve
  89026. * @param endValue End value of the animation curve
  89027. * @param gradient Scalar amount to interpolate
  89028. * @returns Interpolated Size value
  89029. */
  89030. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  89031. /**
  89032. * Interpolates a Color3 linearly
  89033. * @param startValue Start value of the animation curve
  89034. * @param endValue End value of the animation curve
  89035. * @param gradient Scalar amount to interpolate
  89036. * @returns Interpolated Color3 value
  89037. */
  89038. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  89039. /**
  89040. * @hidden Internal use only
  89041. */
  89042. _getKeyValue(value: any): any;
  89043. /**
  89044. * @hidden Internal use only
  89045. */
  89046. _interpolate(currentFrame: number, state: _IAnimationState): any;
  89047. /**
  89048. * Defines the function to use to interpolate matrices
  89049. * @param startValue defines the start matrix
  89050. * @param endValue defines the end matrix
  89051. * @param gradient defines the gradient between both matrices
  89052. * @param result defines an optional target matrix where to store the interpolation
  89053. * @returns the interpolated matrix
  89054. */
  89055. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  89056. /**
  89057. * Makes a copy of the animation
  89058. * @returns Cloned animation
  89059. */
  89060. clone(): Animation;
  89061. /**
  89062. * Sets the key frames of the animation
  89063. * @param values The animation key frames to set
  89064. */
  89065. setKeys(values: Array<IAnimationKey>): void;
  89066. /**
  89067. * Serializes the animation to an object
  89068. * @returns Serialized object
  89069. */
  89070. serialize(): any;
  89071. /**
  89072. * Float animation type
  89073. */
  89074. private static _ANIMATIONTYPE_FLOAT;
  89075. /**
  89076. * Vector3 animation type
  89077. */
  89078. private static _ANIMATIONTYPE_VECTOR3;
  89079. /**
  89080. * Quaternion animation type
  89081. */
  89082. private static _ANIMATIONTYPE_QUATERNION;
  89083. /**
  89084. * Matrix animation type
  89085. */
  89086. private static _ANIMATIONTYPE_MATRIX;
  89087. /**
  89088. * Color3 animation type
  89089. */
  89090. private static _ANIMATIONTYPE_COLOR3;
  89091. /**
  89092. * Vector2 animation type
  89093. */
  89094. private static _ANIMATIONTYPE_VECTOR2;
  89095. /**
  89096. * Size animation type
  89097. */
  89098. private static _ANIMATIONTYPE_SIZE;
  89099. /**
  89100. * Relative Loop Mode
  89101. */
  89102. private static _ANIMATIONLOOPMODE_RELATIVE;
  89103. /**
  89104. * Cycle Loop Mode
  89105. */
  89106. private static _ANIMATIONLOOPMODE_CYCLE;
  89107. /**
  89108. * Constant Loop Mode
  89109. */
  89110. private static _ANIMATIONLOOPMODE_CONSTANT;
  89111. /**
  89112. * Get the float animation type
  89113. */
  89114. static readonly ANIMATIONTYPE_FLOAT: number;
  89115. /**
  89116. * Get the Vector3 animation type
  89117. */
  89118. static readonly ANIMATIONTYPE_VECTOR3: number;
  89119. /**
  89120. * Get the Vector2 animation type
  89121. */
  89122. static readonly ANIMATIONTYPE_VECTOR2: number;
  89123. /**
  89124. * Get the Size animation type
  89125. */
  89126. static readonly ANIMATIONTYPE_SIZE: number;
  89127. /**
  89128. * Get the Quaternion animation type
  89129. */
  89130. static readonly ANIMATIONTYPE_QUATERNION: number;
  89131. /**
  89132. * Get the Matrix animation type
  89133. */
  89134. static readonly ANIMATIONTYPE_MATRIX: number;
  89135. /**
  89136. * Get the Color3 animation type
  89137. */
  89138. static readonly ANIMATIONTYPE_COLOR3: number;
  89139. /**
  89140. * Get the Relative Loop Mode
  89141. */
  89142. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  89143. /**
  89144. * Get the Cycle Loop Mode
  89145. */
  89146. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  89147. /**
  89148. * Get the Constant Loop Mode
  89149. */
  89150. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  89151. /** @hidden */
  89152. static _UniversalLerp(left: any, right: any, amount: number): any;
  89153. /**
  89154. * Parses an animation object and creates an animation
  89155. * @param parsedAnimation Parsed animation object
  89156. * @returns Animation object
  89157. */
  89158. static Parse(parsedAnimation: any): Animation;
  89159. /**
  89160. * Appends the serialized animations from the source animations
  89161. * @param source Source containing the animations
  89162. * @param destination Target to store the animations
  89163. */
  89164. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89165. }
  89166. }
  89167. declare module BABYLON {
  89168. /**
  89169. * Base class of all the textures in babylon.
  89170. * It groups all the common properties the materials, post process, lights... might need
  89171. * in order to make a correct use of the texture.
  89172. */
  89173. export class BaseTexture implements IAnimatable {
  89174. /**
  89175. * Default anisotropic filtering level for the application.
  89176. * It is set to 4 as a good tradeoff between perf and quality.
  89177. */
  89178. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  89179. /**
  89180. * Gets or sets the unique id of the texture
  89181. */
  89182. uniqueId: number;
  89183. /**
  89184. * Define the name of the texture.
  89185. */
  89186. name: string;
  89187. /**
  89188. * Gets or sets an object used to store user defined information.
  89189. */
  89190. metadata: any;
  89191. /**
  89192. * For internal use only. Please do not use.
  89193. */
  89194. reservedDataStore: any;
  89195. private _hasAlpha;
  89196. /**
  89197. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  89198. */
  89199. hasAlpha: boolean;
  89200. /**
  89201. * Defines if the alpha value should be determined via the rgb values.
  89202. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  89203. */
  89204. getAlphaFromRGB: boolean;
  89205. /**
  89206. * Intensity or strength of the texture.
  89207. * It is commonly used by materials to fine tune the intensity of the texture
  89208. */
  89209. level: number;
  89210. /**
  89211. * Define the UV chanel to use starting from 0 and defaulting to 0.
  89212. * This is part of the texture as textures usually maps to one uv set.
  89213. */
  89214. coordinatesIndex: number;
  89215. private _coordinatesMode;
  89216. /**
  89217. * How a texture is mapped.
  89218. *
  89219. * | Value | Type | Description |
  89220. * | ----- | ----------------------------------- | ----------- |
  89221. * | 0 | EXPLICIT_MODE | |
  89222. * | 1 | SPHERICAL_MODE | |
  89223. * | 2 | PLANAR_MODE | |
  89224. * | 3 | CUBIC_MODE | |
  89225. * | 4 | PROJECTION_MODE | |
  89226. * | 5 | SKYBOX_MODE | |
  89227. * | 6 | INVCUBIC_MODE | |
  89228. * | 7 | EQUIRECTANGULAR_MODE | |
  89229. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  89230. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  89231. */
  89232. coordinatesMode: number;
  89233. /**
  89234. * | Value | Type | Description |
  89235. * | ----- | ------------------ | ----------- |
  89236. * | 0 | CLAMP_ADDRESSMODE | |
  89237. * | 1 | WRAP_ADDRESSMODE | |
  89238. * | 2 | MIRROR_ADDRESSMODE | |
  89239. */
  89240. wrapU: number;
  89241. /**
  89242. * | Value | Type | Description |
  89243. * | ----- | ------------------ | ----------- |
  89244. * | 0 | CLAMP_ADDRESSMODE | |
  89245. * | 1 | WRAP_ADDRESSMODE | |
  89246. * | 2 | MIRROR_ADDRESSMODE | |
  89247. */
  89248. wrapV: number;
  89249. /**
  89250. * | Value | Type | Description |
  89251. * | ----- | ------------------ | ----------- |
  89252. * | 0 | CLAMP_ADDRESSMODE | |
  89253. * | 1 | WRAP_ADDRESSMODE | |
  89254. * | 2 | MIRROR_ADDRESSMODE | |
  89255. */
  89256. wrapR: number;
  89257. /**
  89258. * With compliant hardware and browser (supporting anisotropic filtering)
  89259. * this defines the level of anisotropic filtering in the texture.
  89260. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  89261. */
  89262. anisotropicFilteringLevel: number;
  89263. /**
  89264. * Define if the texture is a cube texture or if false a 2d texture.
  89265. */
  89266. isCube: boolean;
  89267. /**
  89268. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  89269. */
  89270. is3D: boolean;
  89271. /**
  89272. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  89273. * HDR texture are usually stored in linear space.
  89274. * This only impacts the PBR and Background materials
  89275. */
  89276. gammaSpace: boolean;
  89277. /**
  89278. * Gets whether or not the texture contains RGBD data.
  89279. */
  89280. readonly isRGBD: boolean;
  89281. /**
  89282. * Is Z inverted in the texture (useful in a cube texture).
  89283. */
  89284. invertZ: boolean;
  89285. /**
  89286. * Are mip maps generated for this texture or not.
  89287. */
  89288. readonly noMipmap: boolean;
  89289. /**
  89290. * @hidden
  89291. */
  89292. lodLevelInAlpha: boolean;
  89293. /**
  89294. * With prefiltered texture, defined the offset used during the prefiltering steps.
  89295. */
  89296. lodGenerationOffset: number;
  89297. /**
  89298. * With prefiltered texture, defined the scale used during the prefiltering steps.
  89299. */
  89300. lodGenerationScale: number;
  89301. /**
  89302. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  89303. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  89304. * average roughness values.
  89305. */
  89306. linearSpecularLOD: boolean;
  89307. /**
  89308. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  89309. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  89310. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  89311. */
  89312. irradianceTexture: Nullable<BaseTexture>;
  89313. /**
  89314. * Define if the texture is a render target.
  89315. */
  89316. isRenderTarget: boolean;
  89317. /**
  89318. * Define the unique id of the texture in the scene.
  89319. */
  89320. readonly uid: string;
  89321. /**
  89322. * Return a string representation of the texture.
  89323. * @returns the texture as a string
  89324. */
  89325. toString(): string;
  89326. /**
  89327. * Get the class name of the texture.
  89328. * @returns "BaseTexture"
  89329. */
  89330. getClassName(): string;
  89331. /**
  89332. * Define the list of animation attached to the texture.
  89333. */
  89334. animations: Animation[];
  89335. /**
  89336. * An event triggered when the texture is disposed.
  89337. */
  89338. onDisposeObservable: Observable<BaseTexture>;
  89339. private _onDisposeObserver;
  89340. /**
  89341. * Callback triggered when the texture has been disposed.
  89342. * Kept for back compatibility, you can use the onDisposeObservable instead.
  89343. */
  89344. onDispose: () => void;
  89345. /**
  89346. * Define the current state of the loading sequence when in delayed load mode.
  89347. */
  89348. delayLoadState: number;
  89349. private _scene;
  89350. /** @hidden */
  89351. _texture: Nullable<InternalTexture>;
  89352. private _uid;
  89353. /**
  89354. * Define if the texture is preventinga material to render or not.
  89355. * If not and the texture is not ready, the engine will use a default black texture instead.
  89356. */
  89357. readonly isBlocking: boolean;
  89358. /**
  89359. * Instantiates a new BaseTexture.
  89360. * Base class of all the textures in babylon.
  89361. * It groups all the common properties the materials, post process, lights... might need
  89362. * in order to make a correct use of the texture.
  89363. * @param scene Define the scene the texture blongs to
  89364. */
  89365. constructor(scene: Nullable<Scene>);
  89366. /**
  89367. * Get the scene the texture belongs to.
  89368. * @returns the scene or null if undefined
  89369. */
  89370. getScene(): Nullable<Scene>;
  89371. /**
  89372. * Get the texture transform matrix used to offset tile the texture for istance.
  89373. * @returns the transformation matrix
  89374. */
  89375. getTextureMatrix(): Matrix;
  89376. /**
  89377. * Get the texture reflection matrix used to rotate/transform the reflection.
  89378. * @returns the reflection matrix
  89379. */
  89380. getReflectionTextureMatrix(): Matrix;
  89381. /**
  89382. * Get the underlying lower level texture from Babylon.
  89383. * @returns the insternal texture
  89384. */
  89385. getInternalTexture(): Nullable<InternalTexture>;
  89386. /**
  89387. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  89388. * @returns true if ready or not blocking
  89389. */
  89390. isReadyOrNotBlocking(): boolean;
  89391. /**
  89392. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  89393. * @returns true if fully ready
  89394. */
  89395. isReady(): boolean;
  89396. private _cachedSize;
  89397. /**
  89398. * Get the size of the texture.
  89399. * @returns the texture size.
  89400. */
  89401. getSize(): ISize;
  89402. /**
  89403. * Get the base size of the texture.
  89404. * It can be different from the size if the texture has been resized for POT for instance
  89405. * @returns the base size
  89406. */
  89407. getBaseSize(): ISize;
  89408. /**
  89409. * Update the sampling mode of the texture.
  89410. * Default is Trilinear mode.
  89411. *
  89412. * | Value | Type | Description |
  89413. * | ----- | ------------------ | ----------- |
  89414. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  89415. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  89416. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  89417. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  89418. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  89419. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  89420. * | 7 | NEAREST_LINEAR | |
  89421. * | 8 | NEAREST_NEAREST | |
  89422. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  89423. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  89424. * | 11 | LINEAR_LINEAR | |
  89425. * | 12 | LINEAR_NEAREST | |
  89426. *
  89427. * > _mag_: magnification filter (close to the viewer)
  89428. * > _min_: minification filter (far from the viewer)
  89429. * > _mip_: filter used between mip map levels
  89430. *@param samplingMode Define the new sampling mode of the texture
  89431. */
  89432. updateSamplingMode(samplingMode: number): void;
  89433. /**
  89434. * Scales the texture if is `canRescale()`
  89435. * @param ratio the resize factor we want to use to rescale
  89436. */
  89437. scale(ratio: number): void;
  89438. /**
  89439. * Get if the texture can rescale.
  89440. */
  89441. readonly canRescale: boolean;
  89442. /** @hidden */
  89443. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89444. /** @hidden */
  89445. _rebuild(): void;
  89446. /**
  89447. * Triggers the load sequence in delayed load mode.
  89448. */
  89449. delayLoad(): void;
  89450. /**
  89451. * Clones the texture.
  89452. * @returns the cloned texture
  89453. */
  89454. clone(): Nullable<BaseTexture>;
  89455. /**
  89456. * Get the texture underlying type (INT, FLOAT...)
  89457. */
  89458. readonly textureType: number;
  89459. /**
  89460. * Get the texture underlying format (RGB, RGBA...)
  89461. */
  89462. readonly textureFormat: number;
  89463. /**
  89464. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89465. * This will returns an RGBA array buffer containing either in values (0-255) or
  89466. * float values (0-1) depending of the underlying buffer type.
  89467. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89468. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89469. * @param buffer defines a user defined buffer to fill with data (can be null)
  89470. * @returns The Array buffer containing the pixels data.
  89471. */
  89472. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89473. /**
  89474. * Release and destroy the underlying lower level texture aka internalTexture.
  89475. */
  89476. releaseInternalTexture(): void;
  89477. /**
  89478. * Get the polynomial representation of the texture data.
  89479. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  89480. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  89481. */
  89482. sphericalPolynomial: Nullable<SphericalPolynomial>;
  89483. /** @hidden */
  89484. readonly _lodTextureHigh: Nullable<BaseTexture>;
  89485. /** @hidden */
  89486. readonly _lodTextureMid: Nullable<BaseTexture>;
  89487. /** @hidden */
  89488. readonly _lodTextureLow: Nullable<BaseTexture>;
  89489. /**
  89490. * Dispose the texture and release its associated resources.
  89491. */
  89492. dispose(): void;
  89493. /**
  89494. * Serialize the texture into a JSON representation that can be parsed later on.
  89495. * @returns the JSON representation of the texture
  89496. */
  89497. serialize(): any;
  89498. /**
  89499. * Helper function to be called back once a list of texture contains only ready textures.
  89500. * @param textures Define the list of textures to wait for
  89501. * @param callback Define the callback triggered once the entire list will be ready
  89502. */
  89503. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89504. }
  89505. }
  89506. declare module BABYLON {
  89507. /**
  89508. * Uniform buffer objects.
  89509. *
  89510. * Handles blocks of uniform on the GPU.
  89511. *
  89512. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89513. *
  89514. * For more information, please refer to :
  89515. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89516. */
  89517. export class UniformBuffer {
  89518. private _engine;
  89519. private _buffer;
  89520. private _data;
  89521. private _bufferData;
  89522. private _dynamic?;
  89523. private _uniformLocations;
  89524. private _uniformSizes;
  89525. private _uniformLocationPointer;
  89526. private _needSync;
  89527. private _noUBO;
  89528. private _currentEffect;
  89529. private static _MAX_UNIFORM_SIZE;
  89530. private static _tempBuffer;
  89531. /**
  89532. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89533. * This is dynamic to allow compat with webgl 1 and 2.
  89534. * You will need to pass the name of the uniform as well as the value.
  89535. */
  89536. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89537. /**
  89538. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89539. * This is dynamic to allow compat with webgl 1 and 2.
  89540. * You will need to pass the name of the uniform as well as the value.
  89541. */
  89542. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89543. /**
  89544. * Lambda to Update a single float in a uniform buffer.
  89545. * This is dynamic to allow compat with webgl 1 and 2.
  89546. * You will need to pass the name of the uniform as well as the value.
  89547. */
  89548. updateFloat: (name: string, x: number) => void;
  89549. /**
  89550. * Lambda to Update a vec2 of float in a uniform buffer.
  89551. * This is dynamic to allow compat with webgl 1 and 2.
  89552. * You will need to pass the name of the uniform as well as the value.
  89553. */
  89554. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89555. /**
  89556. * Lambda to Update a vec3 of float in a uniform buffer.
  89557. * This is dynamic to allow compat with webgl 1 and 2.
  89558. * You will need to pass the name of the uniform as well as the value.
  89559. */
  89560. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89561. /**
  89562. * Lambda to Update a vec4 of float in a uniform buffer.
  89563. * This is dynamic to allow compat with webgl 1 and 2.
  89564. * You will need to pass the name of the uniform as well as the value.
  89565. */
  89566. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89567. /**
  89568. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89569. * This is dynamic to allow compat with webgl 1 and 2.
  89570. * You will need to pass the name of the uniform as well as the value.
  89571. */
  89572. updateMatrix: (name: string, mat: Matrix) => void;
  89573. /**
  89574. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89575. * This is dynamic to allow compat with webgl 1 and 2.
  89576. * You will need to pass the name of the uniform as well as the value.
  89577. */
  89578. updateVector3: (name: string, vector: Vector3) => void;
  89579. /**
  89580. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89581. * This is dynamic to allow compat with webgl 1 and 2.
  89582. * You will need to pass the name of the uniform as well as the value.
  89583. */
  89584. updateVector4: (name: string, vector: Vector4) => void;
  89585. /**
  89586. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89587. * This is dynamic to allow compat with webgl 1 and 2.
  89588. * You will need to pass the name of the uniform as well as the value.
  89589. */
  89590. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89591. /**
  89592. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89593. * This is dynamic to allow compat with webgl 1 and 2.
  89594. * You will need to pass the name of the uniform as well as the value.
  89595. */
  89596. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89597. /**
  89598. * Instantiates a new Uniform buffer objects.
  89599. *
  89600. * Handles blocks of uniform on the GPU.
  89601. *
  89602. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89603. *
  89604. * For more information, please refer to :
  89605. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89606. * @param engine Define the engine the buffer is associated with
  89607. * @param data Define the data contained in the buffer
  89608. * @param dynamic Define if the buffer is updatable
  89609. */
  89610. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89611. /**
  89612. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89613. * or just falling back on setUniformXXX calls.
  89614. */
  89615. readonly useUbo: boolean;
  89616. /**
  89617. * Indicates if the WebGL underlying uniform buffer is in sync
  89618. * with the javascript cache data.
  89619. */
  89620. readonly isSync: boolean;
  89621. /**
  89622. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89623. * Also, a dynamic UniformBuffer will disable cache verification and always
  89624. * update the underlying WebGL uniform buffer to the GPU.
  89625. * @returns if Dynamic, otherwise false
  89626. */
  89627. isDynamic(): boolean;
  89628. /**
  89629. * The data cache on JS side.
  89630. * @returns the underlying data as a float array
  89631. */
  89632. getData(): Float32Array;
  89633. /**
  89634. * The underlying WebGL Uniform buffer.
  89635. * @returns the webgl buffer
  89636. */
  89637. getBuffer(): Nullable<DataBuffer>;
  89638. /**
  89639. * std140 layout specifies how to align data within an UBO structure.
  89640. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89641. * for specs.
  89642. */
  89643. private _fillAlignment;
  89644. /**
  89645. * Adds an uniform in the buffer.
  89646. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89647. * for the layout to be correct !
  89648. * @param name Name of the uniform, as used in the uniform block in the shader.
  89649. * @param size Data size, or data directly.
  89650. */
  89651. addUniform(name: string, size: number | number[]): void;
  89652. /**
  89653. * Adds a Matrix 4x4 to the uniform buffer.
  89654. * @param name Name of the uniform, as used in the uniform block in the shader.
  89655. * @param mat A 4x4 matrix.
  89656. */
  89657. addMatrix(name: string, mat: Matrix): void;
  89658. /**
  89659. * Adds a vec2 to the uniform buffer.
  89660. * @param name Name of the uniform, as used in the uniform block in the shader.
  89661. * @param x Define the x component value of the vec2
  89662. * @param y Define the y component value of the vec2
  89663. */
  89664. addFloat2(name: string, x: number, y: number): void;
  89665. /**
  89666. * Adds a vec3 to the uniform buffer.
  89667. * @param name Name of the uniform, as used in the uniform block in the shader.
  89668. * @param x Define the x component value of the vec3
  89669. * @param y Define the y component value of the vec3
  89670. * @param z Define the z component value of the vec3
  89671. */
  89672. addFloat3(name: string, x: number, y: number, z: number): void;
  89673. /**
  89674. * Adds a vec3 to the uniform buffer.
  89675. * @param name Name of the uniform, as used in the uniform block in the shader.
  89676. * @param color Define the vec3 from a Color
  89677. */
  89678. addColor3(name: string, color: Color3): void;
  89679. /**
  89680. * Adds a vec4 to the uniform buffer.
  89681. * @param name Name of the uniform, as used in the uniform block in the shader.
  89682. * @param color Define the rgb components from a Color
  89683. * @param alpha Define the a component of the vec4
  89684. */
  89685. addColor4(name: string, color: Color3, alpha: number): void;
  89686. /**
  89687. * Adds a vec3 to the uniform buffer.
  89688. * @param name Name of the uniform, as used in the uniform block in the shader.
  89689. * @param vector Define the vec3 components from a Vector
  89690. */
  89691. addVector3(name: string, vector: Vector3): void;
  89692. /**
  89693. * Adds a Matrix 3x3 to the uniform buffer.
  89694. * @param name Name of the uniform, as used in the uniform block in the shader.
  89695. */
  89696. addMatrix3x3(name: string): void;
  89697. /**
  89698. * Adds a Matrix 2x2 to the uniform buffer.
  89699. * @param name Name of the uniform, as used in the uniform block in the shader.
  89700. */
  89701. addMatrix2x2(name: string): void;
  89702. /**
  89703. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89704. */
  89705. create(): void;
  89706. /** @hidden */
  89707. _rebuild(): void;
  89708. /**
  89709. * Updates the WebGL Uniform Buffer on the GPU.
  89710. * If the `dynamic` flag is set to true, no cache comparison is done.
  89711. * Otherwise, the buffer will be updated only if the cache differs.
  89712. */
  89713. update(): void;
  89714. /**
  89715. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89716. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89717. * @param data Define the flattened data
  89718. * @param size Define the size of the data.
  89719. */
  89720. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89721. private _updateMatrix3x3ForUniform;
  89722. private _updateMatrix3x3ForEffect;
  89723. private _updateMatrix2x2ForEffect;
  89724. private _updateMatrix2x2ForUniform;
  89725. private _updateFloatForEffect;
  89726. private _updateFloatForUniform;
  89727. private _updateFloat2ForEffect;
  89728. private _updateFloat2ForUniform;
  89729. private _updateFloat3ForEffect;
  89730. private _updateFloat3ForUniform;
  89731. private _updateFloat4ForEffect;
  89732. private _updateFloat4ForUniform;
  89733. private _updateMatrixForEffect;
  89734. private _updateMatrixForUniform;
  89735. private _updateVector3ForEffect;
  89736. private _updateVector3ForUniform;
  89737. private _updateVector4ForEffect;
  89738. private _updateVector4ForUniform;
  89739. private _updateColor3ForEffect;
  89740. private _updateColor3ForUniform;
  89741. private _updateColor4ForEffect;
  89742. private _updateColor4ForUniform;
  89743. /**
  89744. * Sets a sampler uniform on the effect.
  89745. * @param name Define the name of the sampler.
  89746. * @param texture Define the texture to set in the sampler
  89747. */
  89748. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89749. /**
  89750. * Directly updates the value of the uniform in the cache AND on the GPU.
  89751. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89752. * @param data Define the flattened data
  89753. */
  89754. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89755. /**
  89756. * Binds this uniform buffer to an effect.
  89757. * @param effect Define the effect to bind the buffer to
  89758. * @param name Name of the uniform block in the shader.
  89759. */
  89760. bindToEffect(effect: Effect, name: string): void;
  89761. /**
  89762. * Disposes the uniform buffer.
  89763. */
  89764. dispose(): void;
  89765. }
  89766. }
  89767. declare module BABYLON {
  89768. /**
  89769. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89771. */
  89772. export class Analyser {
  89773. /**
  89774. * Gets or sets the smoothing
  89775. * @ignorenaming
  89776. */
  89777. SMOOTHING: number;
  89778. /**
  89779. * Gets or sets the FFT table size
  89780. * @ignorenaming
  89781. */
  89782. FFT_SIZE: number;
  89783. /**
  89784. * Gets or sets the bar graph amplitude
  89785. * @ignorenaming
  89786. */
  89787. BARGRAPHAMPLITUDE: number;
  89788. /**
  89789. * Gets or sets the position of the debug canvas
  89790. * @ignorenaming
  89791. */
  89792. DEBUGCANVASPOS: {
  89793. x: number;
  89794. y: number;
  89795. };
  89796. /**
  89797. * Gets or sets the debug canvas size
  89798. * @ignorenaming
  89799. */
  89800. DEBUGCANVASSIZE: {
  89801. width: number;
  89802. height: number;
  89803. };
  89804. private _byteFreqs;
  89805. private _byteTime;
  89806. private _floatFreqs;
  89807. private _webAudioAnalyser;
  89808. private _debugCanvas;
  89809. private _debugCanvasContext;
  89810. private _scene;
  89811. private _registerFunc;
  89812. private _audioEngine;
  89813. /**
  89814. * Creates a new analyser
  89815. * @param scene defines hosting scene
  89816. */
  89817. constructor(scene: Scene);
  89818. /**
  89819. * Get the number of data values you will have to play with for the visualization
  89820. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89821. * @returns a number
  89822. */
  89823. getFrequencyBinCount(): number;
  89824. /**
  89825. * Gets the current frequency data as a byte array
  89826. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89827. * @returns a Uint8Array
  89828. */
  89829. getByteFrequencyData(): Uint8Array;
  89830. /**
  89831. * Gets the current waveform as a byte array
  89832. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89833. * @returns a Uint8Array
  89834. */
  89835. getByteTimeDomainData(): Uint8Array;
  89836. /**
  89837. * Gets the current frequency data as a float array
  89838. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89839. * @returns a Float32Array
  89840. */
  89841. getFloatFrequencyData(): Float32Array;
  89842. /**
  89843. * Renders the debug canvas
  89844. */
  89845. drawDebugCanvas(): void;
  89846. /**
  89847. * Stops rendering the debug canvas and removes it
  89848. */
  89849. stopDebugCanvas(): void;
  89850. /**
  89851. * Connects two audio nodes
  89852. * @param inputAudioNode defines first node to connect
  89853. * @param outputAudioNode defines second node to connect
  89854. */
  89855. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89856. /**
  89857. * Releases all associated resources
  89858. */
  89859. dispose(): void;
  89860. }
  89861. }
  89862. declare module BABYLON {
  89863. /**
  89864. * This represents an audio engine and it is responsible
  89865. * to play, synchronize and analyse sounds throughout the application.
  89866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89867. */
  89868. export interface IAudioEngine extends IDisposable {
  89869. /**
  89870. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89871. */
  89872. readonly canUseWebAudio: boolean;
  89873. /**
  89874. * Gets the current AudioContext if available.
  89875. */
  89876. readonly audioContext: Nullable<AudioContext>;
  89877. /**
  89878. * The master gain node defines the global audio volume of your audio engine.
  89879. */
  89880. readonly masterGain: GainNode;
  89881. /**
  89882. * Gets whether or not mp3 are supported by your browser.
  89883. */
  89884. readonly isMP3supported: boolean;
  89885. /**
  89886. * Gets whether or not ogg are supported by your browser.
  89887. */
  89888. readonly isOGGsupported: boolean;
  89889. /**
  89890. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89891. * @ignoreNaming
  89892. */
  89893. WarnedWebAudioUnsupported: boolean;
  89894. /**
  89895. * Defines if the audio engine relies on a custom unlocked button.
  89896. * In this case, the embedded button will not be displayed.
  89897. */
  89898. useCustomUnlockedButton: boolean;
  89899. /**
  89900. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89901. */
  89902. readonly unlocked: boolean;
  89903. /**
  89904. * Event raised when audio has been unlocked on the browser.
  89905. */
  89906. onAudioUnlockedObservable: Observable<AudioEngine>;
  89907. /**
  89908. * Event raised when audio has been locked on the browser.
  89909. */
  89910. onAudioLockedObservable: Observable<AudioEngine>;
  89911. /**
  89912. * Flags the audio engine in Locked state.
  89913. * This happens due to new browser policies preventing audio to autoplay.
  89914. */
  89915. lock(): void;
  89916. /**
  89917. * Unlocks the audio engine once a user action has been done on the dom.
  89918. * This is helpful to resume play once browser policies have been satisfied.
  89919. */
  89920. unlock(): void;
  89921. }
  89922. /**
  89923. * This represents the default audio engine used in babylon.
  89924. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89926. */
  89927. export class AudioEngine implements IAudioEngine {
  89928. private _audioContext;
  89929. private _audioContextInitialized;
  89930. private _muteButton;
  89931. private _hostElement;
  89932. /**
  89933. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89934. */
  89935. canUseWebAudio: boolean;
  89936. /**
  89937. * The master gain node defines the global audio volume of your audio engine.
  89938. */
  89939. masterGain: GainNode;
  89940. /**
  89941. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89942. * @ignoreNaming
  89943. */
  89944. WarnedWebAudioUnsupported: boolean;
  89945. /**
  89946. * Gets whether or not mp3 are supported by your browser.
  89947. */
  89948. isMP3supported: boolean;
  89949. /**
  89950. * Gets whether or not ogg are supported by your browser.
  89951. */
  89952. isOGGsupported: boolean;
  89953. /**
  89954. * Gets whether audio has been unlocked on the device.
  89955. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  89956. * a user interaction has happened.
  89957. */
  89958. unlocked: boolean;
  89959. /**
  89960. * Defines if the audio engine relies on a custom unlocked button.
  89961. * In this case, the embedded button will not be displayed.
  89962. */
  89963. useCustomUnlockedButton: boolean;
  89964. /**
  89965. * Event raised when audio has been unlocked on the browser.
  89966. */
  89967. onAudioUnlockedObservable: Observable<AudioEngine>;
  89968. /**
  89969. * Event raised when audio has been locked on the browser.
  89970. */
  89971. onAudioLockedObservable: Observable<AudioEngine>;
  89972. /**
  89973. * Gets the current AudioContext if available.
  89974. */
  89975. readonly audioContext: Nullable<AudioContext>;
  89976. private _connectedAnalyser;
  89977. /**
  89978. * Instantiates a new audio engine.
  89979. *
  89980. * There should be only one per page as some browsers restrict the number
  89981. * of audio contexts you can create.
  89982. * @param hostElement defines the host element where to display the mute icon if necessary
  89983. */
  89984. constructor(hostElement?: Nullable<HTMLElement>);
  89985. /**
  89986. * Flags the audio engine in Locked state.
  89987. * This happens due to new browser policies preventing audio to autoplay.
  89988. */
  89989. lock(): void;
  89990. /**
  89991. * Unlocks the audio engine once a user action has been done on the dom.
  89992. * This is helpful to resume play once browser policies have been satisfied.
  89993. */
  89994. unlock(): void;
  89995. private _resumeAudioContext;
  89996. private _initializeAudioContext;
  89997. private _tryToRun;
  89998. private _triggerRunningState;
  89999. private _triggerSuspendedState;
  90000. private _displayMuteButton;
  90001. private _moveButtonToTopLeft;
  90002. private _onResize;
  90003. private _hideMuteButton;
  90004. /**
  90005. * Destroy and release the resources associated with the audio ccontext.
  90006. */
  90007. dispose(): void;
  90008. /**
  90009. * Gets the global volume sets on the master gain.
  90010. * @returns the global volume if set or -1 otherwise
  90011. */
  90012. getGlobalVolume(): number;
  90013. /**
  90014. * Sets the global volume of your experience (sets on the master gain).
  90015. * @param newVolume Defines the new global volume of the application
  90016. */
  90017. setGlobalVolume(newVolume: number): void;
  90018. /**
  90019. * Connect the audio engine to an audio analyser allowing some amazing
  90020. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  90021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  90022. * @param analyser The analyser to connect to the engine
  90023. */
  90024. connectToAnalyser(analyser: Analyser): void;
  90025. }
  90026. }
  90027. declare module BABYLON {
  90028. /**
  90029. * Interface used to present a loading screen while loading a scene
  90030. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  90031. */
  90032. export interface ILoadingScreen {
  90033. /**
  90034. * Function called to display the loading screen
  90035. */
  90036. displayLoadingUI: () => void;
  90037. /**
  90038. * Function called to hide the loading screen
  90039. */
  90040. hideLoadingUI: () => void;
  90041. /**
  90042. * Gets or sets the color to use for the background
  90043. */
  90044. loadingUIBackgroundColor: string;
  90045. /**
  90046. * Gets or sets the text to display while loading
  90047. */
  90048. loadingUIText: string;
  90049. }
  90050. /**
  90051. * Class used for the default loading screen
  90052. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  90053. */
  90054. export class DefaultLoadingScreen implements ILoadingScreen {
  90055. private _renderingCanvas;
  90056. private _loadingText;
  90057. private _loadingDivBackgroundColor;
  90058. private _loadingDiv;
  90059. private _loadingTextDiv;
  90060. /** Gets or sets the logo url to use for the default loading screen */
  90061. static DefaultLogoUrl: string;
  90062. /** Gets or sets the spinner url to use for the default loading screen */
  90063. static DefaultSpinnerUrl: string;
  90064. /**
  90065. * Creates a new default loading screen
  90066. * @param _renderingCanvas defines the canvas used to render the scene
  90067. * @param _loadingText defines the default text to display
  90068. * @param _loadingDivBackgroundColor defines the default background color
  90069. */
  90070. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  90071. /**
  90072. * Function called to display the loading screen
  90073. */
  90074. displayLoadingUI(): void;
  90075. /**
  90076. * Function called to hide the loading screen
  90077. */
  90078. hideLoadingUI(): void;
  90079. /**
  90080. * Gets or sets the text to display while loading
  90081. */
  90082. loadingUIText: string;
  90083. /**
  90084. * Gets or sets the color to use for the background
  90085. */
  90086. loadingUIBackgroundColor: string;
  90087. private _resizeLoadingUI;
  90088. }
  90089. }
  90090. declare module BABYLON {
  90091. /** @hidden */
  90092. export class WebGLPipelineContext implements IPipelineContext {
  90093. engine: Engine;
  90094. program: Nullable<WebGLProgram>;
  90095. context?: WebGLRenderingContext;
  90096. vertexShader?: WebGLShader;
  90097. fragmentShader?: WebGLShader;
  90098. isParallelCompiled: boolean;
  90099. onCompiled?: () => void;
  90100. transformFeedback?: WebGLTransformFeedback | null;
  90101. readonly isAsync: boolean;
  90102. readonly isReady: boolean;
  90103. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  90104. }
  90105. }
  90106. declare module BABYLON {
  90107. /** @hidden */
  90108. export class WebGLDataBuffer extends DataBuffer {
  90109. private _buffer;
  90110. constructor(resource: WebGLBuffer);
  90111. readonly underlyingResource: any;
  90112. }
  90113. }
  90114. declare module BABYLON {
  90115. /** @hidden */
  90116. export class WebGL2ShaderProcessor implements IShaderProcessor {
  90117. attributeProcessor(attribute: string): string;
  90118. varyingProcessor(varying: string, isFragment: boolean): string;
  90119. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  90120. }
  90121. }
  90122. declare module BABYLON {
  90123. /**
  90124. * Settings for finer control over video usage
  90125. */
  90126. export interface VideoTextureSettings {
  90127. /**
  90128. * Applies `autoplay` to video, if specified
  90129. */
  90130. autoPlay?: boolean;
  90131. /**
  90132. * Applies `loop` to video, if specified
  90133. */
  90134. loop?: boolean;
  90135. /**
  90136. * Automatically updates internal texture from video at every frame in the render loop
  90137. */
  90138. autoUpdateTexture: boolean;
  90139. /**
  90140. * Image src displayed during the video loading or until the user interacts with the video.
  90141. */
  90142. poster?: string;
  90143. }
  90144. /**
  90145. * If you want to display a video in your scene, this is the special texture for that.
  90146. * This special texture works similar to other textures, with the exception of a few parameters.
  90147. * @see https://doc.babylonjs.com/how_to/video_texture
  90148. */
  90149. export class VideoTexture extends Texture {
  90150. /**
  90151. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  90152. */
  90153. readonly autoUpdateTexture: boolean;
  90154. /**
  90155. * The video instance used by the texture internally
  90156. */
  90157. readonly video: HTMLVideoElement;
  90158. private _onUserActionRequestedObservable;
  90159. /**
  90160. * Event triggerd when a dom action is required by the user to play the video.
  90161. * This happens due to recent changes in browser policies preventing video to auto start.
  90162. */
  90163. readonly onUserActionRequestedObservable: Observable<Texture>;
  90164. private _generateMipMaps;
  90165. private _engine;
  90166. private _stillImageCaptured;
  90167. private _displayingPosterTexture;
  90168. private _settings;
  90169. private _createInternalTextureOnEvent;
  90170. /**
  90171. * Creates a video texture.
  90172. * If you want to display a video in your scene, this is the special texture for that.
  90173. * This special texture works similar to other textures, with the exception of a few parameters.
  90174. * @see https://doc.babylonjs.com/how_to/video_texture
  90175. * @param name optional name, will detect from video source, if not defined
  90176. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  90177. * @param scene is obviously the current scene.
  90178. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  90179. * @param invertY is false by default but can be used to invert video on Y axis
  90180. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  90181. * @param settings allows finer control over video usage
  90182. */
  90183. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  90184. private _getName;
  90185. private _getVideo;
  90186. private _createInternalTexture;
  90187. private reset;
  90188. /**
  90189. * @hidden Internal method to initiate `update`.
  90190. */
  90191. _rebuild(): void;
  90192. /**
  90193. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  90194. */
  90195. update(): void;
  90196. /**
  90197. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  90198. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  90199. */
  90200. updateTexture(isVisible: boolean): void;
  90201. protected _updateInternalTexture: () => void;
  90202. /**
  90203. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  90204. * @param url New url.
  90205. */
  90206. updateURL(url: string): void;
  90207. /**
  90208. * Dispose the texture and release its associated resources.
  90209. */
  90210. dispose(): void;
  90211. /**
  90212. * Creates a video texture straight from a stream.
  90213. * @param scene Define the scene the texture should be created in
  90214. * @param stream Define the stream the texture should be created from
  90215. * @returns The created video texture as a promise
  90216. */
  90217. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  90218. /**
  90219. * Creates a video texture straight from your WebCam video feed.
  90220. * @param scene Define the scene the texture should be created in
  90221. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  90222. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  90223. * @returns The created video texture as a promise
  90224. */
  90225. static CreateFromWebCamAsync(scene: Scene, constraints: {
  90226. minWidth: number;
  90227. maxWidth: number;
  90228. minHeight: number;
  90229. maxHeight: number;
  90230. deviceId: string;
  90231. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  90232. /**
  90233. * Creates a video texture straight from your WebCam video feed.
  90234. * @param scene Define the scene the texture should be created in
  90235. * @param onReady Define a callback to triggered once the texture will be ready
  90236. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  90237. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  90238. */
  90239. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  90240. minWidth: number;
  90241. maxWidth: number;
  90242. minHeight: number;
  90243. maxHeight: number;
  90244. deviceId: string;
  90245. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  90246. }
  90247. }
  90248. declare module BABYLON {
  90249. /**
  90250. * Interface for attribute information associated with buffer instanciation
  90251. */
  90252. export class InstancingAttributeInfo {
  90253. /**
  90254. * Index/offset of the attribute in the vertex shader
  90255. */
  90256. index: number;
  90257. /**
  90258. * size of the attribute, 1, 2, 3 or 4
  90259. */
  90260. attributeSize: number;
  90261. /**
  90262. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  90263. * default is FLOAT
  90264. */
  90265. attribyteType: number;
  90266. /**
  90267. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  90268. */
  90269. normalized: boolean;
  90270. /**
  90271. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  90272. */
  90273. offset: number;
  90274. /**
  90275. * Name of the GLSL attribute, for debugging purpose only
  90276. */
  90277. attributeName: string;
  90278. }
  90279. /**
  90280. * Define options used to create a depth texture
  90281. */
  90282. export class DepthTextureCreationOptions {
  90283. /** Specifies whether or not a stencil should be allocated in the texture */
  90284. generateStencil?: boolean;
  90285. /** Specifies whether or not bilinear filtering is enable on the texture */
  90286. bilinearFiltering?: boolean;
  90287. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  90288. comparisonFunction?: number;
  90289. /** Specifies if the created texture is a cube texture */
  90290. isCube?: boolean;
  90291. }
  90292. /**
  90293. * Class used to describe the capabilities of the engine relatively to the current browser
  90294. */
  90295. export class EngineCapabilities {
  90296. /** Maximum textures units per fragment shader */
  90297. maxTexturesImageUnits: number;
  90298. /** Maximum texture units per vertex shader */
  90299. maxVertexTextureImageUnits: number;
  90300. /** Maximum textures units in the entire pipeline */
  90301. maxCombinedTexturesImageUnits: number;
  90302. /** Maximum texture size */
  90303. maxTextureSize: number;
  90304. /** Maximum cube texture size */
  90305. maxCubemapTextureSize: number;
  90306. /** Maximum render texture size */
  90307. maxRenderTextureSize: number;
  90308. /** Maximum number of vertex attributes */
  90309. maxVertexAttribs: number;
  90310. /** Maximum number of varyings */
  90311. maxVaryingVectors: number;
  90312. /** Maximum number of uniforms per vertex shader */
  90313. maxVertexUniformVectors: number;
  90314. /** Maximum number of uniforms per fragment shader */
  90315. maxFragmentUniformVectors: number;
  90316. /** Defines if standard derivates (dx/dy) are supported */
  90317. standardDerivatives: boolean;
  90318. /** Defines if s3tc texture compression is supported */
  90319. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  90320. /** Defines if pvrtc texture compression is supported */
  90321. pvrtc: any;
  90322. /** Defines if etc1 texture compression is supported */
  90323. etc1: any;
  90324. /** Defines if etc2 texture compression is supported */
  90325. etc2: any;
  90326. /** Defines if astc texture compression is supported */
  90327. astc: any;
  90328. /** Defines if float textures are supported */
  90329. textureFloat: boolean;
  90330. /** Defines if vertex array objects are supported */
  90331. vertexArrayObject: boolean;
  90332. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  90333. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  90334. /** Gets the maximum level of anisotropy supported */
  90335. maxAnisotropy: number;
  90336. /** Defines if instancing is supported */
  90337. instancedArrays: boolean;
  90338. /** Defines if 32 bits indices are supported */
  90339. uintIndices: boolean;
  90340. /** Defines if high precision shaders are supported */
  90341. highPrecisionShaderSupported: boolean;
  90342. /** Defines if depth reading in the fragment shader is supported */
  90343. fragmentDepthSupported: boolean;
  90344. /** Defines if float texture linear filtering is supported*/
  90345. textureFloatLinearFiltering: boolean;
  90346. /** Defines if rendering to float textures is supported */
  90347. textureFloatRender: boolean;
  90348. /** Defines if half float textures are supported*/
  90349. textureHalfFloat: boolean;
  90350. /** Defines if half float texture linear filtering is supported*/
  90351. textureHalfFloatLinearFiltering: boolean;
  90352. /** Defines if rendering to half float textures is supported */
  90353. textureHalfFloatRender: boolean;
  90354. /** Defines if textureLOD shader command is supported */
  90355. textureLOD: boolean;
  90356. /** Defines if draw buffers extension is supported */
  90357. drawBuffersExtension: boolean;
  90358. /** Defines if depth textures are supported */
  90359. depthTextureExtension: boolean;
  90360. /** Defines if float color buffer are supported */
  90361. colorBufferFloat: boolean;
  90362. /** Gets disjoint timer query extension (null if not supported) */
  90363. timerQuery: EXT_disjoint_timer_query;
  90364. /** Defines if timestamp can be used with timer query */
  90365. canUseTimestampForTimerQuery: boolean;
  90366. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  90367. multiview: any;
  90368. /** Function used to let the system compiles shaders in background */
  90369. parallelShaderCompile: {
  90370. COMPLETION_STATUS_KHR: number;
  90371. };
  90372. }
  90373. /** Interface defining initialization parameters for Engine class */
  90374. export interface EngineOptions extends WebGLContextAttributes {
  90375. /**
  90376. * Defines if the engine should no exceed a specified device ratio
  90377. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  90378. */
  90379. limitDeviceRatio?: number;
  90380. /**
  90381. * Defines if webvr should be enabled automatically
  90382. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90383. */
  90384. autoEnableWebVR?: boolean;
  90385. /**
  90386. * Defines if webgl2 should be turned off even if supported
  90387. * @see http://doc.babylonjs.com/features/webgl2
  90388. */
  90389. disableWebGL2Support?: boolean;
  90390. /**
  90391. * Defines if webaudio should be initialized as well
  90392. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90393. */
  90394. audioEngine?: boolean;
  90395. /**
  90396. * Defines if animations should run using a deterministic lock step
  90397. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90398. */
  90399. deterministicLockstep?: boolean;
  90400. /** Defines the maximum steps to use with deterministic lock step mode */
  90401. lockstepMaxSteps?: number;
  90402. /**
  90403. * Defines that engine should ignore context lost events
  90404. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  90405. */
  90406. doNotHandleContextLost?: boolean;
  90407. /**
  90408. * Defines that engine should ignore modifying touch action attribute and style
  90409. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  90410. */
  90411. doNotHandleTouchAction?: boolean;
  90412. /**
  90413. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  90414. */
  90415. useHighPrecisionFloats?: boolean;
  90416. }
  90417. /**
  90418. * Defines the interface used by display changed events
  90419. */
  90420. export interface IDisplayChangedEventArgs {
  90421. /** Gets the vrDisplay object (if any) */
  90422. vrDisplay: Nullable<any>;
  90423. /** Gets a boolean indicating if webVR is supported */
  90424. vrSupported: boolean;
  90425. }
  90426. /**
  90427. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  90428. */
  90429. export class Engine {
  90430. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  90431. static ExceptionList: ({
  90432. key: string;
  90433. capture: string;
  90434. captureConstraint: number;
  90435. targets: string[];
  90436. } | {
  90437. key: string;
  90438. capture: null;
  90439. captureConstraint: null;
  90440. targets: string[];
  90441. })[];
  90442. /** Gets the list of created engines */
  90443. static readonly Instances: Engine[];
  90444. /**
  90445. * Gets the latest created engine
  90446. */
  90447. static readonly LastCreatedEngine: Nullable<Engine>;
  90448. /**
  90449. * Gets the latest created scene
  90450. */
  90451. static readonly LastCreatedScene: Nullable<Scene>;
  90452. /**
  90453. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  90454. * @param flag defines which part of the materials must be marked as dirty
  90455. * @param predicate defines a predicate used to filter which materials should be affected
  90456. */
  90457. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90458. /** @hidden */
  90459. static _TextureLoaders: IInternalTextureLoader[];
  90460. /** Defines that alpha blending is disabled */
  90461. static readonly ALPHA_DISABLE: number;
  90462. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  90463. static readonly ALPHA_ADD: number;
  90464. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  90465. static readonly ALPHA_COMBINE: number;
  90466. /** Defines that alpha blending to DEST - SRC * DEST */
  90467. static readonly ALPHA_SUBTRACT: number;
  90468. /** Defines that alpha blending to SRC * DEST */
  90469. static readonly ALPHA_MULTIPLY: number;
  90470. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  90471. static readonly ALPHA_MAXIMIZED: number;
  90472. /** Defines that alpha blending to SRC + DEST */
  90473. static readonly ALPHA_ONEONE: number;
  90474. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  90475. static readonly ALPHA_PREMULTIPLIED: number;
  90476. /**
  90477. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  90478. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  90479. */
  90480. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  90481. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  90482. static readonly ALPHA_INTERPOLATE: number;
  90483. /**
  90484. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  90485. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  90486. */
  90487. static readonly ALPHA_SCREENMODE: number;
  90488. /** Defines that the ressource is not delayed*/
  90489. static readonly DELAYLOADSTATE_NONE: number;
  90490. /** Defines that the ressource was successfully delay loaded */
  90491. static readonly DELAYLOADSTATE_LOADED: number;
  90492. /** Defines that the ressource is currently delay loading */
  90493. static readonly DELAYLOADSTATE_LOADING: number;
  90494. /** Defines that the ressource is delayed and has not started loading */
  90495. static readonly DELAYLOADSTATE_NOTLOADED: number;
  90496. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  90497. static readonly NEVER: number;
  90498. /** 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 */
  90499. static readonly ALWAYS: number;
  90500. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  90501. static readonly LESS: number;
  90502. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  90503. static readonly EQUAL: number;
  90504. /** 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 */
  90505. static readonly LEQUAL: number;
  90506. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  90507. static readonly GREATER: number;
  90508. /** 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 */
  90509. static readonly GEQUAL: number;
  90510. /** 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 */
  90511. static readonly NOTEQUAL: number;
  90512. /** Passed to stencilOperation to specify that stencil value must be kept */
  90513. static readonly KEEP: number;
  90514. /** Passed to stencilOperation to specify that stencil value must be replaced */
  90515. static readonly REPLACE: number;
  90516. /** Passed to stencilOperation to specify that stencil value must be incremented */
  90517. static readonly INCR: number;
  90518. /** Passed to stencilOperation to specify that stencil value must be decremented */
  90519. static readonly DECR: number;
  90520. /** Passed to stencilOperation to specify that stencil value must be inverted */
  90521. static readonly INVERT: number;
  90522. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  90523. static readonly INCR_WRAP: number;
  90524. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  90525. static readonly DECR_WRAP: number;
  90526. /** Texture is not repeating outside of 0..1 UVs */
  90527. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  90528. /** Texture is repeating outside of 0..1 UVs */
  90529. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  90530. /** Texture is repeating and mirrored */
  90531. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  90532. /** ALPHA */
  90533. static readonly TEXTUREFORMAT_ALPHA: number;
  90534. /** LUMINANCE */
  90535. static readonly TEXTUREFORMAT_LUMINANCE: number;
  90536. /** LUMINANCE_ALPHA */
  90537. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  90538. /** RGB */
  90539. static readonly TEXTUREFORMAT_RGB: number;
  90540. /** RGBA */
  90541. static readonly TEXTUREFORMAT_RGBA: number;
  90542. /** RED */
  90543. static readonly TEXTUREFORMAT_RED: number;
  90544. /** RED (2nd reference) */
  90545. static readonly TEXTUREFORMAT_R: number;
  90546. /** RG */
  90547. static readonly TEXTUREFORMAT_RG: number;
  90548. /** RED_INTEGER */
  90549. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  90550. /** RED_INTEGER (2nd reference) */
  90551. static readonly TEXTUREFORMAT_R_INTEGER: number;
  90552. /** RG_INTEGER */
  90553. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  90554. /** RGB_INTEGER */
  90555. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  90556. /** RGBA_INTEGER */
  90557. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  90558. /** UNSIGNED_BYTE */
  90559. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  90560. /** UNSIGNED_BYTE (2nd reference) */
  90561. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  90562. /** FLOAT */
  90563. static readonly TEXTURETYPE_FLOAT: number;
  90564. /** HALF_FLOAT */
  90565. static readonly TEXTURETYPE_HALF_FLOAT: number;
  90566. /** BYTE */
  90567. static readonly TEXTURETYPE_BYTE: number;
  90568. /** SHORT */
  90569. static readonly TEXTURETYPE_SHORT: number;
  90570. /** UNSIGNED_SHORT */
  90571. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  90572. /** INT */
  90573. static readonly TEXTURETYPE_INT: number;
  90574. /** UNSIGNED_INT */
  90575. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  90576. /** UNSIGNED_SHORT_4_4_4_4 */
  90577. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  90578. /** UNSIGNED_SHORT_5_5_5_1 */
  90579. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  90580. /** UNSIGNED_SHORT_5_6_5 */
  90581. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  90582. /** UNSIGNED_INT_2_10_10_10_REV */
  90583. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  90584. /** UNSIGNED_INT_24_8 */
  90585. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  90586. /** UNSIGNED_INT_10F_11F_11F_REV */
  90587. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  90588. /** UNSIGNED_INT_5_9_9_9_REV */
  90589. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  90590. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  90591. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  90592. /** nearest is mag = nearest and min = nearest and mip = linear */
  90593. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  90594. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90595. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  90596. /** Trilinear is mag = linear and min = linear and mip = linear */
  90597. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  90598. /** nearest is mag = nearest and min = nearest and mip = linear */
  90599. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  90600. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90601. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  90602. /** Trilinear is mag = linear and min = linear and mip = linear */
  90603. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  90604. /** mag = nearest and min = nearest and mip = nearest */
  90605. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  90606. /** mag = nearest and min = linear and mip = nearest */
  90607. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  90608. /** mag = nearest and min = linear and mip = linear */
  90609. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  90610. /** mag = nearest and min = linear and mip = none */
  90611. static readonly TEXTURE_NEAREST_LINEAR: number;
  90612. /** mag = nearest and min = nearest and mip = none */
  90613. static readonly TEXTURE_NEAREST_NEAREST: number;
  90614. /** mag = linear and min = nearest and mip = nearest */
  90615. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  90616. /** mag = linear and min = nearest and mip = linear */
  90617. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  90618. /** mag = linear and min = linear and mip = none */
  90619. static readonly TEXTURE_LINEAR_LINEAR: number;
  90620. /** mag = linear and min = nearest and mip = none */
  90621. static readonly TEXTURE_LINEAR_NEAREST: number;
  90622. /** Explicit coordinates mode */
  90623. static readonly TEXTURE_EXPLICIT_MODE: number;
  90624. /** Spherical coordinates mode */
  90625. static readonly TEXTURE_SPHERICAL_MODE: number;
  90626. /** Planar coordinates mode */
  90627. static readonly TEXTURE_PLANAR_MODE: number;
  90628. /** Cubic coordinates mode */
  90629. static readonly TEXTURE_CUBIC_MODE: number;
  90630. /** Projection coordinates mode */
  90631. static readonly TEXTURE_PROJECTION_MODE: number;
  90632. /** Skybox coordinates mode */
  90633. static readonly TEXTURE_SKYBOX_MODE: number;
  90634. /** Inverse Cubic coordinates mode */
  90635. static readonly TEXTURE_INVCUBIC_MODE: number;
  90636. /** Equirectangular coordinates mode */
  90637. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  90638. /** Equirectangular Fixed coordinates mode */
  90639. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  90640. /** Equirectangular Fixed Mirrored coordinates mode */
  90641. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  90642. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  90643. static readonly SCALEMODE_FLOOR: number;
  90644. /** Defines that texture rescaling will look for the nearest power of 2 size */
  90645. static readonly SCALEMODE_NEAREST: number;
  90646. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  90647. static readonly SCALEMODE_CEILING: number;
  90648. /**
  90649. * Returns the current npm package of the sdk
  90650. */
  90651. static readonly NpmPackage: string;
  90652. /**
  90653. * Returns the current version of the framework
  90654. */
  90655. static readonly Version: string;
  90656. /**
  90657. * Returns a string describing the current engine
  90658. */
  90659. readonly description: string;
  90660. /**
  90661. * Gets or sets the epsilon value used by collision engine
  90662. */
  90663. static CollisionsEpsilon: number;
  90664. /**
  90665. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  90666. */
  90667. static ShadersRepository: string;
  90668. /**
  90669. * Method called to create the default loading screen.
  90670. * This can be overriden in your own app.
  90671. * @param canvas The rendering canvas element
  90672. * @returns The loading screen
  90673. */
  90674. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  90675. /**
  90676. * Method called to create the default rescale post process on each engine.
  90677. */
  90678. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  90679. /** @hidden */
  90680. _shaderProcessor: IShaderProcessor;
  90681. /**
  90682. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  90683. */
  90684. forcePOTTextures: boolean;
  90685. /**
  90686. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  90687. */
  90688. isFullscreen: boolean;
  90689. /**
  90690. * Gets a boolean indicating if the pointer is currently locked
  90691. */
  90692. isPointerLock: boolean;
  90693. /**
  90694. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  90695. */
  90696. cullBackFaces: boolean;
  90697. /**
  90698. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  90699. */
  90700. renderEvenInBackground: boolean;
  90701. /**
  90702. * Gets or sets a boolean indicating that cache can be kept between frames
  90703. */
  90704. preventCacheWipeBetweenFrames: boolean;
  90705. /**
  90706. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90707. **/
  90708. enableOfflineSupport: boolean;
  90709. /**
  90710. * 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)
  90711. **/
  90712. disableManifestCheck: boolean;
  90713. /**
  90714. * Gets the list of created scenes
  90715. */
  90716. scenes: Scene[];
  90717. /**
  90718. * Event raised when a new scene is created
  90719. */
  90720. onNewSceneAddedObservable: Observable<Scene>;
  90721. /**
  90722. * Gets the list of created postprocesses
  90723. */
  90724. postProcesses: PostProcess[];
  90725. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90726. validateShaderPrograms: boolean;
  90727. /**
  90728. * Observable event triggered each time the rendering canvas is resized
  90729. */
  90730. onResizeObservable: Observable<Engine>;
  90731. /**
  90732. * Observable event triggered each time the canvas loses focus
  90733. */
  90734. onCanvasBlurObservable: Observable<Engine>;
  90735. /**
  90736. * Observable event triggered each time the canvas gains focus
  90737. */
  90738. onCanvasFocusObservable: Observable<Engine>;
  90739. /**
  90740. * Observable event triggered each time the canvas receives pointerout event
  90741. */
  90742. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90743. /**
  90744. * Observable event triggered before each texture is initialized
  90745. */
  90746. onBeforeTextureInitObservable: Observable<Texture>;
  90747. /**
  90748. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90749. */
  90750. disableUniformBuffers: boolean;
  90751. /** @hidden */
  90752. _uniformBuffers: UniformBuffer[];
  90753. /**
  90754. * Gets a boolean indicating that the engine supports uniform buffers
  90755. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90756. */
  90757. readonly supportsUniformBuffers: boolean;
  90758. /**
  90759. * Observable raised when the engine begins a new frame
  90760. */
  90761. onBeginFrameObservable: Observable<Engine>;
  90762. /**
  90763. * If set, will be used to request the next animation frame for the render loop
  90764. */
  90765. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90766. /**
  90767. * Observable raised when the engine ends the current frame
  90768. */
  90769. onEndFrameObservable: Observable<Engine>;
  90770. /**
  90771. * Observable raised when the engine is about to compile a shader
  90772. */
  90773. onBeforeShaderCompilationObservable: Observable<Engine>;
  90774. /**
  90775. * Observable raised when the engine has jsut compiled a shader
  90776. */
  90777. onAfterShaderCompilationObservable: Observable<Engine>;
  90778. /** @hidden */
  90779. _gl: WebGLRenderingContext;
  90780. private _renderingCanvas;
  90781. private _windowIsBackground;
  90782. private _webGLVersion;
  90783. protected _highPrecisionShadersAllowed: boolean;
  90784. /** @hidden */
  90785. readonly _shouldUseHighPrecisionShader: boolean;
  90786. /**
  90787. * Gets a boolean indicating that only power of 2 textures are supported
  90788. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90789. */
  90790. readonly needPOTTextures: boolean;
  90791. /** @hidden */
  90792. _badOS: boolean;
  90793. /** @hidden */
  90794. _badDesktopOS: boolean;
  90795. /**
  90796. * Gets the audio engine
  90797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90798. * @ignorenaming
  90799. */
  90800. static audioEngine: IAudioEngine;
  90801. /**
  90802. * Default AudioEngine factory responsible of creating the Audio Engine.
  90803. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90804. */
  90805. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90806. /**
  90807. * Default offline support factory responsible of creating a tool used to store data locally.
  90808. * By default, this will create a Database object if the workload has been embedded.
  90809. */
  90810. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90811. private _onFocus;
  90812. private _onBlur;
  90813. private _onCanvasPointerOut;
  90814. private _onCanvasBlur;
  90815. private _onCanvasFocus;
  90816. private _onFullscreenChange;
  90817. private _onPointerLockChange;
  90818. private _hardwareScalingLevel;
  90819. /** @hidden */
  90820. _caps: EngineCapabilities;
  90821. private _pointerLockRequested;
  90822. private _isStencilEnable;
  90823. private _colorWrite;
  90824. private _loadingScreen;
  90825. /** @hidden */
  90826. _drawCalls: PerfCounter;
  90827. private _glVersion;
  90828. private _glRenderer;
  90829. private _glVendor;
  90830. private _videoTextureSupported;
  90831. private _renderingQueueLaunched;
  90832. private _activeRenderLoops;
  90833. private _deterministicLockstep;
  90834. private _lockstepMaxSteps;
  90835. /**
  90836. * Observable signaled when a context lost event is raised
  90837. */
  90838. onContextLostObservable: Observable<Engine>;
  90839. /**
  90840. * Observable signaled when a context restored event is raised
  90841. */
  90842. onContextRestoredObservable: Observable<Engine>;
  90843. private _onContextLost;
  90844. private _onContextRestored;
  90845. private _contextWasLost;
  90846. /** @hidden */
  90847. _doNotHandleContextLost: boolean;
  90848. /**
  90849. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90850. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90851. */
  90852. doNotHandleContextLost: boolean;
  90853. private _performanceMonitor;
  90854. private _fps;
  90855. private _deltaTime;
  90856. /**
  90857. * Turn this value on if you want to pause FPS computation when in background
  90858. */
  90859. disablePerformanceMonitorInBackground: boolean;
  90860. /**
  90861. * Gets the performance monitor attached to this engine
  90862. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90863. */
  90864. readonly performanceMonitor: PerformanceMonitor;
  90865. /**
  90866. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90867. */
  90868. disableVertexArrayObjects: boolean;
  90869. /** @hidden */
  90870. protected _depthCullingState: _DepthCullingState;
  90871. /** @hidden */
  90872. protected _stencilState: _StencilState;
  90873. /** @hidden */
  90874. protected _alphaState: _AlphaState;
  90875. /** @hidden */
  90876. protected _alphaMode: number;
  90877. /** @hidden */
  90878. _internalTexturesCache: InternalTexture[];
  90879. /** @hidden */
  90880. protected _activeChannel: number;
  90881. private _currentTextureChannel;
  90882. /** @hidden */
  90883. protected _boundTexturesCache: {
  90884. [key: string]: Nullable<InternalTexture>;
  90885. };
  90886. /** @hidden */
  90887. protected _currentEffect: Nullable<Effect>;
  90888. /** @hidden */
  90889. protected _currentProgram: Nullable<WebGLProgram>;
  90890. private _compiledEffects;
  90891. private _vertexAttribArraysEnabled;
  90892. /** @hidden */
  90893. protected _cachedViewport: Nullable<Viewport>;
  90894. private _cachedVertexArrayObject;
  90895. /** @hidden */
  90896. protected _cachedVertexBuffers: any;
  90897. /** @hidden */
  90898. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90899. /** @hidden */
  90900. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90901. /** @hidden */
  90902. _currentRenderTarget: Nullable<InternalTexture>;
  90903. private _uintIndicesCurrentlySet;
  90904. private _currentBoundBuffer;
  90905. /** @hidden */
  90906. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90907. private _currentBufferPointers;
  90908. private _currentInstanceLocations;
  90909. private _currentInstanceBuffers;
  90910. private _textureUnits;
  90911. /** @hidden */
  90912. _workingCanvas: Nullable<HTMLCanvasElement>;
  90913. /** @hidden */
  90914. _workingContext: Nullable<CanvasRenderingContext2D>;
  90915. private _rescalePostProcess;
  90916. private _dummyFramebuffer;
  90917. private _externalData;
  90918. /** @hidden */
  90919. _bindedRenderFunction: any;
  90920. private _vaoRecordInProgress;
  90921. private _mustWipeVertexAttributes;
  90922. private _emptyTexture;
  90923. private _emptyCubeTexture;
  90924. private _emptyTexture3D;
  90925. /** @hidden */
  90926. _frameHandler: number;
  90927. private _nextFreeTextureSlots;
  90928. private _maxSimultaneousTextures;
  90929. private _activeRequests;
  90930. private _texturesSupported;
  90931. /** @hidden */
  90932. _textureFormatInUse: Nullable<string>;
  90933. /**
  90934. * Gets the list of texture formats supported
  90935. */
  90936. readonly texturesSupported: Array<string>;
  90937. /**
  90938. * Gets the list of texture formats in use
  90939. */
  90940. readonly textureFormatInUse: Nullable<string>;
  90941. /**
  90942. * Gets the current viewport
  90943. */
  90944. readonly currentViewport: Nullable<Viewport>;
  90945. /**
  90946. * Gets the default empty texture
  90947. */
  90948. readonly emptyTexture: InternalTexture;
  90949. /**
  90950. * Gets the default empty 3D texture
  90951. */
  90952. readonly emptyTexture3D: InternalTexture;
  90953. /**
  90954. * Gets the default empty cube texture
  90955. */
  90956. readonly emptyCubeTexture: InternalTexture;
  90957. /**
  90958. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  90959. */
  90960. readonly premultipliedAlpha: boolean;
  90961. /**
  90962. * Creates a new engine
  90963. * @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
  90964. * @param antialias defines enable antialiasing (default: false)
  90965. * @param options defines further options to be sent to the getContext() function
  90966. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  90967. */
  90968. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  90969. /**
  90970. * Initializes a webVR display and starts listening to display change events
  90971. * The onVRDisplayChangedObservable will be notified upon these changes
  90972. * @returns The onVRDisplayChangedObservable
  90973. */
  90974. initWebVR(): Observable<IDisplayChangedEventArgs>;
  90975. /** @hidden */
  90976. _prepareVRComponent(): void;
  90977. /** @hidden */
  90978. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  90979. /** @hidden */
  90980. _submitVRFrame(): void;
  90981. /**
  90982. * Call this function to leave webVR mode
  90983. * Will do nothing if webVR is not supported or if there is no webVR device
  90984. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90985. */
  90986. disableVR(): void;
  90987. /**
  90988. * Gets a boolean indicating that the system is in VR mode and is presenting
  90989. * @returns true if VR mode is engaged
  90990. */
  90991. isVRPresenting(): boolean;
  90992. /** @hidden */
  90993. _requestVRFrame(): void;
  90994. private _disableTouchAction;
  90995. private _rebuildInternalTextures;
  90996. private _rebuildEffects;
  90997. /**
  90998. * Gets a boolean indicating if all created effects are ready
  90999. * @returns true if all effects are ready
  91000. */
  91001. areAllEffectsReady(): boolean;
  91002. private _rebuildBuffers;
  91003. private _initGLContext;
  91004. /**
  91005. * Gets version of the current webGL context
  91006. */
  91007. readonly webGLVersion: number;
  91008. /**
  91009. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  91010. */
  91011. readonly isStencilEnable: boolean;
  91012. /** @hidden */
  91013. _prepareWorkingCanvas(): void;
  91014. /**
  91015. * Reset the texture cache to empty state
  91016. */
  91017. resetTextureCache(): void;
  91018. /**
  91019. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  91020. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91021. * @returns true if engine is in deterministic lock step mode
  91022. */
  91023. isDeterministicLockStep(): boolean;
  91024. /**
  91025. * Gets the max steps when engine is running in deterministic lock step
  91026. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91027. * @returns the max steps
  91028. */
  91029. getLockstepMaxSteps(): number;
  91030. /**
  91031. * Gets an object containing information about the current webGL context
  91032. * @returns an object containing the vender, the renderer and the version of the current webGL context
  91033. */
  91034. getGlInfo(): {
  91035. vendor: string;
  91036. renderer: string;
  91037. version: string;
  91038. };
  91039. /**
  91040. * Gets current aspect ratio
  91041. * @param camera defines the camera to use to get the aspect ratio
  91042. * @param useScreen defines if screen size must be used (or the current render target if any)
  91043. * @returns a number defining the aspect ratio
  91044. */
  91045. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  91046. /**
  91047. * Gets current screen aspect ratio
  91048. * @returns a number defining the aspect ratio
  91049. */
  91050. getScreenAspectRatio(): number;
  91051. /**
  91052. * Gets the current render width
  91053. * @param useScreen defines if screen size must be used (or the current render target if any)
  91054. * @returns a number defining the current render width
  91055. */
  91056. getRenderWidth(useScreen?: boolean): number;
  91057. /**
  91058. * Gets the current render height
  91059. * @param useScreen defines if screen size must be used (or the current render target if any)
  91060. * @returns a number defining the current render height
  91061. */
  91062. getRenderHeight(useScreen?: boolean): number;
  91063. /**
  91064. * Gets the HTML canvas attached with the current webGL context
  91065. * @returns a HTML canvas
  91066. */
  91067. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  91068. /**
  91069. * Gets the client rect of the HTML canvas attached with the current webGL context
  91070. * @returns a client rectanglee
  91071. */
  91072. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  91073. /**
  91074. * Defines the hardware scaling level.
  91075. * By default the hardware scaling level is computed from the window device ratio.
  91076. * 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.
  91077. * @param level defines the level to use
  91078. */
  91079. setHardwareScalingLevel(level: number): void;
  91080. /**
  91081. * Gets the current hardware scaling level.
  91082. * By default the hardware scaling level is computed from the window device ratio.
  91083. * 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.
  91084. * @returns a number indicating the current hardware scaling level
  91085. */
  91086. getHardwareScalingLevel(): number;
  91087. /**
  91088. * Gets the list of loaded textures
  91089. * @returns an array containing all loaded textures
  91090. */
  91091. getLoadedTexturesCache(): InternalTexture[];
  91092. /**
  91093. * Gets the object containing all engine capabilities
  91094. * @returns the EngineCapabilities object
  91095. */
  91096. getCaps(): EngineCapabilities;
  91097. /**
  91098. * Gets the current depth function
  91099. * @returns a number defining the depth function
  91100. */
  91101. getDepthFunction(): Nullable<number>;
  91102. /**
  91103. * Sets the current depth function
  91104. * @param depthFunc defines the function to use
  91105. */
  91106. setDepthFunction(depthFunc: number): void;
  91107. /**
  91108. * Sets the current depth function to GREATER
  91109. */
  91110. setDepthFunctionToGreater(): void;
  91111. /**
  91112. * Sets the current depth function to GEQUAL
  91113. */
  91114. setDepthFunctionToGreaterOrEqual(): void;
  91115. /**
  91116. * Sets the current depth function to LESS
  91117. */
  91118. setDepthFunctionToLess(): void;
  91119. private _cachedStencilBuffer;
  91120. private _cachedStencilFunction;
  91121. private _cachedStencilMask;
  91122. private _cachedStencilOperationPass;
  91123. private _cachedStencilOperationFail;
  91124. private _cachedStencilOperationDepthFail;
  91125. private _cachedStencilReference;
  91126. /**
  91127. * Caches the the state of the stencil buffer
  91128. */
  91129. cacheStencilState(): void;
  91130. /**
  91131. * Restores the state of the stencil buffer
  91132. */
  91133. restoreStencilState(): void;
  91134. /**
  91135. * Sets the current depth function to LEQUAL
  91136. */
  91137. setDepthFunctionToLessOrEqual(): void;
  91138. /**
  91139. * Gets a boolean indicating if stencil buffer is enabled
  91140. * @returns the current stencil buffer state
  91141. */
  91142. getStencilBuffer(): boolean;
  91143. /**
  91144. * Enable or disable the stencil buffer
  91145. * @param enable defines if the stencil buffer must be enabled or disabled
  91146. */
  91147. setStencilBuffer(enable: boolean): void;
  91148. /**
  91149. * Gets the current stencil mask
  91150. * @returns a number defining the new stencil mask to use
  91151. */
  91152. getStencilMask(): number;
  91153. /**
  91154. * Sets the current stencil mask
  91155. * @param mask defines the new stencil mask to use
  91156. */
  91157. setStencilMask(mask: number): void;
  91158. /**
  91159. * Gets the current stencil function
  91160. * @returns a number defining the stencil function to use
  91161. */
  91162. getStencilFunction(): number;
  91163. /**
  91164. * Gets the current stencil reference value
  91165. * @returns a number defining the stencil reference value to use
  91166. */
  91167. getStencilFunctionReference(): number;
  91168. /**
  91169. * Gets the current stencil mask
  91170. * @returns a number defining the stencil mask to use
  91171. */
  91172. getStencilFunctionMask(): number;
  91173. /**
  91174. * Sets the current stencil function
  91175. * @param stencilFunc defines the new stencil function to use
  91176. */
  91177. setStencilFunction(stencilFunc: number): void;
  91178. /**
  91179. * Sets the current stencil reference
  91180. * @param reference defines the new stencil reference to use
  91181. */
  91182. setStencilFunctionReference(reference: number): void;
  91183. /**
  91184. * Sets the current stencil mask
  91185. * @param mask defines the new stencil mask to use
  91186. */
  91187. setStencilFunctionMask(mask: number): void;
  91188. /**
  91189. * Gets the current stencil operation when stencil fails
  91190. * @returns a number defining stencil operation to use when stencil fails
  91191. */
  91192. getStencilOperationFail(): number;
  91193. /**
  91194. * Gets the current stencil operation when depth fails
  91195. * @returns a number defining stencil operation to use when depth fails
  91196. */
  91197. getStencilOperationDepthFail(): number;
  91198. /**
  91199. * Gets the current stencil operation when stencil passes
  91200. * @returns a number defining stencil operation to use when stencil passes
  91201. */
  91202. getStencilOperationPass(): number;
  91203. /**
  91204. * Sets the stencil operation to use when stencil fails
  91205. * @param operation defines the stencil operation to use when stencil fails
  91206. */
  91207. setStencilOperationFail(operation: number): void;
  91208. /**
  91209. * Sets the stencil operation to use when depth fails
  91210. * @param operation defines the stencil operation to use when depth fails
  91211. */
  91212. setStencilOperationDepthFail(operation: number): void;
  91213. /**
  91214. * Sets the stencil operation to use when stencil passes
  91215. * @param operation defines the stencil operation to use when stencil passes
  91216. */
  91217. setStencilOperationPass(operation: number): void;
  91218. /**
  91219. * Sets a boolean indicating if the dithering state is enabled or disabled
  91220. * @param value defines the dithering state
  91221. */
  91222. setDitheringState(value: boolean): void;
  91223. /**
  91224. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  91225. * @param value defines the rasterizer state
  91226. */
  91227. setRasterizerState(value: boolean): void;
  91228. /**
  91229. * stop executing a render loop function and remove it from the execution array
  91230. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  91231. */
  91232. stopRenderLoop(renderFunction?: () => void): void;
  91233. /** @hidden */
  91234. _renderLoop(): void;
  91235. /**
  91236. * Register and execute a render loop. The engine can have more than one render function
  91237. * @param renderFunction defines the function to continuously execute
  91238. */
  91239. runRenderLoop(renderFunction: () => void): void;
  91240. /**
  91241. * Toggle full screen mode
  91242. * @param requestPointerLock defines if a pointer lock should be requested from the user
  91243. */
  91244. switchFullscreen(requestPointerLock: boolean): void;
  91245. /**
  91246. * Enters full screen mode
  91247. * @param requestPointerLock defines if a pointer lock should be requested from the user
  91248. */
  91249. enterFullscreen(requestPointerLock: boolean): void;
  91250. /**
  91251. * Exits full screen mode
  91252. */
  91253. exitFullscreen(): void;
  91254. /**
  91255. * Enters Pointerlock mode
  91256. */
  91257. enterPointerlock(): void;
  91258. /**
  91259. * Exits Pointerlock mode
  91260. */
  91261. exitPointerlock(): void;
  91262. /**
  91263. * Clear the current render buffer or the current render target (if any is set up)
  91264. * @param color defines the color to use
  91265. * @param backBuffer defines if the back buffer must be cleared
  91266. * @param depth defines if the depth buffer must be cleared
  91267. * @param stencil defines if the stencil buffer must be cleared
  91268. */
  91269. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  91270. /**
  91271. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  91272. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  91273. * @param y defines the y-coordinate of the corner of the clear rectangle
  91274. * @param width defines the width of the clear rectangle
  91275. * @param height defines the height of the clear rectangle
  91276. * @param clearColor defines the clear color
  91277. */
  91278. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  91279. /**
  91280. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  91281. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  91282. * @param y defines the y-coordinate of the corner of the clear rectangle
  91283. * @param width defines the width of the clear rectangle
  91284. * @param height defines the height of the clear rectangle
  91285. */
  91286. enableScissor(x: number, y: number, width: number, height: number): void;
  91287. /**
  91288. * Disable previously set scissor test rectangle
  91289. */
  91290. disableScissor(): void;
  91291. private _viewportCached;
  91292. /** @hidden */
  91293. _viewport(x: number, y: number, width: number, height: number): void;
  91294. /**
  91295. * Set the WebGL's viewport
  91296. * @param viewport defines the viewport element to be used
  91297. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  91298. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  91299. */
  91300. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  91301. /**
  91302. * Directly set the WebGL Viewport
  91303. * @param x defines the x coordinate of the viewport (in screen space)
  91304. * @param y defines the y coordinate of the viewport (in screen space)
  91305. * @param width defines the width of the viewport (in screen space)
  91306. * @param height defines the height of the viewport (in screen space)
  91307. * @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
  91308. */
  91309. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  91310. /**
  91311. * Begin a new frame
  91312. */
  91313. beginFrame(): void;
  91314. /**
  91315. * Enf the current frame
  91316. */
  91317. endFrame(): void;
  91318. /**
  91319. * Resize the view according to the canvas' size
  91320. */
  91321. resize(): void;
  91322. /**
  91323. * Force a specific size of the canvas
  91324. * @param width defines the new canvas' width
  91325. * @param height defines the new canvas' height
  91326. */
  91327. setSize(width: number, height: number): void;
  91328. /**
  91329. * Binds the frame buffer to the specified texture.
  91330. * @param texture The texture to render to or null for the default canvas
  91331. * @param faceIndex The face of the texture to render to in case of cube texture
  91332. * @param requiredWidth The width of the target to render to
  91333. * @param requiredHeight The height of the target to render to
  91334. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  91335. * @param depthStencilTexture The depth stencil texture to use to render
  91336. * @param lodLevel defines le lod level to bind to the frame buffer
  91337. */
  91338. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  91339. /** @hidden */
  91340. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  91341. /**
  91342. * Unbind the current render target texture from the webGL context
  91343. * @param texture defines the render target texture to unbind
  91344. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  91345. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  91346. */
  91347. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  91348. /**
  91349. * Force the mipmap generation for the given render target texture
  91350. * @param texture defines the render target texture to use
  91351. */
  91352. generateMipMapsForCubemap(texture: InternalTexture): void;
  91353. /**
  91354. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  91355. */
  91356. flushFramebuffer(): void;
  91357. /**
  91358. * Unbind the current render target and bind the default framebuffer
  91359. */
  91360. restoreDefaultFramebuffer(): void;
  91361. /**
  91362. * Create an uniform buffer
  91363. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91364. * @param elements defines the content of the uniform buffer
  91365. * @returns the webGL uniform buffer
  91366. */
  91367. createUniformBuffer(elements: FloatArray): DataBuffer;
  91368. /**
  91369. * Create a dynamic uniform buffer
  91370. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91371. * @param elements defines the content of the uniform buffer
  91372. * @returns the webGL uniform buffer
  91373. */
  91374. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  91375. /**
  91376. * Update an existing uniform buffer
  91377. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91378. * @param uniformBuffer defines the target uniform buffer
  91379. * @param elements defines the content to update
  91380. * @param offset defines the offset in the uniform buffer where update should start
  91381. * @param count defines the size of the data to update
  91382. */
  91383. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  91384. private _resetVertexBufferBinding;
  91385. /**
  91386. * Creates a vertex buffer
  91387. * @param data the data for the vertex buffer
  91388. * @returns the new WebGL static buffer
  91389. */
  91390. createVertexBuffer(data: DataArray): DataBuffer;
  91391. /**
  91392. * Creates a dynamic vertex buffer
  91393. * @param data the data for the dynamic vertex buffer
  91394. * @returns the new WebGL dynamic buffer
  91395. */
  91396. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  91397. /**
  91398. * Update a dynamic index buffer
  91399. * @param indexBuffer defines the target index buffer
  91400. * @param indices defines the data to update
  91401. * @param offset defines the offset in the target index buffer where update should start
  91402. */
  91403. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91404. /**
  91405. * Updates a dynamic vertex buffer.
  91406. * @param vertexBuffer the vertex buffer to update
  91407. * @param data the data used to update the vertex buffer
  91408. * @param byteOffset the byte offset of the data
  91409. * @param byteLength the byte length of the data
  91410. */
  91411. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91412. private _resetIndexBufferBinding;
  91413. /**
  91414. * Creates a new index buffer
  91415. * @param indices defines the content of the index buffer
  91416. * @param updatable defines if the index buffer must be updatable
  91417. * @returns a new webGL buffer
  91418. */
  91419. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  91420. /**
  91421. * Bind a webGL buffer to the webGL context
  91422. * @param buffer defines the buffer to bind
  91423. */
  91424. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  91425. /**
  91426. * Bind an uniform buffer to the current webGL context
  91427. * @param buffer defines the buffer to bind
  91428. */
  91429. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  91430. /**
  91431. * Bind a buffer to the current webGL context at a given location
  91432. * @param buffer defines the buffer to bind
  91433. * @param location defines the index where to bind the buffer
  91434. */
  91435. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  91436. /**
  91437. * Bind a specific block at a given index in a specific shader program
  91438. * @param pipelineContext defines the pipeline context to use
  91439. * @param blockName defines the block name
  91440. * @param index defines the index where to bind the block
  91441. */
  91442. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  91443. private bindIndexBuffer;
  91444. private bindBuffer;
  91445. /**
  91446. * update the bound buffer with the given data
  91447. * @param data defines the data to update
  91448. */
  91449. updateArrayBuffer(data: Float32Array): void;
  91450. private _vertexAttribPointer;
  91451. private _bindIndexBufferWithCache;
  91452. private _bindVertexBuffersAttributes;
  91453. /**
  91454. * Records a vertex array object
  91455. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91456. * @param vertexBuffers defines the list of vertex buffers to store
  91457. * @param indexBuffer defines the index buffer to store
  91458. * @param effect defines the effect to store
  91459. * @returns the new vertex array object
  91460. */
  91461. recordVertexArrayObject(vertexBuffers: {
  91462. [key: string]: VertexBuffer;
  91463. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  91464. /**
  91465. * Bind a specific vertex array object
  91466. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91467. * @param vertexArrayObject defines the vertex array object to bind
  91468. * @param indexBuffer defines the index buffer to bind
  91469. */
  91470. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  91471. /**
  91472. * Bind webGl buffers directly to the webGL context
  91473. * @param vertexBuffer defines the vertex buffer to bind
  91474. * @param indexBuffer defines the index buffer to bind
  91475. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  91476. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  91477. * @param effect defines the effect associated with the vertex buffer
  91478. */
  91479. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  91480. private _unbindVertexArrayObject;
  91481. /**
  91482. * Bind a list of vertex buffers to the webGL context
  91483. * @param vertexBuffers defines the list of vertex buffers to bind
  91484. * @param indexBuffer defines the index buffer to bind
  91485. * @param effect defines the effect associated with the vertex buffers
  91486. */
  91487. bindBuffers(vertexBuffers: {
  91488. [key: string]: Nullable<VertexBuffer>;
  91489. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  91490. /**
  91491. * Unbind all instance attributes
  91492. */
  91493. unbindInstanceAttributes(): void;
  91494. /**
  91495. * Release and free the memory of a vertex array object
  91496. * @param vao defines the vertex array object to delete
  91497. */
  91498. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  91499. /** @hidden */
  91500. _releaseBuffer(buffer: DataBuffer): boolean;
  91501. /**
  91502. * Creates a webGL buffer to use with instanciation
  91503. * @param capacity defines the size of the buffer
  91504. * @returns the webGL buffer
  91505. */
  91506. createInstancesBuffer(capacity: number): DataBuffer;
  91507. /**
  91508. * Delete a webGL buffer used with instanciation
  91509. * @param buffer defines the webGL buffer to delete
  91510. */
  91511. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  91512. /**
  91513. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  91514. * @param instancesBuffer defines the webGL buffer to update and bind
  91515. * @param data defines the data to store in the buffer
  91516. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  91517. */
  91518. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  91519. /**
  91520. * Apply all cached states (depth, culling, stencil and alpha)
  91521. */
  91522. applyStates(): void;
  91523. /**
  91524. * Send a draw order
  91525. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91526. * @param indexStart defines the starting index
  91527. * @param indexCount defines the number of index to draw
  91528. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91529. */
  91530. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  91531. /**
  91532. * Draw a list of points
  91533. * @param verticesStart defines the index of first vertex to draw
  91534. * @param verticesCount defines the count of vertices to draw
  91535. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91536. */
  91537. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91538. /**
  91539. * Draw a list of unindexed primitives
  91540. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91541. * @param verticesStart defines the index of first vertex to draw
  91542. * @param verticesCount defines the count of vertices to draw
  91543. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91544. */
  91545. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91546. /**
  91547. * Draw a list of indexed primitives
  91548. * @param fillMode defines the primitive to use
  91549. * @param indexStart defines the starting index
  91550. * @param indexCount defines the number of index to draw
  91551. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91552. */
  91553. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  91554. /**
  91555. * Draw a list of unindexed primitives
  91556. * @param fillMode defines the primitive to use
  91557. * @param verticesStart defines the index of first vertex to draw
  91558. * @param verticesCount defines the count of vertices to draw
  91559. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91560. */
  91561. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91562. private _drawMode;
  91563. /** @hidden */
  91564. _releaseEffect(effect: Effect): void;
  91565. /** @hidden */
  91566. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  91567. /**
  91568. * Create a new effect (used to store vertex/fragment shaders)
  91569. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  91570. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  91571. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  91572. * @param samplers defines an array of string used to represent textures
  91573. * @param defines defines the string containing the defines to use to compile the shaders
  91574. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  91575. * @param onCompiled defines a function to call when the effect creation is successful
  91576. * @param onError defines a function to call when the effect creation has failed
  91577. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  91578. * @returns the new Effect
  91579. */
  91580. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  91581. private _compileShader;
  91582. private _compileRawShader;
  91583. /**
  91584. * Directly creates a webGL program
  91585. * @param pipelineContext defines the pipeline context to attach to
  91586. * @param vertexCode defines the vertex shader code to use
  91587. * @param fragmentCode defines the fragment shader code to use
  91588. * @param context defines the webGL context to use (if not set, the current one will be used)
  91589. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91590. * @returns the new webGL program
  91591. */
  91592. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91593. /**
  91594. * Creates a webGL program
  91595. * @param pipelineContext defines the pipeline context to attach to
  91596. * @param vertexCode defines the vertex shader code to use
  91597. * @param fragmentCode defines the fragment shader code to use
  91598. * @param defines defines the string containing the defines to use to compile the shaders
  91599. * @param context defines the webGL context to use (if not set, the current one will be used)
  91600. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91601. * @returns the new webGL program
  91602. */
  91603. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91604. /**
  91605. * Creates a new pipeline context
  91606. * @returns the new pipeline
  91607. */
  91608. createPipelineContext(): WebGLPipelineContext;
  91609. private _createShaderProgram;
  91610. private _finalizePipelineContext;
  91611. /** @hidden */
  91612. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  91613. /** @hidden */
  91614. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  91615. /** @hidden */
  91616. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  91617. /**
  91618. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  91619. * @param pipelineContext defines the pipeline context to use
  91620. * @param uniformsNames defines the list of uniform names
  91621. * @returns an array of webGL uniform locations
  91622. */
  91623. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  91624. /**
  91625. * Gets the lsit of active attributes for a given webGL program
  91626. * @param pipelineContext defines the pipeline context to use
  91627. * @param attributesNames defines the list of attribute names to get
  91628. * @returns an array of indices indicating the offset of each attribute
  91629. */
  91630. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  91631. /**
  91632. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  91633. * @param effect defines the effect to activate
  91634. */
  91635. enableEffect(effect: Nullable<Effect>): void;
  91636. /**
  91637. * Set the value of an uniform to an array of int32
  91638. * @param uniform defines the webGL uniform location where to store the value
  91639. * @param array defines the array of int32 to store
  91640. */
  91641. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91642. /**
  91643. * Set the value of an uniform to an array of int32 (stored as vec2)
  91644. * @param uniform defines the webGL uniform location where to store the value
  91645. * @param array defines the array of int32 to store
  91646. */
  91647. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91648. /**
  91649. * Set the value of an uniform to an array of int32 (stored as vec3)
  91650. * @param uniform defines the webGL uniform location where to store the value
  91651. * @param array defines the array of int32 to store
  91652. */
  91653. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91654. /**
  91655. * Set the value of an uniform to an array of int32 (stored as vec4)
  91656. * @param uniform defines the webGL uniform location where to store the value
  91657. * @param array defines the array of int32 to store
  91658. */
  91659. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91660. /**
  91661. * Set the value of an uniform to an array of float32
  91662. * @param uniform defines the webGL uniform location where to store the value
  91663. * @param array defines the array of float32 to store
  91664. */
  91665. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91666. /**
  91667. * Set the value of an uniform to an array of float32 (stored as vec2)
  91668. * @param uniform defines the webGL uniform location where to store the value
  91669. * @param array defines the array of float32 to store
  91670. */
  91671. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91672. /**
  91673. * Set the value of an uniform to an array of float32 (stored as vec3)
  91674. * @param uniform defines the webGL uniform location where to store the value
  91675. * @param array defines the array of float32 to store
  91676. */
  91677. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91678. /**
  91679. * Set the value of an uniform to an array of float32 (stored as vec4)
  91680. * @param uniform defines the webGL uniform location where to store the value
  91681. * @param array defines the array of float32 to store
  91682. */
  91683. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91684. /**
  91685. * Set the value of an uniform to an array of number
  91686. * @param uniform defines the webGL uniform location where to store the value
  91687. * @param array defines the array of number to store
  91688. */
  91689. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91690. /**
  91691. * Set the value of an uniform to an array of number (stored as vec2)
  91692. * @param uniform defines the webGL uniform location where to store the value
  91693. * @param array defines the array of number to store
  91694. */
  91695. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91696. /**
  91697. * Set the value of an uniform to an array of number (stored as vec3)
  91698. * @param uniform defines the webGL uniform location where to store the value
  91699. * @param array defines the array of number to store
  91700. */
  91701. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91702. /**
  91703. * Set the value of an uniform to an array of number (stored as vec4)
  91704. * @param uniform defines the webGL uniform location where to store the value
  91705. * @param array defines the array of number to store
  91706. */
  91707. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91708. /**
  91709. * Set the value of an uniform to an array of float32 (stored as matrices)
  91710. * @param uniform defines the webGL uniform location where to store the value
  91711. * @param matrices defines the array of float32 to store
  91712. */
  91713. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91714. /**
  91715. * Set the value of an uniform to a matrix
  91716. * @param uniform defines the webGL uniform location where to store the value
  91717. * @param matrix defines the matrix to store
  91718. */
  91719. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91720. /**
  91721. * Set the value of an uniform to a matrix (3x3)
  91722. * @param uniform defines the webGL uniform location where to store the value
  91723. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91724. */
  91725. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91726. /**
  91727. * Set the value of an uniform to a matrix (2x2)
  91728. * @param uniform defines the webGL uniform location where to store the value
  91729. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91730. */
  91731. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91732. /**
  91733. * Set the value of an uniform to a number (int)
  91734. * @param uniform defines the webGL uniform location where to store the value
  91735. * @param value defines the int number to store
  91736. */
  91737. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91738. /**
  91739. * Set the value of an uniform to a number (float)
  91740. * @param uniform defines the webGL uniform location where to store the value
  91741. * @param value defines the float number to store
  91742. */
  91743. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91744. /**
  91745. * Set the value of an uniform to a vec2
  91746. * @param uniform defines the webGL uniform location where to store the value
  91747. * @param x defines the 1st component of the value
  91748. * @param y defines the 2nd component of the value
  91749. */
  91750. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91751. /**
  91752. * Set the value of an uniform to a vec3
  91753. * @param uniform defines the webGL uniform location where to store the value
  91754. * @param x defines the 1st component of the value
  91755. * @param y defines the 2nd component of the value
  91756. * @param z defines the 3rd component of the value
  91757. */
  91758. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91759. /**
  91760. * Set the value of an uniform to a boolean
  91761. * @param uniform defines the webGL uniform location where to store the value
  91762. * @param bool defines the boolean to store
  91763. */
  91764. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91765. /**
  91766. * Set the value of an uniform to a vec4
  91767. * @param uniform defines the webGL uniform location where to store the value
  91768. * @param x defines the 1st component of the value
  91769. * @param y defines the 2nd component of the value
  91770. * @param z defines the 3rd component of the value
  91771. * @param w defines the 4th component of the value
  91772. */
  91773. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91774. /**
  91775. * Set the value of an uniform to a Color3
  91776. * @param uniform defines the webGL uniform location where to store the value
  91777. * @param color3 defines the color to store
  91778. */
  91779. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91780. /**
  91781. * Set the value of an uniform to a Color3 and an alpha value
  91782. * @param uniform defines the webGL uniform location where to store the value
  91783. * @param color3 defines the color to store
  91784. * @param alpha defines the alpha component to store
  91785. */
  91786. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91787. /**
  91788. * Sets a Color4 on a uniform variable
  91789. * @param uniform defines the uniform location
  91790. * @param color4 defines the value to be set
  91791. */
  91792. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91793. /**
  91794. * Set various states to the webGL context
  91795. * @param culling defines backface culling state
  91796. * @param zOffset defines the value to apply to zOffset (0 by default)
  91797. * @param force defines if states must be applied even if cache is up to date
  91798. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91799. */
  91800. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91801. /**
  91802. * Set the z offset to apply to current rendering
  91803. * @param value defines the offset to apply
  91804. */
  91805. setZOffset(value: number): void;
  91806. /**
  91807. * Gets the current value of the zOffset
  91808. * @returns the current zOffset state
  91809. */
  91810. getZOffset(): number;
  91811. /**
  91812. * Enable or disable depth buffering
  91813. * @param enable defines the state to set
  91814. */
  91815. setDepthBuffer(enable: boolean): void;
  91816. /**
  91817. * Gets a boolean indicating if depth writing is enabled
  91818. * @returns the current depth writing state
  91819. */
  91820. getDepthWrite(): boolean;
  91821. /**
  91822. * Enable or disable depth writing
  91823. * @param enable defines the state to set
  91824. */
  91825. setDepthWrite(enable: boolean): void;
  91826. /**
  91827. * Enable or disable color writing
  91828. * @param enable defines the state to set
  91829. */
  91830. setColorWrite(enable: boolean): void;
  91831. /**
  91832. * Gets a boolean indicating if color writing is enabled
  91833. * @returns the current color writing state
  91834. */
  91835. getColorWrite(): boolean;
  91836. /**
  91837. * Sets alpha constants used by some alpha blending modes
  91838. * @param r defines the red component
  91839. * @param g defines the green component
  91840. * @param b defines the blue component
  91841. * @param a defines the alpha component
  91842. */
  91843. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91844. /**
  91845. * Sets the current alpha mode
  91846. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91847. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91848. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91849. */
  91850. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91851. /**
  91852. * Gets the current alpha mode
  91853. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91854. * @returns the current alpha mode
  91855. */
  91856. getAlphaMode(): number;
  91857. /**
  91858. * Clears the list of texture accessible through engine.
  91859. * This can help preventing texture load conflict due to name collision.
  91860. */
  91861. clearInternalTexturesCache(): void;
  91862. /**
  91863. * Force the entire cache to be cleared
  91864. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91865. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91866. */
  91867. wipeCaches(bruteForce?: boolean): void;
  91868. /**
  91869. * Set the compressed texture format to use, based on the formats you have, and the formats
  91870. * supported by the hardware / browser.
  91871. *
  91872. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91873. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91874. * to API arguments needed to compressed textures. This puts the burden on the container
  91875. * generator to house the arcane code for determining these for current & future formats.
  91876. *
  91877. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91878. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91879. *
  91880. * Note: The result of this call is not taken into account when a texture is base64.
  91881. *
  91882. * @param formatsAvailable defines the list of those format families you have created
  91883. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91884. *
  91885. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91886. * @returns The extension selected.
  91887. */
  91888. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91889. /** @hidden */
  91890. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91891. min: number;
  91892. mag: number;
  91893. };
  91894. /** @hidden */
  91895. _createTexture(): WebGLTexture;
  91896. /**
  91897. * Usually called from Texture.ts.
  91898. * Passed information to create a WebGLTexture
  91899. * @param urlArg defines a value which contains one of the following:
  91900. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91901. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91902. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91903. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91904. * @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)
  91905. * @param scene needed for loading to the correct scene
  91906. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91907. * @param onLoad optional callback to be called upon successful completion
  91908. * @param onError optional callback to be called upon failure
  91909. * @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
  91910. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91911. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91912. * @param forcedExtension defines the extension to use to pick the right loader
  91913. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91914. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91915. */
  91916. 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;
  91917. /**
  91918. * @hidden
  91919. * Rescales a texture
  91920. * @param source input texutre
  91921. * @param destination destination texture
  91922. * @param scene scene to use to render the resize
  91923. * @param internalFormat format to use when resizing
  91924. * @param onComplete callback to be called when resize has completed
  91925. */
  91926. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  91927. private _unpackFlipYCached;
  91928. /**
  91929. * In case you are sharing the context with other applications, it might
  91930. * be interested to not cache the unpack flip y state to ensure a consistent
  91931. * value would be set.
  91932. */
  91933. enableUnpackFlipYCached: boolean;
  91934. /** @hidden */
  91935. _unpackFlipY(value: boolean): void;
  91936. /** @hidden */
  91937. _getUnpackAlignement(): number;
  91938. /**
  91939. * Creates a dynamic texture
  91940. * @param width defines the width of the texture
  91941. * @param height defines the height of the texture
  91942. * @param generateMipMaps defines if the engine should generate the mip levels
  91943. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91944. * @returns the dynamic texture inside an InternalTexture
  91945. */
  91946. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  91947. /**
  91948. * Update the sampling mode of a given texture
  91949. * @param samplingMode defines the required sampling mode
  91950. * @param texture defines the texture to update
  91951. */
  91952. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  91953. /**
  91954. * Update the content of a dynamic texture
  91955. * @param texture defines the texture to update
  91956. * @param canvas defines the canvas containing the source
  91957. * @param invertY defines if data must be stored with Y axis inverted
  91958. * @param premulAlpha defines if alpha is stored as premultiplied
  91959. * @param format defines the format of the data
  91960. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  91961. */
  91962. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  91963. /**
  91964. * Update a video texture
  91965. * @param texture defines the texture to update
  91966. * @param video defines the video element to use
  91967. * @param invertY defines if data must be stored with Y axis inverted
  91968. */
  91969. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  91970. /**
  91971. * Updates a depth texture Comparison Mode and Function.
  91972. * If the comparison Function is equal to 0, the mode will be set to none.
  91973. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  91974. * @param texture The texture to set the comparison function for
  91975. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  91976. */
  91977. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  91978. /** @hidden */
  91979. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  91980. width: number;
  91981. height: number;
  91982. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  91983. /**
  91984. * Creates a depth stencil texture.
  91985. * This is only available in WebGL 2 or with the depth texture extension available.
  91986. * @param size The size of face edge in the texture.
  91987. * @param options The options defining the texture.
  91988. * @returns The texture
  91989. */
  91990. createDepthStencilTexture(size: number | {
  91991. width: number;
  91992. height: number;
  91993. }, options: DepthTextureCreationOptions): InternalTexture;
  91994. /**
  91995. * Creates a depth stencil texture.
  91996. * This is only available in WebGL 2 or with the depth texture extension available.
  91997. * @param size The size of face edge in the texture.
  91998. * @param options The options defining the texture.
  91999. * @returns The texture
  92000. */
  92001. private _createDepthStencilTexture;
  92002. /**
  92003. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  92004. * @param renderTarget The render target to set the frame buffer for
  92005. */
  92006. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  92007. /**
  92008. * Creates a new render target texture
  92009. * @param size defines the size of the texture
  92010. * @param options defines the options used to create the texture
  92011. * @returns a new render target texture stored in an InternalTexture
  92012. */
  92013. createRenderTargetTexture(size: number | {
  92014. width: number;
  92015. height: number;
  92016. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  92017. /** @hidden */
  92018. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  92019. /**
  92020. * Updates the sample count of a render target texture
  92021. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  92022. * @param texture defines the texture to update
  92023. * @param samples defines the sample count to set
  92024. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  92025. */
  92026. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  92027. /** @hidden */
  92028. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  92029. /** @hidden */
  92030. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  92031. /** @hidden */
  92032. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  92033. /** @hidden */
  92034. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  92035. /**
  92036. * @hidden
  92037. */
  92038. _setCubeMapTextureParams(loadMipmap: boolean): void;
  92039. private _prepareWebGLTextureContinuation;
  92040. private _prepareWebGLTexture;
  92041. /** @hidden */
  92042. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  92043. /** @hidden */
  92044. _releaseFramebufferObjects(texture: InternalTexture): void;
  92045. /** @hidden */
  92046. _releaseTexture(texture: InternalTexture): void;
  92047. private setProgram;
  92048. private _boundUniforms;
  92049. /**
  92050. * Binds an effect to the webGL context
  92051. * @param effect defines the effect to bind
  92052. */
  92053. bindSamplers(effect: Effect): void;
  92054. private _activateCurrentTexture;
  92055. /** @hidden */
  92056. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  92057. /** @hidden */
  92058. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  92059. /**
  92060. * Sets a texture to the webGL context from a postprocess
  92061. * @param channel defines the channel to use
  92062. * @param postProcess defines the source postprocess
  92063. */
  92064. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  92065. /**
  92066. * Binds the output of the passed in post process to the texture channel specified
  92067. * @param channel The channel the texture should be bound to
  92068. * @param postProcess The post process which's output should be bound
  92069. */
  92070. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  92071. /**
  92072. * Unbind all textures from the webGL context
  92073. */
  92074. unbindAllTextures(): void;
  92075. /**
  92076. * Sets a texture to the according uniform.
  92077. * @param channel The texture channel
  92078. * @param uniform The uniform to set
  92079. * @param texture The texture to apply
  92080. */
  92081. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  92082. /**
  92083. * Sets a depth stencil texture from a render target to the according uniform.
  92084. * @param channel The texture channel
  92085. * @param uniform The uniform to set
  92086. * @param texture The render target texture containing the depth stencil texture to apply
  92087. */
  92088. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  92089. private _bindSamplerUniformToChannel;
  92090. private _getTextureWrapMode;
  92091. private _setTexture;
  92092. /**
  92093. * Sets an array of texture to the webGL context
  92094. * @param channel defines the channel where the texture array must be set
  92095. * @param uniform defines the associated uniform location
  92096. * @param textures defines the array of textures to bind
  92097. */
  92098. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  92099. /** @hidden */
  92100. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  92101. private _setTextureParameterFloat;
  92102. private _setTextureParameterInteger;
  92103. /**
  92104. * Reads pixels from the current frame buffer. Please note that this function can be slow
  92105. * @param x defines the x coordinate of the rectangle where pixels must be read
  92106. * @param y defines the y coordinate of the rectangle where pixels must be read
  92107. * @param width defines the width of the rectangle where pixels must be read
  92108. * @param height defines the height of the rectangle where pixels must be read
  92109. * @returns a Uint8Array containing RGBA colors
  92110. */
  92111. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  92112. /**
  92113. * Add an externaly attached data from its key.
  92114. * This method call will fail and return false, if such key already exists.
  92115. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92116. * @param key the unique key that identifies the data
  92117. * @param data the data object to associate to the key for this Engine instance
  92118. * @return true if no such key were already present and the data was added successfully, false otherwise
  92119. */
  92120. addExternalData<T>(key: string, data: T): boolean;
  92121. /**
  92122. * Get an externaly attached data from its key
  92123. * @param key the unique key that identifies the data
  92124. * @return the associated data, if present (can be null), or undefined if not present
  92125. */
  92126. getExternalData<T>(key: string): T;
  92127. /**
  92128. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92129. * @param key the unique key that identifies the data
  92130. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92131. * @return the associated data, can be null if the factory returned null.
  92132. */
  92133. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92134. /**
  92135. * Remove an externaly attached data from the Engine instance
  92136. * @param key the unique key that identifies the data
  92137. * @return true if the data was successfully removed, false if it doesn't exist
  92138. */
  92139. removeExternalData(key: string): boolean;
  92140. /**
  92141. * Unbind all vertex attributes from the webGL context
  92142. */
  92143. unbindAllAttributes(): void;
  92144. /**
  92145. * 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
  92146. */
  92147. releaseEffects(): void;
  92148. /**
  92149. * Dispose and release all associated resources
  92150. */
  92151. dispose(): void;
  92152. /**
  92153. * Display the loading screen
  92154. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92155. */
  92156. displayLoadingUI(): void;
  92157. /**
  92158. * Hide the loading screen
  92159. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92160. */
  92161. hideLoadingUI(): void;
  92162. /**
  92163. * Gets the current loading screen object
  92164. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92165. */
  92166. /**
  92167. * Sets the current loading screen object
  92168. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92169. */
  92170. loadingScreen: ILoadingScreen;
  92171. /**
  92172. * Sets the current loading screen text
  92173. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92174. */
  92175. loadingUIText: string;
  92176. /**
  92177. * Sets the current loading screen background color
  92178. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92179. */
  92180. loadingUIBackgroundColor: string;
  92181. /**
  92182. * Attach a new callback raised when context lost event is fired
  92183. * @param callback defines the callback to call
  92184. */
  92185. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  92186. /**
  92187. * Attach a new callback raised when context restored event is fired
  92188. * @param callback defines the callback to call
  92189. */
  92190. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  92191. /**
  92192. * Gets the source code of the vertex shader associated with a specific webGL program
  92193. * @param program defines the program to use
  92194. * @returns a string containing the source code of the vertex shader associated with the program
  92195. */
  92196. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  92197. /**
  92198. * Gets the source code of the fragment shader associated with a specific webGL program
  92199. * @param program defines the program to use
  92200. * @returns a string containing the source code of the fragment shader associated with the program
  92201. */
  92202. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  92203. /**
  92204. * Get the current error code of the webGL context
  92205. * @returns the error code
  92206. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  92207. */
  92208. getError(): number;
  92209. /**
  92210. * Gets the current framerate
  92211. * @returns a number representing the framerate
  92212. */
  92213. getFps(): number;
  92214. /**
  92215. * Gets the time spent between current and previous frame
  92216. * @returns a number representing the delta time in ms
  92217. */
  92218. getDeltaTime(): number;
  92219. private _measureFps;
  92220. /** @hidden */
  92221. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  92222. private _canRenderToFloatFramebuffer;
  92223. private _canRenderToHalfFloatFramebuffer;
  92224. private _canRenderToFramebuffer;
  92225. /** @hidden */
  92226. _getWebGLTextureType(type: number): number;
  92227. /** @hidden */
  92228. _getInternalFormat(format: number): number;
  92229. /** @hidden */
  92230. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  92231. /** @hidden */
  92232. _getRGBAMultiSampleBufferFormat(type: number): number;
  92233. /** @hidden */
  92234. _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;
  92235. /** @hidden */
  92236. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92237. /**
  92238. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  92239. * @returns true if the engine can be created
  92240. * @ignorenaming
  92241. */
  92242. static isSupported(): boolean;
  92243. }
  92244. }
  92245. declare module BABYLON {
  92246. /**
  92247. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  92248. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  92249. */
  92250. export class EffectFallbacks {
  92251. private _defines;
  92252. private _currentRank;
  92253. private _maxRank;
  92254. private _mesh;
  92255. /**
  92256. * Removes the fallback from the bound mesh.
  92257. */
  92258. unBindMesh(): void;
  92259. /**
  92260. * Adds a fallback on the specified property.
  92261. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92262. * @param define The name of the define in the shader
  92263. */
  92264. addFallback(rank: number, define: string): void;
  92265. /**
  92266. * Sets the mesh to use CPU skinning when needing to fallback.
  92267. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92268. * @param mesh The mesh to use the fallbacks.
  92269. */
  92270. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  92271. /**
  92272. * Checks to see if more fallbacks are still availible.
  92273. */
  92274. readonly isMoreFallbacks: boolean;
  92275. /**
  92276. * Removes the defines that should be removed when falling back.
  92277. * @param currentDefines defines the current define statements for the shader.
  92278. * @param effect defines the current effect we try to compile
  92279. * @returns The resulting defines with defines of the current rank removed.
  92280. */
  92281. reduce(currentDefines: string, effect: Effect): string;
  92282. }
  92283. /**
  92284. * Options to be used when creating an effect.
  92285. */
  92286. export class EffectCreationOptions {
  92287. /**
  92288. * Atrributes that will be used in the shader.
  92289. */
  92290. attributes: string[];
  92291. /**
  92292. * Uniform varible names that will be set in the shader.
  92293. */
  92294. uniformsNames: string[];
  92295. /**
  92296. * Uniform buffer varible names that will be set in the shader.
  92297. */
  92298. uniformBuffersNames: string[];
  92299. /**
  92300. * Sampler texture variable names that will be set in the shader.
  92301. */
  92302. samplers: string[];
  92303. /**
  92304. * Define statements that will be set in the shader.
  92305. */
  92306. defines: any;
  92307. /**
  92308. * Possible fallbacks for this effect to improve performance when needed.
  92309. */
  92310. fallbacks: Nullable<EffectFallbacks>;
  92311. /**
  92312. * Callback that will be called when the shader is compiled.
  92313. */
  92314. onCompiled: Nullable<(effect: Effect) => void>;
  92315. /**
  92316. * Callback that will be called if an error occurs during shader compilation.
  92317. */
  92318. onError: Nullable<(effect: Effect, errors: string) => void>;
  92319. /**
  92320. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92321. */
  92322. indexParameters: any;
  92323. /**
  92324. * Max number of lights that can be used in the shader.
  92325. */
  92326. maxSimultaneousLights: number;
  92327. /**
  92328. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92329. */
  92330. transformFeedbackVaryings: Nullable<string[]>;
  92331. }
  92332. /**
  92333. * Effect containing vertex and fragment shader that can be executed on an object.
  92334. */
  92335. export class Effect implements IDisposable {
  92336. /**
  92337. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92338. */
  92339. static ShadersRepository: string;
  92340. /**
  92341. * Name of the effect.
  92342. */
  92343. name: any;
  92344. /**
  92345. * String container all the define statements that should be set on the shader.
  92346. */
  92347. defines: string;
  92348. /**
  92349. * Callback that will be called when the shader is compiled.
  92350. */
  92351. onCompiled: Nullable<(effect: Effect) => void>;
  92352. /**
  92353. * Callback that will be called if an error occurs during shader compilation.
  92354. */
  92355. onError: Nullable<(effect: Effect, errors: string) => void>;
  92356. /**
  92357. * Callback that will be called when effect is bound.
  92358. */
  92359. onBind: Nullable<(effect: Effect) => void>;
  92360. /**
  92361. * Unique ID of the effect.
  92362. */
  92363. uniqueId: number;
  92364. /**
  92365. * Observable that will be called when the shader is compiled.
  92366. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92367. */
  92368. onCompileObservable: Observable<Effect>;
  92369. /**
  92370. * Observable that will be called if an error occurs during shader compilation.
  92371. */
  92372. onErrorObservable: Observable<Effect>;
  92373. /** @hidden */
  92374. _onBindObservable: Nullable<Observable<Effect>>;
  92375. /**
  92376. * Observable that will be called when effect is bound.
  92377. */
  92378. readonly onBindObservable: Observable<Effect>;
  92379. /** @hidden */
  92380. _bonesComputationForcedToCPU: boolean;
  92381. private static _uniqueIdSeed;
  92382. private _engine;
  92383. private _uniformBuffersNames;
  92384. private _uniformsNames;
  92385. private _samplerList;
  92386. private _samplers;
  92387. private _isReady;
  92388. private _compilationError;
  92389. private _attributesNames;
  92390. private _attributes;
  92391. private _uniforms;
  92392. /**
  92393. * Key for the effect.
  92394. * @hidden
  92395. */
  92396. _key: string;
  92397. private _indexParameters;
  92398. private _fallbacks;
  92399. private _vertexSourceCode;
  92400. private _fragmentSourceCode;
  92401. private _vertexSourceCodeOverride;
  92402. private _fragmentSourceCodeOverride;
  92403. private _transformFeedbackVaryings;
  92404. /**
  92405. * Compiled shader to webGL program.
  92406. * @hidden
  92407. */
  92408. _pipelineContext: Nullable<IPipelineContext>;
  92409. private _valueCache;
  92410. private static _baseCache;
  92411. /**
  92412. * Instantiates an effect.
  92413. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92414. * @param baseName Name of the effect.
  92415. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92416. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92417. * @param samplers List of sampler variables that will be passed to the shader.
  92418. * @param engine Engine to be used to render the effect
  92419. * @param defines Define statements to be added to the shader.
  92420. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92421. * @param onCompiled Callback that will be called when the shader is compiled.
  92422. * @param onError Callback that will be called if an error occurs during shader compilation.
  92423. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92424. */
  92425. 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);
  92426. private _useFinalCode;
  92427. /**
  92428. * Unique key for this effect
  92429. */
  92430. readonly key: string;
  92431. /**
  92432. * If the effect has been compiled and prepared.
  92433. * @returns if the effect is compiled and prepared.
  92434. */
  92435. isReady(): boolean;
  92436. /**
  92437. * The engine the effect was initialized with.
  92438. * @returns the engine.
  92439. */
  92440. getEngine(): Engine;
  92441. /**
  92442. * The pipeline context for this effect
  92443. * @returns the associated pipeline context
  92444. */
  92445. getPipelineContext(): Nullable<IPipelineContext>;
  92446. /**
  92447. * The set of names of attribute variables for the shader.
  92448. * @returns An array of attribute names.
  92449. */
  92450. getAttributesNames(): string[];
  92451. /**
  92452. * Returns the attribute at the given index.
  92453. * @param index The index of the attribute.
  92454. * @returns The location of the attribute.
  92455. */
  92456. getAttributeLocation(index: number): number;
  92457. /**
  92458. * Returns the attribute based on the name of the variable.
  92459. * @param name of the attribute to look up.
  92460. * @returns the attribute location.
  92461. */
  92462. getAttributeLocationByName(name: string): number;
  92463. /**
  92464. * The number of attributes.
  92465. * @returns the numnber of attributes.
  92466. */
  92467. getAttributesCount(): number;
  92468. /**
  92469. * Gets the index of a uniform variable.
  92470. * @param uniformName of the uniform to look up.
  92471. * @returns the index.
  92472. */
  92473. getUniformIndex(uniformName: string): number;
  92474. /**
  92475. * Returns the attribute based on the name of the variable.
  92476. * @param uniformName of the uniform to look up.
  92477. * @returns the location of the uniform.
  92478. */
  92479. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92480. /**
  92481. * Returns an array of sampler variable names
  92482. * @returns The array of sampler variable neames.
  92483. */
  92484. getSamplers(): string[];
  92485. /**
  92486. * The error from the last compilation.
  92487. * @returns the error string.
  92488. */
  92489. getCompilationError(): string;
  92490. /**
  92491. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92492. * @param func The callback to be used.
  92493. */
  92494. executeWhenCompiled(func: (effect: Effect) => void): void;
  92495. private _checkIsReady;
  92496. /** @hidden */
  92497. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92498. /** @hidden */
  92499. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92500. /** @hidden */
  92501. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92502. /**
  92503. * Recompiles the webGL program
  92504. * @param vertexSourceCode The source code for the vertex shader.
  92505. * @param fragmentSourceCode The source code for the fragment shader.
  92506. * @param onCompiled Callback called when completed.
  92507. * @param onError Callback called on error.
  92508. * @hidden
  92509. */
  92510. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92511. /**
  92512. * Prepares the effect
  92513. * @hidden
  92514. */
  92515. _prepareEffect(): void;
  92516. /**
  92517. * Checks if the effect is supported. (Must be called after compilation)
  92518. */
  92519. readonly isSupported: boolean;
  92520. /**
  92521. * Binds a texture to the engine to be used as output of the shader.
  92522. * @param channel Name of the output variable.
  92523. * @param texture Texture to bind.
  92524. * @hidden
  92525. */
  92526. _bindTexture(channel: string, texture: InternalTexture): void;
  92527. /**
  92528. * Sets a texture on the engine to be used in the shader.
  92529. * @param channel Name of the sampler variable.
  92530. * @param texture Texture to set.
  92531. */
  92532. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92533. /**
  92534. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92535. * @param channel Name of the sampler variable.
  92536. * @param texture Texture to set.
  92537. */
  92538. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92539. /**
  92540. * Sets an array of textures on the engine to be used in the shader.
  92541. * @param channel Name of the variable.
  92542. * @param textures Textures to set.
  92543. */
  92544. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92545. /**
  92546. * 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)
  92547. * @param channel Name of the sampler variable.
  92548. * @param postProcess Post process to get the input texture from.
  92549. */
  92550. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92551. /**
  92552. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92553. * 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)
  92554. * @param channel Name of the sampler variable.
  92555. * @param postProcess Post process to get the output texture from.
  92556. */
  92557. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92558. /** @hidden */
  92559. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  92560. /** @hidden */
  92561. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92562. /** @hidden */
  92563. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92564. /** @hidden */
  92565. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92566. /**
  92567. * Binds a buffer to a uniform.
  92568. * @param buffer Buffer to bind.
  92569. * @param name Name of the uniform variable to bind to.
  92570. */
  92571. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92572. /**
  92573. * Binds block to a uniform.
  92574. * @param blockName Name of the block to bind.
  92575. * @param index Index to bind.
  92576. */
  92577. bindUniformBlock(blockName: string, index: number): void;
  92578. /**
  92579. * Sets an interger value on a uniform variable.
  92580. * @param uniformName Name of the variable.
  92581. * @param value Value to be set.
  92582. * @returns this effect.
  92583. */
  92584. setInt(uniformName: string, value: number): Effect;
  92585. /**
  92586. * Sets an int array on a uniform variable.
  92587. * @param uniformName Name of the variable.
  92588. * @param array array to be set.
  92589. * @returns this effect.
  92590. */
  92591. setIntArray(uniformName: string, array: Int32Array): Effect;
  92592. /**
  92593. * 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)
  92594. * @param uniformName Name of the variable.
  92595. * @param array array to be set.
  92596. * @returns this effect.
  92597. */
  92598. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92599. /**
  92600. * 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)
  92601. * @param uniformName Name of the variable.
  92602. * @param array array to be set.
  92603. * @returns this effect.
  92604. */
  92605. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92606. /**
  92607. * 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)
  92608. * @param uniformName Name of the variable.
  92609. * @param array array to be set.
  92610. * @returns this effect.
  92611. */
  92612. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92613. /**
  92614. * Sets an float array on a uniform variable.
  92615. * @param uniformName Name of the variable.
  92616. * @param array array to be set.
  92617. * @returns this effect.
  92618. */
  92619. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92620. /**
  92621. * 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)
  92622. * @param uniformName Name of the variable.
  92623. * @param array array to be set.
  92624. * @returns this effect.
  92625. */
  92626. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92627. /**
  92628. * 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)
  92629. * @param uniformName Name of the variable.
  92630. * @param array array to be set.
  92631. * @returns this effect.
  92632. */
  92633. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92634. /**
  92635. * 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)
  92636. * @param uniformName Name of the variable.
  92637. * @param array array to be set.
  92638. * @returns this effect.
  92639. */
  92640. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92641. /**
  92642. * Sets an array on a uniform variable.
  92643. * @param uniformName Name of the variable.
  92644. * @param array array to be set.
  92645. * @returns this effect.
  92646. */
  92647. setArray(uniformName: string, array: number[]): Effect;
  92648. /**
  92649. * 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)
  92650. * @param uniformName Name of the variable.
  92651. * @param array array to be set.
  92652. * @returns this effect.
  92653. */
  92654. setArray2(uniformName: string, array: number[]): Effect;
  92655. /**
  92656. * 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)
  92657. * @param uniformName Name of the variable.
  92658. * @param array array to be set.
  92659. * @returns this effect.
  92660. */
  92661. setArray3(uniformName: string, array: number[]): Effect;
  92662. /**
  92663. * 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)
  92664. * @param uniformName Name of the variable.
  92665. * @param array array to be set.
  92666. * @returns this effect.
  92667. */
  92668. setArray4(uniformName: string, array: number[]): Effect;
  92669. /**
  92670. * Sets matrices on a uniform variable.
  92671. * @param uniformName Name of the variable.
  92672. * @param matrices matrices to be set.
  92673. * @returns this effect.
  92674. */
  92675. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92676. /**
  92677. * Sets matrix on a uniform variable.
  92678. * @param uniformName Name of the variable.
  92679. * @param matrix matrix to be set.
  92680. * @returns this effect.
  92681. */
  92682. setMatrix(uniformName: string, matrix: Matrix): Effect;
  92683. /**
  92684. * 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)
  92685. * @param uniformName Name of the variable.
  92686. * @param matrix matrix to be set.
  92687. * @returns this effect.
  92688. */
  92689. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92690. /**
  92691. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92692. * @param uniformName Name of the variable.
  92693. * @param matrix matrix to be set.
  92694. * @returns this effect.
  92695. */
  92696. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92697. /**
  92698. * Sets a float on a uniform variable.
  92699. * @param uniformName Name of the variable.
  92700. * @param value value to be set.
  92701. * @returns this effect.
  92702. */
  92703. setFloat(uniformName: string, value: number): Effect;
  92704. /**
  92705. * Sets a boolean on a uniform variable.
  92706. * @param uniformName Name of the variable.
  92707. * @param bool value to be set.
  92708. * @returns this effect.
  92709. */
  92710. setBool(uniformName: string, bool: boolean): Effect;
  92711. /**
  92712. * Sets a Vector2 on a uniform variable.
  92713. * @param uniformName Name of the variable.
  92714. * @param vector2 vector2 to be set.
  92715. * @returns this effect.
  92716. */
  92717. setVector2(uniformName: string, vector2: Vector2): Effect;
  92718. /**
  92719. * Sets a float2 on a uniform variable.
  92720. * @param uniformName Name of the variable.
  92721. * @param x First float in float2.
  92722. * @param y Second float in float2.
  92723. * @returns this effect.
  92724. */
  92725. setFloat2(uniformName: string, x: number, y: number): Effect;
  92726. /**
  92727. * Sets a Vector3 on a uniform variable.
  92728. * @param uniformName Name of the variable.
  92729. * @param vector3 Value to be set.
  92730. * @returns this effect.
  92731. */
  92732. setVector3(uniformName: string, vector3: Vector3): Effect;
  92733. /**
  92734. * Sets a float3 on a uniform variable.
  92735. * @param uniformName Name of the variable.
  92736. * @param x First float in float3.
  92737. * @param y Second float in float3.
  92738. * @param z Third float in float3.
  92739. * @returns this effect.
  92740. */
  92741. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92742. /**
  92743. * Sets a Vector4 on a uniform variable.
  92744. * @param uniformName Name of the variable.
  92745. * @param vector4 Value to be set.
  92746. * @returns this effect.
  92747. */
  92748. setVector4(uniformName: string, vector4: Vector4): Effect;
  92749. /**
  92750. * Sets a float4 on a uniform variable.
  92751. * @param uniformName Name of the variable.
  92752. * @param x First float in float4.
  92753. * @param y Second float in float4.
  92754. * @param z Third float in float4.
  92755. * @param w Fourth float in float4.
  92756. * @returns this effect.
  92757. */
  92758. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92759. /**
  92760. * Sets a Color3 on a uniform variable.
  92761. * @param uniformName Name of the variable.
  92762. * @param color3 Value to be set.
  92763. * @returns this effect.
  92764. */
  92765. setColor3(uniformName: string, color3: Color3): Effect;
  92766. /**
  92767. * Sets a Color4 on a uniform variable.
  92768. * @param uniformName Name of the variable.
  92769. * @param color3 Value to be set.
  92770. * @param alpha Alpha value to be set.
  92771. * @returns this effect.
  92772. */
  92773. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92774. /**
  92775. * Sets a Color4 on a uniform variable
  92776. * @param uniformName defines the name of the variable
  92777. * @param color4 defines the value to be set
  92778. * @returns this effect.
  92779. */
  92780. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92781. /** Release all associated resources */
  92782. dispose(): void;
  92783. /**
  92784. * This function will add a new shader to the shader store
  92785. * @param name the name of the shader
  92786. * @param pixelShader optional pixel shader content
  92787. * @param vertexShader optional vertex shader content
  92788. */
  92789. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92790. /**
  92791. * Store of each shader (The can be looked up using effect.key)
  92792. */
  92793. static ShadersStore: {
  92794. [key: string]: string;
  92795. };
  92796. /**
  92797. * Store of each included file for a shader (The can be looked up using effect.key)
  92798. */
  92799. static IncludesShadersStore: {
  92800. [key: string]: string;
  92801. };
  92802. /**
  92803. * Resets the cache of effects.
  92804. */
  92805. static ResetCache(): void;
  92806. }
  92807. }
  92808. declare module BABYLON {
  92809. /**
  92810. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92811. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92812. * 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;
  92813. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92814. */
  92815. export class ColorCurves {
  92816. private _dirty;
  92817. private _tempColor;
  92818. private _globalCurve;
  92819. private _highlightsCurve;
  92820. private _midtonesCurve;
  92821. private _shadowsCurve;
  92822. private _positiveCurve;
  92823. private _negativeCurve;
  92824. private _globalHue;
  92825. private _globalDensity;
  92826. private _globalSaturation;
  92827. private _globalExposure;
  92828. /**
  92829. * Gets the global Hue value.
  92830. * 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).
  92831. */
  92832. /**
  92833. * Sets the global Hue value.
  92834. * 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).
  92835. */
  92836. globalHue: number;
  92837. /**
  92838. * Gets the global Density value.
  92839. * 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.
  92840. * Values less than zero provide a filter of opposite hue.
  92841. */
  92842. /**
  92843. * Sets the global Density value.
  92844. * 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.
  92845. * Values less than zero provide a filter of opposite hue.
  92846. */
  92847. globalDensity: number;
  92848. /**
  92849. * Gets the global Saturation value.
  92850. * 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.
  92851. */
  92852. /**
  92853. * Sets the global Saturation value.
  92854. * 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.
  92855. */
  92856. globalSaturation: number;
  92857. /**
  92858. * Gets the global Exposure value.
  92859. * 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.
  92860. */
  92861. /**
  92862. * Sets the global Exposure value.
  92863. * 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.
  92864. */
  92865. globalExposure: number;
  92866. private _highlightsHue;
  92867. private _highlightsDensity;
  92868. private _highlightsSaturation;
  92869. private _highlightsExposure;
  92870. /**
  92871. * Gets the highlights Hue value.
  92872. * 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).
  92873. */
  92874. /**
  92875. * Sets the highlights Hue value.
  92876. * 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).
  92877. */
  92878. highlightsHue: number;
  92879. /**
  92880. * Gets the highlights Density value.
  92881. * 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.
  92882. * Values less than zero provide a filter of opposite hue.
  92883. */
  92884. /**
  92885. * Sets the highlights Density value.
  92886. * 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.
  92887. * Values less than zero provide a filter of opposite hue.
  92888. */
  92889. highlightsDensity: number;
  92890. /**
  92891. * Gets the highlights Saturation value.
  92892. * 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.
  92893. */
  92894. /**
  92895. * Sets the highlights Saturation value.
  92896. * 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.
  92897. */
  92898. highlightsSaturation: number;
  92899. /**
  92900. * Gets the highlights Exposure value.
  92901. * 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.
  92902. */
  92903. /**
  92904. * Sets the highlights Exposure value.
  92905. * 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.
  92906. */
  92907. highlightsExposure: number;
  92908. private _midtonesHue;
  92909. private _midtonesDensity;
  92910. private _midtonesSaturation;
  92911. private _midtonesExposure;
  92912. /**
  92913. * Gets the midtones Hue value.
  92914. * 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).
  92915. */
  92916. /**
  92917. * Sets the midtones Hue value.
  92918. * 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).
  92919. */
  92920. midtonesHue: number;
  92921. /**
  92922. * Gets the midtones Density value.
  92923. * 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.
  92924. * Values less than zero provide a filter of opposite hue.
  92925. */
  92926. /**
  92927. * Sets the midtones Density value.
  92928. * 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.
  92929. * Values less than zero provide a filter of opposite hue.
  92930. */
  92931. midtonesDensity: number;
  92932. /**
  92933. * Gets the midtones Saturation value.
  92934. * 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.
  92935. */
  92936. /**
  92937. * Sets the midtones Saturation value.
  92938. * 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.
  92939. */
  92940. midtonesSaturation: number;
  92941. /**
  92942. * Gets the midtones Exposure value.
  92943. * 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.
  92944. */
  92945. /**
  92946. * Sets the midtones Exposure value.
  92947. * 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.
  92948. */
  92949. midtonesExposure: number;
  92950. private _shadowsHue;
  92951. private _shadowsDensity;
  92952. private _shadowsSaturation;
  92953. private _shadowsExposure;
  92954. /**
  92955. * Gets the shadows Hue value.
  92956. * 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).
  92957. */
  92958. /**
  92959. * Sets the shadows Hue value.
  92960. * 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).
  92961. */
  92962. shadowsHue: number;
  92963. /**
  92964. * Gets the shadows Density value.
  92965. * 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.
  92966. * Values less than zero provide a filter of opposite hue.
  92967. */
  92968. /**
  92969. * Sets the shadows Density value.
  92970. * 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.
  92971. * Values less than zero provide a filter of opposite hue.
  92972. */
  92973. shadowsDensity: number;
  92974. /**
  92975. * Gets the shadows Saturation value.
  92976. * 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.
  92977. */
  92978. /**
  92979. * Sets the shadows Saturation value.
  92980. * 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.
  92981. */
  92982. shadowsSaturation: number;
  92983. /**
  92984. * Gets the shadows Exposure value.
  92985. * 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.
  92986. */
  92987. /**
  92988. * Sets the shadows Exposure value.
  92989. * 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.
  92990. */
  92991. shadowsExposure: number;
  92992. /**
  92993. * Returns the class name
  92994. * @returns The class name
  92995. */
  92996. getClassName(): string;
  92997. /**
  92998. * Binds the color curves to the shader.
  92999. * @param colorCurves The color curve to bind
  93000. * @param effect The effect to bind to
  93001. * @param positiveUniform The positive uniform shader parameter
  93002. * @param neutralUniform The neutral uniform shader parameter
  93003. * @param negativeUniform The negative uniform shader parameter
  93004. */
  93005. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  93006. /**
  93007. * Prepare the list of uniforms associated with the ColorCurves effects.
  93008. * @param uniformsList The list of uniforms used in the effect
  93009. */
  93010. static PrepareUniforms(uniformsList: string[]): void;
  93011. /**
  93012. * Returns color grading data based on a hue, density, saturation and exposure value.
  93013. * @param filterHue The hue of the color filter.
  93014. * @param filterDensity The density of the color filter.
  93015. * @param saturation The saturation.
  93016. * @param exposure The exposure.
  93017. * @param result The result data container.
  93018. */
  93019. private getColorGradingDataToRef;
  93020. /**
  93021. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  93022. * @param value The input slider value in range [-100,100].
  93023. * @returns Adjusted value.
  93024. */
  93025. private static applyColorGradingSliderNonlinear;
  93026. /**
  93027. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  93028. * @param hue The hue (H) input.
  93029. * @param saturation The saturation (S) input.
  93030. * @param brightness The brightness (B) input.
  93031. * @result An RGBA color represented as Vector4.
  93032. */
  93033. private static fromHSBToRef;
  93034. /**
  93035. * Returns a value clamped between min and max
  93036. * @param value The value to clamp
  93037. * @param min The minimum of value
  93038. * @param max The maximum of value
  93039. * @returns The clamped value.
  93040. */
  93041. private static clamp;
  93042. /**
  93043. * Clones the current color curve instance.
  93044. * @return The cloned curves
  93045. */
  93046. clone(): ColorCurves;
  93047. /**
  93048. * Serializes the current color curve instance to a json representation.
  93049. * @return a JSON representation
  93050. */
  93051. serialize(): any;
  93052. /**
  93053. * Parses the color curve from a json representation.
  93054. * @param source the JSON source to parse
  93055. * @return The parsed curves
  93056. */
  93057. static Parse(source: any): ColorCurves;
  93058. }
  93059. }
  93060. declare module BABYLON {
  93061. /**
  93062. * Interface to follow in your material defines to integrate easily the
  93063. * Image proccessing functions.
  93064. * @hidden
  93065. */
  93066. export interface IImageProcessingConfigurationDefines {
  93067. IMAGEPROCESSING: boolean;
  93068. VIGNETTE: boolean;
  93069. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93070. VIGNETTEBLENDMODEOPAQUE: boolean;
  93071. TONEMAPPING: boolean;
  93072. TONEMAPPING_ACES: boolean;
  93073. CONTRAST: boolean;
  93074. EXPOSURE: boolean;
  93075. COLORCURVES: boolean;
  93076. COLORGRADING: boolean;
  93077. COLORGRADING3D: boolean;
  93078. SAMPLER3DGREENDEPTH: boolean;
  93079. SAMPLER3DBGRMAP: boolean;
  93080. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93081. }
  93082. /**
  93083. * @hidden
  93084. */
  93085. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  93086. IMAGEPROCESSING: boolean;
  93087. VIGNETTE: boolean;
  93088. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93089. VIGNETTEBLENDMODEOPAQUE: boolean;
  93090. TONEMAPPING: boolean;
  93091. TONEMAPPING_ACES: boolean;
  93092. CONTRAST: boolean;
  93093. COLORCURVES: boolean;
  93094. COLORGRADING: boolean;
  93095. COLORGRADING3D: boolean;
  93096. SAMPLER3DGREENDEPTH: boolean;
  93097. SAMPLER3DBGRMAP: boolean;
  93098. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93099. EXPOSURE: boolean;
  93100. constructor();
  93101. }
  93102. /**
  93103. * This groups together the common properties used for image processing either in direct forward pass
  93104. * or through post processing effect depending on the use of the image processing pipeline in your scene
  93105. * or not.
  93106. */
  93107. export class ImageProcessingConfiguration {
  93108. /**
  93109. * Default tone mapping applied in BabylonJS.
  93110. */
  93111. static readonly TONEMAPPING_STANDARD: number;
  93112. /**
  93113. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  93114. * to other engines rendering to increase portability.
  93115. */
  93116. static readonly TONEMAPPING_ACES: number;
  93117. /**
  93118. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  93119. */
  93120. colorCurves: Nullable<ColorCurves>;
  93121. private _colorCurvesEnabled;
  93122. /**
  93123. * Gets wether the color curves effect is enabled.
  93124. */
  93125. /**
  93126. * Sets wether the color curves effect is enabled.
  93127. */
  93128. colorCurvesEnabled: boolean;
  93129. private _colorGradingTexture;
  93130. /**
  93131. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  93132. */
  93133. /**
  93134. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  93135. */
  93136. colorGradingTexture: Nullable<BaseTexture>;
  93137. private _colorGradingEnabled;
  93138. /**
  93139. * Gets wether the color grading effect is enabled.
  93140. */
  93141. /**
  93142. * Sets wether the color grading effect is enabled.
  93143. */
  93144. colorGradingEnabled: boolean;
  93145. private _colorGradingWithGreenDepth;
  93146. /**
  93147. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  93148. */
  93149. /**
  93150. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  93151. */
  93152. colorGradingWithGreenDepth: boolean;
  93153. private _colorGradingBGR;
  93154. /**
  93155. * Gets wether the color grading texture contains BGR values.
  93156. */
  93157. /**
  93158. * Sets wether the color grading texture contains BGR values.
  93159. */
  93160. colorGradingBGR: boolean;
  93161. /** @hidden */
  93162. _exposure: number;
  93163. /**
  93164. * Gets the Exposure used in the effect.
  93165. */
  93166. /**
  93167. * Sets the Exposure used in the effect.
  93168. */
  93169. exposure: number;
  93170. private _toneMappingEnabled;
  93171. /**
  93172. * Gets wether the tone mapping effect is enabled.
  93173. */
  93174. /**
  93175. * Sets wether the tone mapping effect is enabled.
  93176. */
  93177. toneMappingEnabled: boolean;
  93178. private _toneMappingType;
  93179. /**
  93180. * Gets the type of tone mapping effect.
  93181. */
  93182. /**
  93183. * Sets the type of tone mapping effect used in BabylonJS.
  93184. */
  93185. toneMappingType: number;
  93186. protected _contrast: number;
  93187. /**
  93188. * Gets the contrast used in the effect.
  93189. */
  93190. /**
  93191. * Sets the contrast used in the effect.
  93192. */
  93193. contrast: number;
  93194. /**
  93195. * Vignette stretch size.
  93196. */
  93197. vignetteStretch: number;
  93198. /**
  93199. * Vignette centre X Offset.
  93200. */
  93201. vignetteCentreX: number;
  93202. /**
  93203. * Vignette centre Y Offset.
  93204. */
  93205. vignetteCentreY: number;
  93206. /**
  93207. * Vignette weight or intensity of the vignette effect.
  93208. */
  93209. vignetteWeight: number;
  93210. /**
  93211. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  93212. * if vignetteEnabled is set to true.
  93213. */
  93214. vignetteColor: Color4;
  93215. /**
  93216. * Camera field of view used by the Vignette effect.
  93217. */
  93218. vignetteCameraFov: number;
  93219. private _vignetteBlendMode;
  93220. /**
  93221. * Gets the vignette blend mode allowing different kind of effect.
  93222. */
  93223. /**
  93224. * Sets the vignette blend mode allowing different kind of effect.
  93225. */
  93226. vignetteBlendMode: number;
  93227. private _vignetteEnabled;
  93228. /**
  93229. * Gets wether the vignette effect is enabled.
  93230. */
  93231. /**
  93232. * Sets wether the vignette effect is enabled.
  93233. */
  93234. vignetteEnabled: boolean;
  93235. private _applyByPostProcess;
  93236. /**
  93237. * Gets wether the image processing is applied through a post process or not.
  93238. */
  93239. /**
  93240. * Sets wether the image processing is applied through a post process or not.
  93241. */
  93242. applyByPostProcess: boolean;
  93243. private _isEnabled;
  93244. /**
  93245. * Gets wether the image processing is enabled or not.
  93246. */
  93247. /**
  93248. * Sets wether the image processing is enabled or not.
  93249. */
  93250. isEnabled: boolean;
  93251. /**
  93252. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  93253. */
  93254. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  93255. /**
  93256. * Method called each time the image processing information changes requires to recompile the effect.
  93257. */
  93258. protected _updateParameters(): void;
  93259. /**
  93260. * Gets the current class name.
  93261. * @return "ImageProcessingConfiguration"
  93262. */
  93263. getClassName(): string;
  93264. /**
  93265. * Prepare the list of uniforms associated with the Image Processing effects.
  93266. * @param uniforms The list of uniforms used in the effect
  93267. * @param defines the list of defines currently in use
  93268. */
  93269. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  93270. /**
  93271. * Prepare the list of samplers associated with the Image Processing effects.
  93272. * @param samplersList The list of uniforms used in the effect
  93273. * @param defines the list of defines currently in use
  93274. */
  93275. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  93276. /**
  93277. * Prepare the list of defines associated to the shader.
  93278. * @param defines the list of defines to complete
  93279. * @param forPostProcess Define if we are currently in post process mode or not
  93280. */
  93281. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  93282. /**
  93283. * Returns true if all the image processing information are ready.
  93284. * @returns True if ready, otherwise, false
  93285. */
  93286. isReady(): boolean;
  93287. /**
  93288. * Binds the image processing to the shader.
  93289. * @param effect The effect to bind to
  93290. * @param aspectRatio Define the current aspect ratio of the effect
  93291. */
  93292. bind(effect: Effect, aspectRatio?: number): void;
  93293. /**
  93294. * Clones the current image processing instance.
  93295. * @return The cloned image processing
  93296. */
  93297. clone(): ImageProcessingConfiguration;
  93298. /**
  93299. * Serializes the current image processing instance to a json representation.
  93300. * @return a JSON representation
  93301. */
  93302. serialize(): any;
  93303. /**
  93304. * Parses the image processing from a json representation.
  93305. * @param source the JSON source to parse
  93306. * @return The parsed image processing
  93307. */
  93308. static Parse(source: any): ImageProcessingConfiguration;
  93309. private static _VIGNETTEMODE_MULTIPLY;
  93310. private static _VIGNETTEMODE_OPAQUE;
  93311. /**
  93312. * Used to apply the vignette as a mix with the pixel color.
  93313. */
  93314. static readonly VIGNETTEMODE_MULTIPLY: number;
  93315. /**
  93316. * Used to apply the vignette as a replacement of the pixel color.
  93317. */
  93318. static readonly VIGNETTEMODE_OPAQUE: number;
  93319. }
  93320. }
  93321. declare module BABYLON {
  93322. /**
  93323. * This represents all the required information to add a fresnel effect on a material:
  93324. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93325. */
  93326. export class FresnelParameters {
  93327. private _isEnabled;
  93328. /**
  93329. * Define if the fresnel effect is enable or not.
  93330. */
  93331. isEnabled: boolean;
  93332. /**
  93333. * Define the color used on edges (grazing angle)
  93334. */
  93335. leftColor: Color3;
  93336. /**
  93337. * Define the color used on center
  93338. */
  93339. rightColor: Color3;
  93340. /**
  93341. * Define bias applied to computed fresnel term
  93342. */
  93343. bias: number;
  93344. /**
  93345. * Defined the power exponent applied to fresnel term
  93346. */
  93347. power: number;
  93348. /**
  93349. * Clones the current fresnel and its valuues
  93350. * @returns a clone fresnel configuration
  93351. */
  93352. clone(): FresnelParameters;
  93353. /**
  93354. * Serializes the current fresnel parameters to a JSON representation.
  93355. * @return the JSON serialization
  93356. */
  93357. serialize(): any;
  93358. /**
  93359. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93360. * @param parsedFresnelParameters Define the JSON representation
  93361. * @returns the parsed parameters
  93362. */
  93363. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93364. }
  93365. }
  93366. declare module BABYLON {
  93367. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93368. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93369. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93370. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93371. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93372. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93373. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93374. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93375. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93376. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93377. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93378. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93379. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93380. /**
  93381. * Decorator used to define property that can be serialized as reference to a camera
  93382. * @param sourceName defines the name of the property to decorate
  93383. */
  93384. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93385. /**
  93386. * Class used to help serialization objects
  93387. */
  93388. export class SerializationHelper {
  93389. /** @hidden */
  93390. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93391. /** @hidden */
  93392. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93393. /** @hidden */
  93394. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93395. /** @hidden */
  93396. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93397. /**
  93398. * Appends the serialized animations from the source animations
  93399. * @param source Source containing the animations
  93400. * @param destination Target to store the animations
  93401. */
  93402. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93403. /**
  93404. * Static function used to serialized a specific entity
  93405. * @param entity defines the entity to serialize
  93406. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93407. * @returns a JSON compatible object representing the serialization of the entity
  93408. */
  93409. static Serialize<T>(entity: T, serializationObject?: any): any;
  93410. /**
  93411. * Creates a new entity from a serialization data object
  93412. * @param creationFunction defines a function used to instanciated the new entity
  93413. * @param source defines the source serialization data
  93414. * @param scene defines the hosting scene
  93415. * @param rootUrl defines the root url for resources
  93416. * @returns a new entity
  93417. */
  93418. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93419. /**
  93420. * Clones an object
  93421. * @param creationFunction defines the function used to instanciate the new object
  93422. * @param source defines the source object
  93423. * @returns the cloned object
  93424. */
  93425. static Clone<T>(creationFunction: () => T, source: T): T;
  93426. /**
  93427. * Instanciates a new object based on a source one (some data will be shared between both object)
  93428. * @param creationFunction defines the function used to instanciate the new object
  93429. * @param source defines the source object
  93430. * @returns the new object
  93431. */
  93432. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93433. }
  93434. }
  93435. declare module BABYLON {
  93436. /**
  93437. * This is the base class of all the camera used in the application.
  93438. * @see http://doc.babylonjs.com/features/cameras
  93439. */
  93440. export class Camera extends Node {
  93441. /** @hidden */
  93442. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93443. /**
  93444. * This is the default projection mode used by the cameras.
  93445. * It helps recreating a feeling of perspective and better appreciate depth.
  93446. * This is the best way to simulate real life cameras.
  93447. */
  93448. static readonly PERSPECTIVE_CAMERA: number;
  93449. /**
  93450. * This helps creating camera with an orthographic mode.
  93451. * 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.
  93452. */
  93453. static readonly ORTHOGRAPHIC_CAMERA: number;
  93454. /**
  93455. * This is the default FOV mode for perspective cameras.
  93456. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93457. */
  93458. static readonly FOVMODE_VERTICAL_FIXED: number;
  93459. /**
  93460. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93461. */
  93462. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93463. /**
  93464. * This specifies ther is no need for a camera rig.
  93465. * Basically only one eye is rendered corresponding to the camera.
  93466. */
  93467. static readonly RIG_MODE_NONE: number;
  93468. /**
  93469. * Simulates a camera Rig with one blue eye and one red eye.
  93470. * This can be use with 3d blue and red glasses.
  93471. */
  93472. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93473. /**
  93474. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93475. */
  93476. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93477. /**
  93478. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93479. */
  93480. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93481. /**
  93482. * Defines that both eyes of the camera will be rendered over under each other.
  93483. */
  93484. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93485. /**
  93486. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93487. */
  93488. static readonly RIG_MODE_VR: number;
  93489. /**
  93490. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93491. */
  93492. static readonly RIG_MODE_WEBVR: number;
  93493. /**
  93494. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93495. */
  93496. static readonly RIG_MODE_CUSTOM: number;
  93497. /**
  93498. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93499. */
  93500. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93501. /**
  93502. * Define the input manager associated with the camera.
  93503. */
  93504. inputs: CameraInputsManager<Camera>;
  93505. /** @hidden */
  93506. _position: Vector3;
  93507. /**
  93508. * Define the current local position of the camera in the scene
  93509. */
  93510. position: Vector3;
  93511. /**
  93512. * The vector the camera should consider as up.
  93513. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93514. */
  93515. upVector: Vector3;
  93516. /**
  93517. * Define the current limit on the left side for an orthographic camera
  93518. * In scene unit
  93519. */
  93520. orthoLeft: Nullable<number>;
  93521. /**
  93522. * Define the current limit on the right side for an orthographic camera
  93523. * In scene unit
  93524. */
  93525. orthoRight: Nullable<number>;
  93526. /**
  93527. * Define the current limit on the bottom side for an orthographic camera
  93528. * In scene unit
  93529. */
  93530. orthoBottom: Nullable<number>;
  93531. /**
  93532. * Define the current limit on the top side for an orthographic camera
  93533. * In scene unit
  93534. */
  93535. orthoTop: Nullable<number>;
  93536. /**
  93537. * Field Of View is set in Radians. (default is 0.8)
  93538. */
  93539. fov: number;
  93540. /**
  93541. * Define the minimum distance the camera can see from.
  93542. * This is important to note that the depth buffer are not infinite and the closer it starts
  93543. * the more your scene might encounter depth fighting issue.
  93544. */
  93545. minZ: number;
  93546. /**
  93547. * Define the maximum distance the camera can see to.
  93548. * This is important to note that the depth buffer are not infinite and the further it end
  93549. * the more your scene might encounter depth fighting issue.
  93550. */
  93551. maxZ: number;
  93552. /**
  93553. * Define the default inertia of the camera.
  93554. * This helps giving a smooth feeling to the camera movement.
  93555. */
  93556. inertia: number;
  93557. /**
  93558. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93559. */
  93560. mode: number;
  93561. /**
  93562. * Define wether the camera is intermediate.
  93563. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93564. */
  93565. isIntermediate: boolean;
  93566. /**
  93567. * Define the viewport of the camera.
  93568. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93569. */
  93570. viewport: Viewport;
  93571. /**
  93572. * Restricts the camera to viewing objects with the same layerMask.
  93573. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93574. */
  93575. layerMask: number;
  93576. /**
  93577. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93578. */
  93579. fovMode: number;
  93580. /**
  93581. * Rig mode of the camera.
  93582. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93583. * This is normally controlled byt the camera themselves as internal use.
  93584. */
  93585. cameraRigMode: number;
  93586. /**
  93587. * Defines the distance between both "eyes" in case of a RIG
  93588. */
  93589. interaxialDistance: number;
  93590. /**
  93591. * Defines if stereoscopic rendering is done side by side or over under.
  93592. */
  93593. isStereoscopicSideBySide: boolean;
  93594. /**
  93595. * 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
  93596. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93597. * else in the scene.
  93598. */
  93599. customRenderTargets: RenderTargetTexture[];
  93600. /**
  93601. * When set, the camera will render to this render target instead of the default canvas
  93602. */
  93603. outputRenderTarget: Nullable<RenderTargetTexture>;
  93604. /**
  93605. * Observable triggered when the camera view matrix has changed.
  93606. */
  93607. onViewMatrixChangedObservable: Observable<Camera>;
  93608. /**
  93609. * Observable triggered when the camera Projection matrix has changed.
  93610. */
  93611. onProjectionMatrixChangedObservable: Observable<Camera>;
  93612. /**
  93613. * Observable triggered when the inputs have been processed.
  93614. */
  93615. onAfterCheckInputsObservable: Observable<Camera>;
  93616. /**
  93617. * Observable triggered when reset has been called and applied to the camera.
  93618. */
  93619. onRestoreStateObservable: Observable<Camera>;
  93620. /** @hidden */
  93621. _cameraRigParams: any;
  93622. /** @hidden */
  93623. _rigCameras: Camera[];
  93624. /** @hidden */
  93625. _rigPostProcess: Nullable<PostProcess>;
  93626. protected _webvrViewMatrix: Matrix;
  93627. /** @hidden */
  93628. _skipRendering: boolean;
  93629. /** @hidden */
  93630. _projectionMatrix: Matrix;
  93631. /** @hidden */
  93632. _postProcesses: Nullable<PostProcess>[];
  93633. /** @hidden */
  93634. _activeMeshes: SmartArray<AbstractMesh>;
  93635. protected _globalPosition: Vector3;
  93636. /** @hidden */
  93637. _computedViewMatrix: Matrix;
  93638. private _doNotComputeProjectionMatrix;
  93639. private _transformMatrix;
  93640. private _frustumPlanes;
  93641. private _refreshFrustumPlanes;
  93642. private _storedFov;
  93643. private _stateStored;
  93644. /**
  93645. * Instantiates a new camera object.
  93646. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93647. * @see http://doc.babylonjs.com/features/cameras
  93648. * @param name Defines the name of the camera in the scene
  93649. * @param position Defines the position of the camera
  93650. * @param scene Defines the scene the camera belongs too
  93651. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93652. */
  93653. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93654. /**
  93655. * Store current camera state (fov, position, etc..)
  93656. * @returns the camera
  93657. */
  93658. storeState(): Camera;
  93659. /**
  93660. * Restores the camera state values if it has been stored. You must call storeState() first
  93661. */
  93662. protected _restoreStateValues(): boolean;
  93663. /**
  93664. * Restored camera state. You must call storeState() first.
  93665. * @returns true if restored and false otherwise
  93666. */
  93667. restoreState(): boolean;
  93668. /**
  93669. * Gets the class name of the camera.
  93670. * @returns the class name
  93671. */
  93672. getClassName(): string;
  93673. /** @hidden */
  93674. readonly _isCamera: boolean;
  93675. /**
  93676. * Gets a string representation of the camera useful for debug purpose.
  93677. * @param fullDetails Defines that a more verboe level of logging is required
  93678. * @returns the string representation
  93679. */
  93680. toString(fullDetails?: boolean): string;
  93681. /**
  93682. * Gets the current world space position of the camera.
  93683. */
  93684. readonly globalPosition: Vector3;
  93685. /**
  93686. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93687. * @returns the active meshe list
  93688. */
  93689. getActiveMeshes(): SmartArray<AbstractMesh>;
  93690. /**
  93691. * Check wether a mesh is part of the current active mesh list of the camera
  93692. * @param mesh Defines the mesh to check
  93693. * @returns true if active, false otherwise
  93694. */
  93695. isActiveMesh(mesh: Mesh): boolean;
  93696. /**
  93697. * Is this camera ready to be used/rendered
  93698. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93699. * @return true if the camera is ready
  93700. */
  93701. isReady(completeCheck?: boolean): boolean;
  93702. /** @hidden */
  93703. _initCache(): void;
  93704. /** @hidden */
  93705. _updateCache(ignoreParentClass?: boolean): void;
  93706. /** @hidden */
  93707. _isSynchronized(): boolean;
  93708. /** @hidden */
  93709. _isSynchronizedViewMatrix(): boolean;
  93710. /** @hidden */
  93711. _isSynchronizedProjectionMatrix(): boolean;
  93712. /**
  93713. * Attach the input controls to a specific dom element to get the input from.
  93714. * @param element Defines the element the controls should be listened from
  93715. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93716. */
  93717. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93718. /**
  93719. * Detach the current controls from the specified dom element.
  93720. * @param element Defines the element to stop listening the inputs from
  93721. */
  93722. detachControl(element: HTMLElement): void;
  93723. /**
  93724. * Update the camera state according to the different inputs gathered during the frame.
  93725. */
  93726. update(): void;
  93727. /** @hidden */
  93728. _checkInputs(): void;
  93729. /** @hidden */
  93730. readonly rigCameras: Camera[];
  93731. /**
  93732. * Gets the post process used by the rig cameras
  93733. */
  93734. readonly rigPostProcess: Nullable<PostProcess>;
  93735. /**
  93736. * Internal, gets the first post proces.
  93737. * @returns the first post process to be run on this camera.
  93738. */
  93739. _getFirstPostProcess(): Nullable<PostProcess>;
  93740. private _cascadePostProcessesToRigCams;
  93741. /**
  93742. * Attach a post process to the camera.
  93743. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93744. * @param postProcess The post process to attach to the camera
  93745. * @param insertAt The position of the post process in case several of them are in use in the scene
  93746. * @returns the position the post process has been inserted at
  93747. */
  93748. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93749. /**
  93750. * Detach a post process to the camera.
  93751. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93752. * @param postProcess The post process to detach from the camera
  93753. */
  93754. detachPostProcess(postProcess: PostProcess): void;
  93755. /**
  93756. * Gets the current world matrix of the camera
  93757. */
  93758. getWorldMatrix(): Matrix;
  93759. /** @hidden */
  93760. _getViewMatrix(): Matrix;
  93761. /**
  93762. * Gets the current view matrix of the camera.
  93763. * @param force forces the camera to recompute the matrix without looking at the cached state
  93764. * @returns the view matrix
  93765. */
  93766. getViewMatrix(force?: boolean): Matrix;
  93767. /**
  93768. * Freeze the projection matrix.
  93769. * It will prevent the cache check of the camera projection compute and can speed up perf
  93770. * if no parameter of the camera are meant to change
  93771. * @param projection Defines manually a projection if necessary
  93772. */
  93773. freezeProjectionMatrix(projection?: Matrix): void;
  93774. /**
  93775. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93776. */
  93777. unfreezeProjectionMatrix(): void;
  93778. /**
  93779. * Gets the current projection matrix of the camera.
  93780. * @param force forces the camera to recompute the matrix without looking at the cached state
  93781. * @returns the projection matrix
  93782. */
  93783. getProjectionMatrix(force?: boolean): Matrix;
  93784. /**
  93785. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93786. * @returns a Matrix
  93787. */
  93788. getTransformationMatrix(): Matrix;
  93789. private _updateFrustumPlanes;
  93790. /**
  93791. * Checks if a cullable object (mesh...) is in the camera frustum
  93792. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93793. * @param target The object to check
  93794. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93795. * @returns true if the object is in frustum otherwise false
  93796. */
  93797. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93798. /**
  93799. * Checks if a cullable object (mesh...) is in the camera frustum
  93800. * Unlike isInFrustum this cheks the full bounding box
  93801. * @param target The object to check
  93802. * @returns true if the object is in frustum otherwise false
  93803. */
  93804. isCompletelyInFrustum(target: ICullable): boolean;
  93805. /**
  93806. * Gets a ray in the forward direction from the camera.
  93807. * @param length Defines the length of the ray to create
  93808. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93809. * @param origin Defines the start point of the ray which defaults to the camera position
  93810. * @returns the forward ray
  93811. */
  93812. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93813. /**
  93814. * Releases resources associated with this node.
  93815. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93816. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93817. */
  93818. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93819. /** @hidden */
  93820. _isLeftCamera: boolean;
  93821. /**
  93822. * Gets the left camera of a rig setup in case of Rigged Camera
  93823. */
  93824. readonly isLeftCamera: boolean;
  93825. /** @hidden */
  93826. _isRightCamera: boolean;
  93827. /**
  93828. * Gets the right camera of a rig setup in case of Rigged Camera
  93829. */
  93830. readonly isRightCamera: boolean;
  93831. /**
  93832. * Gets the left camera of a rig setup in case of Rigged Camera
  93833. */
  93834. readonly leftCamera: Nullable<FreeCamera>;
  93835. /**
  93836. * Gets the right camera of a rig setup in case of Rigged Camera
  93837. */
  93838. readonly rightCamera: Nullable<FreeCamera>;
  93839. /**
  93840. * Gets the left camera target of a rig setup in case of Rigged Camera
  93841. * @returns the target position
  93842. */
  93843. getLeftTarget(): Nullable<Vector3>;
  93844. /**
  93845. * Gets the right camera target of a rig setup in case of Rigged Camera
  93846. * @returns the target position
  93847. */
  93848. getRightTarget(): Nullable<Vector3>;
  93849. /**
  93850. * @hidden
  93851. */
  93852. setCameraRigMode(mode: number, rigParams: any): void;
  93853. /** @hidden */
  93854. static _setStereoscopicRigMode(camera: Camera): void;
  93855. /** @hidden */
  93856. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93857. /** @hidden */
  93858. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93859. /** @hidden */
  93860. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93861. /** @hidden */
  93862. _getVRProjectionMatrix(): Matrix;
  93863. protected _updateCameraRotationMatrix(): void;
  93864. protected _updateWebVRCameraRotationMatrix(): void;
  93865. /**
  93866. * This function MUST be overwritten by the different WebVR cameras available.
  93867. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93868. * @hidden
  93869. */
  93870. _getWebVRProjectionMatrix(): Matrix;
  93871. /**
  93872. * This function MUST be overwritten by the different WebVR cameras available.
  93873. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93874. * @hidden
  93875. */
  93876. _getWebVRViewMatrix(): Matrix;
  93877. /** @hidden */
  93878. setCameraRigParameter(name: string, value: any): void;
  93879. /**
  93880. * needs to be overridden by children so sub has required properties to be copied
  93881. * @hidden
  93882. */
  93883. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93884. /**
  93885. * May need to be overridden by children
  93886. * @hidden
  93887. */
  93888. _updateRigCameras(): void;
  93889. /** @hidden */
  93890. _setupInputs(): void;
  93891. /**
  93892. * Serialiaze the camera setup to a json represention
  93893. * @returns the JSON representation
  93894. */
  93895. serialize(): any;
  93896. /**
  93897. * Clones the current camera.
  93898. * @param name The cloned camera name
  93899. * @returns the cloned camera
  93900. */
  93901. clone(name: string): Camera;
  93902. /**
  93903. * Gets the direction of the camera relative to a given local axis.
  93904. * @param localAxis Defines the reference axis to provide a relative direction.
  93905. * @return the direction
  93906. */
  93907. getDirection(localAxis: Vector3): Vector3;
  93908. /**
  93909. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93910. * @param localAxis Defines the reference axis to provide a relative direction.
  93911. * @param result Defines the vector to store the result in
  93912. */
  93913. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93914. /**
  93915. * Gets a camera constructor for a given camera type
  93916. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93917. * @param name The name of the camera the result will be able to instantiate
  93918. * @param scene The scene the result will construct the camera in
  93919. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93920. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93921. * @returns a factory method to construc the camera
  93922. */
  93923. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93924. /**
  93925. * Compute the world matrix of the camera.
  93926. * @returns the camera workd matrix
  93927. */
  93928. computeWorldMatrix(): Matrix;
  93929. /**
  93930. * Parse a JSON and creates the camera from the parsed information
  93931. * @param parsedCamera The JSON to parse
  93932. * @param scene The scene to instantiate the camera in
  93933. * @returns the newly constructed camera
  93934. */
  93935. static Parse(parsedCamera: any, scene: Scene): Camera;
  93936. }
  93937. }
  93938. declare module BABYLON {
  93939. /**
  93940. * Interface for any object that can request an animation frame
  93941. */
  93942. export interface ICustomAnimationFrameRequester {
  93943. /**
  93944. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93945. */
  93946. renderFunction?: Function;
  93947. /**
  93948. * Called to request the next frame to render to
  93949. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93950. */
  93951. requestAnimationFrame: Function;
  93952. /**
  93953. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93954. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93955. */
  93956. requestID?: number;
  93957. }
  93958. /**
  93959. * Interface containing an array of animations
  93960. */
  93961. export interface IAnimatable {
  93962. /**
  93963. * Array of animations
  93964. */
  93965. animations: Nullable<Array<Animation>>;
  93966. }
  93967. /** Interface used by value gradients (color, factor, ...) */
  93968. export interface IValueGradient {
  93969. /**
  93970. * Gets or sets the gradient value (between 0 and 1)
  93971. */
  93972. gradient: number;
  93973. }
  93974. /** Class used to store color4 gradient */
  93975. export class ColorGradient implements IValueGradient {
  93976. /**
  93977. * Gets or sets the gradient value (between 0 and 1)
  93978. */
  93979. gradient: number;
  93980. /**
  93981. * Gets or sets first associated color
  93982. */
  93983. color1: Color4;
  93984. /**
  93985. * Gets or sets second associated color
  93986. */
  93987. color2?: Color4;
  93988. /**
  93989. * Will get a color picked randomly between color1 and color2.
  93990. * If color2 is undefined then color1 will be used
  93991. * @param result defines the target Color4 to store the result in
  93992. */
  93993. getColorToRef(result: Color4): void;
  93994. }
  93995. /** Class used to store color 3 gradient */
  93996. export class Color3Gradient implements IValueGradient {
  93997. /**
  93998. * Gets or sets the gradient value (between 0 and 1)
  93999. */
  94000. gradient: number;
  94001. /**
  94002. * Gets or sets the associated color
  94003. */
  94004. color: Color3;
  94005. }
  94006. /** Class used to store factor gradient */
  94007. export class FactorGradient implements IValueGradient {
  94008. /**
  94009. * Gets or sets the gradient value (between 0 and 1)
  94010. */
  94011. gradient: number;
  94012. /**
  94013. * Gets or sets first associated factor
  94014. */
  94015. factor1: number;
  94016. /**
  94017. * Gets or sets second associated factor
  94018. */
  94019. factor2?: number;
  94020. /**
  94021. * Will get a number picked randomly between factor1 and factor2.
  94022. * If factor2 is undefined then factor1 will be used
  94023. * @returns the picked number
  94024. */
  94025. getFactor(): number;
  94026. }
  94027. /**
  94028. * @ignore
  94029. * Application error to support additional information when loading a file
  94030. */
  94031. export class LoadFileError extends Error {
  94032. /** defines the optional web request */
  94033. request?: WebRequest | undefined;
  94034. private static _setPrototypeOf;
  94035. /**
  94036. * Creates a new LoadFileError
  94037. * @param message defines the message of the error
  94038. * @param request defines the optional web request
  94039. */
  94040. constructor(message: string,
  94041. /** defines the optional web request */
  94042. request?: WebRequest | undefined);
  94043. }
  94044. /**
  94045. * Class used to define a retry strategy when error happens while loading assets
  94046. */
  94047. export class RetryStrategy {
  94048. /**
  94049. * Function used to defines an exponential back off strategy
  94050. * @param maxRetries defines the maximum number of retries (3 by default)
  94051. * @param baseInterval defines the interval between retries
  94052. * @returns the strategy function to use
  94053. */
  94054. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  94055. }
  94056. /**
  94057. * File request interface
  94058. */
  94059. export interface IFileRequest {
  94060. /**
  94061. * Raised when the request is complete (success or error).
  94062. */
  94063. onCompleteObservable: Observable<IFileRequest>;
  94064. /**
  94065. * Aborts the request for a file.
  94066. */
  94067. abort: () => void;
  94068. }
  94069. /**
  94070. * Class containing a set of static utilities functions
  94071. */
  94072. export class Tools {
  94073. /**
  94074. * Gets or sets the base URL to use to load assets
  94075. */
  94076. static BaseUrl: string;
  94077. /**
  94078. * Enable/Disable Custom HTTP Request Headers globally.
  94079. * default = false
  94080. * @see CustomRequestHeaders
  94081. */
  94082. static UseCustomRequestHeaders: boolean;
  94083. /**
  94084. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  94085. * i.e. when loading files, where the server/service expects an Authorization header
  94086. */
  94087. static CustomRequestHeaders: {
  94088. [key: string]: string;
  94089. };
  94090. /**
  94091. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  94092. */
  94093. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  94094. /**
  94095. * Default behaviour for cors in the application.
  94096. * It can be a string if the expected behavior is identical in the entire app.
  94097. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  94098. */
  94099. static CorsBehavior: string | ((url: string | string[]) => string);
  94100. /**
  94101. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  94102. * @ignorenaming
  94103. */
  94104. static UseFallbackTexture: boolean;
  94105. /**
  94106. * Use this object to register external classes like custom textures or material
  94107. * to allow the laoders to instantiate them
  94108. */
  94109. static RegisteredExternalClasses: {
  94110. [key: string]: Object;
  94111. };
  94112. /**
  94113. * Texture content used if a texture cannot loaded
  94114. * @ignorenaming
  94115. */
  94116. static fallbackTexture: string;
  94117. /**
  94118. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  94119. * @param u defines the coordinate on X axis
  94120. * @param v defines the coordinate on Y axis
  94121. * @param width defines the width of the source data
  94122. * @param height defines the height of the source data
  94123. * @param pixels defines the source byte array
  94124. * @param color defines the output color
  94125. */
  94126. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  94127. /**
  94128. * Interpolates between a and b via alpha
  94129. * @param a The lower value (returned when alpha = 0)
  94130. * @param b The upper value (returned when alpha = 1)
  94131. * @param alpha The interpolation-factor
  94132. * @return The mixed value
  94133. */
  94134. static Mix(a: number, b: number, alpha: number): number;
  94135. /**
  94136. * Tries to instantiate a new object from a given class name
  94137. * @param className defines the class name to instantiate
  94138. * @returns the new object or null if the system was not able to do the instantiation
  94139. */
  94140. static Instantiate(className: string): any;
  94141. /**
  94142. * Provides a slice function that will work even on IE
  94143. * @param data defines the array to slice
  94144. * @param start defines the start of the data (optional)
  94145. * @param end defines the end of the data (optional)
  94146. * @returns the new sliced array
  94147. */
  94148. static Slice<T>(data: T, start?: number, end?: number): T;
  94149. /**
  94150. * Polyfill for setImmediate
  94151. * @param action defines the action to execute after the current execution block
  94152. */
  94153. static SetImmediate(action: () => void): void;
  94154. /**
  94155. * Function indicating if a number is an exponent of 2
  94156. * @param value defines the value to test
  94157. * @returns true if the value is an exponent of 2
  94158. */
  94159. static IsExponentOfTwo(value: number): boolean;
  94160. private static _tmpFloatArray;
  94161. /**
  94162. * Returns the nearest 32-bit single precision float representation of a Number
  94163. * @param value A Number. If the parameter is of a different type, it will get converted
  94164. * to a number or to NaN if it cannot be converted
  94165. * @returns number
  94166. */
  94167. static FloatRound(value: number): number;
  94168. /**
  94169. * Find the next highest power of two.
  94170. * @param x Number to start search from.
  94171. * @return Next highest power of two.
  94172. */
  94173. static CeilingPOT(x: number): number;
  94174. /**
  94175. * Find the next lowest power of two.
  94176. * @param x Number to start search from.
  94177. * @return Next lowest power of two.
  94178. */
  94179. static FloorPOT(x: number): number;
  94180. /**
  94181. * Find the nearest power of two.
  94182. * @param x Number to start search from.
  94183. * @return Next nearest power of two.
  94184. */
  94185. static NearestPOT(x: number): number;
  94186. /**
  94187. * Get the closest exponent of two
  94188. * @param value defines the value to approximate
  94189. * @param max defines the maximum value to return
  94190. * @param mode defines how to define the closest value
  94191. * @returns closest exponent of two of the given value
  94192. */
  94193. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  94194. /**
  94195. * Extracts the filename from a path
  94196. * @param path defines the path to use
  94197. * @returns the filename
  94198. */
  94199. static GetFilename(path: string): string;
  94200. /**
  94201. * Extracts the "folder" part of a path (everything before the filename).
  94202. * @param uri The URI to extract the info from
  94203. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  94204. * @returns The "folder" part of the path
  94205. */
  94206. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  94207. /**
  94208. * Extracts text content from a DOM element hierarchy
  94209. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  94210. */
  94211. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  94212. /**
  94213. * Convert an angle in radians to degrees
  94214. * @param angle defines the angle to convert
  94215. * @returns the angle in degrees
  94216. */
  94217. static ToDegrees(angle: number): number;
  94218. /**
  94219. * Convert an angle in degrees to radians
  94220. * @param angle defines the angle to convert
  94221. * @returns the angle in radians
  94222. */
  94223. static ToRadians(angle: number): number;
  94224. /**
  94225. * Encode a buffer to a base64 string
  94226. * @param buffer defines the buffer to encode
  94227. * @returns the encoded string
  94228. */
  94229. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  94230. /**
  94231. * Extracts minimum and maximum values from a list of indexed positions
  94232. * @param positions defines the positions to use
  94233. * @param indices defines the indices to the positions
  94234. * @param indexStart defines the start index
  94235. * @param indexCount defines the end index
  94236. * @param bias defines bias value to add to the result
  94237. * @return minimum and maximum values
  94238. */
  94239. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  94240. minimum: Vector3;
  94241. maximum: Vector3;
  94242. };
  94243. /**
  94244. * Extracts minimum and maximum values from a list of positions
  94245. * @param positions defines the positions to use
  94246. * @param start defines the start index in the positions array
  94247. * @param count defines the number of positions to handle
  94248. * @param bias defines bias value to add to the result
  94249. * @param stride defines the stride size to use (distance between two positions in the positions array)
  94250. * @return minimum and maximum values
  94251. */
  94252. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  94253. minimum: Vector3;
  94254. maximum: Vector3;
  94255. };
  94256. /**
  94257. * Returns an array if obj is not an array
  94258. * @param obj defines the object to evaluate as an array
  94259. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  94260. * @returns either obj directly if obj is an array or a new array containing obj
  94261. */
  94262. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  94263. /**
  94264. * Gets the pointer prefix to use
  94265. * @returns "pointer" if touch is enabled. Else returns "mouse"
  94266. */
  94267. static GetPointerPrefix(): string;
  94268. /**
  94269. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  94270. * @param func - the function to be called
  94271. * @param requester - the object that will request the next frame. Falls back to window.
  94272. * @returns frame number
  94273. */
  94274. static QueueNewFrame(func: () => void, requester?: any): number;
  94275. /**
  94276. * Ask the browser to promote the current element to fullscreen rendering mode
  94277. * @param element defines the DOM element to promote
  94278. */
  94279. static RequestFullscreen(element: HTMLElement): void;
  94280. /**
  94281. * Asks the browser to exit fullscreen mode
  94282. */
  94283. static ExitFullscreen(): void;
  94284. /**
  94285. * Ask the browser to promote the current element to pointerlock mode
  94286. * @param element defines the DOM element to promote
  94287. */
  94288. static RequestPointerlock(element: HTMLElement): void;
  94289. /**
  94290. * Asks the browser to exit pointerlock mode
  94291. */
  94292. static ExitPointerlock(): void;
  94293. /**
  94294. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  94295. * @param url define the url we are trying
  94296. * @param element define the dom element where to configure the cors policy
  94297. */
  94298. static SetCorsBehavior(url: string | string[], element: {
  94299. crossOrigin: string | null;
  94300. }): void;
  94301. /**
  94302. * Removes unwanted characters from an url
  94303. * @param url defines the url to clean
  94304. * @returns the cleaned url
  94305. */
  94306. static CleanUrl(url: string): string;
  94307. /**
  94308. * Gets or sets a function used to pre-process url before using them to load assets
  94309. */
  94310. static PreprocessUrl: (url: string) => string;
  94311. /**
  94312. * Loads an image as an HTMLImageElement.
  94313. * @param input url string, ArrayBuffer, or Blob to load
  94314. * @param onLoad callback called when the image successfully loads
  94315. * @param onError callback called when the image fails to load
  94316. * @param offlineProvider offline provider for caching
  94317. * @returns the HTMLImageElement of the loaded image
  94318. */
  94319. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  94320. /**
  94321. * Loads a file
  94322. * @param url url string, ArrayBuffer, or Blob to load
  94323. * @param onSuccess callback called when the file successfully loads
  94324. * @param onProgress callback called while file is loading (if the server supports this mode)
  94325. * @param offlineProvider defines the offline provider for caching
  94326. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  94327. * @param onError callback called when the file fails to load
  94328. * @returns a file request object
  94329. */
  94330. 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;
  94331. /**
  94332. * Loads a file from a url
  94333. * @param url the file url to load
  94334. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  94335. */
  94336. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  94337. /**
  94338. * Load a script (identified by an url). When the url returns, the
  94339. * content of this file is added into a new script element, attached to the DOM (body element)
  94340. * @param scriptUrl defines the url of the script to laod
  94341. * @param onSuccess defines the callback called when the script is loaded
  94342. * @param onError defines the callback to call if an error occurs
  94343. * @param scriptId defines the id of the script element
  94344. */
  94345. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  94346. /**
  94347. * Load an asynchronous script (identified by an url). When the url returns, the
  94348. * content of this file is added into a new script element, attached to the DOM (body element)
  94349. * @param scriptUrl defines the url of the script to laod
  94350. * @param scriptId defines the id of the script element
  94351. * @returns a promise request object
  94352. */
  94353. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  94354. /**
  94355. * Loads a file from a blob
  94356. * @param fileToLoad defines the blob to use
  94357. * @param callback defines the callback to call when data is loaded
  94358. * @param progressCallback defines the callback to call during loading process
  94359. * @returns a file request object
  94360. */
  94361. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  94362. /**
  94363. * Loads a file
  94364. * @param fileToLoad defines the file to load
  94365. * @param callback defines the callback to call when data is loaded
  94366. * @param progressCallBack defines the callback to call during loading process
  94367. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  94368. * @returns a file request object
  94369. */
  94370. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  94371. /**
  94372. * Creates a data url from a given string content
  94373. * @param content defines the content to convert
  94374. * @returns the new data url link
  94375. */
  94376. static FileAsURL(content: string): string;
  94377. /**
  94378. * Format the given number to a specific decimal format
  94379. * @param value defines the number to format
  94380. * @param decimals defines the number of decimals to use
  94381. * @returns the formatted string
  94382. */
  94383. static Format(value: number, decimals?: number): string;
  94384. /**
  94385. * Checks if a given vector is inside a specific range
  94386. * @param v defines the vector to test
  94387. * @param min defines the minimum range
  94388. * @param max defines the maximum range
  94389. */
  94390. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  94391. /**
  94392. * Tries to copy an object by duplicating every property
  94393. * @param source defines the source object
  94394. * @param destination defines the target object
  94395. * @param doNotCopyList defines a list of properties to avoid
  94396. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  94397. */
  94398. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  94399. /**
  94400. * Gets a boolean indicating if the given object has no own property
  94401. * @param obj defines the object to test
  94402. * @returns true if object has no own property
  94403. */
  94404. static IsEmpty(obj: any): boolean;
  94405. /**
  94406. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  94407. * @param str Source string
  94408. * @param suffix Suffix to search for in the source string
  94409. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94410. */
  94411. static EndsWith(str: string, suffix: string): boolean;
  94412. /**
  94413. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  94414. * @param str Source string
  94415. * @param suffix Suffix to search for in the source string
  94416. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94417. */
  94418. static StartsWith(str: string, suffix: string): boolean;
  94419. /**
  94420. * Function used to register events at window level
  94421. * @param events defines the events to register
  94422. */
  94423. static RegisterTopRootEvents(events: {
  94424. name: string;
  94425. handler: Nullable<(e: FocusEvent) => any>;
  94426. }[]): void;
  94427. /**
  94428. * Function used to unregister events from window level
  94429. * @param events defines the events to unregister
  94430. */
  94431. static UnregisterTopRootEvents(events: {
  94432. name: string;
  94433. handler: Nullable<(e: FocusEvent) => any>;
  94434. }[]): void;
  94435. /**
  94436. * @ignore
  94437. */
  94438. static _ScreenshotCanvas: HTMLCanvasElement;
  94439. /**
  94440. * Dumps the current bound framebuffer
  94441. * @param width defines the rendering width
  94442. * @param height defines the rendering height
  94443. * @param engine defines the hosting engine
  94444. * @param successCallback defines the callback triggered once the data are available
  94445. * @param mimeType defines the mime type of the result
  94446. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  94447. */
  94448. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94449. /**
  94450. * Converts the canvas data to blob.
  94451. * This acts as a polyfill for browsers not supporting the to blob function.
  94452. * @param canvas Defines the canvas to extract the data from
  94453. * @param successCallback Defines the callback triggered once the data are available
  94454. * @param mimeType Defines the mime type of the result
  94455. */
  94456. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  94457. /**
  94458. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  94459. * @param successCallback defines the callback triggered once the data are available
  94460. * @param mimeType defines the mime type of the result
  94461. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  94462. */
  94463. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94464. /**
  94465. * Downloads a blob in the browser
  94466. * @param blob defines the blob to download
  94467. * @param fileName defines the name of the downloaded file
  94468. */
  94469. static Download(blob: Blob, fileName: string): void;
  94470. /**
  94471. * Captures a screenshot of the current rendering
  94472. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94473. * @param engine defines the rendering engine
  94474. * @param camera defines the source camera
  94475. * @param size This parameter can be set to a single number or to an object with the
  94476. * following (optional) properties: precision, width, height. If a single number is passed,
  94477. * it will be used for both width and height. If an object is passed, the screenshot size
  94478. * will be derived from the parameters. The precision property is a multiplier allowing
  94479. * rendering at a higher or lower resolution
  94480. * @param successCallback defines the callback receives a single parameter which contains the
  94481. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94482. * src parameter of an <img> to display it
  94483. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  94484. * Check your browser for supported MIME types
  94485. */
  94486. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  94487. /**
  94488. * Generates an image screenshot from the specified camera.
  94489. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94490. * @param engine The engine to use for rendering
  94491. * @param camera The camera to use for rendering
  94492. * @param size This parameter can be set to a single number or to an object with the
  94493. * following (optional) properties: precision, width, height. If a single number is passed,
  94494. * it will be used for both width and height. If an object is passed, the screenshot size
  94495. * will be derived from the parameters. The precision property is a multiplier allowing
  94496. * rendering at a higher or lower resolution
  94497. * @param successCallback The callback receives a single parameter which contains the
  94498. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94499. * src parameter of an <img> to display it
  94500. * @param mimeType The MIME type of the screenshot image (default: image/png).
  94501. * Check your browser for supported MIME types
  94502. * @param samples Texture samples (default: 1)
  94503. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  94504. * @param fileName A name for for the downloaded file.
  94505. */
  94506. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  94507. /**
  94508. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94509. * Be aware Math.random() could cause collisions, but:
  94510. * "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"
  94511. * @returns a pseudo random id
  94512. */
  94513. static RandomId(): string;
  94514. /**
  94515. * Test if the given uri is a base64 string
  94516. * @param uri The uri to test
  94517. * @return True if the uri is a base64 string or false otherwise
  94518. */
  94519. static IsBase64(uri: string): boolean;
  94520. /**
  94521. * Decode the given base64 uri.
  94522. * @param uri The uri to decode
  94523. * @return The decoded base64 data.
  94524. */
  94525. static DecodeBase64(uri: string): ArrayBuffer;
  94526. /**
  94527. * Gets the absolute url.
  94528. * @param url the input url
  94529. * @return the absolute url
  94530. */
  94531. static GetAbsoluteUrl(url: string): string;
  94532. /**
  94533. * No log
  94534. */
  94535. static readonly NoneLogLevel: number;
  94536. /**
  94537. * Only message logs
  94538. */
  94539. static readonly MessageLogLevel: number;
  94540. /**
  94541. * Only warning logs
  94542. */
  94543. static readonly WarningLogLevel: number;
  94544. /**
  94545. * Only error logs
  94546. */
  94547. static readonly ErrorLogLevel: number;
  94548. /**
  94549. * All logs
  94550. */
  94551. static readonly AllLogLevel: number;
  94552. /**
  94553. * Gets a value indicating the number of loading errors
  94554. * @ignorenaming
  94555. */
  94556. static readonly errorsCount: number;
  94557. /**
  94558. * Callback called when a new log is added
  94559. */
  94560. static OnNewCacheEntry: (entry: string) => void;
  94561. /**
  94562. * Log a message to the console
  94563. * @param message defines the message to log
  94564. */
  94565. static Log(message: string): void;
  94566. /**
  94567. * Write a warning message to the console
  94568. * @param message defines the message to log
  94569. */
  94570. static Warn(message: string): void;
  94571. /**
  94572. * Write an error message to the console
  94573. * @param message defines the message to log
  94574. */
  94575. static Error(message: string): void;
  94576. /**
  94577. * Gets current log cache (list of logs)
  94578. */
  94579. static readonly LogCache: string;
  94580. /**
  94581. * Clears the log cache
  94582. */
  94583. static ClearLogCache(): void;
  94584. /**
  94585. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94586. */
  94587. static LogLevels: number;
  94588. /**
  94589. * Checks if the loaded document was accessed via `file:`-Protocol.
  94590. * @returns boolean
  94591. */
  94592. static IsFileURL(): boolean;
  94593. /**
  94594. * Checks if the window object exists
  94595. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  94596. */
  94597. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  94598. /**
  94599. * No performance log
  94600. */
  94601. static readonly PerformanceNoneLogLevel: number;
  94602. /**
  94603. * Use user marks to log performance
  94604. */
  94605. static readonly PerformanceUserMarkLogLevel: number;
  94606. /**
  94607. * Log performance to the console
  94608. */
  94609. static readonly PerformanceConsoleLogLevel: number;
  94610. private static _performance;
  94611. /**
  94612. * Sets the current performance log level
  94613. */
  94614. static PerformanceLogLevel: number;
  94615. private static _StartPerformanceCounterDisabled;
  94616. private static _EndPerformanceCounterDisabled;
  94617. private static _StartUserMark;
  94618. private static _EndUserMark;
  94619. private static _StartPerformanceConsole;
  94620. private static _EndPerformanceConsole;
  94621. /**
  94622. * Starts a performance counter
  94623. */
  94624. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94625. /**
  94626. * Ends a specific performance coutner
  94627. */
  94628. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94629. /**
  94630. * Gets either window.performance.now() if supported or Date.now() else
  94631. */
  94632. static readonly Now: number;
  94633. /**
  94634. * This method will return the name of the class used to create the instance of the given object.
  94635. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  94636. * @param object the object to get the class name from
  94637. * @param isType defines if the object is actually a type
  94638. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  94639. */
  94640. static GetClassName(object: any, isType?: boolean): string;
  94641. /**
  94642. * Gets the first element of an array satisfying a given predicate
  94643. * @param array defines the array to browse
  94644. * @param predicate defines the predicate to use
  94645. * @returns null if not found or the element
  94646. */
  94647. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  94648. /**
  94649. * This method will return the name of the full name of the class, including its owning module (if any).
  94650. * 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).
  94651. * @param object the object to get the class name from
  94652. * @param isType defines if the object is actually a type
  94653. * @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.
  94654. * @ignorenaming
  94655. */
  94656. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  94657. /**
  94658. * Returns a promise that resolves after the given amount of time.
  94659. * @param delay Number of milliseconds to delay
  94660. * @returns Promise that resolves after the given amount of time
  94661. */
  94662. static DelayAsync(delay: number): Promise<void>;
  94663. /**
  94664. * Gets the current gradient from an array of IValueGradient
  94665. * @param ratio defines the current ratio to get
  94666. * @param gradients defines the array of IValueGradient
  94667. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  94668. */
  94669. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  94670. }
  94671. /**
  94672. * This class is used to track a performance counter which is number based.
  94673. * The user has access to many properties which give statistics of different nature.
  94674. *
  94675. * The implementer can track two kinds of Performance Counter: time and count.
  94676. * 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.
  94677. * 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.
  94678. */
  94679. export class PerfCounter {
  94680. /**
  94681. * Gets or sets a global boolean to turn on and off all the counters
  94682. */
  94683. static Enabled: boolean;
  94684. /**
  94685. * Returns the smallest value ever
  94686. */
  94687. readonly min: number;
  94688. /**
  94689. * Returns the biggest value ever
  94690. */
  94691. readonly max: number;
  94692. /**
  94693. * Returns the average value since the performance counter is running
  94694. */
  94695. readonly average: number;
  94696. /**
  94697. * Returns the average value of the last second the counter was monitored
  94698. */
  94699. readonly lastSecAverage: number;
  94700. /**
  94701. * Returns the current value
  94702. */
  94703. readonly current: number;
  94704. /**
  94705. * Gets the accumulated total
  94706. */
  94707. readonly total: number;
  94708. /**
  94709. * Gets the total value count
  94710. */
  94711. readonly count: number;
  94712. /**
  94713. * Creates a new counter
  94714. */
  94715. constructor();
  94716. /**
  94717. * Call this method to start monitoring a new frame.
  94718. * 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.
  94719. */
  94720. fetchNewFrame(): void;
  94721. /**
  94722. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94723. * @param newCount the count value to add to the monitored count
  94724. * @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.
  94725. */
  94726. addCount(newCount: number, fetchResult: boolean): void;
  94727. /**
  94728. * Start monitoring this performance counter
  94729. */
  94730. beginMonitoring(): void;
  94731. /**
  94732. * Compute the time lapsed since the previous beginMonitoring() call.
  94733. * @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
  94734. */
  94735. endMonitoring(newFrame?: boolean): void;
  94736. private _fetchResult;
  94737. private _startMonitoringTime;
  94738. private _min;
  94739. private _max;
  94740. private _average;
  94741. private _current;
  94742. private _totalValueCount;
  94743. private _totalAccumulated;
  94744. private _lastSecAverage;
  94745. private _lastSecAccumulated;
  94746. private _lastSecTime;
  94747. private _lastSecValueCount;
  94748. }
  94749. /**
  94750. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94751. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94752. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94753. * @param name The name of the class, case should be preserved
  94754. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94755. */
  94756. export function className(name: string, module?: string): (target: Object) => void;
  94757. /**
  94758. * An implementation of a loop for asynchronous functions.
  94759. */
  94760. export class AsyncLoop {
  94761. /**
  94762. * Defines the number of iterations for the loop
  94763. */
  94764. iterations: number;
  94765. /**
  94766. * Defines the current index of the loop.
  94767. */
  94768. index: number;
  94769. private _done;
  94770. private _fn;
  94771. private _successCallback;
  94772. /**
  94773. * Constructor.
  94774. * @param iterations the number of iterations.
  94775. * @param func the function to run each iteration
  94776. * @param successCallback the callback that will be called upon succesful execution
  94777. * @param offset starting offset.
  94778. */
  94779. constructor(
  94780. /**
  94781. * Defines the number of iterations for the loop
  94782. */
  94783. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94784. /**
  94785. * Execute the next iteration. Must be called after the last iteration was finished.
  94786. */
  94787. executeNext(): void;
  94788. /**
  94789. * Break the loop and run the success callback.
  94790. */
  94791. breakLoop(): void;
  94792. /**
  94793. * Create and run an async loop.
  94794. * @param iterations the number of iterations.
  94795. * @param fn the function to run each iteration
  94796. * @param successCallback the callback that will be called upon succesful execution
  94797. * @param offset starting offset.
  94798. * @returns the created async loop object
  94799. */
  94800. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94801. /**
  94802. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94803. * @param iterations total number of iterations
  94804. * @param syncedIterations number of synchronous iterations in each async iteration.
  94805. * @param fn the function to call each iteration.
  94806. * @param callback a success call back that will be called when iterating stops.
  94807. * @param breakFunction a break condition (optional)
  94808. * @param timeout timeout settings for the setTimeout function. default - 0.
  94809. * @returns the created async loop object
  94810. */
  94811. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94812. }
  94813. }
  94814. declare module BABYLON {
  94815. /** @hidden */
  94816. export interface ICollisionCoordinator {
  94817. createCollider(): Collider;
  94818. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94819. init(scene: Scene): void;
  94820. }
  94821. /** @hidden */
  94822. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94823. private _scene;
  94824. private _scaledPosition;
  94825. private _scaledVelocity;
  94826. private _finalPosition;
  94827. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94828. createCollider(): Collider;
  94829. init(scene: Scene): void;
  94830. private _collideWithWorld;
  94831. }
  94832. }
  94833. declare module BABYLON {
  94834. /**
  94835. * Class used to manage all inputs for the scene.
  94836. */
  94837. export class InputManager {
  94838. /** The distance in pixel that you have to move to prevent some events */
  94839. static DragMovementThreshold: number;
  94840. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94841. static LongPressDelay: number;
  94842. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94843. static DoubleClickDelay: number;
  94844. /** If you need to check double click without raising a single click at first click, enable this flag */
  94845. static ExclusiveDoubleClickMode: boolean;
  94846. private _wheelEventName;
  94847. private _onPointerMove;
  94848. private _onPointerDown;
  94849. private _onPointerUp;
  94850. private _initClickEvent;
  94851. private _initActionManager;
  94852. private _delayedSimpleClick;
  94853. private _delayedSimpleClickTimeout;
  94854. private _previousDelayedSimpleClickTimeout;
  94855. private _meshPickProceed;
  94856. private _previousButtonPressed;
  94857. private _currentPickResult;
  94858. private _previousPickResult;
  94859. private _totalPointersPressed;
  94860. private _doubleClickOccured;
  94861. private _pointerOverMesh;
  94862. private _pickedDownMesh;
  94863. private _pickedUpMesh;
  94864. private _pointerX;
  94865. private _pointerY;
  94866. private _unTranslatedPointerX;
  94867. private _unTranslatedPointerY;
  94868. private _startingPointerPosition;
  94869. private _previousStartingPointerPosition;
  94870. private _startingPointerTime;
  94871. private _previousStartingPointerTime;
  94872. private _pointerCaptures;
  94873. private _onKeyDown;
  94874. private _onKeyUp;
  94875. private _onCanvasFocusObserver;
  94876. private _onCanvasBlurObserver;
  94877. private _scene;
  94878. /**
  94879. * Creates a new InputManager
  94880. * @param scene defines the hosting scene
  94881. */
  94882. constructor(scene: Scene);
  94883. /**
  94884. * Gets the mesh that is currently under the pointer
  94885. */
  94886. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94887. /**
  94888. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94889. */
  94890. readonly unTranslatedPointer: Vector2;
  94891. /**
  94892. * Gets or sets the current on-screen X position of the pointer
  94893. */
  94894. pointerX: number;
  94895. /**
  94896. * Gets or sets the current on-screen Y position of the pointer
  94897. */
  94898. pointerY: number;
  94899. private _updatePointerPosition;
  94900. private _processPointerMove;
  94901. private _setRayOnPointerInfo;
  94902. private _checkPrePointerObservable;
  94903. /**
  94904. * Use this method to simulate a pointer move on a mesh
  94905. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94906. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94907. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94908. */
  94909. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94910. /**
  94911. * Use this method to simulate a pointer down on a mesh
  94912. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94913. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94914. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94915. */
  94916. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94917. private _processPointerDown;
  94918. /** @hidden */
  94919. _isPointerSwiping(): boolean;
  94920. /**
  94921. * Use this method to simulate a pointer up on a mesh
  94922. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94923. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94924. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94925. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94926. */
  94927. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  94928. private _processPointerUp;
  94929. /**
  94930. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94931. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94932. * @returns true if the pointer was captured
  94933. */
  94934. isPointerCaptured(pointerId?: number): boolean;
  94935. /**
  94936. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  94937. * @param attachUp defines if you want to attach events to pointerup
  94938. * @param attachDown defines if you want to attach events to pointerdown
  94939. * @param attachMove defines if you want to attach events to pointermove
  94940. */
  94941. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  94942. /**
  94943. * Detaches all event handlers
  94944. */
  94945. detachControl(): void;
  94946. /**
  94947. * Force the value of meshUnderPointer
  94948. * @param mesh defines the mesh to use
  94949. */
  94950. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  94951. /**
  94952. * Gets the mesh under the pointer
  94953. * @returns a Mesh or null if no mesh is under the pointer
  94954. */
  94955. getPointerOverMesh(): Nullable<AbstractMesh>;
  94956. }
  94957. }
  94958. declare module BABYLON {
  94959. /**
  94960. * This class defines the direct association between an animation and a target
  94961. */
  94962. export class TargetedAnimation {
  94963. /**
  94964. * Animation to perform
  94965. */
  94966. animation: Animation;
  94967. /**
  94968. * Target to animate
  94969. */
  94970. target: any;
  94971. /**
  94972. * Serialize the object
  94973. * @returns the JSON object representing the current entity
  94974. */
  94975. serialize(): any;
  94976. }
  94977. /**
  94978. * Use this class to create coordinated animations on multiple targets
  94979. */
  94980. export class AnimationGroup implements IDisposable {
  94981. /** The name of the animation group */
  94982. name: string;
  94983. private _scene;
  94984. private _targetedAnimations;
  94985. private _animatables;
  94986. private _from;
  94987. private _to;
  94988. private _isStarted;
  94989. private _isPaused;
  94990. private _speedRatio;
  94991. private _loopAnimation;
  94992. /**
  94993. * Gets or sets the unique id of the node
  94994. */
  94995. uniqueId: number;
  94996. /**
  94997. * This observable will notify when one animation have ended
  94998. */
  94999. onAnimationEndObservable: Observable<TargetedAnimation>;
  95000. /**
  95001. * Observer raised when one animation loops
  95002. */
  95003. onAnimationLoopObservable: Observable<TargetedAnimation>;
  95004. /**
  95005. * This observable will notify when all animations have ended.
  95006. */
  95007. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  95008. /**
  95009. * This observable will notify when all animations have paused.
  95010. */
  95011. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  95012. /**
  95013. * This observable will notify when all animations are playing.
  95014. */
  95015. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  95016. /**
  95017. * Gets the first frame
  95018. */
  95019. readonly from: number;
  95020. /**
  95021. * Gets the last frame
  95022. */
  95023. readonly to: number;
  95024. /**
  95025. * Define if the animations are started
  95026. */
  95027. readonly isStarted: boolean;
  95028. /**
  95029. * Gets a value indicating that the current group is playing
  95030. */
  95031. readonly isPlaying: boolean;
  95032. /**
  95033. * Gets or sets the speed ratio to use for all animations
  95034. */
  95035. /**
  95036. * Gets or sets the speed ratio to use for all animations
  95037. */
  95038. speedRatio: number;
  95039. /**
  95040. * Gets or sets if all animations should loop or not
  95041. */
  95042. loopAnimation: boolean;
  95043. /**
  95044. * Gets the targeted animations for this animation group
  95045. */
  95046. readonly targetedAnimations: Array<TargetedAnimation>;
  95047. /**
  95048. * returning the list of animatables controlled by this animation group.
  95049. */
  95050. readonly animatables: Array<Animatable>;
  95051. /**
  95052. * Instantiates a new Animation Group.
  95053. * This helps managing several animations at once.
  95054. * @see http://doc.babylonjs.com/how_to/group
  95055. * @param name Defines the name of the group
  95056. * @param scene Defines the scene the group belongs to
  95057. */
  95058. constructor(
  95059. /** The name of the animation group */
  95060. name: string, scene?: Nullable<Scene>);
  95061. /**
  95062. * Add an animation (with its target) in the group
  95063. * @param animation defines the animation we want to add
  95064. * @param target defines the target of the animation
  95065. * @returns the TargetedAnimation object
  95066. */
  95067. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  95068. /**
  95069. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  95070. * It can add constant keys at begin or end
  95071. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  95072. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  95073. * @returns the animation group
  95074. */
  95075. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  95076. /**
  95077. * Start all animations on given targets
  95078. * @param loop defines if animations must loop
  95079. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  95080. * @param from defines the from key (optional)
  95081. * @param to defines the to key (optional)
  95082. * @returns the current animation group
  95083. */
  95084. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  95085. /**
  95086. * Pause all animations
  95087. * @returns the animation group
  95088. */
  95089. pause(): AnimationGroup;
  95090. /**
  95091. * Play all animations to initial state
  95092. * This function will start() the animations if they were not started or will restart() them if they were paused
  95093. * @param loop defines if animations must loop
  95094. * @returns the animation group
  95095. */
  95096. play(loop?: boolean): AnimationGroup;
  95097. /**
  95098. * Reset all animations to initial state
  95099. * @returns the animation group
  95100. */
  95101. reset(): AnimationGroup;
  95102. /**
  95103. * Restart animations from key 0
  95104. * @returns the animation group
  95105. */
  95106. restart(): AnimationGroup;
  95107. /**
  95108. * Stop all animations
  95109. * @returns the animation group
  95110. */
  95111. stop(): AnimationGroup;
  95112. /**
  95113. * Set animation weight for all animatables
  95114. * @param weight defines the weight to use
  95115. * @return the animationGroup
  95116. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  95117. */
  95118. setWeightForAllAnimatables(weight: number): AnimationGroup;
  95119. /**
  95120. * Synchronize and normalize all animatables with a source animatable
  95121. * @param root defines the root animatable to synchronize with
  95122. * @return the animationGroup
  95123. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  95124. */
  95125. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  95126. /**
  95127. * Goes to a specific frame in this animation group
  95128. * @param frame the frame number to go to
  95129. * @return the animationGroup
  95130. */
  95131. goToFrame(frame: number): AnimationGroup;
  95132. /**
  95133. * Dispose all associated resources
  95134. */
  95135. dispose(): void;
  95136. private _checkAnimationGroupEnded;
  95137. /**
  95138. * Clone the current animation group and returns a copy
  95139. * @param newName defines the name of the new group
  95140. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  95141. * @returns the new aniamtion group
  95142. */
  95143. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  95144. /**
  95145. * Serializes the animationGroup to an object
  95146. * @returns Serialized object
  95147. */
  95148. serialize(): any;
  95149. /**
  95150. * Returns a new AnimationGroup object parsed from the source provided.
  95151. * @param parsedAnimationGroup defines the source
  95152. * @param scene defines the scene that will receive the animationGroup
  95153. * @returns a new AnimationGroup
  95154. */
  95155. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  95156. /**
  95157. * Returns the string "AnimationGroup"
  95158. * @returns "AnimationGroup"
  95159. */
  95160. getClassName(): string;
  95161. /**
  95162. * Creates a detailled string about the object
  95163. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  95164. * @returns a string representing the object
  95165. */
  95166. toString(fullDetails?: boolean): string;
  95167. }
  95168. }
  95169. declare module BABYLON {
  95170. /**
  95171. * Define an interface for all classes that will hold resources
  95172. */
  95173. export interface IDisposable {
  95174. /**
  95175. * Releases all held resources
  95176. */
  95177. dispose(): void;
  95178. }
  95179. /** Interface defining initialization parameters for Scene class */
  95180. export interface SceneOptions {
  95181. /**
  95182. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  95183. * It will improve performance when the number of geometries becomes important.
  95184. */
  95185. useGeometryUniqueIdsMap?: boolean;
  95186. /**
  95187. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  95188. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  95189. */
  95190. useMaterialMeshMap?: boolean;
  95191. /**
  95192. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  95193. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  95194. */
  95195. useClonedMeshhMap?: boolean;
  95196. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  95197. virtual?: boolean;
  95198. }
  95199. /**
  95200. * Represents a scene to be rendered by the engine.
  95201. * @see http://doc.babylonjs.com/features/scene
  95202. */
  95203. export class Scene extends AbstractScene implements IAnimatable {
  95204. private static _uniqueIdCounter;
  95205. /** The fog is deactivated */
  95206. static readonly FOGMODE_NONE: number;
  95207. /** The fog density is following an exponential function */
  95208. static readonly FOGMODE_EXP: number;
  95209. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  95210. static readonly FOGMODE_EXP2: number;
  95211. /** The fog density is following a linear function. */
  95212. static readonly FOGMODE_LINEAR: number;
  95213. /**
  95214. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  95215. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95216. */
  95217. static MinDeltaTime: number;
  95218. /**
  95219. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  95220. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95221. */
  95222. static MaxDeltaTime: number;
  95223. /**
  95224. * Factory used to create the default material.
  95225. * @param name The name of the material to create
  95226. * @param scene The scene to create the material for
  95227. * @returns The default material
  95228. */
  95229. static DefaultMaterialFactory(scene: Scene): Material;
  95230. /**
  95231. * Factory used to create the a collision coordinator.
  95232. * @returns The collision coordinator
  95233. */
  95234. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  95235. /** @hidden */
  95236. _inputManager: InputManager;
  95237. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  95238. cameraToUseForPointers: Nullable<Camera>;
  95239. /** @hidden */
  95240. readonly _isScene: boolean;
  95241. /**
  95242. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  95243. */
  95244. autoClear: boolean;
  95245. /**
  95246. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  95247. */
  95248. autoClearDepthAndStencil: boolean;
  95249. /**
  95250. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  95251. */
  95252. clearColor: Color4;
  95253. /**
  95254. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  95255. */
  95256. ambientColor: Color3;
  95257. /**
  95258. * This is use to store the default BRDF lookup for PBR materials in your scene.
  95259. * It should only be one of the following (if not the default embedded one):
  95260. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  95261. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  95262. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  95263. * The material properties need to be setup according to the type of texture in use.
  95264. */
  95265. environmentBRDFTexture: BaseTexture;
  95266. /** @hidden */
  95267. protected _environmentTexture: Nullable<BaseTexture>;
  95268. /**
  95269. * Texture used in all pbr material as the reflection texture.
  95270. * As in the majority of the scene they are the same (exception for multi room and so on),
  95271. * this is easier to reference from here than from all the materials.
  95272. */
  95273. /**
  95274. * Texture used in all pbr material as the reflection texture.
  95275. * As in the majority of the scene they are the same (exception for multi room and so on),
  95276. * this is easier to set here than in all the materials.
  95277. */
  95278. environmentTexture: Nullable<BaseTexture>;
  95279. /** @hidden */
  95280. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95281. /**
  95282. * Default image processing configuration used either in the rendering
  95283. * Forward main pass or through the imageProcessingPostProcess if present.
  95284. * As in the majority of the scene they are the same (exception for multi camera),
  95285. * this is easier to reference from here than from all the materials and post process.
  95286. *
  95287. * No setter as we it is a shared configuration, you can set the values instead.
  95288. */
  95289. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  95290. private _forceWireframe;
  95291. /**
  95292. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  95293. */
  95294. forceWireframe: boolean;
  95295. private _forcePointsCloud;
  95296. /**
  95297. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  95298. */
  95299. forcePointsCloud: boolean;
  95300. /**
  95301. * Gets or sets the active clipplane 1
  95302. */
  95303. clipPlane: Nullable<Plane>;
  95304. /**
  95305. * Gets or sets the active clipplane 2
  95306. */
  95307. clipPlane2: Nullable<Plane>;
  95308. /**
  95309. * Gets or sets the active clipplane 3
  95310. */
  95311. clipPlane3: Nullable<Plane>;
  95312. /**
  95313. * Gets or sets the active clipplane 4
  95314. */
  95315. clipPlane4: Nullable<Plane>;
  95316. /**
  95317. * Gets or sets a boolean indicating if animations are enabled
  95318. */
  95319. animationsEnabled: boolean;
  95320. private _animationPropertiesOverride;
  95321. /**
  95322. * Gets or sets the animation properties override
  95323. */
  95324. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95325. /**
  95326. * Gets or sets a boolean indicating if a constant deltatime has to be used
  95327. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  95328. */
  95329. useConstantAnimationDeltaTime: boolean;
  95330. /**
  95331. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  95332. * Please note that it requires to run a ray cast through the scene on every frame
  95333. */
  95334. constantlyUpdateMeshUnderPointer: boolean;
  95335. /**
  95336. * Defines the HTML cursor to use when hovering over interactive elements
  95337. */
  95338. hoverCursor: string;
  95339. /**
  95340. * Defines the HTML default cursor to use (empty by default)
  95341. */
  95342. defaultCursor: string;
  95343. /**
  95344. * This is used to call preventDefault() on pointer down
  95345. * in order to block unwanted artifacts like system double clicks
  95346. */
  95347. preventDefaultOnPointerDown: boolean;
  95348. /**
  95349. * This is used to call preventDefault() on pointer up
  95350. * in order to block unwanted artifacts like system double clicks
  95351. */
  95352. preventDefaultOnPointerUp: boolean;
  95353. /**
  95354. * Gets or sets user defined metadata
  95355. */
  95356. metadata: any;
  95357. /**
  95358. * For internal use only. Please do not use.
  95359. */
  95360. reservedDataStore: any;
  95361. /**
  95362. * Gets the name of the plugin used to load this scene (null by default)
  95363. */
  95364. loadingPluginName: string;
  95365. /**
  95366. * Use this array to add regular expressions used to disable offline support for specific urls
  95367. */
  95368. disableOfflineSupportExceptionRules: RegExp[];
  95369. /**
  95370. * An event triggered when the scene is disposed.
  95371. */
  95372. onDisposeObservable: Observable<Scene>;
  95373. private _onDisposeObserver;
  95374. /** Sets a function to be executed when this scene is disposed. */
  95375. onDispose: () => void;
  95376. /**
  95377. * An event triggered before rendering the scene (right after animations and physics)
  95378. */
  95379. onBeforeRenderObservable: Observable<Scene>;
  95380. private _onBeforeRenderObserver;
  95381. /** Sets a function to be executed before rendering this scene */
  95382. beforeRender: Nullable<() => void>;
  95383. /**
  95384. * An event triggered after rendering the scene
  95385. */
  95386. onAfterRenderObservable: Observable<Scene>;
  95387. /**
  95388. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  95389. */
  95390. onAfterRenderCameraObservable: Observable<Camera>;
  95391. private _onAfterRenderObserver;
  95392. /** Sets a function to be executed after rendering this scene */
  95393. afterRender: Nullable<() => void>;
  95394. /**
  95395. * An event triggered before animating the scene
  95396. */
  95397. onBeforeAnimationsObservable: Observable<Scene>;
  95398. /**
  95399. * An event triggered after animations processing
  95400. */
  95401. onAfterAnimationsObservable: Observable<Scene>;
  95402. /**
  95403. * An event triggered before draw calls are ready to be sent
  95404. */
  95405. onBeforeDrawPhaseObservable: Observable<Scene>;
  95406. /**
  95407. * An event triggered after draw calls have been sent
  95408. */
  95409. onAfterDrawPhaseObservable: Observable<Scene>;
  95410. /**
  95411. * An event triggered when the scene is ready
  95412. */
  95413. onReadyObservable: Observable<Scene>;
  95414. /**
  95415. * An event triggered before rendering a camera
  95416. */
  95417. onBeforeCameraRenderObservable: Observable<Camera>;
  95418. private _onBeforeCameraRenderObserver;
  95419. /** Sets a function to be executed before rendering a camera*/
  95420. beforeCameraRender: () => void;
  95421. /**
  95422. * An event triggered after rendering a camera
  95423. */
  95424. onAfterCameraRenderObservable: Observable<Camera>;
  95425. private _onAfterCameraRenderObserver;
  95426. /** Sets a function to be executed after rendering a camera*/
  95427. afterCameraRender: () => void;
  95428. /**
  95429. * An event triggered when active meshes evaluation is about to start
  95430. */
  95431. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  95432. /**
  95433. * An event triggered when active meshes evaluation is done
  95434. */
  95435. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  95436. /**
  95437. * An event triggered when particles rendering is about to start
  95438. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95439. */
  95440. onBeforeParticlesRenderingObservable: Observable<Scene>;
  95441. /**
  95442. * An event triggered when particles rendering is done
  95443. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95444. */
  95445. onAfterParticlesRenderingObservable: Observable<Scene>;
  95446. /**
  95447. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  95448. */
  95449. onDataLoadedObservable: Observable<Scene>;
  95450. /**
  95451. * An event triggered when a camera is created
  95452. */
  95453. onNewCameraAddedObservable: Observable<Camera>;
  95454. /**
  95455. * An event triggered when a camera is removed
  95456. */
  95457. onCameraRemovedObservable: Observable<Camera>;
  95458. /**
  95459. * An event triggered when a light is created
  95460. */
  95461. onNewLightAddedObservable: Observable<Light>;
  95462. /**
  95463. * An event triggered when a light is removed
  95464. */
  95465. onLightRemovedObservable: Observable<Light>;
  95466. /**
  95467. * An event triggered when a geometry is created
  95468. */
  95469. onNewGeometryAddedObservable: Observable<Geometry>;
  95470. /**
  95471. * An event triggered when a geometry is removed
  95472. */
  95473. onGeometryRemovedObservable: Observable<Geometry>;
  95474. /**
  95475. * An event triggered when a transform node is created
  95476. */
  95477. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  95478. /**
  95479. * An event triggered when a transform node is removed
  95480. */
  95481. onTransformNodeRemovedObservable: Observable<TransformNode>;
  95482. /**
  95483. * An event triggered when a mesh is created
  95484. */
  95485. onNewMeshAddedObservable: Observable<AbstractMesh>;
  95486. /**
  95487. * An event triggered when a mesh is removed
  95488. */
  95489. onMeshRemovedObservable: Observable<AbstractMesh>;
  95490. /**
  95491. * An event triggered when a skeleton is created
  95492. */
  95493. onNewSkeletonAddedObservable: Observable<Skeleton>;
  95494. /**
  95495. * An event triggered when a skeleton is removed
  95496. */
  95497. onSkeletonRemovedObservable: Observable<Skeleton>;
  95498. /**
  95499. * An event triggered when a material is created
  95500. */
  95501. onNewMaterialAddedObservable: Observable<Material>;
  95502. /**
  95503. * An event triggered when a material is removed
  95504. */
  95505. onMaterialRemovedObservable: Observable<Material>;
  95506. /**
  95507. * An event triggered when a texture is created
  95508. */
  95509. onNewTextureAddedObservable: Observable<BaseTexture>;
  95510. /**
  95511. * An event triggered when a texture is removed
  95512. */
  95513. onTextureRemovedObservable: Observable<BaseTexture>;
  95514. /**
  95515. * An event triggered when render targets are about to be rendered
  95516. * Can happen multiple times per frame.
  95517. */
  95518. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  95519. /**
  95520. * An event triggered when render targets were rendered.
  95521. * Can happen multiple times per frame.
  95522. */
  95523. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  95524. /**
  95525. * An event triggered before calculating deterministic simulation step
  95526. */
  95527. onBeforeStepObservable: Observable<Scene>;
  95528. /**
  95529. * An event triggered after calculating deterministic simulation step
  95530. */
  95531. onAfterStepObservable: Observable<Scene>;
  95532. /**
  95533. * An event triggered when the activeCamera property is updated
  95534. */
  95535. onActiveCameraChanged: Observable<Scene>;
  95536. /**
  95537. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  95538. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95539. * 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)
  95540. */
  95541. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95542. /**
  95543. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  95544. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95545. * 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)
  95546. */
  95547. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95548. /**
  95549. * This Observable will when a mesh has been imported into the scene.
  95550. */
  95551. onMeshImportedObservable: Observable<AbstractMesh>;
  95552. /**
  95553. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  95554. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  95555. */
  95556. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  95557. /** @hidden */
  95558. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  95559. /**
  95560. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  95561. */
  95562. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  95563. /**
  95564. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  95565. */
  95566. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  95567. /**
  95568. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  95569. */
  95570. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  95571. /** Callback called when a pointer move is detected */
  95572. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95573. /** Callback called when a pointer down is detected */
  95574. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95575. /** Callback called when a pointer up is detected */
  95576. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  95577. /** Callback called when a pointer pick is detected */
  95578. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  95579. /**
  95580. * 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).
  95581. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  95582. */
  95583. onPrePointerObservable: Observable<PointerInfoPre>;
  95584. /**
  95585. * Observable event triggered each time an input event is received from the rendering canvas
  95586. */
  95587. onPointerObservable: Observable<PointerInfo>;
  95588. /**
  95589. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  95590. */
  95591. readonly unTranslatedPointer: Vector2;
  95592. /**
  95593. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  95594. */
  95595. static DragMovementThreshold: number;
  95596. /**
  95597. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  95598. */
  95599. static LongPressDelay: number;
  95600. /**
  95601. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  95602. */
  95603. static DoubleClickDelay: number;
  95604. /** If you need to check double click without raising a single click at first click, enable this flag */
  95605. static ExclusiveDoubleClickMode: boolean;
  95606. /** @hidden */
  95607. _mirroredCameraPosition: Nullable<Vector3>;
  95608. /**
  95609. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  95610. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  95611. */
  95612. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  95613. /**
  95614. * Observable event triggered each time an keyboard event is received from the hosting window
  95615. */
  95616. onKeyboardObservable: Observable<KeyboardInfo>;
  95617. private _useRightHandedSystem;
  95618. /**
  95619. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  95620. */
  95621. useRightHandedSystem: boolean;
  95622. private _timeAccumulator;
  95623. private _currentStepId;
  95624. private _currentInternalStep;
  95625. /**
  95626. * Sets the step Id used by deterministic lock step
  95627. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95628. * @param newStepId defines the step Id
  95629. */
  95630. setStepId(newStepId: number): void;
  95631. /**
  95632. * Gets the step Id used by deterministic lock step
  95633. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95634. * @returns the step Id
  95635. */
  95636. getStepId(): number;
  95637. /**
  95638. * Gets the internal step used by deterministic lock step
  95639. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95640. * @returns the internal step
  95641. */
  95642. getInternalStep(): number;
  95643. private _fogEnabled;
  95644. /**
  95645. * Gets or sets a boolean indicating if fog is enabled on this scene
  95646. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95647. * (Default is true)
  95648. */
  95649. fogEnabled: boolean;
  95650. private _fogMode;
  95651. /**
  95652. * Gets or sets the fog mode to use
  95653. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95654. * | mode | value |
  95655. * | --- | --- |
  95656. * | FOGMODE_NONE | 0 |
  95657. * | FOGMODE_EXP | 1 |
  95658. * | FOGMODE_EXP2 | 2 |
  95659. * | FOGMODE_LINEAR | 3 |
  95660. */
  95661. fogMode: number;
  95662. /**
  95663. * Gets or sets the fog color to use
  95664. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95665. * (Default is Color3(0.2, 0.2, 0.3))
  95666. */
  95667. fogColor: Color3;
  95668. /**
  95669. * Gets or sets the fog density to use
  95670. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95671. * (Default is 0.1)
  95672. */
  95673. fogDensity: number;
  95674. /**
  95675. * Gets or sets the fog start distance to use
  95676. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95677. * (Default is 0)
  95678. */
  95679. fogStart: number;
  95680. /**
  95681. * Gets or sets the fog end distance to use
  95682. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95683. * (Default is 1000)
  95684. */
  95685. fogEnd: number;
  95686. private _shadowsEnabled;
  95687. /**
  95688. * Gets or sets a boolean indicating if shadows are enabled on this scene
  95689. */
  95690. shadowsEnabled: boolean;
  95691. private _lightsEnabled;
  95692. /**
  95693. * Gets or sets a boolean indicating if lights are enabled on this scene
  95694. */
  95695. lightsEnabled: boolean;
  95696. /** All of the active cameras added to this scene. */
  95697. activeCameras: Camera[];
  95698. /** @hidden */
  95699. _activeCamera: Nullable<Camera>;
  95700. /** Gets or sets the current active camera */
  95701. activeCamera: Nullable<Camera>;
  95702. private _defaultMaterial;
  95703. /** The default material used on meshes when no material is affected */
  95704. /** The default material used on meshes when no material is affected */
  95705. defaultMaterial: Material;
  95706. private _texturesEnabled;
  95707. /**
  95708. * Gets or sets a boolean indicating if textures are enabled on this scene
  95709. */
  95710. texturesEnabled: boolean;
  95711. /**
  95712. * Gets or sets a boolean indicating if particles are enabled on this scene
  95713. */
  95714. particlesEnabled: boolean;
  95715. /**
  95716. * Gets or sets a boolean indicating if sprites are enabled on this scene
  95717. */
  95718. spritesEnabled: boolean;
  95719. private _skeletonsEnabled;
  95720. /**
  95721. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  95722. */
  95723. skeletonsEnabled: boolean;
  95724. /**
  95725. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  95726. */
  95727. lensFlaresEnabled: boolean;
  95728. /**
  95729. * Gets or sets a boolean indicating if collisions are enabled on this scene
  95730. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95731. */
  95732. collisionsEnabled: boolean;
  95733. private _collisionCoordinator;
  95734. /** @hidden */
  95735. readonly collisionCoordinator: ICollisionCoordinator;
  95736. /**
  95737. * Defines the gravity applied to this scene (used only for collisions)
  95738. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95739. */
  95740. gravity: Vector3;
  95741. /**
  95742. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  95743. */
  95744. postProcessesEnabled: boolean;
  95745. /**
  95746. * The list of postprocesses added to the scene
  95747. */
  95748. postProcesses: PostProcess[];
  95749. /**
  95750. * Gets the current postprocess manager
  95751. */
  95752. postProcessManager: PostProcessManager;
  95753. /**
  95754. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95755. */
  95756. renderTargetsEnabled: boolean;
  95757. /**
  95758. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95759. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95760. */
  95761. dumpNextRenderTargets: boolean;
  95762. /**
  95763. * The list of user defined render targets added to the scene
  95764. */
  95765. customRenderTargets: RenderTargetTexture[];
  95766. /**
  95767. * Defines if texture loading must be delayed
  95768. * If true, textures will only be loaded when they need to be rendered
  95769. */
  95770. useDelayedTextureLoading: boolean;
  95771. /**
  95772. * Gets the list of meshes imported to the scene through SceneLoader
  95773. */
  95774. importedMeshesFiles: String[];
  95775. /**
  95776. * Gets or sets a boolean indicating if probes are enabled on this scene
  95777. */
  95778. probesEnabled: boolean;
  95779. /**
  95780. * Gets or sets the current offline provider to use to store scene data
  95781. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95782. */
  95783. offlineProvider: IOfflineProvider;
  95784. /**
  95785. * Gets or sets the action manager associated with the scene
  95786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95787. */
  95788. actionManager: AbstractActionManager;
  95789. private _meshesForIntersections;
  95790. /**
  95791. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95792. */
  95793. proceduralTexturesEnabled: boolean;
  95794. private _engine;
  95795. private _totalVertices;
  95796. /** @hidden */
  95797. _activeIndices: PerfCounter;
  95798. /** @hidden */
  95799. _activeParticles: PerfCounter;
  95800. /** @hidden */
  95801. _activeBones: PerfCounter;
  95802. private _animationRatio;
  95803. /** @hidden */
  95804. _animationTimeLast: number;
  95805. /** @hidden */
  95806. _animationTime: number;
  95807. /**
  95808. * Gets or sets a general scale for animation speed
  95809. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95810. */
  95811. animationTimeScale: number;
  95812. /** @hidden */
  95813. _cachedMaterial: Nullable<Material>;
  95814. /** @hidden */
  95815. _cachedEffect: Nullable<Effect>;
  95816. /** @hidden */
  95817. _cachedVisibility: Nullable<number>;
  95818. private _renderId;
  95819. private _frameId;
  95820. private _executeWhenReadyTimeoutId;
  95821. private _intermediateRendering;
  95822. private _viewUpdateFlag;
  95823. private _projectionUpdateFlag;
  95824. /** @hidden */
  95825. _toBeDisposed: Nullable<IDisposable>[];
  95826. private _activeRequests;
  95827. /** @hidden */
  95828. _pendingData: any[];
  95829. private _isDisposed;
  95830. /**
  95831. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95832. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95833. */
  95834. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95835. private _activeMeshes;
  95836. private _processedMaterials;
  95837. private _renderTargets;
  95838. /** @hidden */
  95839. _activeParticleSystems: SmartArray<IParticleSystem>;
  95840. private _activeSkeletons;
  95841. private _softwareSkinnedMeshes;
  95842. private _renderingManager;
  95843. /** @hidden */
  95844. _activeAnimatables: Animatable[];
  95845. private _transformMatrix;
  95846. private _sceneUbo;
  95847. /** @hidden */
  95848. _viewMatrix: Matrix;
  95849. private _projectionMatrix;
  95850. /** @hidden */
  95851. _forcedViewPosition: Nullable<Vector3>;
  95852. /** @hidden */
  95853. _frustumPlanes: Plane[];
  95854. /**
  95855. * Gets the list of frustum planes (built from the active camera)
  95856. */
  95857. readonly frustumPlanes: Plane[];
  95858. /**
  95859. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95860. * This is useful if there are more lights that the maximum simulteanous authorized
  95861. */
  95862. requireLightSorting: boolean;
  95863. /** @hidden */
  95864. readonly useMaterialMeshMap: boolean;
  95865. /** @hidden */
  95866. readonly useClonedMeshhMap: boolean;
  95867. private _externalData;
  95868. private _uid;
  95869. /**
  95870. * @hidden
  95871. * Backing store of defined scene components.
  95872. */
  95873. _components: ISceneComponent[];
  95874. /**
  95875. * @hidden
  95876. * Backing store of defined scene components.
  95877. */
  95878. _serializableComponents: ISceneSerializableComponent[];
  95879. /**
  95880. * List of components to register on the next registration step.
  95881. */
  95882. private _transientComponents;
  95883. /**
  95884. * Registers the transient components if needed.
  95885. */
  95886. private _registerTransientComponents;
  95887. /**
  95888. * @hidden
  95889. * Add a component to the scene.
  95890. * Note that the ccomponent could be registered on th next frame if this is called after
  95891. * the register component stage.
  95892. * @param component Defines the component to add to the scene
  95893. */
  95894. _addComponent(component: ISceneComponent): void;
  95895. /**
  95896. * @hidden
  95897. * Gets a component from the scene.
  95898. * @param name defines the name of the component to retrieve
  95899. * @returns the component or null if not present
  95900. */
  95901. _getComponent(name: string): Nullable<ISceneComponent>;
  95902. /**
  95903. * @hidden
  95904. * Defines the actions happening before camera updates.
  95905. */
  95906. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95907. /**
  95908. * @hidden
  95909. * Defines the actions happening before clear the canvas.
  95910. */
  95911. _beforeClearStage: Stage<SimpleStageAction>;
  95912. /**
  95913. * @hidden
  95914. * Defines the actions when collecting render targets for the frame.
  95915. */
  95916. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95917. /**
  95918. * @hidden
  95919. * Defines the actions happening for one camera in the frame.
  95920. */
  95921. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95922. /**
  95923. * @hidden
  95924. * Defines the actions happening during the per mesh ready checks.
  95925. */
  95926. _isReadyForMeshStage: Stage<MeshStageAction>;
  95927. /**
  95928. * @hidden
  95929. * Defines the actions happening before evaluate active mesh checks.
  95930. */
  95931. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  95932. /**
  95933. * @hidden
  95934. * Defines the actions happening during the evaluate sub mesh checks.
  95935. */
  95936. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  95937. /**
  95938. * @hidden
  95939. * Defines the actions happening during the active mesh stage.
  95940. */
  95941. _activeMeshStage: Stage<ActiveMeshStageAction>;
  95942. /**
  95943. * @hidden
  95944. * Defines the actions happening during the per camera render target step.
  95945. */
  95946. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  95947. /**
  95948. * @hidden
  95949. * Defines the actions happening just before the active camera is drawing.
  95950. */
  95951. _beforeCameraDrawStage: Stage<CameraStageAction>;
  95952. /**
  95953. * @hidden
  95954. * Defines the actions happening just before a render target is drawing.
  95955. */
  95956. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95957. /**
  95958. * @hidden
  95959. * Defines the actions happening just before a rendering group is drawing.
  95960. */
  95961. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95962. /**
  95963. * @hidden
  95964. * Defines the actions happening just before a mesh is drawing.
  95965. */
  95966. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95967. /**
  95968. * @hidden
  95969. * Defines the actions happening just after a mesh has been drawn.
  95970. */
  95971. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95972. /**
  95973. * @hidden
  95974. * Defines the actions happening just after a rendering group has been drawn.
  95975. */
  95976. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95977. /**
  95978. * @hidden
  95979. * Defines the actions happening just after the active camera has been drawn.
  95980. */
  95981. _afterCameraDrawStage: Stage<CameraStageAction>;
  95982. /**
  95983. * @hidden
  95984. * Defines the actions happening just after a render target has been drawn.
  95985. */
  95986. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95987. /**
  95988. * @hidden
  95989. * Defines the actions happening just after rendering all cameras and computing intersections.
  95990. */
  95991. _afterRenderStage: Stage<SimpleStageAction>;
  95992. /**
  95993. * @hidden
  95994. * Defines the actions happening when a pointer move event happens.
  95995. */
  95996. _pointerMoveStage: Stage<PointerMoveStageAction>;
  95997. /**
  95998. * @hidden
  95999. * Defines the actions happening when a pointer down event happens.
  96000. */
  96001. _pointerDownStage: Stage<PointerUpDownStageAction>;
  96002. /**
  96003. * @hidden
  96004. * Defines the actions happening when a pointer up event happens.
  96005. */
  96006. _pointerUpStage: Stage<PointerUpDownStageAction>;
  96007. /**
  96008. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  96009. */
  96010. private geometriesByUniqueId;
  96011. /**
  96012. * Creates a new Scene
  96013. * @param engine defines the engine to use to render this scene
  96014. * @param options defines the scene options
  96015. */
  96016. constructor(engine: Engine, options?: SceneOptions);
  96017. /**
  96018. * Gets a string idenfifying the name of the class
  96019. * @returns "Scene" string
  96020. */
  96021. getClassName(): string;
  96022. private _defaultMeshCandidates;
  96023. /**
  96024. * @hidden
  96025. */
  96026. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  96027. private _defaultSubMeshCandidates;
  96028. /**
  96029. * @hidden
  96030. */
  96031. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  96032. /**
  96033. * Sets the default candidate providers for the scene.
  96034. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  96035. * and getCollidingSubMeshCandidates to their default function
  96036. */
  96037. setDefaultCandidateProviders(): void;
  96038. /**
  96039. * Gets the mesh that is currently under the pointer
  96040. */
  96041. readonly meshUnderPointer: Nullable<AbstractMesh>;
  96042. /**
  96043. * Gets or sets the current on-screen X position of the pointer
  96044. */
  96045. pointerX: number;
  96046. /**
  96047. * Gets or sets the current on-screen Y position of the pointer
  96048. */
  96049. pointerY: number;
  96050. /**
  96051. * Gets the cached material (ie. the latest rendered one)
  96052. * @returns the cached material
  96053. */
  96054. getCachedMaterial(): Nullable<Material>;
  96055. /**
  96056. * Gets the cached effect (ie. the latest rendered one)
  96057. * @returns the cached effect
  96058. */
  96059. getCachedEffect(): Nullable<Effect>;
  96060. /**
  96061. * Gets the cached visibility state (ie. the latest rendered one)
  96062. * @returns the cached visibility state
  96063. */
  96064. getCachedVisibility(): Nullable<number>;
  96065. /**
  96066. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  96067. * @param material defines the current material
  96068. * @param effect defines the current effect
  96069. * @param visibility defines the current visibility state
  96070. * @returns true if one parameter is not cached
  96071. */
  96072. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  96073. /**
  96074. * Gets the engine associated with the scene
  96075. * @returns an Engine
  96076. */
  96077. getEngine(): Engine;
  96078. /**
  96079. * Gets the total number of vertices rendered per frame
  96080. * @returns the total number of vertices rendered per frame
  96081. */
  96082. getTotalVertices(): number;
  96083. /**
  96084. * Gets the performance counter for total vertices
  96085. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96086. */
  96087. readonly totalVerticesPerfCounter: PerfCounter;
  96088. /**
  96089. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  96090. * @returns the total number of active indices rendered per frame
  96091. */
  96092. getActiveIndices(): number;
  96093. /**
  96094. * Gets the performance counter for active indices
  96095. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96096. */
  96097. readonly totalActiveIndicesPerfCounter: PerfCounter;
  96098. /**
  96099. * Gets the total number of active particles rendered per frame
  96100. * @returns the total number of active particles rendered per frame
  96101. */
  96102. getActiveParticles(): number;
  96103. /**
  96104. * Gets the performance counter for active particles
  96105. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96106. */
  96107. readonly activeParticlesPerfCounter: PerfCounter;
  96108. /**
  96109. * Gets the total number of active bones rendered per frame
  96110. * @returns the total number of active bones rendered per frame
  96111. */
  96112. getActiveBones(): number;
  96113. /**
  96114. * Gets the performance counter for active bones
  96115. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96116. */
  96117. readonly activeBonesPerfCounter: PerfCounter;
  96118. /**
  96119. * Gets the array of active meshes
  96120. * @returns an array of AbstractMesh
  96121. */
  96122. getActiveMeshes(): SmartArray<AbstractMesh>;
  96123. /**
  96124. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  96125. * @returns a number
  96126. */
  96127. getAnimationRatio(): number;
  96128. /**
  96129. * Gets an unique Id for the current render phase
  96130. * @returns a number
  96131. */
  96132. getRenderId(): number;
  96133. /**
  96134. * Gets an unique Id for the current frame
  96135. * @returns a number
  96136. */
  96137. getFrameId(): number;
  96138. /** Call this function if you want to manually increment the render Id*/
  96139. incrementRenderId(): void;
  96140. private _createUbo;
  96141. /**
  96142. * Use this method to simulate a pointer move on a mesh
  96143. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96144. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96145. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96146. * @returns the current scene
  96147. */
  96148. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  96149. /**
  96150. * Use this method to simulate a pointer down on a mesh
  96151. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96152. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96153. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96154. * @returns the current scene
  96155. */
  96156. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  96157. /**
  96158. * Use this method to simulate a pointer up on a mesh
  96159. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96160. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96161. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96162. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96163. * @returns the current scene
  96164. */
  96165. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  96166. /**
  96167. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96168. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96169. * @returns true if the pointer was captured
  96170. */
  96171. isPointerCaptured(pointerId?: number): boolean;
  96172. /**
  96173. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96174. * @param attachUp defines if you want to attach events to pointerup
  96175. * @param attachDown defines if you want to attach events to pointerdown
  96176. * @param attachMove defines if you want to attach events to pointermove
  96177. */
  96178. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96179. /** Detaches all event handlers*/
  96180. detachControl(): void;
  96181. /**
  96182. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  96183. * Delay loaded resources are not taking in account
  96184. * @return true if all required resources are ready
  96185. */
  96186. isReady(): boolean;
  96187. /** Resets all cached information relative to material (including effect and visibility) */
  96188. resetCachedMaterial(): void;
  96189. /**
  96190. * Registers a function to be called before every frame render
  96191. * @param func defines the function to register
  96192. */
  96193. registerBeforeRender(func: () => void): void;
  96194. /**
  96195. * Unregisters a function called before every frame render
  96196. * @param func defines the function to unregister
  96197. */
  96198. unregisterBeforeRender(func: () => void): void;
  96199. /**
  96200. * Registers a function to be called after every frame render
  96201. * @param func defines the function to register
  96202. */
  96203. registerAfterRender(func: () => void): void;
  96204. /**
  96205. * Unregisters a function called after every frame render
  96206. * @param func defines the function to unregister
  96207. */
  96208. unregisterAfterRender(func: () => void): void;
  96209. private _executeOnceBeforeRender;
  96210. /**
  96211. * The provided function will run before render once and will be disposed afterwards.
  96212. * A timeout delay can be provided so that the function will be executed in N ms.
  96213. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  96214. * @param func The function to be executed.
  96215. * @param timeout optional delay in ms
  96216. */
  96217. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  96218. /** @hidden */
  96219. _addPendingData(data: any): void;
  96220. /** @hidden */
  96221. _removePendingData(data: any): void;
  96222. /**
  96223. * Returns the number of items waiting to be loaded
  96224. * @returns the number of items waiting to be loaded
  96225. */
  96226. getWaitingItemsCount(): number;
  96227. /**
  96228. * Returns a boolean indicating if the scene is still loading data
  96229. */
  96230. readonly isLoading: boolean;
  96231. /**
  96232. * Registers a function to be executed when the scene is ready
  96233. * @param {Function} func - the function to be executed
  96234. */
  96235. executeWhenReady(func: () => void): void;
  96236. /**
  96237. * Returns a promise that resolves when the scene is ready
  96238. * @returns A promise that resolves when the scene is ready
  96239. */
  96240. whenReadyAsync(): Promise<void>;
  96241. /** @hidden */
  96242. _checkIsReady(): void;
  96243. /**
  96244. * Gets all animatable attached to the scene
  96245. */
  96246. readonly animatables: Animatable[];
  96247. /**
  96248. * Resets the last animation time frame.
  96249. * Useful to override when animations start running when loading a scene for the first time.
  96250. */
  96251. resetLastAnimationTimeFrame(): void;
  96252. /**
  96253. * Gets the current view matrix
  96254. * @returns a Matrix
  96255. */
  96256. getViewMatrix(): Matrix;
  96257. /**
  96258. * Gets the current projection matrix
  96259. * @returns a Matrix
  96260. */
  96261. getProjectionMatrix(): Matrix;
  96262. /**
  96263. * Gets the current transform matrix
  96264. * @returns a Matrix made of View * Projection
  96265. */
  96266. getTransformMatrix(): Matrix;
  96267. /**
  96268. * Sets the current transform matrix
  96269. * @param viewL defines the View matrix to use
  96270. * @param projectionL defines the Projection matrix to use
  96271. * @param viewR defines the right View matrix to use (if provided)
  96272. * @param projectionR defines the right Projection matrix to use (if provided)
  96273. */
  96274. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  96275. /**
  96276. * Gets the uniform buffer used to store scene data
  96277. * @returns a UniformBuffer
  96278. */
  96279. getSceneUniformBuffer(): UniformBuffer;
  96280. /**
  96281. * Gets an unique (relatively to the current scene) Id
  96282. * @returns an unique number for the scene
  96283. */
  96284. getUniqueId(): number;
  96285. /**
  96286. * Add a mesh to the list of scene's meshes
  96287. * @param newMesh defines the mesh to add
  96288. * @param recursive if all child meshes should also be added to the scene
  96289. */
  96290. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  96291. /**
  96292. * Remove a mesh for the list of scene's meshes
  96293. * @param toRemove defines the mesh to remove
  96294. * @param recursive if all child meshes should also be removed from the scene
  96295. * @returns the index where the mesh was in the mesh list
  96296. */
  96297. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  96298. /**
  96299. * Add a transform node to the list of scene's transform nodes
  96300. * @param newTransformNode defines the transform node to add
  96301. */
  96302. addTransformNode(newTransformNode: TransformNode): void;
  96303. /**
  96304. * Remove a transform node for the list of scene's transform nodes
  96305. * @param toRemove defines the transform node to remove
  96306. * @returns the index where the transform node was in the transform node list
  96307. */
  96308. removeTransformNode(toRemove: TransformNode): number;
  96309. /**
  96310. * Remove a skeleton for the list of scene's skeletons
  96311. * @param toRemove defines the skeleton to remove
  96312. * @returns the index where the skeleton was in the skeleton list
  96313. */
  96314. removeSkeleton(toRemove: Skeleton): number;
  96315. /**
  96316. * Remove a morph target for the list of scene's morph targets
  96317. * @param toRemove defines the morph target to remove
  96318. * @returns the index where the morph target was in the morph target list
  96319. */
  96320. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  96321. /**
  96322. * Remove a light for the list of scene's lights
  96323. * @param toRemove defines the light to remove
  96324. * @returns the index where the light was in the light list
  96325. */
  96326. removeLight(toRemove: Light): number;
  96327. /**
  96328. * Remove a camera for the list of scene's cameras
  96329. * @param toRemove defines the camera to remove
  96330. * @returns the index where the camera was in the camera list
  96331. */
  96332. removeCamera(toRemove: Camera): number;
  96333. /**
  96334. * Remove a particle system for the list of scene's particle systems
  96335. * @param toRemove defines the particle system to remove
  96336. * @returns the index where the particle system was in the particle system list
  96337. */
  96338. removeParticleSystem(toRemove: IParticleSystem): number;
  96339. /**
  96340. * Remove a animation for the list of scene's animations
  96341. * @param toRemove defines the animation to remove
  96342. * @returns the index where the animation was in the animation list
  96343. */
  96344. removeAnimation(toRemove: Animation): number;
  96345. /**
  96346. * Will stop the animation of the given target
  96347. * @param target - the target
  96348. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  96349. * @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)
  96350. */
  96351. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  96352. /**
  96353. * Removes the given animation group from this scene.
  96354. * @param toRemove The animation group to remove
  96355. * @returns The index of the removed animation group
  96356. */
  96357. removeAnimationGroup(toRemove: AnimationGroup): number;
  96358. /**
  96359. * Removes the given multi-material from this scene.
  96360. * @param toRemove The multi-material to remove
  96361. * @returns The index of the removed multi-material
  96362. */
  96363. removeMultiMaterial(toRemove: MultiMaterial): number;
  96364. /**
  96365. * Removes the given material from this scene.
  96366. * @param toRemove The material to remove
  96367. * @returns The index of the removed material
  96368. */
  96369. removeMaterial(toRemove: Material): number;
  96370. /**
  96371. * Removes the given action manager from this scene.
  96372. * @param toRemove The action manager to remove
  96373. * @returns The index of the removed action manager
  96374. */
  96375. removeActionManager(toRemove: AbstractActionManager): number;
  96376. /**
  96377. * Removes the given texture from this scene.
  96378. * @param toRemove The texture to remove
  96379. * @returns The index of the removed texture
  96380. */
  96381. removeTexture(toRemove: BaseTexture): number;
  96382. /**
  96383. * Adds the given light to this scene
  96384. * @param newLight The light to add
  96385. */
  96386. addLight(newLight: Light): void;
  96387. /**
  96388. * Sorts the list list based on light priorities
  96389. */
  96390. sortLightsByPriority(): void;
  96391. /**
  96392. * Adds the given camera to this scene
  96393. * @param newCamera The camera to add
  96394. */
  96395. addCamera(newCamera: Camera): void;
  96396. /**
  96397. * Adds the given skeleton to this scene
  96398. * @param newSkeleton The skeleton to add
  96399. */
  96400. addSkeleton(newSkeleton: Skeleton): void;
  96401. /**
  96402. * Adds the given particle system to this scene
  96403. * @param newParticleSystem The particle system to add
  96404. */
  96405. addParticleSystem(newParticleSystem: IParticleSystem): void;
  96406. /**
  96407. * Adds the given animation to this scene
  96408. * @param newAnimation The animation to add
  96409. */
  96410. addAnimation(newAnimation: Animation): void;
  96411. /**
  96412. * Adds the given animation group to this scene.
  96413. * @param newAnimationGroup The animation group to add
  96414. */
  96415. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  96416. /**
  96417. * Adds the given multi-material to this scene
  96418. * @param newMultiMaterial The multi-material to add
  96419. */
  96420. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  96421. /**
  96422. * Adds the given material to this scene
  96423. * @param newMaterial The material to add
  96424. */
  96425. addMaterial(newMaterial: Material): void;
  96426. /**
  96427. * Adds the given morph target to this scene
  96428. * @param newMorphTargetManager The morph target to add
  96429. */
  96430. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  96431. /**
  96432. * Adds the given geometry to this scene
  96433. * @param newGeometry The geometry to add
  96434. */
  96435. addGeometry(newGeometry: Geometry): void;
  96436. /**
  96437. * Adds the given action manager to this scene
  96438. * @param newActionManager The action manager to add
  96439. */
  96440. addActionManager(newActionManager: AbstractActionManager): void;
  96441. /**
  96442. * Adds the given texture to this scene.
  96443. * @param newTexture The texture to add
  96444. */
  96445. addTexture(newTexture: BaseTexture): void;
  96446. /**
  96447. * Switch active camera
  96448. * @param newCamera defines the new active camera
  96449. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  96450. */
  96451. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  96452. /**
  96453. * sets the active camera of the scene using its ID
  96454. * @param id defines the camera's ID
  96455. * @return the new active camera or null if none found.
  96456. */
  96457. setActiveCameraByID(id: string): Nullable<Camera>;
  96458. /**
  96459. * sets the active camera of the scene using its name
  96460. * @param name defines the camera's name
  96461. * @returns the new active camera or null if none found.
  96462. */
  96463. setActiveCameraByName(name: string): Nullable<Camera>;
  96464. /**
  96465. * get an animation group using its name
  96466. * @param name defines the material's name
  96467. * @return the animation group or null if none found.
  96468. */
  96469. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  96470. /**
  96471. * Get a material using its unique id
  96472. * @param uniqueId defines the material's unique id
  96473. * @return the material or null if none found.
  96474. */
  96475. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  96476. /**
  96477. * get a material using its id
  96478. * @param id defines the material's ID
  96479. * @return the material or null if none found.
  96480. */
  96481. getMaterialByID(id: string): Nullable<Material>;
  96482. /**
  96483. * Gets a material using its name
  96484. * @param name defines the material's name
  96485. * @return the material or null if none found.
  96486. */
  96487. getMaterialByName(name: string): Nullable<Material>;
  96488. /**
  96489. * Gets a camera using its id
  96490. * @param id defines the id to look for
  96491. * @returns the camera or null if not found
  96492. */
  96493. getCameraByID(id: string): Nullable<Camera>;
  96494. /**
  96495. * Gets a camera using its unique id
  96496. * @param uniqueId defines the unique id to look for
  96497. * @returns the camera or null if not found
  96498. */
  96499. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  96500. /**
  96501. * Gets a camera using its name
  96502. * @param name defines the camera's name
  96503. * @return the camera or null if none found.
  96504. */
  96505. getCameraByName(name: string): Nullable<Camera>;
  96506. /**
  96507. * Gets a bone using its id
  96508. * @param id defines the bone's id
  96509. * @return the bone or null if not found
  96510. */
  96511. getBoneByID(id: string): Nullable<Bone>;
  96512. /**
  96513. * Gets a bone using its id
  96514. * @param name defines the bone's name
  96515. * @return the bone or null if not found
  96516. */
  96517. getBoneByName(name: string): Nullable<Bone>;
  96518. /**
  96519. * Gets a light node using its name
  96520. * @param name defines the the light's name
  96521. * @return the light or null if none found.
  96522. */
  96523. getLightByName(name: string): Nullable<Light>;
  96524. /**
  96525. * Gets a light node using its id
  96526. * @param id defines the light's id
  96527. * @return the light or null if none found.
  96528. */
  96529. getLightByID(id: string): Nullable<Light>;
  96530. /**
  96531. * Gets a light node using its scene-generated unique ID
  96532. * @param uniqueId defines the light's unique id
  96533. * @return the light or null if none found.
  96534. */
  96535. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  96536. /**
  96537. * Gets a particle system by id
  96538. * @param id defines the particle system id
  96539. * @return the corresponding system or null if none found
  96540. */
  96541. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  96542. /**
  96543. * Gets a geometry using its ID
  96544. * @param id defines the geometry's id
  96545. * @return the geometry or null if none found.
  96546. */
  96547. getGeometryByID(id: string): Nullable<Geometry>;
  96548. private _getGeometryByUniqueID;
  96549. /**
  96550. * Add a new geometry to this scene
  96551. * @param geometry defines the geometry to be added to the scene.
  96552. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  96553. * @return a boolean defining if the geometry was added or not
  96554. */
  96555. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  96556. /**
  96557. * Removes an existing geometry
  96558. * @param geometry defines the geometry to be removed from the scene
  96559. * @return a boolean defining if the geometry was removed or not
  96560. */
  96561. removeGeometry(geometry: Geometry): boolean;
  96562. /**
  96563. * Gets the list of geometries attached to the scene
  96564. * @returns an array of Geometry
  96565. */
  96566. getGeometries(): Geometry[];
  96567. /**
  96568. * Gets the first added mesh found of a given ID
  96569. * @param id defines the id to search for
  96570. * @return the mesh found or null if not found at all
  96571. */
  96572. getMeshByID(id: string): Nullable<AbstractMesh>;
  96573. /**
  96574. * Gets a list of meshes using their id
  96575. * @param id defines the id to search for
  96576. * @returns a list of meshes
  96577. */
  96578. getMeshesByID(id: string): Array<AbstractMesh>;
  96579. /**
  96580. * Gets the first added transform node found of a given ID
  96581. * @param id defines the id to search for
  96582. * @return the found transform node or null if not found at all.
  96583. */
  96584. getTransformNodeByID(id: string): Nullable<TransformNode>;
  96585. /**
  96586. * Gets a transform node with its auto-generated unique id
  96587. * @param uniqueId efines the unique id to search for
  96588. * @return the found transform node or null if not found at all.
  96589. */
  96590. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  96591. /**
  96592. * Gets a list of transform nodes using their id
  96593. * @param id defines the id to search for
  96594. * @returns a list of transform nodes
  96595. */
  96596. getTransformNodesByID(id: string): Array<TransformNode>;
  96597. /**
  96598. * Gets a mesh with its auto-generated unique id
  96599. * @param uniqueId defines the unique id to search for
  96600. * @return the found mesh or null if not found at all.
  96601. */
  96602. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  96603. /**
  96604. * Gets a the last added mesh using a given id
  96605. * @param id defines the id to search for
  96606. * @return the found mesh or null if not found at all.
  96607. */
  96608. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  96609. /**
  96610. * Gets a the last added node (Mesh, Camera, Light) using a given id
  96611. * @param id defines the id to search for
  96612. * @return the found node or null if not found at all
  96613. */
  96614. getLastEntryByID(id: string): Nullable<Node>;
  96615. /**
  96616. * Gets a node (Mesh, Camera, Light) using a given id
  96617. * @param id defines the id to search for
  96618. * @return the found node or null if not found at all
  96619. */
  96620. getNodeByID(id: string): Nullable<Node>;
  96621. /**
  96622. * Gets a node (Mesh, Camera, Light) using a given name
  96623. * @param name defines the name to search for
  96624. * @return the found node or null if not found at all.
  96625. */
  96626. getNodeByName(name: string): Nullable<Node>;
  96627. /**
  96628. * Gets a mesh using a given name
  96629. * @param name defines the name to search for
  96630. * @return the found mesh or null if not found at all.
  96631. */
  96632. getMeshByName(name: string): Nullable<AbstractMesh>;
  96633. /**
  96634. * Gets a transform node using a given name
  96635. * @param name defines the name to search for
  96636. * @return the found transform node or null if not found at all.
  96637. */
  96638. getTransformNodeByName(name: string): Nullable<TransformNode>;
  96639. /**
  96640. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  96641. * @param id defines the id to search for
  96642. * @return the found skeleton or null if not found at all.
  96643. */
  96644. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  96645. /**
  96646. * Gets a skeleton using a given auto generated unique id
  96647. * @param uniqueId defines the unique id to search for
  96648. * @return the found skeleton or null if not found at all.
  96649. */
  96650. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  96651. /**
  96652. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  96653. * @param id defines the id to search for
  96654. * @return the found skeleton or null if not found at all.
  96655. */
  96656. getSkeletonById(id: string): Nullable<Skeleton>;
  96657. /**
  96658. * Gets a skeleton using a given name
  96659. * @param name defines the name to search for
  96660. * @return the found skeleton or null if not found at all.
  96661. */
  96662. getSkeletonByName(name: string): Nullable<Skeleton>;
  96663. /**
  96664. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  96665. * @param id defines the id to search for
  96666. * @return the found morph target manager or null if not found at all.
  96667. */
  96668. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  96669. /**
  96670. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  96671. * @param id defines the id to search for
  96672. * @return the found morph target or null if not found at all.
  96673. */
  96674. getMorphTargetById(id: string): Nullable<MorphTarget>;
  96675. /**
  96676. * Gets a boolean indicating if the given mesh is active
  96677. * @param mesh defines the mesh to look for
  96678. * @returns true if the mesh is in the active list
  96679. */
  96680. isActiveMesh(mesh: AbstractMesh): boolean;
  96681. /**
  96682. * Return a unique id as a string which can serve as an identifier for the scene
  96683. */
  96684. readonly uid: string;
  96685. /**
  96686. * Add an externaly attached data from its key.
  96687. * This method call will fail and return false, if such key already exists.
  96688. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96689. * @param key the unique key that identifies the data
  96690. * @param data the data object to associate to the key for this Engine instance
  96691. * @return true if no such key were already present and the data was added successfully, false otherwise
  96692. */
  96693. addExternalData<T>(key: string, data: T): boolean;
  96694. /**
  96695. * Get an externaly attached data from its key
  96696. * @param key the unique key that identifies the data
  96697. * @return the associated data, if present (can be null), or undefined if not present
  96698. */
  96699. getExternalData<T>(key: string): Nullable<T>;
  96700. /**
  96701. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96702. * @param key the unique key that identifies the data
  96703. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96704. * @return the associated data, can be null if the factory returned null.
  96705. */
  96706. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96707. /**
  96708. * Remove an externaly attached data from the Engine instance
  96709. * @param key the unique key that identifies the data
  96710. * @return true if the data was successfully removed, false if it doesn't exist
  96711. */
  96712. removeExternalData(key: string): boolean;
  96713. private _evaluateSubMesh;
  96714. /**
  96715. * Clear the processed materials smart array preventing retention point in material dispose.
  96716. */
  96717. freeProcessedMaterials(): void;
  96718. private _preventFreeActiveMeshesAndRenderingGroups;
  96719. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  96720. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  96721. * when disposing several meshes in a row or a hierarchy of meshes.
  96722. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  96723. */
  96724. blockfreeActiveMeshesAndRenderingGroups: boolean;
  96725. /**
  96726. * Clear the active meshes smart array preventing retention point in mesh dispose.
  96727. */
  96728. freeActiveMeshes(): void;
  96729. /**
  96730. * Clear the info related to rendering groups preventing retention points during dispose.
  96731. */
  96732. freeRenderingGroups(): void;
  96733. /** @hidden */
  96734. _isInIntermediateRendering(): boolean;
  96735. /**
  96736. * Lambda returning the list of potentially active meshes.
  96737. */
  96738. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  96739. /**
  96740. * Lambda returning the list of potentially active sub meshes.
  96741. */
  96742. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  96743. /**
  96744. * Lambda returning the list of potentially intersecting sub meshes.
  96745. */
  96746. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96747. /**
  96748. * Lambda returning the list of potentially colliding sub meshes.
  96749. */
  96750. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96751. private _activeMeshesFrozen;
  96752. /**
  96753. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96754. * @returns the current scene
  96755. */
  96756. freezeActiveMeshes(): Scene;
  96757. /**
  96758. * Use this function to restart evaluating active meshes on every frame
  96759. * @returns the current scene
  96760. */
  96761. unfreezeActiveMeshes(): Scene;
  96762. private _evaluateActiveMeshes;
  96763. private _activeMesh;
  96764. /**
  96765. * Update the transform matrix to update from the current active camera
  96766. * @param force defines a boolean used to force the update even if cache is up to date
  96767. */
  96768. updateTransformMatrix(force?: boolean): void;
  96769. private _bindFrameBuffer;
  96770. /** @hidden */
  96771. _allowPostProcessClearColor: boolean;
  96772. /** @hidden */
  96773. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96774. private _processSubCameras;
  96775. private _checkIntersections;
  96776. /** @hidden */
  96777. _advancePhysicsEngineStep(step: number): void;
  96778. /**
  96779. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96780. */
  96781. getDeterministicFrameTime: () => number;
  96782. /** @hidden */
  96783. _animate(): void;
  96784. /** Execute all animations (for a frame) */
  96785. animate(): void;
  96786. /**
  96787. * Render the scene
  96788. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96789. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96790. */
  96791. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96792. /**
  96793. * Freeze all materials
  96794. * A frozen material will not be updatable but should be faster to render
  96795. */
  96796. freezeMaterials(): void;
  96797. /**
  96798. * Unfreeze all materials
  96799. * A frozen material will not be updatable but should be faster to render
  96800. */
  96801. unfreezeMaterials(): void;
  96802. /**
  96803. * Releases all held ressources
  96804. */
  96805. dispose(): void;
  96806. /**
  96807. * Gets if the scene is already disposed
  96808. */
  96809. readonly isDisposed: boolean;
  96810. /**
  96811. * Call this function to reduce memory footprint of the scene.
  96812. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96813. */
  96814. clearCachedVertexData(): void;
  96815. /**
  96816. * This function will remove the local cached buffer data from texture.
  96817. * It will save memory but will prevent the texture from being rebuilt
  96818. */
  96819. cleanCachedTextureBuffer(): void;
  96820. /**
  96821. * Get the world extend vectors with an optional filter
  96822. *
  96823. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96824. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96825. */
  96826. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96827. min: Vector3;
  96828. max: Vector3;
  96829. };
  96830. /**
  96831. * Creates a ray that can be used to pick in the scene
  96832. * @param x defines the x coordinate of the origin (on-screen)
  96833. * @param y defines the y coordinate of the origin (on-screen)
  96834. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96835. * @param camera defines the camera to use for the picking
  96836. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96837. * @returns a Ray
  96838. */
  96839. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96840. /**
  96841. * Creates a ray that can be used to pick in the scene
  96842. * @param x defines the x coordinate of the origin (on-screen)
  96843. * @param y defines the y coordinate of the origin (on-screen)
  96844. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96845. * @param result defines the ray where to store the picking ray
  96846. * @param camera defines the camera to use for the picking
  96847. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96848. * @returns the current scene
  96849. */
  96850. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96851. /**
  96852. * Creates a ray that can be used to pick in the scene
  96853. * @param x defines the x coordinate of the origin (on-screen)
  96854. * @param y defines the y coordinate of the origin (on-screen)
  96855. * @param camera defines the camera to use for the picking
  96856. * @returns a Ray
  96857. */
  96858. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96859. /**
  96860. * Creates a ray that can be used to pick in the scene
  96861. * @param x defines the x coordinate of the origin (on-screen)
  96862. * @param y defines the y coordinate of the origin (on-screen)
  96863. * @param result defines the ray where to store the picking ray
  96864. * @param camera defines the camera to use for the picking
  96865. * @returns the current scene
  96866. */
  96867. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96868. /** Launch a ray to try to pick a mesh in the scene
  96869. * @param x position on screen
  96870. * @param y position on screen
  96871. * @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
  96872. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96873. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96874. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96875. * @returns a PickingInfo
  96876. */
  96877. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96878. /** Use the given ray to pick a mesh in the scene
  96879. * @param ray The ray to use to pick meshes
  96880. * @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
  96881. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96882. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96883. * @returns a PickingInfo
  96884. */
  96885. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96886. /**
  96887. * Launch a ray to try to pick a mesh in the scene
  96888. * @param x X position on screen
  96889. * @param y Y position on screen
  96890. * @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
  96891. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96892. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96893. * @returns an array of PickingInfo
  96894. */
  96895. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96896. /**
  96897. * Launch a ray to try to pick a mesh in the scene
  96898. * @param ray Ray to use
  96899. * @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
  96900. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96901. * @returns an array of PickingInfo
  96902. */
  96903. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96904. /**
  96905. * Force the value of meshUnderPointer
  96906. * @param mesh defines the mesh to use
  96907. */
  96908. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96909. /**
  96910. * Gets the mesh under the pointer
  96911. * @returns a Mesh or null if no mesh is under the pointer
  96912. */
  96913. getPointerOverMesh(): Nullable<AbstractMesh>;
  96914. /** @hidden */
  96915. _rebuildGeometries(): void;
  96916. /** @hidden */
  96917. _rebuildTextures(): void;
  96918. private _getByTags;
  96919. /**
  96920. * Get a list of meshes by tags
  96921. * @param tagsQuery defines the tags query to use
  96922. * @param forEach defines a predicate used to filter results
  96923. * @returns an array of Mesh
  96924. */
  96925. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  96926. /**
  96927. * Get a list of cameras by tags
  96928. * @param tagsQuery defines the tags query to use
  96929. * @param forEach defines a predicate used to filter results
  96930. * @returns an array of Camera
  96931. */
  96932. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  96933. /**
  96934. * Get a list of lights by tags
  96935. * @param tagsQuery defines the tags query to use
  96936. * @param forEach defines a predicate used to filter results
  96937. * @returns an array of Light
  96938. */
  96939. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  96940. /**
  96941. * Get a list of materials by tags
  96942. * @param tagsQuery defines the tags query to use
  96943. * @param forEach defines a predicate used to filter results
  96944. * @returns an array of Material
  96945. */
  96946. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  96947. /**
  96948. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96949. * This allowed control for front to back rendering or reversly depending of the special needs.
  96950. *
  96951. * @param renderingGroupId The rendering group id corresponding to its index
  96952. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96953. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96954. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96955. */
  96956. 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;
  96957. /**
  96958. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96959. *
  96960. * @param renderingGroupId The rendering group id corresponding to its index
  96961. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96962. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96963. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96964. */
  96965. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96966. /**
  96967. * Gets the current auto clear configuration for one rendering group of the rendering
  96968. * manager.
  96969. * @param index the rendering group index to get the information for
  96970. * @returns The auto clear setup for the requested rendering group
  96971. */
  96972. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96973. private _blockMaterialDirtyMechanism;
  96974. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  96975. blockMaterialDirtyMechanism: boolean;
  96976. /**
  96977. * Will flag all materials as dirty to trigger new shader compilation
  96978. * @param flag defines the flag used to specify which material part must be marked as dirty
  96979. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  96980. */
  96981. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  96982. /** @hidden */
  96983. _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;
  96984. /** @hidden */
  96985. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96986. }
  96987. }
  96988. declare module BABYLON {
  96989. /**
  96990. * Set of assets to keep when moving a scene into an asset container.
  96991. */
  96992. export class KeepAssets extends AbstractScene {
  96993. }
  96994. /**
  96995. * Container with a set of assets that can be added or removed from a scene.
  96996. */
  96997. export class AssetContainer extends AbstractScene {
  96998. /**
  96999. * The scene the AssetContainer belongs to.
  97000. */
  97001. scene: Scene;
  97002. /**
  97003. * Instantiates an AssetContainer.
  97004. * @param scene The scene the AssetContainer belongs to.
  97005. */
  97006. constructor(scene: Scene);
  97007. /**
  97008. * Adds all the assets from the container to the scene.
  97009. */
  97010. addAllToScene(): void;
  97011. /**
  97012. * Removes all the assets in the container from the scene
  97013. */
  97014. removeAllFromScene(): void;
  97015. /**
  97016. * Disposes all the assets in the container
  97017. */
  97018. dispose(): void;
  97019. private _moveAssets;
  97020. /**
  97021. * Removes all the assets contained in the scene and adds them to the container.
  97022. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  97023. */
  97024. moveAllFromScene(keepAssets?: KeepAssets): void;
  97025. /**
  97026. * 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.
  97027. * @returns the root mesh
  97028. */
  97029. createRootMesh(): Mesh;
  97030. }
  97031. }
  97032. declare module BABYLON {
  97033. /**
  97034. * Defines how the parser contract is defined.
  97035. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  97036. */
  97037. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  97038. /**
  97039. * Defines how the individual parser contract is defined.
  97040. * These parser can parse an individual asset
  97041. */
  97042. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  97043. /**
  97044. * Base class of the scene acting as a container for the different elements composing a scene.
  97045. * This class is dynamically extended by the different components of the scene increasing
  97046. * flexibility and reducing coupling
  97047. */
  97048. export abstract class AbstractScene {
  97049. /**
  97050. * Stores the list of available parsers in the application.
  97051. */
  97052. private static _BabylonFileParsers;
  97053. /**
  97054. * Stores the list of available individual parsers in the application.
  97055. */
  97056. private static _IndividualBabylonFileParsers;
  97057. /**
  97058. * Adds a parser in the list of available ones
  97059. * @param name Defines the name of the parser
  97060. * @param parser Defines the parser to add
  97061. */
  97062. static AddParser(name: string, parser: BabylonFileParser): void;
  97063. /**
  97064. * Gets a general parser from the list of avaialble ones
  97065. * @param name Defines the name of the parser
  97066. * @returns the requested parser or null
  97067. */
  97068. static GetParser(name: string): Nullable<BabylonFileParser>;
  97069. /**
  97070. * Adds n individual parser in the list of available ones
  97071. * @param name Defines the name of the parser
  97072. * @param parser Defines the parser to add
  97073. */
  97074. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  97075. /**
  97076. * Gets an individual parser from the list of avaialble ones
  97077. * @param name Defines the name of the parser
  97078. * @returns the requested parser or null
  97079. */
  97080. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  97081. /**
  97082. * Parser json data and populate both a scene and its associated container object
  97083. * @param jsonData Defines the data to parse
  97084. * @param scene Defines the scene to parse the data for
  97085. * @param container Defines the container attached to the parsing sequence
  97086. * @param rootUrl Defines the root url of the data
  97087. */
  97088. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  97089. /**
  97090. * Gets the list of root nodes (ie. nodes with no parent)
  97091. */
  97092. rootNodes: Node[];
  97093. /** All of the cameras added to this scene
  97094. * @see http://doc.babylonjs.com/babylon101/cameras
  97095. */
  97096. cameras: Camera[];
  97097. /**
  97098. * All of the lights added to this scene
  97099. * @see http://doc.babylonjs.com/babylon101/lights
  97100. */
  97101. lights: Light[];
  97102. /**
  97103. * All of the (abstract) meshes added to this scene
  97104. */
  97105. meshes: AbstractMesh[];
  97106. /**
  97107. * The list of skeletons added to the scene
  97108. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  97109. */
  97110. skeletons: Skeleton[];
  97111. /**
  97112. * All of the particle systems added to this scene
  97113. * @see http://doc.babylonjs.com/babylon101/particles
  97114. */
  97115. particleSystems: IParticleSystem[];
  97116. /**
  97117. * Gets a list of Animations associated with the scene
  97118. */
  97119. animations: Animation[];
  97120. /**
  97121. * All of the animation groups added to this scene
  97122. * @see http://doc.babylonjs.com/how_to/group
  97123. */
  97124. animationGroups: AnimationGroup[];
  97125. /**
  97126. * All of the multi-materials added to this scene
  97127. * @see http://doc.babylonjs.com/how_to/multi_materials
  97128. */
  97129. multiMaterials: MultiMaterial[];
  97130. /**
  97131. * All of the materials added to this scene
  97132. * In the context of a Scene, it is not supposed to be modified manually.
  97133. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  97134. * Note also that the order of the Material wihin the array is not significant and might change.
  97135. * @see http://doc.babylonjs.com/babylon101/materials
  97136. */
  97137. materials: Material[];
  97138. /**
  97139. * The list of morph target managers added to the scene
  97140. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  97141. */
  97142. morphTargetManagers: MorphTargetManager[];
  97143. /**
  97144. * The list of geometries used in the scene.
  97145. */
  97146. geometries: Geometry[];
  97147. /**
  97148. * All of the tranform nodes added to this scene
  97149. * In the context of a Scene, it is not supposed to be modified manually.
  97150. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  97151. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  97152. * @see http://doc.babylonjs.com/how_to/transformnode
  97153. */
  97154. transformNodes: TransformNode[];
  97155. /**
  97156. * ActionManagers available on the scene.
  97157. */
  97158. actionManagers: AbstractActionManager[];
  97159. /**
  97160. * Textures to keep.
  97161. */
  97162. textures: BaseTexture[];
  97163. /**
  97164. * Environment texture for the scene
  97165. */
  97166. environmentTexture: Nullable<BaseTexture>;
  97167. }
  97168. }
  97169. declare module BABYLON {
  97170. /**
  97171. * Interface used to define options for Sound class
  97172. */
  97173. export interface ISoundOptions {
  97174. /**
  97175. * Does the sound autoplay once loaded.
  97176. */
  97177. autoplay?: boolean;
  97178. /**
  97179. * Does the sound loop after it finishes playing once.
  97180. */
  97181. loop?: boolean;
  97182. /**
  97183. * Sound's volume
  97184. */
  97185. volume?: number;
  97186. /**
  97187. * Is it a spatial sound?
  97188. */
  97189. spatialSound?: boolean;
  97190. /**
  97191. * Maximum distance to hear that sound
  97192. */
  97193. maxDistance?: number;
  97194. /**
  97195. * Uses user defined attenuation function
  97196. */
  97197. useCustomAttenuation?: boolean;
  97198. /**
  97199. * Define the roll off factor of spatial sounds.
  97200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97201. */
  97202. rolloffFactor?: number;
  97203. /**
  97204. * Define the reference distance the sound should be heard perfectly.
  97205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97206. */
  97207. refDistance?: number;
  97208. /**
  97209. * Define the distance attenuation model the sound will follow.
  97210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97211. */
  97212. distanceModel?: string;
  97213. /**
  97214. * Defines the playback speed (1 by default)
  97215. */
  97216. playbackRate?: number;
  97217. /**
  97218. * Defines if the sound is from a streaming source
  97219. */
  97220. streaming?: boolean;
  97221. /**
  97222. * Defines an optional length (in seconds) inside the sound file
  97223. */
  97224. length?: number;
  97225. /**
  97226. * Defines an optional offset (in seconds) inside the sound file
  97227. */
  97228. offset?: number;
  97229. }
  97230. /**
  97231. * Defines a sound that can be played in the application.
  97232. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  97233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97234. */
  97235. export class Sound {
  97236. /**
  97237. * The name of the sound in the scene.
  97238. */
  97239. name: string;
  97240. /**
  97241. * Does the sound autoplay once loaded.
  97242. */
  97243. autoplay: boolean;
  97244. /**
  97245. * Does the sound loop after it finishes playing once.
  97246. */
  97247. loop: boolean;
  97248. /**
  97249. * Does the sound use a custom attenuation curve to simulate the falloff
  97250. * happening when the source gets further away from the camera.
  97251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97252. */
  97253. useCustomAttenuation: boolean;
  97254. /**
  97255. * The sound track id this sound belongs to.
  97256. */
  97257. soundTrackId: number;
  97258. /**
  97259. * Is this sound currently played.
  97260. */
  97261. isPlaying: boolean;
  97262. /**
  97263. * Is this sound currently paused.
  97264. */
  97265. isPaused: boolean;
  97266. /**
  97267. * Does this sound enables spatial sound.
  97268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97269. */
  97270. spatialSound: boolean;
  97271. /**
  97272. * Define the reference distance the sound should be heard perfectly.
  97273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97274. */
  97275. refDistance: number;
  97276. /**
  97277. * Define the roll off factor of spatial sounds.
  97278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97279. */
  97280. rolloffFactor: number;
  97281. /**
  97282. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  97283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97284. */
  97285. maxDistance: number;
  97286. /**
  97287. * Define the distance attenuation model the sound will follow.
  97288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97289. */
  97290. distanceModel: string;
  97291. /**
  97292. * @hidden
  97293. * Back Compat
  97294. **/
  97295. onended: () => any;
  97296. /**
  97297. * Observable event when the current playing sound finishes.
  97298. */
  97299. onEndedObservable: Observable<Sound>;
  97300. private _panningModel;
  97301. private _playbackRate;
  97302. private _streaming;
  97303. private _startTime;
  97304. private _startOffset;
  97305. private _position;
  97306. /** @hidden */
  97307. _positionInEmitterSpace: boolean;
  97308. private _localDirection;
  97309. private _volume;
  97310. private _isReadyToPlay;
  97311. private _isDirectional;
  97312. private _readyToPlayCallback;
  97313. private _audioBuffer;
  97314. private _soundSource;
  97315. private _streamingSource;
  97316. private _soundPanner;
  97317. private _soundGain;
  97318. private _inputAudioNode;
  97319. private _outputAudioNode;
  97320. private _coneInnerAngle;
  97321. private _coneOuterAngle;
  97322. private _coneOuterGain;
  97323. private _scene;
  97324. private _connectedTransformNode;
  97325. private _customAttenuationFunction;
  97326. private _registerFunc;
  97327. private _isOutputConnected;
  97328. private _htmlAudioElement;
  97329. private _urlType;
  97330. private _length?;
  97331. private _offset?;
  97332. /** @hidden */
  97333. static _SceneComponentInitialization: (scene: Scene) => void;
  97334. /**
  97335. * Create a sound and attach it to a scene
  97336. * @param name Name of your sound
  97337. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  97338. * @param scene defines the scene the sound belongs to
  97339. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  97340. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  97341. */
  97342. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  97343. /**
  97344. * Release the sound and its associated resources
  97345. */
  97346. dispose(): void;
  97347. /**
  97348. * Gets if the sounds is ready to be played or not.
  97349. * @returns true if ready, otherwise false
  97350. */
  97351. isReady(): boolean;
  97352. private _soundLoaded;
  97353. /**
  97354. * Sets the data of the sound from an audiobuffer
  97355. * @param audioBuffer The audioBuffer containing the data
  97356. */
  97357. setAudioBuffer(audioBuffer: AudioBuffer): void;
  97358. /**
  97359. * Updates the current sounds options such as maxdistance, loop...
  97360. * @param options A JSON object containing values named as the object properties
  97361. */
  97362. updateOptions(options: ISoundOptions): void;
  97363. private _createSpatialParameters;
  97364. private _updateSpatialParameters;
  97365. /**
  97366. * Switch the panning model to HRTF:
  97367. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97369. */
  97370. switchPanningModelToHRTF(): void;
  97371. /**
  97372. * Switch the panning model to Equal Power:
  97373. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97375. */
  97376. switchPanningModelToEqualPower(): void;
  97377. private _switchPanningModel;
  97378. /**
  97379. * Connect this sound to a sound track audio node like gain...
  97380. * @param soundTrackAudioNode the sound track audio node to connect to
  97381. */
  97382. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  97383. /**
  97384. * Transform this sound into a directional source
  97385. * @param coneInnerAngle Size of the inner cone in degree
  97386. * @param coneOuterAngle Size of the outer cone in degree
  97387. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  97388. */
  97389. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  97390. /**
  97391. * Gets or sets the inner angle for the directional cone.
  97392. */
  97393. /**
  97394. * Gets or sets the inner angle for the directional cone.
  97395. */
  97396. directionalConeInnerAngle: number;
  97397. /**
  97398. * Gets or sets the outer angle for the directional cone.
  97399. */
  97400. /**
  97401. * Gets or sets the outer angle for the directional cone.
  97402. */
  97403. directionalConeOuterAngle: number;
  97404. /**
  97405. * Sets the position of the emitter if spatial sound is enabled
  97406. * @param newPosition Defines the new posisiton
  97407. */
  97408. setPosition(newPosition: Vector3): void;
  97409. /**
  97410. * Sets the local direction of the emitter if spatial sound is enabled
  97411. * @param newLocalDirection Defines the new local direction
  97412. */
  97413. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  97414. private _updateDirection;
  97415. /** @hidden */
  97416. updateDistanceFromListener(): void;
  97417. /**
  97418. * Sets a new custom attenuation function for the sound.
  97419. * @param callback Defines the function used for the attenuation
  97420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97421. */
  97422. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  97423. /**
  97424. * Play the sound
  97425. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  97426. * @param offset (optional) Start the sound at a specific time in seconds
  97427. * @param length (optional) Sound duration (in seconds)
  97428. */
  97429. play(time?: number, offset?: number, length?: number): void;
  97430. private _onended;
  97431. /**
  97432. * Stop the sound
  97433. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  97434. */
  97435. stop(time?: number): void;
  97436. /**
  97437. * Put the sound in pause
  97438. */
  97439. pause(): void;
  97440. /**
  97441. * Sets a dedicated volume for this sounds
  97442. * @param newVolume Define the new volume of the sound
  97443. * @param time Define time for gradual change to new volume
  97444. */
  97445. setVolume(newVolume: number, time?: number): void;
  97446. /**
  97447. * Set the sound play back rate
  97448. * @param newPlaybackRate Define the playback rate the sound should be played at
  97449. */
  97450. setPlaybackRate(newPlaybackRate: number): void;
  97451. /**
  97452. * Gets the volume of the sound.
  97453. * @returns the volume of the sound
  97454. */
  97455. getVolume(): number;
  97456. /**
  97457. * Attach the sound to a dedicated mesh
  97458. * @param transformNode The transform node to connect the sound with
  97459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97460. */
  97461. attachToMesh(transformNode: TransformNode): void;
  97462. /**
  97463. * Detach the sound from the previously attached mesh
  97464. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97465. */
  97466. detachFromMesh(): void;
  97467. private _onRegisterAfterWorldMatrixUpdate;
  97468. /**
  97469. * Clone the current sound in the scene.
  97470. * @returns the new sound clone
  97471. */
  97472. clone(): Nullable<Sound>;
  97473. /**
  97474. * Gets the current underlying audio buffer containing the data
  97475. * @returns the audio buffer
  97476. */
  97477. getAudioBuffer(): Nullable<AudioBuffer>;
  97478. /**
  97479. * Serializes the Sound in a JSON representation
  97480. * @returns the JSON representation of the sound
  97481. */
  97482. serialize(): any;
  97483. /**
  97484. * Parse a JSON representation of a sound to innstantiate in a given scene
  97485. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  97486. * @param scene Define the scene the new parsed sound should be created in
  97487. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  97488. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  97489. * @returns the newly parsed sound
  97490. */
  97491. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  97492. }
  97493. }
  97494. declare module BABYLON {
  97495. /**
  97496. * This defines an action helpful to play a defined sound on a triggered action.
  97497. */
  97498. export class PlaySoundAction extends Action {
  97499. private _sound;
  97500. /**
  97501. * Instantiate the action
  97502. * @param triggerOptions defines the trigger options
  97503. * @param sound defines the sound to play
  97504. * @param condition defines the trigger related conditions
  97505. */
  97506. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97507. /** @hidden */
  97508. _prepare(): void;
  97509. /**
  97510. * Execute the action and play the sound.
  97511. */
  97512. execute(): void;
  97513. /**
  97514. * Serializes the actions and its related information.
  97515. * @param parent defines the object to serialize in
  97516. * @returns the serialized object
  97517. */
  97518. serialize(parent: any): any;
  97519. }
  97520. /**
  97521. * This defines an action helpful to stop a defined sound on a triggered action.
  97522. */
  97523. export class StopSoundAction extends Action {
  97524. private _sound;
  97525. /**
  97526. * Instantiate the action
  97527. * @param triggerOptions defines the trigger options
  97528. * @param sound defines the sound to stop
  97529. * @param condition defines the trigger related conditions
  97530. */
  97531. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97532. /** @hidden */
  97533. _prepare(): void;
  97534. /**
  97535. * Execute the action and stop the sound.
  97536. */
  97537. execute(): void;
  97538. /**
  97539. * Serializes the actions and its related information.
  97540. * @param parent defines the object to serialize in
  97541. * @returns the serialized object
  97542. */
  97543. serialize(parent: any): any;
  97544. }
  97545. }
  97546. declare module BABYLON {
  97547. /**
  97548. * This defines an action responsible to change the value of a property
  97549. * by interpolating between its current value and the newly set one once triggered.
  97550. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97551. */
  97552. export class InterpolateValueAction extends Action {
  97553. /**
  97554. * Defines the path of the property where the value should be interpolated
  97555. */
  97556. propertyPath: string;
  97557. /**
  97558. * Defines the target value at the end of the interpolation.
  97559. */
  97560. value: any;
  97561. /**
  97562. * Defines the time it will take for the property to interpolate to the value.
  97563. */
  97564. duration: number;
  97565. /**
  97566. * Defines if the other scene animations should be stopped when the action has been triggered
  97567. */
  97568. stopOtherAnimations?: boolean;
  97569. /**
  97570. * Defines a callback raised once the interpolation animation has been done.
  97571. */
  97572. onInterpolationDone?: () => void;
  97573. /**
  97574. * Observable triggered once the interpolation animation has been done.
  97575. */
  97576. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  97577. private _target;
  97578. private _effectiveTarget;
  97579. private _property;
  97580. /**
  97581. * Instantiate the action
  97582. * @param triggerOptions defines the trigger options
  97583. * @param target defines the object containing the value to interpolate
  97584. * @param propertyPath defines the path to the property in the target object
  97585. * @param value defines the target value at the end of the interpolation
  97586. * @param duration deines the time it will take for the property to interpolate to the value.
  97587. * @param condition defines the trigger related conditions
  97588. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  97589. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  97590. */
  97591. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  97592. /** @hidden */
  97593. _prepare(): void;
  97594. /**
  97595. * Execute the action starts the value interpolation.
  97596. */
  97597. execute(): void;
  97598. /**
  97599. * Serializes the actions and its related information.
  97600. * @param parent defines the object to serialize in
  97601. * @returns the serialized object
  97602. */
  97603. serialize(parent: any): any;
  97604. }
  97605. }
  97606. declare module BABYLON {
  97607. /**
  97608. * Options allowed during the creation of a sound track.
  97609. */
  97610. export interface ISoundTrackOptions {
  97611. /**
  97612. * The volume the sound track should take during creation
  97613. */
  97614. volume?: number;
  97615. /**
  97616. * Define if the sound track is the main sound track of the scene
  97617. */
  97618. mainTrack?: boolean;
  97619. }
  97620. /**
  97621. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  97622. * It will be also used in a future release to apply effects on a specific track.
  97623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97624. */
  97625. export class SoundTrack {
  97626. /**
  97627. * The unique identifier of the sound track in the scene.
  97628. */
  97629. id: number;
  97630. /**
  97631. * The list of sounds included in the sound track.
  97632. */
  97633. soundCollection: Array<Sound>;
  97634. private _outputAudioNode;
  97635. private _scene;
  97636. private _isMainTrack;
  97637. private _connectedAnalyser;
  97638. private _options;
  97639. private _isInitialized;
  97640. /**
  97641. * Creates a new sound track.
  97642. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97643. * @param scene Define the scene the sound track belongs to
  97644. * @param options
  97645. */
  97646. constructor(scene: Scene, options?: ISoundTrackOptions);
  97647. private _initializeSoundTrackAudioGraph;
  97648. /**
  97649. * Release the sound track and its associated resources
  97650. */
  97651. dispose(): void;
  97652. /**
  97653. * Adds a sound to this sound track
  97654. * @param sound define the cound to add
  97655. * @ignoreNaming
  97656. */
  97657. AddSound(sound: Sound): void;
  97658. /**
  97659. * Removes a sound to this sound track
  97660. * @param sound define the cound to remove
  97661. * @ignoreNaming
  97662. */
  97663. RemoveSound(sound: Sound): void;
  97664. /**
  97665. * Set a global volume for the full sound track.
  97666. * @param newVolume Define the new volume of the sound track
  97667. */
  97668. setVolume(newVolume: number): void;
  97669. /**
  97670. * Switch the panning model to HRTF:
  97671. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97673. */
  97674. switchPanningModelToHRTF(): void;
  97675. /**
  97676. * Switch the panning model to Equal Power:
  97677. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97679. */
  97680. switchPanningModelToEqualPower(): void;
  97681. /**
  97682. * Connect the sound track to an audio analyser allowing some amazing
  97683. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97684. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97685. * @param analyser The analyser to connect to the engine
  97686. */
  97687. connectToAnalyser(analyser: Analyser): void;
  97688. }
  97689. }
  97690. declare module BABYLON {
  97691. interface AbstractScene {
  97692. /**
  97693. * The list of sounds used in the scene.
  97694. */
  97695. sounds: Nullable<Array<Sound>>;
  97696. }
  97697. interface Scene {
  97698. /**
  97699. * @hidden
  97700. * Backing field
  97701. */
  97702. _mainSoundTrack: SoundTrack;
  97703. /**
  97704. * The main sound track played by the scene.
  97705. * It cotains your primary collection of sounds.
  97706. */
  97707. mainSoundTrack: SoundTrack;
  97708. /**
  97709. * The list of sound tracks added to the scene
  97710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97711. */
  97712. soundTracks: Nullable<Array<SoundTrack>>;
  97713. /**
  97714. * Gets a sound using a given name
  97715. * @param name defines the name to search for
  97716. * @return the found sound or null if not found at all.
  97717. */
  97718. getSoundByName(name: string): Nullable<Sound>;
  97719. /**
  97720. * Gets or sets if audio support is enabled
  97721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97722. */
  97723. audioEnabled: boolean;
  97724. /**
  97725. * Gets or sets if audio will be output to headphones
  97726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97727. */
  97728. headphone: boolean;
  97729. }
  97730. /**
  97731. * Defines the sound scene component responsible to manage any sounds
  97732. * in a given scene.
  97733. */
  97734. export class AudioSceneComponent implements ISceneSerializableComponent {
  97735. /**
  97736. * The component name helpfull to identify the component in the list of scene components.
  97737. */
  97738. readonly name: string;
  97739. /**
  97740. * The scene the component belongs to.
  97741. */
  97742. scene: Scene;
  97743. private _audioEnabled;
  97744. /**
  97745. * Gets whether audio is enabled or not.
  97746. * Please use related enable/disable method to switch state.
  97747. */
  97748. readonly audioEnabled: boolean;
  97749. private _headphone;
  97750. /**
  97751. * Gets whether audio is outputing to headphone or not.
  97752. * Please use the according Switch methods to change output.
  97753. */
  97754. readonly headphone: boolean;
  97755. /**
  97756. * Creates a new instance of the component for the given scene
  97757. * @param scene Defines the scene to register the component in
  97758. */
  97759. constructor(scene: Scene);
  97760. /**
  97761. * Registers the component in a given scene
  97762. */
  97763. register(): void;
  97764. /**
  97765. * Rebuilds the elements related to this component in case of
  97766. * context lost for instance.
  97767. */
  97768. rebuild(): void;
  97769. /**
  97770. * Serializes the component data to the specified json object
  97771. * @param serializationObject The object to serialize to
  97772. */
  97773. serialize(serializationObject: any): void;
  97774. /**
  97775. * Adds all the elements from the container to the scene
  97776. * @param container the container holding the elements
  97777. */
  97778. addFromContainer(container: AbstractScene): void;
  97779. /**
  97780. * Removes all the elements in the container from the scene
  97781. * @param container contains the elements to remove
  97782. * @param dispose if the removed element should be disposed (default: false)
  97783. */
  97784. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  97785. /**
  97786. * Disposes the component and the associated ressources.
  97787. */
  97788. dispose(): void;
  97789. /**
  97790. * Disables audio in the associated scene.
  97791. */
  97792. disableAudio(): void;
  97793. /**
  97794. * Enables audio in the associated scene.
  97795. */
  97796. enableAudio(): void;
  97797. /**
  97798. * Switch audio to headphone output.
  97799. */
  97800. switchAudioModeForHeadphones(): void;
  97801. /**
  97802. * Switch audio to normal speakers.
  97803. */
  97804. switchAudioModeForNormalSpeakers(): void;
  97805. private _afterRender;
  97806. }
  97807. }
  97808. declare module BABYLON {
  97809. /**
  97810. * Wraps one or more Sound objects and selects one with random weight for playback.
  97811. */
  97812. export class WeightedSound {
  97813. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97814. loop: boolean;
  97815. private _coneInnerAngle;
  97816. private _coneOuterAngle;
  97817. private _volume;
  97818. /** A Sound is currently playing. */
  97819. isPlaying: boolean;
  97820. /** A Sound is currently paused. */
  97821. isPaused: boolean;
  97822. private _sounds;
  97823. private _weights;
  97824. private _currentIndex?;
  97825. /**
  97826. * Creates a new WeightedSound from the list of sounds given.
  97827. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97828. * @param sounds Array of Sounds that will be selected from.
  97829. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97830. */
  97831. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97832. /**
  97833. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97834. */
  97835. /**
  97836. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97837. */
  97838. directionalConeInnerAngle: number;
  97839. /**
  97840. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97841. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97842. */
  97843. /**
  97844. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97845. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97846. */
  97847. directionalConeOuterAngle: number;
  97848. /**
  97849. * Playback volume.
  97850. */
  97851. /**
  97852. * Playback volume.
  97853. */
  97854. volume: number;
  97855. private _onended;
  97856. /**
  97857. * Suspend playback
  97858. */
  97859. pause(): void;
  97860. /**
  97861. * Stop playback
  97862. */
  97863. stop(): void;
  97864. /**
  97865. * Start playback.
  97866. * @param startOffset Position the clip head at a specific time in seconds.
  97867. */
  97868. play(startOffset?: number): void;
  97869. }
  97870. }
  97871. declare module BABYLON {
  97872. /**
  97873. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97874. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97875. */
  97876. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97877. /**
  97878. * Gets the name of the behavior.
  97879. */
  97880. readonly name: string;
  97881. /**
  97882. * The easing function used by animations
  97883. */
  97884. static EasingFunction: BackEase;
  97885. /**
  97886. * The easing mode used by animations
  97887. */
  97888. static EasingMode: number;
  97889. /**
  97890. * The duration of the animation, in milliseconds
  97891. */
  97892. transitionDuration: number;
  97893. /**
  97894. * Length of the distance animated by the transition when lower radius is reached
  97895. */
  97896. lowerRadiusTransitionRange: number;
  97897. /**
  97898. * Length of the distance animated by the transition when upper radius is reached
  97899. */
  97900. upperRadiusTransitionRange: number;
  97901. private _autoTransitionRange;
  97902. /**
  97903. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97904. */
  97905. /**
  97906. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97907. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97908. */
  97909. autoTransitionRange: boolean;
  97910. private _attachedCamera;
  97911. private _onAfterCheckInputsObserver;
  97912. private _onMeshTargetChangedObserver;
  97913. /**
  97914. * Initializes the behavior.
  97915. */
  97916. init(): void;
  97917. /**
  97918. * Attaches the behavior to its arc rotate camera.
  97919. * @param camera Defines the camera to attach the behavior to
  97920. */
  97921. attach(camera: ArcRotateCamera): void;
  97922. /**
  97923. * Detaches the behavior from its current arc rotate camera.
  97924. */
  97925. detach(): void;
  97926. private _radiusIsAnimating;
  97927. private _radiusBounceTransition;
  97928. private _animatables;
  97929. private _cachedWheelPrecision;
  97930. /**
  97931. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  97932. * @param radiusLimit The limit to check against.
  97933. * @return Bool to indicate if at limit.
  97934. */
  97935. private _isRadiusAtLimit;
  97936. /**
  97937. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  97938. * @param radiusDelta The delta by which to animate to. Can be negative.
  97939. */
  97940. private _applyBoundRadiusAnimation;
  97941. /**
  97942. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  97943. */
  97944. protected _clearAnimationLocks(): void;
  97945. /**
  97946. * Stops and removes all animations that have been applied to the camera
  97947. */
  97948. stopAllAnimations(): void;
  97949. }
  97950. }
  97951. declare module BABYLON {
  97952. /**
  97953. * 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.
  97954. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97955. */
  97956. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  97957. /**
  97958. * Gets the name of the behavior.
  97959. */
  97960. readonly name: string;
  97961. private _mode;
  97962. private _radiusScale;
  97963. private _positionScale;
  97964. private _defaultElevation;
  97965. private _elevationReturnTime;
  97966. private _elevationReturnWaitTime;
  97967. private _zoomStopsAnimation;
  97968. private _framingTime;
  97969. /**
  97970. * The easing function used by animations
  97971. */
  97972. static EasingFunction: ExponentialEase;
  97973. /**
  97974. * The easing mode used by animations
  97975. */
  97976. static EasingMode: number;
  97977. /**
  97978. * Sets the current mode used by the behavior
  97979. */
  97980. /**
  97981. * Gets current mode used by the behavior.
  97982. */
  97983. mode: number;
  97984. /**
  97985. * Sets the scale applied to the radius (1 by default)
  97986. */
  97987. /**
  97988. * Gets the scale applied to the radius
  97989. */
  97990. radiusScale: number;
  97991. /**
  97992. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97993. */
  97994. /**
  97995. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97996. */
  97997. positionScale: number;
  97998. /**
  97999. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  98000. * behaviour is triggered, in radians.
  98001. */
  98002. /**
  98003. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  98004. * behaviour is triggered, in radians.
  98005. */
  98006. defaultElevation: number;
  98007. /**
  98008. * Sets the time (in milliseconds) taken to return to the default beta position.
  98009. * Negative value indicates camera should not return to default.
  98010. */
  98011. /**
  98012. * Gets the time (in milliseconds) taken to return to the default beta position.
  98013. * Negative value indicates camera should not return to default.
  98014. */
  98015. elevationReturnTime: number;
  98016. /**
  98017. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  98018. */
  98019. /**
  98020. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  98021. */
  98022. elevationReturnWaitTime: number;
  98023. /**
  98024. * Sets the flag that indicates if user zooming should stop animation.
  98025. */
  98026. /**
  98027. * Gets the flag that indicates if user zooming should stop animation.
  98028. */
  98029. zoomStopsAnimation: boolean;
  98030. /**
  98031. * Sets the transition time when framing the mesh, in milliseconds
  98032. */
  98033. /**
  98034. * Gets the transition time when framing the mesh, in milliseconds
  98035. */
  98036. framingTime: number;
  98037. /**
  98038. * Define if the behavior should automatically change the configured
  98039. * camera limits and sensibilities.
  98040. */
  98041. autoCorrectCameraLimitsAndSensibility: boolean;
  98042. private _onPrePointerObservableObserver;
  98043. private _onAfterCheckInputsObserver;
  98044. private _onMeshTargetChangedObserver;
  98045. private _attachedCamera;
  98046. private _isPointerDown;
  98047. private _lastInteractionTime;
  98048. /**
  98049. * Initializes the behavior.
  98050. */
  98051. init(): void;
  98052. /**
  98053. * Attaches the behavior to its arc rotate camera.
  98054. * @param camera Defines the camera to attach the behavior to
  98055. */
  98056. attach(camera: ArcRotateCamera): void;
  98057. /**
  98058. * Detaches the behavior from its current arc rotate camera.
  98059. */
  98060. detach(): void;
  98061. private _animatables;
  98062. private _betaIsAnimating;
  98063. private _betaTransition;
  98064. private _radiusTransition;
  98065. private _vectorTransition;
  98066. /**
  98067. * Targets the given mesh and updates zoom level accordingly.
  98068. * @param mesh The mesh to target.
  98069. * @param radius Optional. If a cached radius position already exists, overrides default.
  98070. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98071. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98072. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98073. */
  98074. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98075. /**
  98076. * Targets the given mesh with its children and updates zoom level accordingly.
  98077. * @param mesh The mesh to target.
  98078. * @param radius Optional. If a cached radius position already exists, overrides default.
  98079. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98080. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98081. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98082. */
  98083. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98084. /**
  98085. * Targets the given meshes with their children and updates zoom level accordingly.
  98086. * @param meshes The mesh to target.
  98087. * @param radius Optional. If a cached radius position already exists, overrides default.
  98088. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98089. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98090. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98091. */
  98092. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98093. /**
  98094. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  98095. * @param minimumWorld Determines the smaller position of the bounding box extend
  98096. * @param maximumWorld Determines the bigger position of the bounding box extend
  98097. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98098. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98099. */
  98100. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98101. /**
  98102. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  98103. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  98104. * frustum width.
  98105. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  98106. * to fully enclose the mesh in the viewing frustum.
  98107. */
  98108. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  98109. /**
  98110. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  98111. * is automatically returned to its default position (expected to be above ground plane).
  98112. */
  98113. private _maintainCameraAboveGround;
  98114. /**
  98115. * Returns the frustum slope based on the canvas ratio and camera FOV
  98116. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  98117. */
  98118. private _getFrustumSlope;
  98119. /**
  98120. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  98121. */
  98122. private _clearAnimationLocks;
  98123. /**
  98124. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98125. */
  98126. private _applyUserInteraction;
  98127. /**
  98128. * Stops and removes all animations that have been applied to the camera
  98129. */
  98130. stopAllAnimations(): void;
  98131. /**
  98132. * Gets a value indicating if the user is moving the camera
  98133. */
  98134. readonly isUserIsMoving: boolean;
  98135. /**
  98136. * The camera can move all the way towards the mesh.
  98137. */
  98138. static IgnoreBoundsSizeMode: number;
  98139. /**
  98140. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  98141. */
  98142. static FitFrustumSidesMode: number;
  98143. }
  98144. }
  98145. declare module BABYLON {
  98146. /**
  98147. * Base class for Camera Pointer Inputs.
  98148. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  98149. * for example usage.
  98150. */
  98151. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  98152. /**
  98153. * Defines the camera the input is attached to.
  98154. */
  98155. abstract camera: Camera;
  98156. /**
  98157. * Whether keyboard modifier keys are pressed at time of last mouse event.
  98158. */
  98159. protected _altKey: boolean;
  98160. protected _ctrlKey: boolean;
  98161. protected _metaKey: boolean;
  98162. protected _shiftKey: boolean;
  98163. /**
  98164. * Which mouse buttons were pressed at time of last mouse event.
  98165. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  98166. */
  98167. protected _buttonsPressed: number;
  98168. /**
  98169. * Defines the buttons associated with the input to handle camera move.
  98170. */
  98171. buttons: number[];
  98172. /**
  98173. * Attach the input controls to a specific dom element to get the input from.
  98174. * @param element Defines the element the controls should be listened from
  98175. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98176. */
  98177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98178. /**
  98179. * Detach the current controls from the specified dom element.
  98180. * @param element Defines the element to stop listening the inputs from
  98181. */
  98182. detachControl(element: Nullable<HTMLElement>): void;
  98183. /**
  98184. * Gets the class name of the current input.
  98185. * @returns the class name
  98186. */
  98187. getClassName(): string;
  98188. /**
  98189. * Get the friendly name associated with the input class.
  98190. * @returns the input friendly name
  98191. */
  98192. getSimpleName(): string;
  98193. /**
  98194. * Called on pointer POINTERDOUBLETAP event.
  98195. * Override this method to provide functionality on POINTERDOUBLETAP event.
  98196. */
  98197. protected onDoubleTap(type: string): void;
  98198. /**
  98199. * Called on pointer POINTERMOVE event if only a single touch is active.
  98200. * Override this method to provide functionality.
  98201. */
  98202. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98203. /**
  98204. * Called on pointer POINTERMOVE event if multiple touches are active.
  98205. * Override this method to provide functionality.
  98206. */
  98207. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98208. /**
  98209. * Called on JS contextmenu event.
  98210. * Override this method to provide functionality.
  98211. */
  98212. protected onContextMenu(evt: PointerEvent): void;
  98213. /**
  98214. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98215. * press.
  98216. * Override this method to provide functionality.
  98217. */
  98218. protected onButtonDown(evt: PointerEvent): void;
  98219. /**
  98220. * Called each time a new POINTERUP event occurs. Ie, for each button
  98221. * release.
  98222. * Override this method to provide functionality.
  98223. */
  98224. protected onButtonUp(evt: PointerEvent): void;
  98225. /**
  98226. * Called when window becomes inactive.
  98227. * Override this method to provide functionality.
  98228. */
  98229. protected onLostFocus(): void;
  98230. private _pointerInput;
  98231. private _observer;
  98232. private _onLostFocus;
  98233. private pointA;
  98234. private pointB;
  98235. }
  98236. }
  98237. declare module BABYLON {
  98238. /**
  98239. * Manage the pointers inputs to control an arc rotate camera.
  98240. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98241. */
  98242. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  98243. /**
  98244. * Defines the camera the input is attached to.
  98245. */
  98246. camera: ArcRotateCamera;
  98247. /**
  98248. * Gets the class name of the current input.
  98249. * @returns the class name
  98250. */
  98251. getClassName(): string;
  98252. /**
  98253. * Defines the buttons associated with the input to handle camera move.
  98254. */
  98255. buttons: number[];
  98256. /**
  98257. * Defines the pointer angular sensibility along the X axis or how fast is
  98258. * the camera rotating.
  98259. */
  98260. angularSensibilityX: number;
  98261. /**
  98262. * Defines the pointer angular sensibility along the Y axis or how fast is
  98263. * the camera rotating.
  98264. */
  98265. angularSensibilityY: number;
  98266. /**
  98267. * Defines the pointer pinch precision or how fast is the camera zooming.
  98268. */
  98269. pinchPrecision: number;
  98270. /**
  98271. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  98272. * from 0.
  98273. * It defines the percentage of current camera.radius to use as delta when
  98274. * pinch zoom is used.
  98275. */
  98276. pinchDeltaPercentage: number;
  98277. /**
  98278. * Defines the pointer panning sensibility or how fast is the camera moving.
  98279. */
  98280. panningSensibility: number;
  98281. /**
  98282. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  98283. */
  98284. multiTouchPanning: boolean;
  98285. /**
  98286. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  98287. * zoom (pinch) through multitouch.
  98288. */
  98289. multiTouchPanAndZoom: boolean;
  98290. /**
  98291. * Revers pinch action direction.
  98292. */
  98293. pinchInwards: boolean;
  98294. private _isPanClick;
  98295. private _twoFingerActivityCount;
  98296. private _isPinching;
  98297. /**
  98298. * Called on pointer POINTERMOVE event if only a single touch is active.
  98299. */
  98300. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98301. /**
  98302. * Called on pointer POINTERDOUBLETAP event.
  98303. */
  98304. protected onDoubleTap(type: string): void;
  98305. /**
  98306. * Called on pointer POINTERMOVE event if multiple touches are active.
  98307. */
  98308. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98309. /**
  98310. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98311. * press.
  98312. */
  98313. protected onButtonDown(evt: PointerEvent): void;
  98314. /**
  98315. * Called each time a new POINTERUP event occurs. Ie, for each button
  98316. * release.
  98317. */
  98318. protected onButtonUp(evt: PointerEvent): void;
  98319. /**
  98320. * Called when window becomes inactive.
  98321. */
  98322. protected onLostFocus(): void;
  98323. }
  98324. }
  98325. declare module BABYLON {
  98326. /**
  98327. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  98328. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98329. */
  98330. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  98331. /**
  98332. * Defines the camera the input is attached to.
  98333. */
  98334. camera: ArcRotateCamera;
  98335. /**
  98336. * Defines the list of key codes associated with the up action (increase alpha)
  98337. */
  98338. keysUp: number[];
  98339. /**
  98340. * Defines the list of key codes associated with the down action (decrease alpha)
  98341. */
  98342. keysDown: number[];
  98343. /**
  98344. * Defines the list of key codes associated with the left action (increase beta)
  98345. */
  98346. keysLeft: number[];
  98347. /**
  98348. * Defines the list of key codes associated with the right action (decrease beta)
  98349. */
  98350. keysRight: number[];
  98351. /**
  98352. * Defines the list of key codes associated with the reset action.
  98353. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  98354. */
  98355. keysReset: number[];
  98356. /**
  98357. * Defines the panning sensibility of the inputs.
  98358. * (How fast is the camera paning)
  98359. */
  98360. panningSensibility: number;
  98361. /**
  98362. * Defines the zooming sensibility of the inputs.
  98363. * (How fast is the camera zooming)
  98364. */
  98365. zoomingSensibility: number;
  98366. /**
  98367. * Defines wether maintaining the alt key down switch the movement mode from
  98368. * orientation to zoom.
  98369. */
  98370. useAltToZoom: boolean;
  98371. /**
  98372. * Rotation speed of the camera
  98373. */
  98374. angularSpeed: number;
  98375. private _keys;
  98376. private _ctrlPressed;
  98377. private _altPressed;
  98378. private _onCanvasBlurObserver;
  98379. private _onKeyboardObserver;
  98380. private _engine;
  98381. private _scene;
  98382. /**
  98383. * Attach the input controls to a specific dom element to get the input from.
  98384. * @param element Defines the element the controls should be listened from
  98385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98386. */
  98387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98388. /**
  98389. * Detach the current controls from the specified dom element.
  98390. * @param element Defines the element to stop listening the inputs from
  98391. */
  98392. detachControl(element: Nullable<HTMLElement>): void;
  98393. /**
  98394. * Update the current camera state depending on the inputs that have been used this frame.
  98395. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98396. */
  98397. checkInputs(): void;
  98398. /**
  98399. * Gets the class name of the current intput.
  98400. * @returns the class name
  98401. */
  98402. getClassName(): string;
  98403. /**
  98404. * Get the friendly name associated with the input class.
  98405. * @returns the input friendly name
  98406. */
  98407. getSimpleName(): string;
  98408. }
  98409. }
  98410. declare module BABYLON {
  98411. /**
  98412. * Manage the mouse wheel inputs to control an arc rotate camera.
  98413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98414. */
  98415. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  98416. /**
  98417. * Defines the camera the input is attached to.
  98418. */
  98419. camera: ArcRotateCamera;
  98420. /**
  98421. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98422. */
  98423. wheelPrecision: number;
  98424. /**
  98425. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  98426. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  98427. */
  98428. wheelDeltaPercentage: number;
  98429. private _wheel;
  98430. private _observer;
  98431. private computeDeltaFromMouseWheelLegacyEvent;
  98432. /**
  98433. * Attach the input controls to a specific dom element to get the input from.
  98434. * @param element Defines the element the controls should be listened from
  98435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98436. */
  98437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98438. /**
  98439. * Detach the current controls from the specified dom element.
  98440. * @param element Defines the element to stop listening the inputs from
  98441. */
  98442. detachControl(element: Nullable<HTMLElement>): void;
  98443. /**
  98444. * Gets the class name of the current intput.
  98445. * @returns the class name
  98446. */
  98447. getClassName(): string;
  98448. /**
  98449. * Get the friendly name associated with the input class.
  98450. * @returns the input friendly name
  98451. */
  98452. getSimpleName(): string;
  98453. }
  98454. }
  98455. declare module BABYLON {
  98456. /**
  98457. * Default Inputs manager for the ArcRotateCamera.
  98458. * It groups all the default supported inputs for ease of use.
  98459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98460. */
  98461. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  98462. /**
  98463. * Instantiates a new ArcRotateCameraInputsManager.
  98464. * @param camera Defines the camera the inputs belong to
  98465. */
  98466. constructor(camera: ArcRotateCamera);
  98467. /**
  98468. * Add mouse wheel input support to the input manager.
  98469. * @returns the current input manager
  98470. */
  98471. addMouseWheel(): ArcRotateCameraInputsManager;
  98472. /**
  98473. * Add pointers input support to the input manager.
  98474. * @returns the current input manager
  98475. */
  98476. addPointers(): ArcRotateCameraInputsManager;
  98477. /**
  98478. * Add keyboard input support to the input manager.
  98479. * @returns the current input manager
  98480. */
  98481. addKeyboard(): ArcRotateCameraInputsManager;
  98482. }
  98483. }
  98484. declare module BABYLON {
  98485. /**
  98486. * This represents an orbital type of camera.
  98487. *
  98488. * 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.
  98489. * 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.
  98490. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  98491. */
  98492. export class ArcRotateCamera extends TargetCamera {
  98493. /**
  98494. * Defines the rotation angle of the camera along the longitudinal axis.
  98495. */
  98496. alpha: number;
  98497. /**
  98498. * Defines the rotation angle of the camera along the latitudinal axis.
  98499. */
  98500. beta: number;
  98501. /**
  98502. * Defines the radius of the camera from it s target point.
  98503. */
  98504. radius: number;
  98505. protected _target: Vector3;
  98506. protected _targetHost: Nullable<AbstractMesh>;
  98507. /**
  98508. * Defines the target point of the camera.
  98509. * The camera looks towards it form the radius distance.
  98510. */
  98511. target: Vector3;
  98512. /**
  98513. * Define the current local position of the camera in the scene
  98514. */
  98515. position: Vector3;
  98516. protected _upVector: Vector3;
  98517. protected _upToYMatrix: Matrix;
  98518. protected _YToUpMatrix: Matrix;
  98519. /**
  98520. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  98521. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  98522. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  98523. */
  98524. upVector: Vector3;
  98525. /**
  98526. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  98527. */
  98528. setMatUp(): void;
  98529. /**
  98530. * Current inertia value on the longitudinal axis.
  98531. * The bigger this number the longer it will take for the camera to stop.
  98532. */
  98533. inertialAlphaOffset: number;
  98534. /**
  98535. * Current inertia value on the latitudinal axis.
  98536. * The bigger this number the longer it will take for the camera to stop.
  98537. */
  98538. inertialBetaOffset: number;
  98539. /**
  98540. * Current inertia value on the radius axis.
  98541. * The bigger this number the longer it will take for the camera to stop.
  98542. */
  98543. inertialRadiusOffset: number;
  98544. /**
  98545. * Minimum allowed angle on the longitudinal axis.
  98546. * This can help limiting how the Camera is able to move in the scene.
  98547. */
  98548. lowerAlphaLimit: Nullable<number>;
  98549. /**
  98550. * Maximum allowed angle on the longitudinal axis.
  98551. * This can help limiting how the Camera is able to move in the scene.
  98552. */
  98553. upperAlphaLimit: Nullable<number>;
  98554. /**
  98555. * Minimum allowed angle on the latitudinal axis.
  98556. * This can help limiting how the Camera is able to move in the scene.
  98557. */
  98558. lowerBetaLimit: number;
  98559. /**
  98560. * Maximum allowed angle on the latitudinal axis.
  98561. * This can help limiting how the Camera is able to move in the scene.
  98562. */
  98563. upperBetaLimit: number;
  98564. /**
  98565. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  98566. * This can help limiting how the Camera is able to move in the scene.
  98567. */
  98568. lowerRadiusLimit: Nullable<number>;
  98569. /**
  98570. * Maximum allowed distance of the camera to the target (The camera can not get further).
  98571. * This can help limiting how the Camera is able to move in the scene.
  98572. */
  98573. upperRadiusLimit: Nullable<number>;
  98574. /**
  98575. * Defines the current inertia value used during panning of the camera along the X axis.
  98576. */
  98577. inertialPanningX: number;
  98578. /**
  98579. * Defines the current inertia value used during panning of the camera along the Y axis.
  98580. */
  98581. inertialPanningY: number;
  98582. /**
  98583. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  98584. * Basically if your fingers moves away from more than this distance you will be considered
  98585. * in pinch mode.
  98586. */
  98587. pinchToPanMaxDistance: number;
  98588. /**
  98589. * Defines the maximum distance the camera can pan.
  98590. * This could help keeping the cammera always in your scene.
  98591. */
  98592. panningDistanceLimit: Nullable<number>;
  98593. /**
  98594. * Defines the target of the camera before paning.
  98595. */
  98596. panningOriginTarget: Vector3;
  98597. /**
  98598. * Defines the value of the inertia used during panning.
  98599. * 0 would mean stop inertia and one would mean no decelleration at all.
  98600. */
  98601. panningInertia: number;
  98602. /**
  98603. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  98604. */
  98605. angularSensibilityX: number;
  98606. /**
  98607. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  98608. */
  98609. angularSensibilityY: number;
  98610. /**
  98611. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  98612. */
  98613. pinchPrecision: number;
  98614. /**
  98615. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  98616. * It will be used instead of pinchDeltaPrecision if different from 0.
  98617. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98618. */
  98619. pinchDeltaPercentage: number;
  98620. /**
  98621. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  98622. */
  98623. panningSensibility: number;
  98624. /**
  98625. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  98626. */
  98627. keysUp: number[];
  98628. /**
  98629. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  98630. */
  98631. keysDown: number[];
  98632. /**
  98633. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  98634. */
  98635. keysLeft: number[];
  98636. /**
  98637. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  98638. */
  98639. keysRight: number[];
  98640. /**
  98641. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98642. */
  98643. wheelPrecision: number;
  98644. /**
  98645. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  98646. * It will be used instead of pinchDeltaPrecision if different from 0.
  98647. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98648. */
  98649. wheelDeltaPercentage: number;
  98650. /**
  98651. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  98652. */
  98653. zoomOnFactor: number;
  98654. /**
  98655. * Defines a screen offset for the camera position.
  98656. */
  98657. targetScreenOffset: Vector2;
  98658. /**
  98659. * Allows the camera to be completely reversed.
  98660. * If false the camera can not arrive upside down.
  98661. */
  98662. allowUpsideDown: boolean;
  98663. /**
  98664. * Define if double tap/click is used to restore the previously saved state of the camera.
  98665. */
  98666. useInputToRestoreState: boolean;
  98667. /** @hidden */
  98668. _viewMatrix: Matrix;
  98669. /** @hidden */
  98670. _useCtrlForPanning: boolean;
  98671. /** @hidden */
  98672. _panningMouseButton: number;
  98673. /**
  98674. * Defines the input associated to the camera.
  98675. */
  98676. inputs: ArcRotateCameraInputsManager;
  98677. /** @hidden */
  98678. _reset: () => void;
  98679. /**
  98680. * Defines the allowed panning axis.
  98681. */
  98682. panningAxis: Vector3;
  98683. protected _localDirection: Vector3;
  98684. protected _transformedDirection: Vector3;
  98685. private _bouncingBehavior;
  98686. /**
  98687. * Gets the bouncing behavior of the camera if it has been enabled.
  98688. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98689. */
  98690. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  98691. /**
  98692. * Defines if the bouncing behavior of the camera is enabled on the camera.
  98693. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98694. */
  98695. useBouncingBehavior: boolean;
  98696. private _framingBehavior;
  98697. /**
  98698. * Gets the framing behavior of the camera if it has been enabled.
  98699. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98700. */
  98701. readonly framingBehavior: Nullable<FramingBehavior>;
  98702. /**
  98703. * Defines if the framing behavior of the camera is enabled on the camera.
  98704. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98705. */
  98706. useFramingBehavior: boolean;
  98707. private _autoRotationBehavior;
  98708. /**
  98709. * Gets the auto rotation behavior of the camera if it has been enabled.
  98710. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98711. */
  98712. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  98713. /**
  98714. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  98715. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98716. */
  98717. useAutoRotationBehavior: boolean;
  98718. /**
  98719. * Observable triggered when the mesh target has been changed on the camera.
  98720. */
  98721. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  98722. /**
  98723. * Event raised when the camera is colliding with a mesh.
  98724. */
  98725. onCollide: (collidedMesh: AbstractMesh) => void;
  98726. /**
  98727. * Defines whether the camera should check collision with the objects oh the scene.
  98728. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  98729. */
  98730. checkCollisions: boolean;
  98731. /**
  98732. * Defines the collision radius of the camera.
  98733. * This simulates a sphere around the camera.
  98734. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98735. */
  98736. collisionRadius: Vector3;
  98737. protected _collider: Collider;
  98738. protected _previousPosition: Vector3;
  98739. protected _collisionVelocity: Vector3;
  98740. protected _newPosition: Vector3;
  98741. protected _previousAlpha: number;
  98742. protected _previousBeta: number;
  98743. protected _previousRadius: number;
  98744. protected _collisionTriggered: boolean;
  98745. protected _targetBoundingCenter: Nullable<Vector3>;
  98746. private _computationVector;
  98747. /**
  98748. * Instantiates a new ArcRotateCamera in a given scene
  98749. * @param name Defines the name of the camera
  98750. * @param alpha Defines the camera rotation along the logitudinal axis
  98751. * @param beta Defines the camera rotation along the latitudinal axis
  98752. * @param radius Defines the camera distance from its target
  98753. * @param target Defines the camera target
  98754. * @param scene Defines the scene the camera belongs to
  98755. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98756. */
  98757. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98758. /** @hidden */
  98759. _initCache(): void;
  98760. /** @hidden */
  98761. _updateCache(ignoreParentClass?: boolean): void;
  98762. protected _getTargetPosition(): Vector3;
  98763. private _storedAlpha;
  98764. private _storedBeta;
  98765. private _storedRadius;
  98766. private _storedTarget;
  98767. /**
  98768. * Stores the current state of the camera (alpha, beta, radius and target)
  98769. * @returns the camera itself
  98770. */
  98771. storeState(): Camera;
  98772. /**
  98773. * @hidden
  98774. * Restored camera state. You must call storeState() first
  98775. */
  98776. _restoreStateValues(): boolean;
  98777. /** @hidden */
  98778. _isSynchronizedViewMatrix(): boolean;
  98779. /**
  98780. * Attached controls to the current camera.
  98781. * @param element Defines the element the controls should be listened from
  98782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98783. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  98784. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  98785. */
  98786. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  98787. /**
  98788. * Detach the current controls from the camera.
  98789. * The camera will stop reacting to inputs.
  98790. * @param element Defines the element to stop listening the inputs from
  98791. */
  98792. detachControl(element: HTMLElement): void;
  98793. /** @hidden */
  98794. _checkInputs(): void;
  98795. protected _checkLimits(): void;
  98796. /**
  98797. * Rebuilds angles (alpha, beta) and radius from the give position and target
  98798. */
  98799. rebuildAnglesAndRadius(): void;
  98800. /**
  98801. * Use a position to define the current camera related information like aplha, beta and radius
  98802. * @param position Defines the position to set the camera at
  98803. */
  98804. setPosition(position: Vector3): void;
  98805. /**
  98806. * Defines the target the camera should look at.
  98807. * This will automatically adapt alpha beta and radius to fit within the new target.
  98808. * @param target Defines the new target as a Vector or a mesh
  98809. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98810. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98811. */
  98812. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98813. /** @hidden */
  98814. _getViewMatrix(): Matrix;
  98815. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98816. /**
  98817. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98818. * @param meshes Defines the mesh to zoom on
  98819. * @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)
  98820. */
  98821. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98822. /**
  98823. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98824. * The target will be changed but the radius
  98825. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98826. * @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)
  98827. */
  98828. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98829. min: Vector3;
  98830. max: Vector3;
  98831. distance: number;
  98832. }, doNotUpdateMaxZ?: boolean): void;
  98833. /**
  98834. * @override
  98835. * Override Camera.createRigCamera
  98836. */
  98837. createRigCamera(name: string, cameraIndex: number): Camera;
  98838. /**
  98839. * @hidden
  98840. * @override
  98841. * Override Camera._updateRigCameras
  98842. */
  98843. _updateRigCameras(): void;
  98844. /**
  98845. * Destroy the camera and release the current resources hold by it.
  98846. */
  98847. dispose(): void;
  98848. /**
  98849. * Gets the current object class name.
  98850. * @return the class name
  98851. */
  98852. getClassName(): string;
  98853. }
  98854. }
  98855. declare module BABYLON {
  98856. /**
  98857. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98858. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98859. */
  98860. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98861. /**
  98862. * Gets the name of the behavior.
  98863. */
  98864. readonly name: string;
  98865. private _zoomStopsAnimation;
  98866. private _idleRotationSpeed;
  98867. private _idleRotationWaitTime;
  98868. private _idleRotationSpinupTime;
  98869. /**
  98870. * Sets the flag that indicates if user zooming should stop animation.
  98871. */
  98872. /**
  98873. * Gets the flag that indicates if user zooming should stop animation.
  98874. */
  98875. zoomStopsAnimation: boolean;
  98876. /**
  98877. * Sets the default speed at which the camera rotates around the model.
  98878. */
  98879. /**
  98880. * Gets the default speed at which the camera rotates around the model.
  98881. */
  98882. idleRotationSpeed: number;
  98883. /**
  98884. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98885. */
  98886. /**
  98887. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98888. */
  98889. idleRotationWaitTime: number;
  98890. /**
  98891. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98892. */
  98893. /**
  98894. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98895. */
  98896. idleRotationSpinupTime: number;
  98897. /**
  98898. * Gets a value indicating if the camera is currently rotating because of this behavior
  98899. */
  98900. readonly rotationInProgress: boolean;
  98901. private _onPrePointerObservableObserver;
  98902. private _onAfterCheckInputsObserver;
  98903. private _attachedCamera;
  98904. private _isPointerDown;
  98905. private _lastFrameTime;
  98906. private _lastInteractionTime;
  98907. private _cameraRotationSpeed;
  98908. /**
  98909. * Initializes the behavior.
  98910. */
  98911. init(): void;
  98912. /**
  98913. * Attaches the behavior to its arc rotate camera.
  98914. * @param camera Defines the camera to attach the behavior to
  98915. */
  98916. attach(camera: ArcRotateCamera): void;
  98917. /**
  98918. * Detaches the behavior from its current arc rotate camera.
  98919. */
  98920. detach(): void;
  98921. /**
  98922. * Returns true if user is scrolling.
  98923. * @return true if user is scrolling.
  98924. */
  98925. private _userIsZooming;
  98926. private _lastFrameRadius;
  98927. private _shouldAnimationStopForInteraction;
  98928. /**
  98929. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98930. */
  98931. private _applyUserInteraction;
  98932. private _userIsMoving;
  98933. }
  98934. }
  98935. declare module BABYLON {
  98936. /**
  98937. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  98938. */
  98939. export class AttachToBoxBehavior implements Behavior<Mesh> {
  98940. private ui;
  98941. /**
  98942. * The name of the behavior
  98943. */
  98944. name: string;
  98945. /**
  98946. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  98947. */
  98948. distanceAwayFromFace: number;
  98949. /**
  98950. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  98951. */
  98952. distanceAwayFromBottomOfFace: number;
  98953. private _faceVectors;
  98954. private _target;
  98955. private _scene;
  98956. private _onRenderObserver;
  98957. private _tmpMatrix;
  98958. private _tmpVector;
  98959. /**
  98960. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  98961. * @param ui The transform node that should be attched to the mesh
  98962. */
  98963. constructor(ui: TransformNode);
  98964. /**
  98965. * Initializes the behavior
  98966. */
  98967. init(): void;
  98968. private _closestFace;
  98969. private _zeroVector;
  98970. private _lookAtTmpMatrix;
  98971. private _lookAtToRef;
  98972. /**
  98973. * Attaches the AttachToBoxBehavior to the passed in mesh
  98974. * @param target The mesh that the specified node will be attached to
  98975. */
  98976. attach(target: Mesh): void;
  98977. /**
  98978. * Detaches the behavior from the mesh
  98979. */
  98980. detach(): void;
  98981. }
  98982. }
  98983. declare module BABYLON {
  98984. /**
  98985. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  98986. */
  98987. export class FadeInOutBehavior implements Behavior<Mesh> {
  98988. /**
  98989. * Time in milliseconds to delay before fading in (Default: 0)
  98990. */
  98991. delay: number;
  98992. /**
  98993. * Time in milliseconds for the mesh to fade in (Default: 300)
  98994. */
  98995. fadeInTime: number;
  98996. private _millisecondsPerFrame;
  98997. private _hovered;
  98998. private _hoverValue;
  98999. private _ownerNode;
  99000. /**
  99001. * Instatiates the FadeInOutBehavior
  99002. */
  99003. constructor();
  99004. /**
  99005. * The name of the behavior
  99006. */
  99007. readonly name: string;
  99008. /**
  99009. * Initializes the behavior
  99010. */
  99011. init(): void;
  99012. /**
  99013. * Attaches the fade behavior on the passed in mesh
  99014. * @param ownerNode The mesh that will be faded in/out once attached
  99015. */
  99016. attach(ownerNode: Mesh): void;
  99017. /**
  99018. * Detaches the behavior from the mesh
  99019. */
  99020. detach(): void;
  99021. /**
  99022. * Triggers the mesh to begin fading in or out
  99023. * @param value if the object should fade in or out (true to fade in)
  99024. */
  99025. fadeIn(value: boolean): void;
  99026. private _update;
  99027. private _setAllVisibility;
  99028. }
  99029. }
  99030. declare module BABYLON {
  99031. /**
  99032. * Class containing a set of static utilities functions for managing Pivots
  99033. * @hidden
  99034. */
  99035. export class PivotTools {
  99036. private static _PivotCached;
  99037. private static _OldPivotPoint;
  99038. private static _PivotTranslation;
  99039. private static _PivotTmpVector;
  99040. /** @hidden */
  99041. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  99042. /** @hidden */
  99043. static _RestorePivotPoint(mesh: AbstractMesh): void;
  99044. }
  99045. }
  99046. declare module BABYLON {
  99047. /**
  99048. * Class containing static functions to help procedurally build meshes
  99049. */
  99050. export class PlaneBuilder {
  99051. /**
  99052. * Creates a plane mesh
  99053. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  99054. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  99055. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  99056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99059. * @param name defines the name of the mesh
  99060. * @param options defines the options used to create the mesh
  99061. * @param scene defines the hosting scene
  99062. * @returns the plane mesh
  99063. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  99064. */
  99065. static CreatePlane(name: string, options: {
  99066. size?: number;
  99067. width?: number;
  99068. height?: number;
  99069. sideOrientation?: number;
  99070. frontUVs?: Vector4;
  99071. backUVs?: Vector4;
  99072. updatable?: boolean;
  99073. sourcePlane?: Plane;
  99074. }, scene?: Nullable<Scene>): Mesh;
  99075. }
  99076. }
  99077. declare module BABYLON {
  99078. /**
  99079. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  99080. */
  99081. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  99082. private static _AnyMouseID;
  99083. /**
  99084. * Abstract mesh the behavior is set on
  99085. */
  99086. attachedNode: AbstractMesh;
  99087. private _dragPlane;
  99088. private _scene;
  99089. private _pointerObserver;
  99090. private _beforeRenderObserver;
  99091. private static _planeScene;
  99092. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  99093. /**
  99094. * 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)
  99095. */
  99096. maxDragAngle: number;
  99097. /**
  99098. * @hidden
  99099. */
  99100. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  99101. /**
  99102. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  99103. */
  99104. currentDraggingPointerID: number;
  99105. /**
  99106. * The last position where the pointer hit the drag plane in world space
  99107. */
  99108. lastDragPosition: Vector3;
  99109. /**
  99110. * If the behavior is currently in a dragging state
  99111. */
  99112. dragging: boolean;
  99113. /**
  99114. * 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)
  99115. */
  99116. dragDeltaRatio: number;
  99117. /**
  99118. * If the drag plane orientation should be updated during the dragging (Default: true)
  99119. */
  99120. updateDragPlane: boolean;
  99121. private _debugMode;
  99122. private _moving;
  99123. /**
  99124. * Fires each time the attached mesh is dragged with the pointer
  99125. * * delta between last drag position and current drag position in world space
  99126. * * dragDistance along the drag axis
  99127. * * dragPlaneNormal normal of the current drag plane used during the drag
  99128. * * dragPlanePoint in world space where the drag intersects the drag plane
  99129. */
  99130. onDragObservable: Observable<{
  99131. delta: Vector3;
  99132. dragPlanePoint: Vector3;
  99133. dragPlaneNormal: Vector3;
  99134. dragDistance: number;
  99135. pointerId: number;
  99136. }>;
  99137. /**
  99138. * Fires each time a drag begins (eg. mouse down on mesh)
  99139. */
  99140. onDragStartObservable: Observable<{
  99141. dragPlanePoint: Vector3;
  99142. pointerId: number;
  99143. }>;
  99144. /**
  99145. * Fires each time a drag ends (eg. mouse release after drag)
  99146. */
  99147. onDragEndObservable: Observable<{
  99148. dragPlanePoint: Vector3;
  99149. pointerId: number;
  99150. }>;
  99151. /**
  99152. * If the attached mesh should be moved when dragged
  99153. */
  99154. moveAttached: boolean;
  99155. /**
  99156. * If the drag behavior will react to drag events (Default: true)
  99157. */
  99158. enabled: boolean;
  99159. /**
  99160. * If camera controls should be detached during the drag
  99161. */
  99162. detachCameraControls: boolean;
  99163. /**
  99164. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  99165. */
  99166. useObjectOrienationForDragging: boolean;
  99167. private _options;
  99168. /**
  99169. * Creates a pointer drag behavior that can be attached to a mesh
  99170. * @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)
  99171. */
  99172. constructor(options?: {
  99173. dragAxis?: Vector3;
  99174. dragPlaneNormal?: Vector3;
  99175. });
  99176. /**
  99177. * Predicate to determine if it is valid to move the object to a new position when it is moved
  99178. */
  99179. validateDrag: (targetPosition: Vector3) => boolean;
  99180. /**
  99181. * The name of the behavior
  99182. */
  99183. readonly name: string;
  99184. /**
  99185. * Initializes the behavior
  99186. */
  99187. init(): void;
  99188. private _tmpVector;
  99189. private _alternatePickedPoint;
  99190. private _worldDragAxis;
  99191. private _targetPosition;
  99192. private _attachedElement;
  99193. /**
  99194. * Attaches the drag behavior the passed in mesh
  99195. * @param ownerNode The mesh that will be dragged around once attached
  99196. */
  99197. attach(ownerNode: AbstractMesh): void;
  99198. /**
  99199. * Force relase the drag action by code.
  99200. */
  99201. releaseDrag(): void;
  99202. private _startDragRay;
  99203. private _lastPointerRay;
  99204. /**
  99205. * Simulates the start of a pointer drag event on the behavior
  99206. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  99207. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  99208. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  99209. */
  99210. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  99211. private _startDrag;
  99212. private _dragDelta;
  99213. private _moveDrag;
  99214. private _pickWithRayOnDragPlane;
  99215. private _pointA;
  99216. private _pointB;
  99217. private _pointC;
  99218. private _lineA;
  99219. private _lineB;
  99220. private _localAxis;
  99221. private _lookAt;
  99222. private _updateDragPlanePosition;
  99223. /**
  99224. * Detaches the behavior from the mesh
  99225. */
  99226. detach(): void;
  99227. }
  99228. }
  99229. declare module BABYLON {
  99230. /**
  99231. * A behavior that when attached to a mesh will allow the mesh to be scaled
  99232. */
  99233. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  99234. private _dragBehaviorA;
  99235. private _dragBehaviorB;
  99236. private _startDistance;
  99237. private _initialScale;
  99238. private _targetScale;
  99239. private _ownerNode;
  99240. private _sceneRenderObserver;
  99241. /**
  99242. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  99243. */
  99244. constructor();
  99245. /**
  99246. * The name of the behavior
  99247. */
  99248. readonly name: string;
  99249. /**
  99250. * Initializes the behavior
  99251. */
  99252. init(): void;
  99253. private _getCurrentDistance;
  99254. /**
  99255. * Attaches the scale behavior the passed in mesh
  99256. * @param ownerNode The mesh that will be scaled around once attached
  99257. */
  99258. attach(ownerNode: Mesh): void;
  99259. /**
  99260. * Detaches the behavior from the mesh
  99261. */
  99262. detach(): void;
  99263. }
  99264. }
  99265. declare module BABYLON {
  99266. /**
  99267. * 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
  99268. */
  99269. export class SixDofDragBehavior implements Behavior<Mesh> {
  99270. private static _virtualScene;
  99271. private _ownerNode;
  99272. private _sceneRenderObserver;
  99273. private _scene;
  99274. private _targetPosition;
  99275. private _virtualOriginMesh;
  99276. private _virtualDragMesh;
  99277. private _pointerObserver;
  99278. private _moving;
  99279. private _startingOrientation;
  99280. /**
  99281. * 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)
  99282. */
  99283. private zDragFactor;
  99284. /**
  99285. * If the object should rotate to face the drag origin
  99286. */
  99287. rotateDraggedObject: boolean;
  99288. /**
  99289. * If the behavior is currently in a dragging state
  99290. */
  99291. dragging: boolean;
  99292. /**
  99293. * 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)
  99294. */
  99295. dragDeltaRatio: number;
  99296. /**
  99297. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  99298. */
  99299. currentDraggingPointerID: number;
  99300. /**
  99301. * If camera controls should be detached during the drag
  99302. */
  99303. detachCameraControls: boolean;
  99304. /**
  99305. * Fires each time a drag starts
  99306. */
  99307. onDragStartObservable: Observable<{}>;
  99308. /**
  99309. * Fires each time a drag ends (eg. mouse release after drag)
  99310. */
  99311. onDragEndObservable: Observable<{}>;
  99312. /**
  99313. * 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
  99314. */
  99315. constructor();
  99316. /**
  99317. * The name of the behavior
  99318. */
  99319. readonly name: string;
  99320. /**
  99321. * Initializes the behavior
  99322. */
  99323. init(): void;
  99324. /**
  99325. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  99326. */
  99327. private readonly _pointerCamera;
  99328. /**
  99329. * Attaches the scale behavior the passed in mesh
  99330. * @param ownerNode The mesh that will be scaled around once attached
  99331. */
  99332. attach(ownerNode: Mesh): void;
  99333. /**
  99334. * Detaches the behavior from the mesh
  99335. */
  99336. detach(): void;
  99337. }
  99338. }
  99339. declare module BABYLON {
  99340. /**
  99341. * Class used to apply inverse kinematics to bones
  99342. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  99343. */
  99344. export class BoneIKController {
  99345. private static _tmpVecs;
  99346. private static _tmpQuat;
  99347. private static _tmpMats;
  99348. /**
  99349. * Gets or sets the target mesh
  99350. */
  99351. targetMesh: AbstractMesh;
  99352. /** Gets or sets the mesh used as pole */
  99353. poleTargetMesh: AbstractMesh;
  99354. /**
  99355. * Gets or sets the bone used as pole
  99356. */
  99357. poleTargetBone: Nullable<Bone>;
  99358. /**
  99359. * Gets or sets the target position
  99360. */
  99361. targetPosition: Vector3;
  99362. /**
  99363. * Gets or sets the pole target position
  99364. */
  99365. poleTargetPosition: Vector3;
  99366. /**
  99367. * Gets or sets the pole target local offset
  99368. */
  99369. poleTargetLocalOffset: Vector3;
  99370. /**
  99371. * Gets or sets the pole angle
  99372. */
  99373. poleAngle: number;
  99374. /**
  99375. * Gets or sets the mesh associated with the controller
  99376. */
  99377. mesh: AbstractMesh;
  99378. /**
  99379. * 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)
  99380. */
  99381. slerpAmount: number;
  99382. private _bone1Quat;
  99383. private _bone1Mat;
  99384. private _bone2Ang;
  99385. private _bone1;
  99386. private _bone2;
  99387. private _bone1Length;
  99388. private _bone2Length;
  99389. private _maxAngle;
  99390. private _maxReach;
  99391. private _rightHandedSystem;
  99392. private _bendAxis;
  99393. private _slerping;
  99394. private _adjustRoll;
  99395. /**
  99396. * Gets or sets maximum allowed angle
  99397. */
  99398. maxAngle: number;
  99399. /**
  99400. * Creates a new BoneIKController
  99401. * @param mesh defines the mesh to control
  99402. * @param bone defines the bone to control
  99403. * @param options defines options to set up the controller
  99404. */
  99405. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  99406. targetMesh?: AbstractMesh;
  99407. poleTargetMesh?: AbstractMesh;
  99408. poleTargetBone?: Bone;
  99409. poleTargetLocalOffset?: Vector3;
  99410. poleAngle?: number;
  99411. bendAxis?: Vector3;
  99412. maxAngle?: number;
  99413. slerpAmount?: number;
  99414. });
  99415. private _setMaxAngle;
  99416. /**
  99417. * Force the controller to update the bones
  99418. */
  99419. update(): void;
  99420. }
  99421. }
  99422. declare module BABYLON {
  99423. /**
  99424. * Class used to make a bone look toward a point in space
  99425. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  99426. */
  99427. export class BoneLookController {
  99428. private static _tmpVecs;
  99429. private static _tmpQuat;
  99430. private static _tmpMats;
  99431. /**
  99432. * The target Vector3 that the bone will look at
  99433. */
  99434. target: Vector3;
  99435. /**
  99436. * The mesh that the bone is attached to
  99437. */
  99438. mesh: AbstractMesh;
  99439. /**
  99440. * The bone that will be looking to the target
  99441. */
  99442. bone: Bone;
  99443. /**
  99444. * The up axis of the coordinate system that is used when the bone is rotated
  99445. */
  99446. upAxis: Vector3;
  99447. /**
  99448. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  99449. */
  99450. upAxisSpace: Space;
  99451. /**
  99452. * Used to make an adjustment to the yaw of the bone
  99453. */
  99454. adjustYaw: number;
  99455. /**
  99456. * Used to make an adjustment to the pitch of the bone
  99457. */
  99458. adjustPitch: number;
  99459. /**
  99460. * Used to make an adjustment to the roll of the bone
  99461. */
  99462. adjustRoll: number;
  99463. /**
  99464. * 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)
  99465. */
  99466. slerpAmount: number;
  99467. private _minYaw;
  99468. private _maxYaw;
  99469. private _minPitch;
  99470. private _maxPitch;
  99471. private _minYawSin;
  99472. private _minYawCos;
  99473. private _maxYawSin;
  99474. private _maxYawCos;
  99475. private _midYawConstraint;
  99476. private _minPitchTan;
  99477. private _maxPitchTan;
  99478. private _boneQuat;
  99479. private _slerping;
  99480. private _transformYawPitch;
  99481. private _transformYawPitchInv;
  99482. private _firstFrameSkipped;
  99483. private _yawRange;
  99484. private _fowardAxis;
  99485. /**
  99486. * Gets or sets the minimum yaw angle that the bone can look to
  99487. */
  99488. minYaw: number;
  99489. /**
  99490. * Gets or sets the maximum yaw angle that the bone can look to
  99491. */
  99492. maxYaw: number;
  99493. /**
  99494. * Gets or sets the minimum pitch angle that the bone can look to
  99495. */
  99496. minPitch: number;
  99497. /**
  99498. * Gets or sets the maximum pitch angle that the bone can look to
  99499. */
  99500. maxPitch: number;
  99501. /**
  99502. * Create a BoneLookController
  99503. * @param mesh the mesh that the bone belongs to
  99504. * @param bone the bone that will be looking to the target
  99505. * @param target the target Vector3 to look at
  99506. * @param options optional settings:
  99507. * * maxYaw: the maximum angle the bone will yaw to
  99508. * * minYaw: the minimum angle the bone will yaw to
  99509. * * maxPitch: the maximum angle the bone will pitch to
  99510. * * minPitch: the minimum angle the bone will yaw to
  99511. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  99512. * * upAxis: the up axis of the coordinate system
  99513. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  99514. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  99515. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  99516. * * adjustYaw: used to make an adjustment to the yaw of the bone
  99517. * * adjustPitch: used to make an adjustment to the pitch of the bone
  99518. * * adjustRoll: used to make an adjustment to the roll of the bone
  99519. **/
  99520. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  99521. maxYaw?: number;
  99522. minYaw?: number;
  99523. maxPitch?: number;
  99524. minPitch?: number;
  99525. slerpAmount?: number;
  99526. upAxis?: Vector3;
  99527. upAxisSpace?: Space;
  99528. yawAxis?: Vector3;
  99529. pitchAxis?: Vector3;
  99530. adjustYaw?: number;
  99531. adjustPitch?: number;
  99532. adjustRoll?: number;
  99533. });
  99534. /**
  99535. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  99536. */
  99537. update(): void;
  99538. private _getAngleDiff;
  99539. private _getAngleBetween;
  99540. private _isAngleBetween;
  99541. }
  99542. }
  99543. declare module BABYLON {
  99544. /**
  99545. * Manage the gamepad inputs to control an arc rotate camera.
  99546. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99547. */
  99548. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  99549. /**
  99550. * Defines the camera the input is attached to.
  99551. */
  99552. camera: ArcRotateCamera;
  99553. /**
  99554. * Defines the gamepad the input is gathering event from.
  99555. */
  99556. gamepad: Nullable<Gamepad>;
  99557. /**
  99558. * Defines the gamepad rotation sensiblity.
  99559. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99560. */
  99561. gamepadRotationSensibility: number;
  99562. /**
  99563. * Defines the gamepad move sensiblity.
  99564. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99565. */
  99566. gamepadMoveSensibility: number;
  99567. private _onGamepadConnectedObserver;
  99568. private _onGamepadDisconnectedObserver;
  99569. /**
  99570. * Attach the input controls to a specific dom element to get the input from.
  99571. * @param element Defines the element the controls should be listened from
  99572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99573. */
  99574. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99575. /**
  99576. * Detach the current controls from the specified dom element.
  99577. * @param element Defines the element to stop listening the inputs from
  99578. */
  99579. detachControl(element: Nullable<HTMLElement>): void;
  99580. /**
  99581. * Update the current camera state depending on the inputs that have been used this frame.
  99582. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99583. */
  99584. checkInputs(): void;
  99585. /**
  99586. * Gets the class name of the current intput.
  99587. * @returns the class name
  99588. */
  99589. getClassName(): string;
  99590. /**
  99591. * Get the friendly name associated with the input class.
  99592. * @returns the input friendly name
  99593. */
  99594. getSimpleName(): string;
  99595. }
  99596. }
  99597. declare module BABYLON {
  99598. interface ArcRotateCameraInputsManager {
  99599. /**
  99600. * Add orientation input support to the input manager.
  99601. * @returns the current input manager
  99602. */
  99603. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  99604. }
  99605. /**
  99606. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  99607. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99608. */
  99609. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  99610. /**
  99611. * Defines the camera the input is attached to.
  99612. */
  99613. camera: ArcRotateCamera;
  99614. /**
  99615. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  99616. */
  99617. alphaCorrection: number;
  99618. /**
  99619. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  99620. */
  99621. gammaCorrection: number;
  99622. private _alpha;
  99623. private _gamma;
  99624. private _dirty;
  99625. private _deviceOrientationHandler;
  99626. /**
  99627. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  99628. */
  99629. constructor();
  99630. /**
  99631. * Attach the input controls to a specific dom element to get the input from.
  99632. * @param element Defines the element the controls should be listened from
  99633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99634. */
  99635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99636. /** @hidden */
  99637. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  99638. /**
  99639. * Update the current camera state depending on the inputs that have been used this frame.
  99640. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99641. */
  99642. checkInputs(): void;
  99643. /**
  99644. * Detach the current controls from the specified dom element.
  99645. * @param element Defines the element to stop listening the inputs from
  99646. */
  99647. detachControl(element: Nullable<HTMLElement>): void;
  99648. /**
  99649. * Gets the class name of the current intput.
  99650. * @returns the class name
  99651. */
  99652. getClassName(): string;
  99653. /**
  99654. * Get the friendly name associated with the input class.
  99655. * @returns the input friendly name
  99656. */
  99657. getSimpleName(): string;
  99658. }
  99659. }
  99660. declare module BABYLON {
  99661. /**
  99662. * Listen to mouse events to control the camera.
  99663. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99664. */
  99665. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  99666. /**
  99667. * Defines the camera the input is attached to.
  99668. */
  99669. camera: FlyCamera;
  99670. /**
  99671. * Defines if touch is enabled. (Default is true.)
  99672. */
  99673. touchEnabled: boolean;
  99674. /**
  99675. * Defines the buttons associated with the input to handle camera rotation.
  99676. */
  99677. buttons: number[];
  99678. /**
  99679. * Assign buttons for Yaw control.
  99680. */
  99681. buttonsYaw: number[];
  99682. /**
  99683. * Assign buttons for Pitch control.
  99684. */
  99685. buttonsPitch: number[];
  99686. /**
  99687. * Assign buttons for Roll control.
  99688. */
  99689. buttonsRoll: number[];
  99690. /**
  99691. * Detect if any button is being pressed while mouse is moved.
  99692. * -1 = Mouse locked.
  99693. * 0 = Left button.
  99694. * 1 = Middle Button.
  99695. * 2 = Right Button.
  99696. */
  99697. activeButton: number;
  99698. /**
  99699. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  99700. * Higher values reduce its sensitivity.
  99701. */
  99702. angularSensibility: number;
  99703. private _mousemoveCallback;
  99704. private _observer;
  99705. private _rollObserver;
  99706. private previousPosition;
  99707. private noPreventDefault;
  99708. private element;
  99709. /**
  99710. * Listen to mouse events to control the camera.
  99711. * @param touchEnabled Define if touch is enabled. (Default is true.)
  99712. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99713. */
  99714. constructor(touchEnabled?: boolean);
  99715. /**
  99716. * Attach the mouse control to the HTML DOM element.
  99717. * @param element Defines the element that listens to the input events.
  99718. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  99719. */
  99720. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99721. /**
  99722. * Detach the current controls from the specified dom element.
  99723. * @param element Defines the element to stop listening the inputs from
  99724. */
  99725. detachControl(element: Nullable<HTMLElement>): void;
  99726. /**
  99727. * Gets the class name of the current input.
  99728. * @returns the class name.
  99729. */
  99730. getClassName(): string;
  99731. /**
  99732. * Get the friendly name associated with the input class.
  99733. * @returns the input's friendly name.
  99734. */
  99735. getSimpleName(): string;
  99736. private _pointerInput;
  99737. private _onMouseMove;
  99738. /**
  99739. * Rotate camera by mouse offset.
  99740. */
  99741. private rotateCamera;
  99742. }
  99743. }
  99744. declare module BABYLON {
  99745. /**
  99746. * Default Inputs manager for the FlyCamera.
  99747. * It groups all the default supported inputs for ease of use.
  99748. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99749. */
  99750. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  99751. /**
  99752. * Instantiates a new FlyCameraInputsManager.
  99753. * @param camera Defines the camera the inputs belong to.
  99754. */
  99755. constructor(camera: FlyCamera);
  99756. /**
  99757. * Add keyboard input support to the input manager.
  99758. * @returns the new FlyCameraKeyboardMoveInput().
  99759. */
  99760. addKeyboard(): FlyCameraInputsManager;
  99761. /**
  99762. * Add mouse input support to the input manager.
  99763. * @param touchEnabled Enable touch screen support.
  99764. * @returns the new FlyCameraMouseInput().
  99765. */
  99766. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  99767. }
  99768. }
  99769. declare module BABYLON {
  99770. /**
  99771. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99772. * such as in a 3D Space Shooter or a Flight Simulator.
  99773. */
  99774. export class FlyCamera extends TargetCamera {
  99775. /**
  99776. * Define the collision ellipsoid of the camera.
  99777. * This is helpful for simulating a camera body, like a player's body.
  99778. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99779. */
  99780. ellipsoid: Vector3;
  99781. /**
  99782. * Define an offset for the position of the ellipsoid around the camera.
  99783. * This can be helpful if the camera is attached away from the player's body center,
  99784. * such as at its head.
  99785. */
  99786. ellipsoidOffset: Vector3;
  99787. /**
  99788. * Enable or disable collisions of the camera with the rest of the scene objects.
  99789. */
  99790. checkCollisions: boolean;
  99791. /**
  99792. * Enable or disable gravity on the camera.
  99793. */
  99794. applyGravity: boolean;
  99795. /**
  99796. * Define the current direction the camera is moving to.
  99797. */
  99798. cameraDirection: Vector3;
  99799. /**
  99800. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  99801. * This overrides and empties cameraRotation.
  99802. */
  99803. rotationQuaternion: Quaternion;
  99804. /**
  99805. * Track Roll to maintain the wanted Rolling when looking around.
  99806. */
  99807. _trackRoll: number;
  99808. /**
  99809. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  99810. */
  99811. rollCorrect: number;
  99812. /**
  99813. * Mimic a banked turn, Rolling the camera when Yawing.
  99814. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99815. */
  99816. bankedTurn: boolean;
  99817. /**
  99818. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99819. */
  99820. bankedTurnLimit: number;
  99821. /**
  99822. * Value of 0 disables the banked Roll.
  99823. * Value of 1 is equal to the Yaw angle in radians.
  99824. */
  99825. bankedTurnMultiplier: number;
  99826. /**
  99827. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99828. */
  99829. inputs: FlyCameraInputsManager;
  99830. /**
  99831. * Gets the input sensibility for mouse input.
  99832. * Higher values reduce sensitivity.
  99833. */
  99834. /**
  99835. * Sets the input sensibility for a mouse input.
  99836. * Higher values reduce sensitivity.
  99837. */
  99838. angularSensibility: number;
  99839. /**
  99840. * Get the keys for camera movement forward.
  99841. */
  99842. /**
  99843. * Set the keys for camera movement forward.
  99844. */
  99845. keysForward: number[];
  99846. /**
  99847. * Get the keys for camera movement backward.
  99848. */
  99849. keysBackward: number[];
  99850. /**
  99851. * Get the keys for camera movement up.
  99852. */
  99853. /**
  99854. * Set the keys for camera movement up.
  99855. */
  99856. keysUp: number[];
  99857. /**
  99858. * Get the keys for camera movement down.
  99859. */
  99860. /**
  99861. * Set the keys for camera movement down.
  99862. */
  99863. keysDown: number[];
  99864. /**
  99865. * Get the keys for camera movement left.
  99866. */
  99867. /**
  99868. * Set the keys for camera movement left.
  99869. */
  99870. keysLeft: number[];
  99871. /**
  99872. * Set the keys for camera movement right.
  99873. */
  99874. /**
  99875. * Set the keys for camera movement right.
  99876. */
  99877. keysRight: number[];
  99878. /**
  99879. * Event raised when the camera collides with a mesh in the scene.
  99880. */
  99881. onCollide: (collidedMesh: AbstractMesh) => void;
  99882. private _collider;
  99883. private _needMoveForGravity;
  99884. private _oldPosition;
  99885. private _diffPosition;
  99886. private _newPosition;
  99887. /** @hidden */
  99888. _localDirection: Vector3;
  99889. /** @hidden */
  99890. _transformedDirection: Vector3;
  99891. /**
  99892. * Instantiates a FlyCamera.
  99893. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99894. * such as in a 3D Space Shooter or a Flight Simulator.
  99895. * @param name Define the name of the camera in the scene.
  99896. * @param position Define the starting position of the camera in the scene.
  99897. * @param scene Define the scene the camera belongs to.
  99898. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99899. */
  99900. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99901. /**
  99902. * Attach a control to the HTML DOM element.
  99903. * @param element Defines the element that listens to the input events.
  99904. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99905. */
  99906. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99907. /**
  99908. * Detach a control from the HTML DOM element.
  99909. * The camera will stop reacting to that input.
  99910. * @param element Defines the element that listens to the input events.
  99911. */
  99912. detachControl(element: HTMLElement): void;
  99913. private _collisionMask;
  99914. /**
  99915. * Get the mask that the camera ignores in collision events.
  99916. */
  99917. /**
  99918. * Set the mask that the camera ignores in collision events.
  99919. */
  99920. collisionMask: number;
  99921. /** @hidden */
  99922. _collideWithWorld(displacement: Vector3): void;
  99923. /** @hidden */
  99924. private _onCollisionPositionChange;
  99925. /** @hidden */
  99926. _checkInputs(): void;
  99927. /** @hidden */
  99928. _decideIfNeedsToMove(): boolean;
  99929. /** @hidden */
  99930. _updatePosition(): void;
  99931. /**
  99932. * Restore the Roll to its target value at the rate specified.
  99933. * @param rate - Higher means slower restoring.
  99934. * @hidden
  99935. */
  99936. restoreRoll(rate: number): void;
  99937. /**
  99938. * Destroy the camera and release the current resources held by it.
  99939. */
  99940. dispose(): void;
  99941. /**
  99942. * Get the current object class name.
  99943. * @returns the class name.
  99944. */
  99945. getClassName(): string;
  99946. }
  99947. }
  99948. declare module BABYLON {
  99949. /**
  99950. * Listen to keyboard events to control the camera.
  99951. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99952. */
  99953. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  99954. /**
  99955. * Defines the camera the input is attached to.
  99956. */
  99957. camera: FlyCamera;
  99958. /**
  99959. * The list of keyboard keys used to control the forward move of the camera.
  99960. */
  99961. keysForward: number[];
  99962. /**
  99963. * The list of keyboard keys used to control the backward move of the camera.
  99964. */
  99965. keysBackward: number[];
  99966. /**
  99967. * The list of keyboard keys used to control the forward move of the camera.
  99968. */
  99969. keysUp: number[];
  99970. /**
  99971. * The list of keyboard keys used to control the backward move of the camera.
  99972. */
  99973. keysDown: number[];
  99974. /**
  99975. * The list of keyboard keys used to control the right strafe move of the camera.
  99976. */
  99977. keysRight: number[];
  99978. /**
  99979. * The list of keyboard keys used to control the left strafe move of the camera.
  99980. */
  99981. keysLeft: number[];
  99982. private _keys;
  99983. private _onCanvasBlurObserver;
  99984. private _onKeyboardObserver;
  99985. private _engine;
  99986. private _scene;
  99987. /**
  99988. * Attach the input controls to a specific dom element to get the input from.
  99989. * @param element Defines the element the controls should be listened from
  99990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99991. */
  99992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99993. /**
  99994. * Detach the current controls from the specified dom element.
  99995. * @param element Defines the element to stop listening the inputs from
  99996. */
  99997. detachControl(element: Nullable<HTMLElement>): void;
  99998. /**
  99999. * Gets the class name of the current intput.
  100000. * @returns the class name
  100001. */
  100002. getClassName(): string;
  100003. /** @hidden */
  100004. _onLostFocus(e: FocusEvent): void;
  100005. /**
  100006. * Get the friendly name associated with the input class.
  100007. * @returns the input friendly name
  100008. */
  100009. getSimpleName(): string;
  100010. /**
  100011. * Update the current camera state depending on the inputs that have been used this frame.
  100012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100013. */
  100014. checkInputs(): void;
  100015. }
  100016. }
  100017. declare module BABYLON {
  100018. /**
  100019. * Manage the mouse wheel inputs to control a follow camera.
  100020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100021. */
  100022. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  100023. /**
  100024. * Defines the camera the input is attached to.
  100025. */
  100026. camera: FollowCamera;
  100027. /**
  100028. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  100029. */
  100030. axisControlRadius: boolean;
  100031. /**
  100032. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  100033. */
  100034. axisControlHeight: boolean;
  100035. /**
  100036. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  100037. */
  100038. axisControlRotation: boolean;
  100039. /**
  100040. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  100041. * relation to mouseWheel events.
  100042. */
  100043. wheelPrecision: number;
  100044. /**
  100045. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  100046. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  100047. */
  100048. wheelDeltaPercentage: number;
  100049. private _wheel;
  100050. private _observer;
  100051. /**
  100052. * Attach the input controls to a specific dom element to get the input from.
  100053. * @param element Defines the element the controls should be listened from
  100054. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100055. */
  100056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100057. /**
  100058. * Detach the current controls from the specified dom element.
  100059. * @param element Defines the element to stop listening the inputs from
  100060. */
  100061. detachControl(element: Nullable<HTMLElement>): void;
  100062. /**
  100063. * Gets the class name of the current intput.
  100064. * @returns the class name
  100065. */
  100066. getClassName(): string;
  100067. /**
  100068. * Get the friendly name associated with the input class.
  100069. * @returns the input friendly name
  100070. */
  100071. getSimpleName(): string;
  100072. }
  100073. }
  100074. declare module BABYLON {
  100075. /**
  100076. * Manage the pointers inputs to control an follow camera.
  100077. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100078. */
  100079. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  100080. /**
  100081. * Defines the camera the input is attached to.
  100082. */
  100083. camera: FollowCamera;
  100084. /**
  100085. * Gets the class name of the current input.
  100086. * @returns the class name
  100087. */
  100088. getClassName(): string;
  100089. /**
  100090. * Defines the pointer angular sensibility along the X axis or how fast is
  100091. * the camera rotating.
  100092. * A negative number will reverse the axis direction.
  100093. */
  100094. angularSensibilityX: number;
  100095. /**
  100096. * Defines the pointer angular sensibility along the Y axis or how fast is
  100097. * the camera rotating.
  100098. * A negative number will reverse the axis direction.
  100099. */
  100100. angularSensibilityY: number;
  100101. /**
  100102. * Defines the pointer pinch precision or how fast is the camera zooming.
  100103. * A negative number will reverse the axis direction.
  100104. */
  100105. pinchPrecision: number;
  100106. /**
  100107. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  100108. * from 0.
  100109. * It defines the percentage of current camera.radius to use as delta when
  100110. * pinch zoom is used.
  100111. */
  100112. pinchDeltaPercentage: number;
  100113. /**
  100114. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  100115. */
  100116. axisXControlRadius: boolean;
  100117. /**
  100118. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  100119. */
  100120. axisXControlHeight: boolean;
  100121. /**
  100122. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  100123. */
  100124. axisXControlRotation: boolean;
  100125. /**
  100126. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  100127. */
  100128. axisYControlRadius: boolean;
  100129. /**
  100130. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  100131. */
  100132. axisYControlHeight: boolean;
  100133. /**
  100134. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  100135. */
  100136. axisYControlRotation: boolean;
  100137. /**
  100138. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  100139. */
  100140. axisPinchControlRadius: boolean;
  100141. /**
  100142. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  100143. */
  100144. axisPinchControlHeight: boolean;
  100145. /**
  100146. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  100147. */
  100148. axisPinchControlRotation: boolean;
  100149. /**
  100150. * Log error messages if basic misconfiguration has occurred.
  100151. */
  100152. warningEnable: boolean;
  100153. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100154. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100155. private _warningCounter;
  100156. private _warning;
  100157. }
  100158. }
  100159. declare module BABYLON {
  100160. /**
  100161. * Default Inputs manager for the FollowCamera.
  100162. * It groups all the default supported inputs for ease of use.
  100163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100164. */
  100165. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  100166. /**
  100167. * Instantiates a new FollowCameraInputsManager.
  100168. * @param camera Defines the camera the inputs belong to
  100169. */
  100170. constructor(camera: FollowCamera);
  100171. /**
  100172. * Add keyboard input support to the input manager.
  100173. * @returns the current input manager
  100174. */
  100175. addKeyboard(): FollowCameraInputsManager;
  100176. /**
  100177. * Add mouse wheel input support to the input manager.
  100178. * @returns the current input manager
  100179. */
  100180. addMouseWheel(): FollowCameraInputsManager;
  100181. /**
  100182. * Add pointers input support to the input manager.
  100183. * @returns the current input manager
  100184. */
  100185. addPointers(): FollowCameraInputsManager;
  100186. /**
  100187. * Add orientation input support to the input manager.
  100188. * @returns the current input manager
  100189. */
  100190. addVRDeviceOrientation(): FollowCameraInputsManager;
  100191. }
  100192. }
  100193. declare module BABYLON {
  100194. /**
  100195. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  100196. * an arc rotate version arcFollowCamera are available.
  100197. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100198. */
  100199. export class FollowCamera extends TargetCamera {
  100200. /**
  100201. * Distance the follow camera should follow an object at
  100202. */
  100203. radius: number;
  100204. /**
  100205. * Minimum allowed distance of the camera to the axis of rotation
  100206. * (The camera can not get closer).
  100207. * This can help limiting how the Camera is able to move in the scene.
  100208. */
  100209. lowerRadiusLimit: Nullable<number>;
  100210. /**
  100211. * Maximum allowed distance of the camera to the axis of rotation
  100212. * (The camera can not get further).
  100213. * This can help limiting how the Camera is able to move in the scene.
  100214. */
  100215. upperRadiusLimit: Nullable<number>;
  100216. /**
  100217. * Define a rotation offset between the camera and the object it follows
  100218. */
  100219. rotationOffset: number;
  100220. /**
  100221. * Minimum allowed angle to camera position relative to target object.
  100222. * This can help limiting how the Camera is able to move in the scene.
  100223. */
  100224. lowerRotationOffsetLimit: Nullable<number>;
  100225. /**
  100226. * Maximum allowed angle to camera position relative to target object.
  100227. * This can help limiting how the Camera is able to move in the scene.
  100228. */
  100229. upperRotationOffsetLimit: Nullable<number>;
  100230. /**
  100231. * Define a height offset between the camera and the object it follows.
  100232. * It can help following an object from the top (like a car chaing a plane)
  100233. */
  100234. heightOffset: number;
  100235. /**
  100236. * Minimum allowed height of camera position relative to target object.
  100237. * This can help limiting how the Camera is able to move in the scene.
  100238. */
  100239. lowerHeightOffsetLimit: Nullable<number>;
  100240. /**
  100241. * Maximum allowed height of camera position relative to target object.
  100242. * This can help limiting how the Camera is able to move in the scene.
  100243. */
  100244. upperHeightOffsetLimit: Nullable<number>;
  100245. /**
  100246. * Define how fast the camera can accelerate to follow it s target.
  100247. */
  100248. cameraAcceleration: number;
  100249. /**
  100250. * Define the speed limit of the camera following an object.
  100251. */
  100252. maxCameraSpeed: number;
  100253. /**
  100254. * Define the target of the camera.
  100255. */
  100256. lockedTarget: Nullable<AbstractMesh>;
  100257. /**
  100258. * Defines the input associated with the camera.
  100259. */
  100260. inputs: FollowCameraInputsManager;
  100261. /**
  100262. * Instantiates the follow camera.
  100263. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100264. * @param name Define the name of the camera in the scene
  100265. * @param position Define the position of the camera
  100266. * @param scene Define the scene the camera belong to
  100267. * @param lockedTarget Define the target of the camera
  100268. */
  100269. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  100270. private _follow;
  100271. /**
  100272. * Attached controls to the current camera.
  100273. * @param element Defines the element the controls should be listened from
  100274. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100275. */
  100276. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100277. /**
  100278. * Detach the current controls from the camera.
  100279. * The camera will stop reacting to inputs.
  100280. * @param element Defines the element to stop listening the inputs from
  100281. */
  100282. detachControl(element: HTMLElement): void;
  100283. /** @hidden */
  100284. _checkInputs(): void;
  100285. private _checkLimits;
  100286. /**
  100287. * Gets the camera class name.
  100288. * @returns the class name
  100289. */
  100290. getClassName(): string;
  100291. }
  100292. /**
  100293. * Arc Rotate version of the follow camera.
  100294. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  100295. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100296. */
  100297. export class ArcFollowCamera extends TargetCamera {
  100298. /** The longitudinal angle of the camera */
  100299. alpha: number;
  100300. /** The latitudinal angle of the camera */
  100301. beta: number;
  100302. /** The radius of the camera from its target */
  100303. radius: number;
  100304. /** Define the camera target (the messh it should follow) */
  100305. target: Nullable<AbstractMesh>;
  100306. private _cartesianCoordinates;
  100307. /**
  100308. * Instantiates a new ArcFollowCamera
  100309. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100310. * @param name Define the name of the camera
  100311. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  100312. * @param beta Define the rotation angle of the camera around the elevation axis
  100313. * @param radius Define the radius of the camera from its target point
  100314. * @param target Define the target of the camera
  100315. * @param scene Define the scene the camera belongs to
  100316. */
  100317. constructor(name: string,
  100318. /** The longitudinal angle of the camera */
  100319. alpha: number,
  100320. /** The latitudinal angle of the camera */
  100321. beta: number,
  100322. /** The radius of the camera from its target */
  100323. radius: number,
  100324. /** Define the camera target (the messh it should follow) */
  100325. target: Nullable<AbstractMesh>, scene: Scene);
  100326. private _follow;
  100327. /** @hidden */
  100328. _checkInputs(): void;
  100329. /**
  100330. * Returns the class name of the object.
  100331. * It is mostly used internally for serialization purposes.
  100332. */
  100333. getClassName(): string;
  100334. }
  100335. }
  100336. declare module BABYLON {
  100337. /**
  100338. * Manage the keyboard inputs to control the movement of a follow camera.
  100339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100340. */
  100341. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  100342. /**
  100343. * Defines the camera the input is attached to.
  100344. */
  100345. camera: FollowCamera;
  100346. /**
  100347. * Defines the list of key codes associated with the up action (increase heightOffset)
  100348. */
  100349. keysHeightOffsetIncr: number[];
  100350. /**
  100351. * Defines the list of key codes associated with the down action (decrease heightOffset)
  100352. */
  100353. keysHeightOffsetDecr: number[];
  100354. /**
  100355. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  100356. */
  100357. keysHeightOffsetModifierAlt: boolean;
  100358. /**
  100359. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  100360. */
  100361. keysHeightOffsetModifierCtrl: boolean;
  100362. /**
  100363. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  100364. */
  100365. keysHeightOffsetModifierShift: boolean;
  100366. /**
  100367. * Defines the list of key codes associated with the left action (increase rotationOffset)
  100368. */
  100369. keysRotationOffsetIncr: number[];
  100370. /**
  100371. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  100372. */
  100373. keysRotationOffsetDecr: number[];
  100374. /**
  100375. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  100376. */
  100377. keysRotationOffsetModifierAlt: boolean;
  100378. /**
  100379. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  100380. */
  100381. keysRotationOffsetModifierCtrl: boolean;
  100382. /**
  100383. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  100384. */
  100385. keysRotationOffsetModifierShift: boolean;
  100386. /**
  100387. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  100388. */
  100389. keysRadiusIncr: number[];
  100390. /**
  100391. * Defines the list of key codes associated with the zoom-out action (increase radius)
  100392. */
  100393. keysRadiusDecr: number[];
  100394. /**
  100395. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  100396. */
  100397. keysRadiusModifierAlt: boolean;
  100398. /**
  100399. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  100400. */
  100401. keysRadiusModifierCtrl: boolean;
  100402. /**
  100403. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  100404. */
  100405. keysRadiusModifierShift: boolean;
  100406. /**
  100407. * Defines the rate of change of heightOffset.
  100408. */
  100409. heightSensibility: number;
  100410. /**
  100411. * Defines the rate of change of rotationOffset.
  100412. */
  100413. rotationSensibility: number;
  100414. /**
  100415. * Defines the rate of change of radius.
  100416. */
  100417. radiusSensibility: number;
  100418. private _keys;
  100419. private _ctrlPressed;
  100420. private _altPressed;
  100421. private _shiftPressed;
  100422. private _onCanvasBlurObserver;
  100423. private _onKeyboardObserver;
  100424. private _engine;
  100425. private _scene;
  100426. /**
  100427. * Attach the input controls to a specific dom element to get the input from.
  100428. * @param element Defines the element the controls should be listened from
  100429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100430. */
  100431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100432. /**
  100433. * Detach the current controls from the specified dom element.
  100434. * @param element Defines the element to stop listening the inputs from
  100435. */
  100436. detachControl(element: Nullable<HTMLElement>): void;
  100437. /**
  100438. * Update the current camera state depending on the inputs that have been used this frame.
  100439. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100440. */
  100441. checkInputs(): void;
  100442. /**
  100443. * Gets the class name of the current input.
  100444. * @returns the class name
  100445. */
  100446. getClassName(): string;
  100447. /**
  100448. * Get the friendly name associated with the input class.
  100449. * @returns the input friendly name
  100450. */
  100451. getSimpleName(): string;
  100452. /**
  100453. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100454. * allow modification of the heightOffset value.
  100455. */
  100456. private _modifierHeightOffset;
  100457. /**
  100458. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100459. * allow modification of the rotationOffset value.
  100460. */
  100461. private _modifierRotationOffset;
  100462. /**
  100463. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100464. * allow modification of the radius value.
  100465. */
  100466. private _modifierRadius;
  100467. }
  100468. }
  100469. declare module BABYLON {
  100470. interface FreeCameraInputsManager {
  100471. /**
  100472. * @hidden
  100473. */
  100474. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  100475. /**
  100476. * Add orientation input support to the input manager.
  100477. * @returns the current input manager
  100478. */
  100479. addDeviceOrientation(): FreeCameraInputsManager;
  100480. }
  100481. /**
  100482. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  100483. * Screen rotation is taken into account.
  100484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100485. */
  100486. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  100487. private _camera;
  100488. private _screenOrientationAngle;
  100489. private _constantTranform;
  100490. private _screenQuaternion;
  100491. private _alpha;
  100492. private _beta;
  100493. private _gamma;
  100494. /**
  100495. * Can be used to detect if a device orientation sensor is availible on a device
  100496. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  100497. * @returns a promise that will resolve on orientation change
  100498. */
  100499. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  100500. /**
  100501. * @hidden
  100502. */
  100503. _onDeviceOrientationChangedObservable: Observable<void>;
  100504. /**
  100505. * Instantiates a new input
  100506. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100507. */
  100508. constructor();
  100509. /**
  100510. * Define the camera controlled by the input.
  100511. */
  100512. camera: FreeCamera;
  100513. /**
  100514. * Attach the input controls to a specific dom element to get the input from.
  100515. * @param element Defines the element the controls should be listened from
  100516. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100517. */
  100518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100519. private _orientationChanged;
  100520. private _deviceOrientation;
  100521. /**
  100522. * Detach the current controls from the specified dom element.
  100523. * @param element Defines the element to stop listening the inputs from
  100524. */
  100525. detachControl(element: Nullable<HTMLElement>): void;
  100526. /**
  100527. * Update the current camera state depending on the inputs that have been used this frame.
  100528. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100529. */
  100530. checkInputs(): void;
  100531. /**
  100532. * Gets the class name of the current intput.
  100533. * @returns the class name
  100534. */
  100535. getClassName(): string;
  100536. /**
  100537. * Get the friendly name associated with the input class.
  100538. * @returns the input friendly name
  100539. */
  100540. getSimpleName(): string;
  100541. }
  100542. }
  100543. declare module BABYLON {
  100544. /**
  100545. * Manage the gamepad inputs to control a free camera.
  100546. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100547. */
  100548. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  100549. /**
  100550. * Define the camera the input is attached to.
  100551. */
  100552. camera: FreeCamera;
  100553. /**
  100554. * Define the Gamepad controlling the input
  100555. */
  100556. gamepad: Nullable<Gamepad>;
  100557. /**
  100558. * Defines the gamepad rotation sensiblity.
  100559. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100560. */
  100561. gamepadAngularSensibility: number;
  100562. /**
  100563. * Defines the gamepad move sensiblity.
  100564. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100565. */
  100566. gamepadMoveSensibility: number;
  100567. private _onGamepadConnectedObserver;
  100568. private _onGamepadDisconnectedObserver;
  100569. private _cameraTransform;
  100570. private _deltaTransform;
  100571. private _vector3;
  100572. private _vector2;
  100573. /**
  100574. * Attach the input controls to a specific dom element to get the input from.
  100575. * @param element Defines the element the controls should be listened from
  100576. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100577. */
  100578. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100579. /**
  100580. * Detach the current controls from the specified dom element.
  100581. * @param element Defines the element to stop listening the inputs from
  100582. */
  100583. detachControl(element: Nullable<HTMLElement>): void;
  100584. /**
  100585. * Update the current camera state depending on the inputs that have been used this frame.
  100586. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100587. */
  100588. checkInputs(): void;
  100589. /**
  100590. * Gets the class name of the current intput.
  100591. * @returns the class name
  100592. */
  100593. getClassName(): string;
  100594. /**
  100595. * Get the friendly name associated with the input class.
  100596. * @returns the input friendly name
  100597. */
  100598. getSimpleName(): string;
  100599. }
  100600. }
  100601. declare module BABYLON {
  100602. /**
  100603. * Defines the potential axis of a Joystick
  100604. */
  100605. export enum JoystickAxis {
  100606. /** X axis */
  100607. X = 0,
  100608. /** Y axis */
  100609. Y = 1,
  100610. /** Z axis */
  100611. Z = 2
  100612. }
  100613. /**
  100614. * Class used to define virtual joystick (used in touch mode)
  100615. */
  100616. export class VirtualJoystick {
  100617. /**
  100618. * Gets or sets a boolean indicating that left and right values must be inverted
  100619. */
  100620. reverseLeftRight: boolean;
  100621. /**
  100622. * Gets or sets a boolean indicating that up and down values must be inverted
  100623. */
  100624. reverseUpDown: boolean;
  100625. /**
  100626. * Gets the offset value for the position (ie. the change of the position value)
  100627. */
  100628. deltaPosition: Vector3;
  100629. /**
  100630. * Gets a boolean indicating if the virtual joystick was pressed
  100631. */
  100632. pressed: boolean;
  100633. /**
  100634. * Canvas the virtual joystick will render onto, default z-index of this is 5
  100635. */
  100636. static Canvas: Nullable<HTMLCanvasElement>;
  100637. private static _globalJoystickIndex;
  100638. private static vjCanvasContext;
  100639. private static vjCanvasWidth;
  100640. private static vjCanvasHeight;
  100641. private static halfWidth;
  100642. private _action;
  100643. private _axisTargetedByLeftAndRight;
  100644. private _axisTargetedByUpAndDown;
  100645. private _joystickSensibility;
  100646. private _inversedSensibility;
  100647. private _joystickPointerID;
  100648. private _joystickColor;
  100649. private _joystickPointerPos;
  100650. private _joystickPreviousPointerPos;
  100651. private _joystickPointerStartPos;
  100652. private _deltaJoystickVector;
  100653. private _leftJoystick;
  100654. private _touches;
  100655. private _onPointerDownHandlerRef;
  100656. private _onPointerMoveHandlerRef;
  100657. private _onPointerUpHandlerRef;
  100658. private _onResize;
  100659. /**
  100660. * Creates a new virtual joystick
  100661. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100662. */
  100663. constructor(leftJoystick?: boolean);
  100664. /**
  100665. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100666. * @param newJoystickSensibility defines the new sensibility
  100667. */
  100668. setJoystickSensibility(newJoystickSensibility: number): void;
  100669. private _onPointerDown;
  100670. private _onPointerMove;
  100671. private _onPointerUp;
  100672. /**
  100673. * Change the color of the virtual joystick
  100674. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100675. */
  100676. setJoystickColor(newColor: string): void;
  100677. /**
  100678. * Defines a callback to call when the joystick is touched
  100679. * @param action defines the callback
  100680. */
  100681. setActionOnTouch(action: () => any): void;
  100682. /**
  100683. * Defines which axis you'd like to control for left & right
  100684. * @param axis defines the axis to use
  100685. */
  100686. setAxisForLeftRight(axis: JoystickAxis): void;
  100687. /**
  100688. * Defines which axis you'd like to control for up & down
  100689. * @param axis defines the axis to use
  100690. */
  100691. setAxisForUpDown(axis: JoystickAxis): void;
  100692. private _drawVirtualJoystick;
  100693. /**
  100694. * Release internal HTML canvas
  100695. */
  100696. releaseCanvas(): void;
  100697. }
  100698. }
  100699. declare module BABYLON {
  100700. interface FreeCameraInputsManager {
  100701. /**
  100702. * Add virtual joystick input support to the input manager.
  100703. * @returns the current input manager
  100704. */
  100705. addVirtualJoystick(): FreeCameraInputsManager;
  100706. }
  100707. /**
  100708. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  100709. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100710. */
  100711. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  100712. /**
  100713. * Defines the camera the input is attached to.
  100714. */
  100715. camera: FreeCamera;
  100716. private _leftjoystick;
  100717. private _rightjoystick;
  100718. /**
  100719. * Gets the left stick of the virtual joystick.
  100720. * @returns The virtual Joystick
  100721. */
  100722. getLeftJoystick(): VirtualJoystick;
  100723. /**
  100724. * Gets the right stick of the virtual joystick.
  100725. * @returns The virtual Joystick
  100726. */
  100727. getRightJoystick(): VirtualJoystick;
  100728. /**
  100729. * Update the current camera state depending on the inputs that have been used this frame.
  100730. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100731. */
  100732. checkInputs(): void;
  100733. /**
  100734. * Attach the input controls to a specific dom element to get the input from.
  100735. * @param element Defines the element the controls should be listened from
  100736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100737. */
  100738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100739. /**
  100740. * Detach the current controls from the specified dom element.
  100741. * @param element Defines the element to stop listening the inputs from
  100742. */
  100743. detachControl(element: Nullable<HTMLElement>): void;
  100744. /**
  100745. * Gets the class name of the current intput.
  100746. * @returns the class name
  100747. */
  100748. getClassName(): string;
  100749. /**
  100750. * Get the friendly name associated with the input class.
  100751. * @returns the input friendly name
  100752. */
  100753. getSimpleName(): string;
  100754. }
  100755. }
  100756. declare module BABYLON {
  100757. /**
  100758. * This represents a FPS type of camera controlled by touch.
  100759. * This is like a universal camera minus the Gamepad controls.
  100760. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100761. */
  100762. export class TouchCamera extends FreeCamera {
  100763. /**
  100764. * Defines the touch sensibility for rotation.
  100765. * The higher the faster.
  100766. */
  100767. touchAngularSensibility: number;
  100768. /**
  100769. * Defines the touch sensibility for move.
  100770. * The higher the faster.
  100771. */
  100772. touchMoveSensibility: number;
  100773. /**
  100774. * Instantiates a new touch camera.
  100775. * This represents a FPS type of camera controlled by touch.
  100776. * This is like a universal camera minus the Gamepad controls.
  100777. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100778. * @param name Define the name of the camera in the scene
  100779. * @param position Define the start position of the camera in the scene
  100780. * @param scene Define the scene the camera belongs to
  100781. */
  100782. constructor(name: string, position: Vector3, scene: Scene);
  100783. /**
  100784. * Gets the current object class name.
  100785. * @return the class name
  100786. */
  100787. getClassName(): string;
  100788. /** @hidden */
  100789. _setupInputs(): void;
  100790. }
  100791. }
  100792. declare module BABYLON {
  100793. /**
  100794. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  100795. * being tilted forward or back and left or right.
  100796. */
  100797. export class DeviceOrientationCamera extends FreeCamera {
  100798. private _initialQuaternion;
  100799. private _quaternionCache;
  100800. private _tmpDragQuaternion;
  100801. /**
  100802. * Creates a new device orientation camera
  100803. * @param name The name of the camera
  100804. * @param position The start position camera
  100805. * @param scene The scene the camera belongs to
  100806. */
  100807. constructor(name: string, position: Vector3, scene: Scene);
  100808. /**
  100809. * @hidden
  100810. * Disabled pointer input on first orientation sensor update (Default: true)
  100811. */
  100812. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  100813. private _dragFactor;
  100814. /**
  100815. * Enabled turning on the y axis when the orientation sensor is active
  100816. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  100817. */
  100818. enableHorizontalDragging(dragFactor?: number): void;
  100819. /**
  100820. * Gets the current instance class name ("DeviceOrientationCamera").
  100821. * This helps avoiding instanceof at run time.
  100822. * @returns the class name
  100823. */
  100824. getClassName(): string;
  100825. /**
  100826. * @hidden
  100827. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100828. */
  100829. _checkInputs(): void;
  100830. /**
  100831. * Reset the camera to its default orientation on the specified axis only.
  100832. * @param axis The axis to reset
  100833. */
  100834. resetToCurrentRotation(axis?: Axis): void;
  100835. }
  100836. }
  100837. declare module BABYLON {
  100838. /**
  100839. * Defines supported buttons for XBox360 compatible gamepads
  100840. */
  100841. export enum Xbox360Button {
  100842. /** A */
  100843. A = 0,
  100844. /** B */
  100845. B = 1,
  100846. /** X */
  100847. X = 2,
  100848. /** Y */
  100849. Y = 3,
  100850. /** Start */
  100851. Start = 4,
  100852. /** Back */
  100853. Back = 5,
  100854. /** Left button */
  100855. LB = 6,
  100856. /** Right button */
  100857. RB = 7,
  100858. /** Left stick */
  100859. LeftStick = 8,
  100860. /** Right stick */
  100861. RightStick = 9
  100862. }
  100863. /** Defines values for XBox360 DPad */
  100864. export enum Xbox360Dpad {
  100865. /** Up */
  100866. Up = 0,
  100867. /** Down */
  100868. Down = 1,
  100869. /** Left */
  100870. Left = 2,
  100871. /** Right */
  100872. Right = 3
  100873. }
  100874. /**
  100875. * Defines a XBox360 gamepad
  100876. */
  100877. export class Xbox360Pad extends Gamepad {
  100878. private _leftTrigger;
  100879. private _rightTrigger;
  100880. private _onlefttriggerchanged;
  100881. private _onrighttriggerchanged;
  100882. private _onbuttondown;
  100883. private _onbuttonup;
  100884. private _ondpaddown;
  100885. private _ondpadup;
  100886. /** Observable raised when a button is pressed */
  100887. onButtonDownObservable: Observable<Xbox360Button>;
  100888. /** Observable raised when a button is released */
  100889. onButtonUpObservable: Observable<Xbox360Button>;
  100890. /** Observable raised when a pad is pressed */
  100891. onPadDownObservable: Observable<Xbox360Dpad>;
  100892. /** Observable raised when a pad is released */
  100893. onPadUpObservable: Observable<Xbox360Dpad>;
  100894. private _buttonA;
  100895. private _buttonB;
  100896. private _buttonX;
  100897. private _buttonY;
  100898. private _buttonBack;
  100899. private _buttonStart;
  100900. private _buttonLB;
  100901. private _buttonRB;
  100902. private _buttonLeftStick;
  100903. private _buttonRightStick;
  100904. private _dPadUp;
  100905. private _dPadDown;
  100906. private _dPadLeft;
  100907. private _dPadRight;
  100908. private _isXboxOnePad;
  100909. /**
  100910. * Creates a new XBox360 gamepad object
  100911. * @param id defines the id of this gamepad
  100912. * @param index defines its index
  100913. * @param gamepad defines the internal HTML gamepad object
  100914. * @param xboxOne defines if it is a XBox One gamepad
  100915. */
  100916. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  100917. /**
  100918. * Defines the callback to call when left trigger is pressed
  100919. * @param callback defines the callback to use
  100920. */
  100921. onlefttriggerchanged(callback: (value: number) => void): void;
  100922. /**
  100923. * Defines the callback to call when right trigger is pressed
  100924. * @param callback defines the callback to use
  100925. */
  100926. onrighttriggerchanged(callback: (value: number) => void): void;
  100927. /**
  100928. * Gets the left trigger value
  100929. */
  100930. /**
  100931. * Sets the left trigger value
  100932. */
  100933. leftTrigger: number;
  100934. /**
  100935. * Gets the right trigger value
  100936. */
  100937. /**
  100938. * Sets the right trigger value
  100939. */
  100940. rightTrigger: number;
  100941. /**
  100942. * Defines the callback to call when a button is pressed
  100943. * @param callback defines the callback to use
  100944. */
  100945. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  100946. /**
  100947. * Defines the callback to call when a button is released
  100948. * @param callback defines the callback to use
  100949. */
  100950. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  100951. /**
  100952. * Defines the callback to call when a pad is pressed
  100953. * @param callback defines the callback to use
  100954. */
  100955. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  100956. /**
  100957. * Defines the callback to call when a pad is released
  100958. * @param callback defines the callback to use
  100959. */
  100960. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  100961. private _setButtonValue;
  100962. private _setDPadValue;
  100963. /**
  100964. * Gets the value of the `A` button
  100965. */
  100966. /**
  100967. * Sets the value of the `A` button
  100968. */
  100969. buttonA: number;
  100970. /**
  100971. * Gets the value of the `B` button
  100972. */
  100973. /**
  100974. * Sets the value of the `B` button
  100975. */
  100976. buttonB: number;
  100977. /**
  100978. * Gets the value of the `X` button
  100979. */
  100980. /**
  100981. * Sets the value of the `X` button
  100982. */
  100983. buttonX: number;
  100984. /**
  100985. * Gets the value of the `Y` button
  100986. */
  100987. /**
  100988. * Sets the value of the `Y` button
  100989. */
  100990. buttonY: number;
  100991. /**
  100992. * Gets the value of the `Start` button
  100993. */
  100994. /**
  100995. * Sets the value of the `Start` button
  100996. */
  100997. buttonStart: number;
  100998. /**
  100999. * Gets the value of the `Back` button
  101000. */
  101001. /**
  101002. * Sets the value of the `Back` button
  101003. */
  101004. buttonBack: number;
  101005. /**
  101006. * Gets the value of the `Left` button
  101007. */
  101008. /**
  101009. * Sets the value of the `Left` button
  101010. */
  101011. buttonLB: number;
  101012. /**
  101013. * Gets the value of the `Right` button
  101014. */
  101015. /**
  101016. * Sets the value of the `Right` button
  101017. */
  101018. buttonRB: number;
  101019. /**
  101020. * Gets the value of the Left joystick
  101021. */
  101022. /**
  101023. * Sets the value of the Left joystick
  101024. */
  101025. buttonLeftStick: number;
  101026. /**
  101027. * Gets the value of the Right joystick
  101028. */
  101029. /**
  101030. * Sets the value of the Right joystick
  101031. */
  101032. buttonRightStick: number;
  101033. /**
  101034. * Gets the value of D-pad up
  101035. */
  101036. /**
  101037. * Sets the value of D-pad up
  101038. */
  101039. dPadUp: number;
  101040. /**
  101041. * Gets the value of D-pad down
  101042. */
  101043. /**
  101044. * Sets the value of D-pad down
  101045. */
  101046. dPadDown: number;
  101047. /**
  101048. * Gets the value of D-pad left
  101049. */
  101050. /**
  101051. * Sets the value of D-pad left
  101052. */
  101053. dPadLeft: number;
  101054. /**
  101055. * Gets the value of D-pad right
  101056. */
  101057. /**
  101058. * Sets the value of D-pad right
  101059. */
  101060. dPadRight: number;
  101061. /**
  101062. * Force the gamepad to synchronize with device values
  101063. */
  101064. update(): void;
  101065. /**
  101066. * Disposes the gamepad
  101067. */
  101068. dispose(): void;
  101069. }
  101070. }
  101071. declare module BABYLON {
  101072. /**
  101073. * Manager for handling gamepads
  101074. */
  101075. export class GamepadManager {
  101076. private _scene?;
  101077. private _babylonGamepads;
  101078. private _oneGamepadConnected;
  101079. /** @hidden */
  101080. _isMonitoring: boolean;
  101081. private _gamepadEventSupported;
  101082. private _gamepadSupport;
  101083. /**
  101084. * observable to be triggered when the gamepad controller has been connected
  101085. */
  101086. onGamepadConnectedObservable: Observable<Gamepad>;
  101087. /**
  101088. * observable to be triggered when the gamepad controller has been disconnected
  101089. */
  101090. onGamepadDisconnectedObservable: Observable<Gamepad>;
  101091. private _onGamepadConnectedEvent;
  101092. private _onGamepadDisconnectedEvent;
  101093. /**
  101094. * Initializes the gamepad manager
  101095. * @param _scene BabylonJS scene
  101096. */
  101097. constructor(_scene?: Scene | undefined);
  101098. /**
  101099. * The gamepads in the game pad manager
  101100. */
  101101. readonly gamepads: Gamepad[];
  101102. /**
  101103. * Get the gamepad controllers based on type
  101104. * @param type The type of gamepad controller
  101105. * @returns Nullable gamepad
  101106. */
  101107. getGamepadByType(type?: number): Nullable<Gamepad>;
  101108. /**
  101109. * Disposes the gamepad manager
  101110. */
  101111. dispose(): void;
  101112. private _addNewGamepad;
  101113. private _startMonitoringGamepads;
  101114. private _stopMonitoringGamepads;
  101115. /** @hidden */
  101116. _checkGamepadsStatus(): void;
  101117. private _updateGamepadObjects;
  101118. }
  101119. }
  101120. declare module BABYLON {
  101121. interface Scene {
  101122. /** @hidden */
  101123. _gamepadManager: Nullable<GamepadManager>;
  101124. /**
  101125. * Gets the gamepad manager associated with the scene
  101126. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  101127. */
  101128. gamepadManager: GamepadManager;
  101129. }
  101130. /**
  101131. * Interface representing a free camera inputs manager
  101132. */
  101133. interface FreeCameraInputsManager {
  101134. /**
  101135. * Adds gamepad input support to the FreeCameraInputsManager.
  101136. * @returns the FreeCameraInputsManager
  101137. */
  101138. addGamepad(): FreeCameraInputsManager;
  101139. }
  101140. /**
  101141. * Interface representing an arc rotate camera inputs manager
  101142. */
  101143. interface ArcRotateCameraInputsManager {
  101144. /**
  101145. * Adds gamepad input support to the ArcRotateCamera InputManager.
  101146. * @returns the camera inputs manager
  101147. */
  101148. addGamepad(): ArcRotateCameraInputsManager;
  101149. }
  101150. /**
  101151. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  101152. */
  101153. export class GamepadSystemSceneComponent implements ISceneComponent {
  101154. /**
  101155. * The component name helpfull to identify the component in the list of scene components.
  101156. */
  101157. readonly name: string;
  101158. /**
  101159. * The scene the component belongs to.
  101160. */
  101161. scene: Scene;
  101162. /**
  101163. * Creates a new instance of the component for the given scene
  101164. * @param scene Defines the scene to register the component in
  101165. */
  101166. constructor(scene: Scene);
  101167. /**
  101168. * Registers the component in a given scene
  101169. */
  101170. register(): void;
  101171. /**
  101172. * Rebuilds the elements related to this component in case of
  101173. * context lost for instance.
  101174. */
  101175. rebuild(): void;
  101176. /**
  101177. * Disposes the component and the associated ressources
  101178. */
  101179. dispose(): void;
  101180. private _beforeCameraUpdate;
  101181. }
  101182. }
  101183. declare module BABYLON {
  101184. /**
  101185. * 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,
  101186. * which still works and will still be found in many Playgrounds.
  101187. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101188. */
  101189. export class UniversalCamera extends TouchCamera {
  101190. /**
  101191. * Defines the gamepad rotation sensiblity.
  101192. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101193. */
  101194. gamepadAngularSensibility: number;
  101195. /**
  101196. * Defines the gamepad move sensiblity.
  101197. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101198. */
  101199. gamepadMoveSensibility: number;
  101200. /**
  101201. * 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,
  101202. * which still works and will still be found in many Playgrounds.
  101203. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101204. * @param name Define the name of the camera in the scene
  101205. * @param position Define the start position of the camera in the scene
  101206. * @param scene Define the scene the camera belongs to
  101207. */
  101208. constructor(name: string, position: Vector3, scene: Scene);
  101209. /**
  101210. * Gets the current object class name.
  101211. * @return the class name
  101212. */
  101213. getClassName(): string;
  101214. }
  101215. }
  101216. declare module BABYLON {
  101217. /**
  101218. * This represents a FPS type of camera. This is only here for back compat purpose.
  101219. * Please use the UniversalCamera instead as both are identical.
  101220. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101221. */
  101222. export class GamepadCamera extends UniversalCamera {
  101223. /**
  101224. * Instantiates a new Gamepad Camera
  101225. * This represents a FPS type of camera. This is only here for back compat purpose.
  101226. * Please use the UniversalCamera instead as both are identical.
  101227. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101228. * @param name Define the name of the camera in the scene
  101229. * @param position Define the start position of the camera in the scene
  101230. * @param scene Define the scene the camera belongs to
  101231. */
  101232. constructor(name: string, position: Vector3, scene: Scene);
  101233. /**
  101234. * Gets the current object class name.
  101235. * @return the class name
  101236. */
  101237. getClassName(): string;
  101238. }
  101239. }
  101240. declare module BABYLON {
  101241. /** @hidden */
  101242. export var passPixelShader: {
  101243. name: string;
  101244. shader: string;
  101245. };
  101246. }
  101247. declare module BABYLON {
  101248. /** @hidden */
  101249. export var passCubePixelShader: {
  101250. name: string;
  101251. shader: string;
  101252. };
  101253. }
  101254. declare module BABYLON {
  101255. /**
  101256. * PassPostProcess which produces an output the same as it's input
  101257. */
  101258. export class PassPostProcess extends PostProcess {
  101259. /**
  101260. * Creates the PassPostProcess
  101261. * @param name The name of the effect.
  101262. * @param options The required width/height ratio to downsize to before computing the render pass.
  101263. * @param camera The camera to apply the render pass to.
  101264. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101265. * @param engine The engine which the post process will be applied. (default: current engine)
  101266. * @param reusable If the post process can be reused on the same frame. (default: false)
  101267. * @param textureType The type of texture to be used when performing the post processing.
  101268. * @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)
  101269. */
  101270. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101271. }
  101272. /**
  101273. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  101274. */
  101275. export class PassCubePostProcess extends PostProcess {
  101276. private _face;
  101277. /**
  101278. * Gets or sets the cube face to display.
  101279. * * 0 is +X
  101280. * * 1 is -X
  101281. * * 2 is +Y
  101282. * * 3 is -Y
  101283. * * 4 is +Z
  101284. * * 5 is -Z
  101285. */
  101286. face: number;
  101287. /**
  101288. * Creates the PassCubePostProcess
  101289. * @param name The name of the effect.
  101290. * @param options The required width/height ratio to downsize to before computing the render pass.
  101291. * @param camera The camera to apply the render pass to.
  101292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101293. * @param engine The engine which the post process will be applied. (default: current engine)
  101294. * @param reusable If the post process can be reused on the same frame. (default: false)
  101295. * @param textureType The type of texture to be used when performing the post processing.
  101296. * @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)
  101297. */
  101298. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101299. }
  101300. }
  101301. declare module BABYLON {
  101302. /** @hidden */
  101303. export var anaglyphPixelShader: {
  101304. name: string;
  101305. shader: string;
  101306. };
  101307. }
  101308. declare module BABYLON {
  101309. /**
  101310. * Postprocess used to generate anaglyphic rendering
  101311. */
  101312. export class AnaglyphPostProcess extends PostProcess {
  101313. private _passedProcess;
  101314. /**
  101315. * Creates a new AnaglyphPostProcess
  101316. * @param name defines postprocess name
  101317. * @param options defines creation options or target ratio scale
  101318. * @param rigCameras defines cameras using this postprocess
  101319. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  101320. * @param engine defines hosting engine
  101321. * @param reusable defines if the postprocess will be reused multiple times per frame
  101322. */
  101323. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  101324. }
  101325. }
  101326. declare module BABYLON {
  101327. /**
  101328. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  101329. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101330. */
  101331. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  101332. /**
  101333. * Creates a new AnaglyphArcRotateCamera
  101334. * @param name defines camera name
  101335. * @param alpha defines alpha angle (in radians)
  101336. * @param beta defines beta angle (in radians)
  101337. * @param radius defines radius
  101338. * @param target defines camera target
  101339. * @param interaxialDistance defines distance between each color axis
  101340. * @param scene defines the hosting scene
  101341. */
  101342. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  101343. /**
  101344. * Gets camera class name
  101345. * @returns AnaglyphArcRotateCamera
  101346. */
  101347. getClassName(): string;
  101348. }
  101349. }
  101350. declare module BABYLON {
  101351. /**
  101352. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  101353. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101354. */
  101355. export class AnaglyphFreeCamera extends FreeCamera {
  101356. /**
  101357. * Creates a new AnaglyphFreeCamera
  101358. * @param name defines camera name
  101359. * @param position defines initial position
  101360. * @param interaxialDistance defines distance between each color axis
  101361. * @param scene defines the hosting scene
  101362. */
  101363. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101364. /**
  101365. * Gets camera class name
  101366. * @returns AnaglyphFreeCamera
  101367. */
  101368. getClassName(): string;
  101369. }
  101370. }
  101371. declare module BABYLON {
  101372. /**
  101373. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  101374. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101375. */
  101376. export class AnaglyphGamepadCamera extends GamepadCamera {
  101377. /**
  101378. * Creates a new AnaglyphGamepadCamera
  101379. * @param name defines camera name
  101380. * @param position defines initial position
  101381. * @param interaxialDistance defines distance between each color axis
  101382. * @param scene defines the hosting scene
  101383. */
  101384. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101385. /**
  101386. * Gets camera class name
  101387. * @returns AnaglyphGamepadCamera
  101388. */
  101389. getClassName(): string;
  101390. }
  101391. }
  101392. declare module BABYLON {
  101393. /**
  101394. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  101395. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101396. */
  101397. export class AnaglyphUniversalCamera extends UniversalCamera {
  101398. /**
  101399. * Creates a new AnaglyphUniversalCamera
  101400. * @param name defines camera name
  101401. * @param position defines initial position
  101402. * @param interaxialDistance defines distance between each color axis
  101403. * @param scene defines the hosting scene
  101404. */
  101405. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101406. /**
  101407. * Gets camera class name
  101408. * @returns AnaglyphUniversalCamera
  101409. */
  101410. getClassName(): string;
  101411. }
  101412. }
  101413. declare module BABYLON {
  101414. /** @hidden */
  101415. export var stereoscopicInterlacePixelShader: {
  101416. name: string;
  101417. shader: string;
  101418. };
  101419. }
  101420. declare module BABYLON {
  101421. /**
  101422. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  101423. */
  101424. export class StereoscopicInterlacePostProcess extends PostProcess {
  101425. private _stepSize;
  101426. private _passedProcess;
  101427. /**
  101428. * Initializes a StereoscopicInterlacePostProcess
  101429. * @param name The name of the effect.
  101430. * @param rigCameras The rig cameras to be appled to the post process
  101431. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  101432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101433. * @param engine The engine which the post process will be applied. (default: current engine)
  101434. * @param reusable If the post process can be reused on the same frame. (default: false)
  101435. */
  101436. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  101437. }
  101438. }
  101439. declare module BABYLON {
  101440. /**
  101441. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  101442. * @see http://doc.babylonjs.com/features/cameras
  101443. */
  101444. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  101445. /**
  101446. * Creates a new StereoscopicArcRotateCamera
  101447. * @param name defines camera name
  101448. * @param alpha defines alpha angle (in radians)
  101449. * @param beta defines beta angle (in radians)
  101450. * @param radius defines radius
  101451. * @param target defines camera target
  101452. * @param interaxialDistance defines distance between each color axis
  101453. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101454. * @param scene defines the hosting scene
  101455. */
  101456. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101457. /**
  101458. * Gets camera class name
  101459. * @returns StereoscopicArcRotateCamera
  101460. */
  101461. getClassName(): string;
  101462. }
  101463. }
  101464. declare module BABYLON {
  101465. /**
  101466. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  101467. * @see http://doc.babylonjs.com/features/cameras
  101468. */
  101469. export class StereoscopicFreeCamera extends FreeCamera {
  101470. /**
  101471. * Creates a new StereoscopicFreeCamera
  101472. * @param name defines camera name
  101473. * @param position defines initial position
  101474. * @param interaxialDistance defines distance between each color axis
  101475. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101476. * @param scene defines the hosting scene
  101477. */
  101478. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101479. /**
  101480. * Gets camera class name
  101481. * @returns StereoscopicFreeCamera
  101482. */
  101483. getClassName(): string;
  101484. }
  101485. }
  101486. declare module BABYLON {
  101487. /**
  101488. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  101489. * @see http://doc.babylonjs.com/features/cameras
  101490. */
  101491. export class StereoscopicGamepadCamera extends GamepadCamera {
  101492. /**
  101493. * Creates a new StereoscopicGamepadCamera
  101494. * @param name defines camera name
  101495. * @param position defines initial position
  101496. * @param interaxialDistance defines distance between each color axis
  101497. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101498. * @param scene defines the hosting scene
  101499. */
  101500. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101501. /**
  101502. * Gets camera class name
  101503. * @returns StereoscopicGamepadCamera
  101504. */
  101505. getClassName(): string;
  101506. }
  101507. }
  101508. declare module BABYLON {
  101509. /**
  101510. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  101511. * @see http://doc.babylonjs.com/features/cameras
  101512. */
  101513. export class StereoscopicUniversalCamera extends UniversalCamera {
  101514. /**
  101515. * Creates a new StereoscopicUniversalCamera
  101516. * @param name defines camera name
  101517. * @param position defines initial position
  101518. * @param interaxialDistance defines distance between each color axis
  101519. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101520. * @param scene defines the hosting scene
  101521. */
  101522. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101523. /**
  101524. * Gets camera class name
  101525. * @returns StereoscopicUniversalCamera
  101526. */
  101527. getClassName(): string;
  101528. }
  101529. }
  101530. declare module BABYLON {
  101531. /**
  101532. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  101533. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101534. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101535. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101536. */
  101537. export class VirtualJoysticksCamera extends FreeCamera {
  101538. /**
  101539. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  101540. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101541. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101542. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101543. * @param name Define the name of the camera in the scene
  101544. * @param position Define the start position of the camera in the scene
  101545. * @param scene Define the scene the camera belongs to
  101546. */
  101547. constructor(name: string, position: Vector3, scene: Scene);
  101548. /**
  101549. * Gets the current object class name.
  101550. * @return the class name
  101551. */
  101552. getClassName(): string;
  101553. }
  101554. }
  101555. declare module BABYLON {
  101556. /**
  101557. * This represents all the required metrics to create a VR camera.
  101558. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  101559. */
  101560. export class VRCameraMetrics {
  101561. /**
  101562. * Define the horizontal resolution off the screen.
  101563. */
  101564. hResolution: number;
  101565. /**
  101566. * Define the vertical resolution off the screen.
  101567. */
  101568. vResolution: number;
  101569. /**
  101570. * Define the horizontal screen size.
  101571. */
  101572. hScreenSize: number;
  101573. /**
  101574. * Define the vertical screen size.
  101575. */
  101576. vScreenSize: number;
  101577. /**
  101578. * Define the vertical screen center position.
  101579. */
  101580. vScreenCenter: number;
  101581. /**
  101582. * Define the distance of the eyes to the screen.
  101583. */
  101584. eyeToScreenDistance: number;
  101585. /**
  101586. * Define the distance between both lenses
  101587. */
  101588. lensSeparationDistance: number;
  101589. /**
  101590. * Define the distance between both viewer's eyes.
  101591. */
  101592. interpupillaryDistance: number;
  101593. /**
  101594. * Define the distortion factor of the VR postprocess.
  101595. * Please, touch with care.
  101596. */
  101597. distortionK: number[];
  101598. /**
  101599. * Define the chromatic aberration correction factors for the VR post process.
  101600. */
  101601. chromaAbCorrection: number[];
  101602. /**
  101603. * Define the scale factor of the post process.
  101604. * The smaller the better but the slower.
  101605. */
  101606. postProcessScaleFactor: number;
  101607. /**
  101608. * Define an offset for the lens center.
  101609. */
  101610. lensCenterOffset: number;
  101611. /**
  101612. * Define if the current vr camera should compensate the distortion of the lense or not.
  101613. */
  101614. compensateDistortion: boolean;
  101615. /**
  101616. * Defines if multiview should be enabled when rendering (Default: false)
  101617. */
  101618. multiviewEnabled: boolean;
  101619. /**
  101620. * Gets the rendering aspect ratio based on the provided resolutions.
  101621. */
  101622. readonly aspectRatio: number;
  101623. /**
  101624. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  101625. */
  101626. readonly aspectRatioFov: number;
  101627. /**
  101628. * @hidden
  101629. */
  101630. readonly leftHMatrix: Matrix;
  101631. /**
  101632. * @hidden
  101633. */
  101634. readonly rightHMatrix: Matrix;
  101635. /**
  101636. * @hidden
  101637. */
  101638. readonly leftPreViewMatrix: Matrix;
  101639. /**
  101640. * @hidden
  101641. */
  101642. readonly rightPreViewMatrix: Matrix;
  101643. /**
  101644. * Get the default VRMetrics based on the most generic setup.
  101645. * @returns the default vr metrics
  101646. */
  101647. static GetDefault(): VRCameraMetrics;
  101648. }
  101649. }
  101650. declare module BABYLON {
  101651. /** @hidden */
  101652. export var vrDistortionCorrectionPixelShader: {
  101653. name: string;
  101654. shader: string;
  101655. };
  101656. }
  101657. declare module BABYLON {
  101658. /**
  101659. * VRDistortionCorrectionPostProcess used for mobile VR
  101660. */
  101661. export class VRDistortionCorrectionPostProcess extends PostProcess {
  101662. private _isRightEye;
  101663. private _distortionFactors;
  101664. private _postProcessScaleFactor;
  101665. private _lensCenterOffset;
  101666. private _scaleIn;
  101667. private _scaleFactor;
  101668. private _lensCenter;
  101669. /**
  101670. * Initializes the VRDistortionCorrectionPostProcess
  101671. * @param name The name of the effect.
  101672. * @param camera The camera to apply the render pass to.
  101673. * @param isRightEye If this is for the right eye distortion
  101674. * @param vrMetrics All the required metrics for the VR camera
  101675. */
  101676. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  101677. }
  101678. }
  101679. declare module BABYLON {
  101680. /**
  101681. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  101682. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101683. */
  101684. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  101685. /**
  101686. * Creates a new VRDeviceOrientationArcRotateCamera
  101687. * @param name defines camera name
  101688. * @param alpha defines the camera rotation along the logitudinal axis
  101689. * @param beta defines the camera rotation along the latitudinal axis
  101690. * @param radius defines the camera distance from its target
  101691. * @param target defines the camera target
  101692. * @param scene defines the scene the camera belongs to
  101693. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101694. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101695. */
  101696. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101697. /**
  101698. * Gets camera class name
  101699. * @returns VRDeviceOrientationArcRotateCamera
  101700. */
  101701. getClassName(): string;
  101702. }
  101703. }
  101704. declare module BABYLON {
  101705. /**
  101706. * Camera used to simulate VR rendering (based on FreeCamera)
  101707. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101708. */
  101709. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  101710. /**
  101711. * Creates a new VRDeviceOrientationFreeCamera
  101712. * @param name defines camera name
  101713. * @param position defines the start position of the camera
  101714. * @param scene defines the scene the camera belongs to
  101715. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101716. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101717. */
  101718. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101719. /**
  101720. * Gets camera class name
  101721. * @returns VRDeviceOrientationFreeCamera
  101722. */
  101723. getClassName(): string;
  101724. }
  101725. }
  101726. declare module BABYLON {
  101727. /**
  101728. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  101729. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101730. */
  101731. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  101732. /**
  101733. * Creates a new VRDeviceOrientationGamepadCamera
  101734. * @param name defines camera name
  101735. * @param position defines the start position of the camera
  101736. * @param scene defines the scene the camera belongs to
  101737. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101738. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101739. */
  101740. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101741. /**
  101742. * Gets camera class name
  101743. * @returns VRDeviceOrientationGamepadCamera
  101744. */
  101745. getClassName(): string;
  101746. }
  101747. }
  101748. declare module BABYLON {
  101749. /**
  101750. * Base class of materials working in push mode in babylon JS
  101751. * @hidden
  101752. */
  101753. export class PushMaterial extends Material {
  101754. protected _activeEffect: Effect;
  101755. protected _normalMatrix: Matrix;
  101756. /**
  101757. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  101758. * This means that the material can keep using a previous shader while a new one is being compiled.
  101759. * This is mostly used when shader parallel compilation is supported (true by default)
  101760. */
  101761. allowShaderHotSwapping: boolean;
  101762. constructor(name: string, scene: Scene);
  101763. getEffect(): Effect;
  101764. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101765. /**
  101766. * Binds the given world matrix to the active effect
  101767. *
  101768. * @param world the matrix to bind
  101769. */
  101770. bindOnlyWorldMatrix(world: Matrix): void;
  101771. /**
  101772. * Binds the given normal matrix to the active effect
  101773. *
  101774. * @param normalMatrix the matrix to bind
  101775. */
  101776. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101777. bind(world: Matrix, mesh?: Mesh): void;
  101778. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101779. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101780. }
  101781. }
  101782. declare module BABYLON {
  101783. /**
  101784. * This groups all the flags used to control the materials channel.
  101785. */
  101786. export class MaterialFlags {
  101787. private static _DiffuseTextureEnabled;
  101788. /**
  101789. * Are diffuse textures enabled in the application.
  101790. */
  101791. static DiffuseTextureEnabled: boolean;
  101792. private static _AmbientTextureEnabled;
  101793. /**
  101794. * Are ambient textures enabled in the application.
  101795. */
  101796. static AmbientTextureEnabled: boolean;
  101797. private static _OpacityTextureEnabled;
  101798. /**
  101799. * Are opacity textures enabled in the application.
  101800. */
  101801. static OpacityTextureEnabled: boolean;
  101802. private static _ReflectionTextureEnabled;
  101803. /**
  101804. * Are reflection textures enabled in the application.
  101805. */
  101806. static ReflectionTextureEnabled: boolean;
  101807. private static _EmissiveTextureEnabled;
  101808. /**
  101809. * Are emissive textures enabled in the application.
  101810. */
  101811. static EmissiveTextureEnabled: boolean;
  101812. private static _SpecularTextureEnabled;
  101813. /**
  101814. * Are specular textures enabled in the application.
  101815. */
  101816. static SpecularTextureEnabled: boolean;
  101817. private static _BumpTextureEnabled;
  101818. /**
  101819. * Are bump textures enabled in the application.
  101820. */
  101821. static BumpTextureEnabled: boolean;
  101822. private static _LightmapTextureEnabled;
  101823. /**
  101824. * Are lightmap textures enabled in the application.
  101825. */
  101826. static LightmapTextureEnabled: boolean;
  101827. private static _RefractionTextureEnabled;
  101828. /**
  101829. * Are refraction textures enabled in the application.
  101830. */
  101831. static RefractionTextureEnabled: boolean;
  101832. private static _ColorGradingTextureEnabled;
  101833. /**
  101834. * Are color grading textures enabled in the application.
  101835. */
  101836. static ColorGradingTextureEnabled: boolean;
  101837. private static _FresnelEnabled;
  101838. /**
  101839. * Are fresnels enabled in the application.
  101840. */
  101841. static FresnelEnabled: boolean;
  101842. private static _ClearCoatTextureEnabled;
  101843. /**
  101844. * Are clear coat textures enabled in the application.
  101845. */
  101846. static ClearCoatTextureEnabled: boolean;
  101847. private static _ClearCoatBumpTextureEnabled;
  101848. /**
  101849. * Are clear coat bump textures enabled in the application.
  101850. */
  101851. static ClearCoatBumpTextureEnabled: boolean;
  101852. private static _ClearCoatTintTextureEnabled;
  101853. /**
  101854. * Are clear coat tint textures enabled in the application.
  101855. */
  101856. static ClearCoatTintTextureEnabled: boolean;
  101857. private static _SheenTextureEnabled;
  101858. /**
  101859. * Are sheen textures enabled in the application.
  101860. */
  101861. static SheenTextureEnabled: boolean;
  101862. private static _AnisotropicTextureEnabled;
  101863. /**
  101864. * Are anisotropic textures enabled in the application.
  101865. */
  101866. static AnisotropicTextureEnabled: boolean;
  101867. private static _ThicknessTextureEnabled;
  101868. /**
  101869. * Are thickness textures enabled in the application.
  101870. */
  101871. static ThicknessTextureEnabled: boolean;
  101872. }
  101873. }
  101874. declare module BABYLON {
  101875. /** @hidden */
  101876. export var defaultFragmentDeclaration: {
  101877. name: string;
  101878. shader: string;
  101879. };
  101880. }
  101881. declare module BABYLON {
  101882. /** @hidden */
  101883. export var defaultUboDeclaration: {
  101884. name: string;
  101885. shader: string;
  101886. };
  101887. }
  101888. declare module BABYLON {
  101889. /** @hidden */
  101890. export var lightFragmentDeclaration: {
  101891. name: string;
  101892. shader: string;
  101893. };
  101894. }
  101895. declare module BABYLON {
  101896. /** @hidden */
  101897. export var lightUboDeclaration: {
  101898. name: string;
  101899. shader: string;
  101900. };
  101901. }
  101902. declare module BABYLON {
  101903. /** @hidden */
  101904. export var lightsFragmentFunctions: {
  101905. name: string;
  101906. shader: string;
  101907. };
  101908. }
  101909. declare module BABYLON {
  101910. /** @hidden */
  101911. export var shadowsFragmentFunctions: {
  101912. name: string;
  101913. shader: string;
  101914. };
  101915. }
  101916. declare module BABYLON {
  101917. /** @hidden */
  101918. export var fresnelFunction: {
  101919. name: string;
  101920. shader: string;
  101921. };
  101922. }
  101923. declare module BABYLON {
  101924. /** @hidden */
  101925. export var reflectionFunction: {
  101926. name: string;
  101927. shader: string;
  101928. };
  101929. }
  101930. declare module BABYLON {
  101931. /** @hidden */
  101932. export var bumpFragmentFunctions: {
  101933. name: string;
  101934. shader: string;
  101935. };
  101936. }
  101937. declare module BABYLON {
  101938. /** @hidden */
  101939. export var logDepthDeclaration: {
  101940. name: string;
  101941. shader: string;
  101942. };
  101943. }
  101944. declare module BABYLON {
  101945. /** @hidden */
  101946. export var bumpFragment: {
  101947. name: string;
  101948. shader: string;
  101949. };
  101950. }
  101951. declare module BABYLON {
  101952. /** @hidden */
  101953. export var depthPrePass: {
  101954. name: string;
  101955. shader: string;
  101956. };
  101957. }
  101958. declare module BABYLON {
  101959. /** @hidden */
  101960. export var lightFragment: {
  101961. name: string;
  101962. shader: string;
  101963. };
  101964. }
  101965. declare module BABYLON {
  101966. /** @hidden */
  101967. export var logDepthFragment: {
  101968. name: string;
  101969. shader: string;
  101970. };
  101971. }
  101972. declare module BABYLON {
  101973. /** @hidden */
  101974. export var defaultPixelShader: {
  101975. name: string;
  101976. shader: string;
  101977. };
  101978. }
  101979. declare module BABYLON {
  101980. /** @hidden */
  101981. export var defaultVertexDeclaration: {
  101982. name: string;
  101983. shader: string;
  101984. };
  101985. }
  101986. declare module BABYLON {
  101987. /** @hidden */
  101988. export var bumpVertexDeclaration: {
  101989. name: string;
  101990. shader: string;
  101991. };
  101992. }
  101993. declare module BABYLON {
  101994. /** @hidden */
  101995. export var bumpVertex: {
  101996. name: string;
  101997. shader: string;
  101998. };
  101999. }
  102000. declare module BABYLON {
  102001. /** @hidden */
  102002. export var fogVertex: {
  102003. name: string;
  102004. shader: string;
  102005. };
  102006. }
  102007. declare module BABYLON {
  102008. /** @hidden */
  102009. export var shadowsVertex: {
  102010. name: string;
  102011. shader: string;
  102012. };
  102013. }
  102014. declare module BABYLON {
  102015. /** @hidden */
  102016. export var pointCloudVertex: {
  102017. name: string;
  102018. shader: string;
  102019. };
  102020. }
  102021. declare module BABYLON {
  102022. /** @hidden */
  102023. export var logDepthVertex: {
  102024. name: string;
  102025. shader: string;
  102026. };
  102027. }
  102028. declare module BABYLON {
  102029. /** @hidden */
  102030. export var defaultVertexShader: {
  102031. name: string;
  102032. shader: string;
  102033. };
  102034. }
  102035. declare module BABYLON {
  102036. /** @hidden */
  102037. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102038. MAINUV1: boolean;
  102039. MAINUV2: boolean;
  102040. DIFFUSE: boolean;
  102041. DIFFUSEDIRECTUV: number;
  102042. AMBIENT: boolean;
  102043. AMBIENTDIRECTUV: number;
  102044. OPACITY: boolean;
  102045. OPACITYDIRECTUV: number;
  102046. OPACITYRGB: boolean;
  102047. REFLECTION: boolean;
  102048. EMISSIVE: boolean;
  102049. EMISSIVEDIRECTUV: number;
  102050. SPECULAR: boolean;
  102051. SPECULARDIRECTUV: number;
  102052. BUMP: boolean;
  102053. BUMPDIRECTUV: number;
  102054. PARALLAX: boolean;
  102055. PARALLAXOCCLUSION: boolean;
  102056. SPECULAROVERALPHA: boolean;
  102057. CLIPPLANE: boolean;
  102058. CLIPPLANE2: boolean;
  102059. CLIPPLANE3: boolean;
  102060. CLIPPLANE4: boolean;
  102061. ALPHATEST: boolean;
  102062. DEPTHPREPASS: boolean;
  102063. ALPHAFROMDIFFUSE: boolean;
  102064. POINTSIZE: boolean;
  102065. FOG: boolean;
  102066. SPECULARTERM: boolean;
  102067. DIFFUSEFRESNEL: boolean;
  102068. OPACITYFRESNEL: boolean;
  102069. REFLECTIONFRESNEL: boolean;
  102070. REFRACTIONFRESNEL: boolean;
  102071. EMISSIVEFRESNEL: boolean;
  102072. FRESNEL: boolean;
  102073. NORMAL: boolean;
  102074. UV1: boolean;
  102075. UV2: boolean;
  102076. VERTEXCOLOR: boolean;
  102077. VERTEXALPHA: boolean;
  102078. NUM_BONE_INFLUENCERS: number;
  102079. BonesPerMesh: number;
  102080. BONETEXTURE: boolean;
  102081. INSTANCES: boolean;
  102082. GLOSSINESS: boolean;
  102083. ROUGHNESS: boolean;
  102084. EMISSIVEASILLUMINATION: boolean;
  102085. LINKEMISSIVEWITHDIFFUSE: boolean;
  102086. REFLECTIONFRESNELFROMSPECULAR: boolean;
  102087. LIGHTMAP: boolean;
  102088. LIGHTMAPDIRECTUV: number;
  102089. OBJECTSPACE_NORMALMAP: boolean;
  102090. USELIGHTMAPASSHADOWMAP: boolean;
  102091. REFLECTIONMAP_3D: boolean;
  102092. REFLECTIONMAP_SPHERICAL: boolean;
  102093. REFLECTIONMAP_PLANAR: boolean;
  102094. REFLECTIONMAP_CUBIC: boolean;
  102095. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102096. REFLECTIONMAP_PROJECTION: boolean;
  102097. REFLECTIONMAP_SKYBOX: boolean;
  102098. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  102099. REFLECTIONMAP_EXPLICIT: boolean;
  102100. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102101. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102102. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102103. INVERTCUBICMAP: boolean;
  102104. LOGARITHMICDEPTH: boolean;
  102105. REFRACTION: boolean;
  102106. REFRACTIONMAP_3D: boolean;
  102107. REFLECTIONOVERALPHA: boolean;
  102108. TWOSIDEDLIGHTING: boolean;
  102109. SHADOWFLOAT: boolean;
  102110. MORPHTARGETS: boolean;
  102111. MORPHTARGETS_NORMAL: boolean;
  102112. MORPHTARGETS_TANGENT: boolean;
  102113. MORPHTARGETS_UV: boolean;
  102114. NUM_MORPH_INFLUENCERS: number;
  102115. NONUNIFORMSCALING: boolean;
  102116. PREMULTIPLYALPHA: boolean;
  102117. IMAGEPROCESSING: boolean;
  102118. VIGNETTE: boolean;
  102119. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102120. VIGNETTEBLENDMODEOPAQUE: boolean;
  102121. TONEMAPPING: boolean;
  102122. TONEMAPPING_ACES: boolean;
  102123. CONTRAST: boolean;
  102124. COLORCURVES: boolean;
  102125. COLORGRADING: boolean;
  102126. COLORGRADING3D: boolean;
  102127. SAMPLER3DGREENDEPTH: boolean;
  102128. SAMPLER3DBGRMAP: boolean;
  102129. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102130. MULTIVIEW: boolean;
  102131. /**
  102132. * If the reflection texture on this material is in linear color space
  102133. * @hidden
  102134. */
  102135. IS_REFLECTION_LINEAR: boolean;
  102136. /**
  102137. * If the refraction texture on this material is in linear color space
  102138. * @hidden
  102139. */
  102140. IS_REFRACTION_LINEAR: boolean;
  102141. EXPOSURE: boolean;
  102142. constructor();
  102143. setReflectionMode(modeToEnable: string): void;
  102144. }
  102145. /**
  102146. * This is the default material used in Babylon. It is the best trade off between quality
  102147. * and performances.
  102148. * @see http://doc.babylonjs.com/babylon101/materials
  102149. */
  102150. export class StandardMaterial extends PushMaterial {
  102151. private _diffuseTexture;
  102152. /**
  102153. * The basic texture of the material as viewed under a light.
  102154. */
  102155. diffuseTexture: Nullable<BaseTexture>;
  102156. private _ambientTexture;
  102157. /**
  102158. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  102159. */
  102160. ambientTexture: Nullable<BaseTexture>;
  102161. private _opacityTexture;
  102162. /**
  102163. * Define the transparency of the material from a texture.
  102164. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  102165. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  102166. */
  102167. opacityTexture: Nullable<BaseTexture>;
  102168. private _reflectionTexture;
  102169. /**
  102170. * Define the texture used to display the reflection.
  102171. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102172. */
  102173. reflectionTexture: Nullable<BaseTexture>;
  102174. private _emissiveTexture;
  102175. /**
  102176. * Define texture of the material as if self lit.
  102177. * This will be mixed in the final result even in the absence of light.
  102178. */
  102179. emissiveTexture: Nullable<BaseTexture>;
  102180. private _specularTexture;
  102181. /**
  102182. * Define how the color and intensity of the highlight given by the light in the material.
  102183. */
  102184. specularTexture: Nullable<BaseTexture>;
  102185. private _bumpTexture;
  102186. /**
  102187. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  102188. * 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.
  102189. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  102190. */
  102191. bumpTexture: Nullable<BaseTexture>;
  102192. private _lightmapTexture;
  102193. /**
  102194. * Complex lighting can be computationally expensive to compute at runtime.
  102195. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  102196. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  102197. */
  102198. lightmapTexture: Nullable<BaseTexture>;
  102199. private _refractionTexture;
  102200. /**
  102201. * Define the texture used to display the refraction.
  102202. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102203. */
  102204. refractionTexture: Nullable<BaseTexture>;
  102205. /**
  102206. * The color of the material lit by the environmental background lighting.
  102207. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  102208. */
  102209. ambientColor: Color3;
  102210. /**
  102211. * The basic color of the material as viewed under a light.
  102212. */
  102213. diffuseColor: Color3;
  102214. /**
  102215. * Define how the color and intensity of the highlight given by the light in the material.
  102216. */
  102217. specularColor: Color3;
  102218. /**
  102219. * Define the color of the material as if self lit.
  102220. * This will be mixed in the final result even in the absence of light.
  102221. */
  102222. emissiveColor: Color3;
  102223. /**
  102224. * Defines how sharp are the highlights in the material.
  102225. * The bigger the value the sharper giving a more glossy feeling to the result.
  102226. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  102227. */
  102228. specularPower: number;
  102229. private _useAlphaFromDiffuseTexture;
  102230. /**
  102231. * Does the transparency come from the diffuse texture alpha channel.
  102232. */
  102233. useAlphaFromDiffuseTexture: boolean;
  102234. private _useEmissiveAsIllumination;
  102235. /**
  102236. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  102237. */
  102238. useEmissiveAsIllumination: boolean;
  102239. private _linkEmissiveWithDiffuse;
  102240. /**
  102241. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  102242. * the emissive level when the final color is close to one.
  102243. */
  102244. linkEmissiveWithDiffuse: boolean;
  102245. private _useSpecularOverAlpha;
  102246. /**
  102247. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102248. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102249. */
  102250. useSpecularOverAlpha: boolean;
  102251. private _useReflectionOverAlpha;
  102252. /**
  102253. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102254. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102255. */
  102256. useReflectionOverAlpha: boolean;
  102257. private _disableLighting;
  102258. /**
  102259. * Does lights from the scene impacts this material.
  102260. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  102261. */
  102262. disableLighting: boolean;
  102263. private _useObjectSpaceNormalMap;
  102264. /**
  102265. * Allows using an object space normal map (instead of tangent space).
  102266. */
  102267. useObjectSpaceNormalMap: boolean;
  102268. private _useParallax;
  102269. /**
  102270. * Is parallax enabled or not.
  102271. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102272. */
  102273. useParallax: boolean;
  102274. private _useParallaxOcclusion;
  102275. /**
  102276. * Is parallax occlusion enabled or not.
  102277. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  102278. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102279. */
  102280. useParallaxOcclusion: boolean;
  102281. /**
  102282. * 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.
  102283. */
  102284. parallaxScaleBias: number;
  102285. private _roughness;
  102286. /**
  102287. * Helps to define how blurry the reflections should appears in the material.
  102288. */
  102289. roughness: number;
  102290. /**
  102291. * In case of refraction, define the value of the index of refraction.
  102292. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102293. */
  102294. indexOfRefraction: number;
  102295. /**
  102296. * Invert the refraction texture alongside the y axis.
  102297. * It can be useful with procedural textures or probe for instance.
  102298. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102299. */
  102300. invertRefractionY: boolean;
  102301. /**
  102302. * Defines the alpha limits in alpha test mode.
  102303. */
  102304. alphaCutOff: number;
  102305. private _useLightmapAsShadowmap;
  102306. /**
  102307. * In case of light mapping, define whether the map contains light or shadow informations.
  102308. */
  102309. useLightmapAsShadowmap: boolean;
  102310. private _diffuseFresnelParameters;
  102311. /**
  102312. * Define the diffuse fresnel parameters of the material.
  102313. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102314. */
  102315. diffuseFresnelParameters: FresnelParameters;
  102316. private _opacityFresnelParameters;
  102317. /**
  102318. * Define the opacity fresnel parameters of the material.
  102319. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102320. */
  102321. opacityFresnelParameters: FresnelParameters;
  102322. private _reflectionFresnelParameters;
  102323. /**
  102324. * Define the reflection fresnel parameters of the material.
  102325. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102326. */
  102327. reflectionFresnelParameters: FresnelParameters;
  102328. private _refractionFresnelParameters;
  102329. /**
  102330. * Define the refraction fresnel parameters of the material.
  102331. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102332. */
  102333. refractionFresnelParameters: FresnelParameters;
  102334. private _emissiveFresnelParameters;
  102335. /**
  102336. * Define the emissive fresnel parameters of the material.
  102337. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102338. */
  102339. emissiveFresnelParameters: FresnelParameters;
  102340. private _useReflectionFresnelFromSpecular;
  102341. /**
  102342. * If true automatically deducts the fresnels values from the material specularity.
  102343. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102344. */
  102345. useReflectionFresnelFromSpecular: boolean;
  102346. private _useGlossinessFromSpecularMapAlpha;
  102347. /**
  102348. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  102349. */
  102350. useGlossinessFromSpecularMapAlpha: boolean;
  102351. private _maxSimultaneousLights;
  102352. /**
  102353. * Defines the maximum number of lights that can be used in the material
  102354. */
  102355. maxSimultaneousLights: number;
  102356. private _invertNormalMapX;
  102357. /**
  102358. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102359. */
  102360. invertNormalMapX: boolean;
  102361. private _invertNormalMapY;
  102362. /**
  102363. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102364. */
  102365. invertNormalMapY: boolean;
  102366. private _twoSidedLighting;
  102367. /**
  102368. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102369. */
  102370. twoSidedLighting: boolean;
  102371. /**
  102372. * Default configuration related to image processing available in the standard Material.
  102373. */
  102374. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102375. /**
  102376. * Gets the image processing configuration used either in this material.
  102377. */
  102378. /**
  102379. * Sets the Default image processing configuration used either in the this material.
  102380. *
  102381. * If sets to null, the scene one is in use.
  102382. */
  102383. imageProcessingConfiguration: ImageProcessingConfiguration;
  102384. /**
  102385. * Keep track of the image processing observer to allow dispose and replace.
  102386. */
  102387. private _imageProcessingObserver;
  102388. /**
  102389. * Attaches a new image processing configuration to the Standard Material.
  102390. * @param configuration
  102391. */
  102392. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102393. /**
  102394. * Gets wether the color curves effect is enabled.
  102395. */
  102396. /**
  102397. * Sets wether the color curves effect is enabled.
  102398. */
  102399. cameraColorCurvesEnabled: boolean;
  102400. /**
  102401. * Gets wether the color grading effect is enabled.
  102402. */
  102403. /**
  102404. * Gets wether the color grading effect is enabled.
  102405. */
  102406. cameraColorGradingEnabled: boolean;
  102407. /**
  102408. * Gets wether tonemapping is enabled or not.
  102409. */
  102410. /**
  102411. * Sets wether tonemapping is enabled or not
  102412. */
  102413. cameraToneMappingEnabled: boolean;
  102414. /**
  102415. * The camera exposure used on this material.
  102416. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102417. * This corresponds to a photographic exposure.
  102418. */
  102419. /**
  102420. * The camera exposure used on this material.
  102421. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102422. * This corresponds to a photographic exposure.
  102423. */
  102424. cameraExposure: number;
  102425. /**
  102426. * Gets The camera contrast used on this material.
  102427. */
  102428. /**
  102429. * Sets The camera contrast used on this material.
  102430. */
  102431. cameraContrast: number;
  102432. /**
  102433. * Gets the Color Grading 2D Lookup Texture.
  102434. */
  102435. /**
  102436. * Sets the Color Grading 2D Lookup Texture.
  102437. */
  102438. cameraColorGradingTexture: Nullable<BaseTexture>;
  102439. /**
  102440. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102441. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102442. * 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;
  102443. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102444. */
  102445. /**
  102446. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102447. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102448. * 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;
  102449. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102450. */
  102451. cameraColorCurves: Nullable<ColorCurves>;
  102452. /**
  102453. * Custom callback helping to override the default shader used in the material.
  102454. */
  102455. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  102456. protected _renderTargets: SmartArray<RenderTargetTexture>;
  102457. protected _worldViewProjectionMatrix: Matrix;
  102458. protected _globalAmbientColor: Color3;
  102459. protected _useLogarithmicDepth: boolean;
  102460. /**
  102461. * Instantiates a new standard material.
  102462. * This is the default material used in Babylon. It is the best trade off between quality
  102463. * and performances.
  102464. * @see http://doc.babylonjs.com/babylon101/materials
  102465. * @param name Define the name of the material in the scene
  102466. * @param scene Define the scene the material belong to
  102467. */
  102468. constructor(name: string, scene: Scene);
  102469. /**
  102470. * Gets a boolean indicating that current material needs to register RTT
  102471. */
  102472. readonly hasRenderTargetTextures: boolean;
  102473. /**
  102474. * Gets the current class name of the material e.g. "StandardMaterial"
  102475. * Mainly use in serialization.
  102476. * @returns the class name
  102477. */
  102478. getClassName(): string;
  102479. /**
  102480. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  102481. * You can try switching to logarithmic depth.
  102482. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  102483. */
  102484. useLogarithmicDepth: boolean;
  102485. /**
  102486. * Specifies if the material will require alpha blending
  102487. * @returns a boolean specifying if alpha blending is needed
  102488. */
  102489. needAlphaBlending(): boolean;
  102490. /**
  102491. * Specifies if this material should be rendered in alpha test mode
  102492. * @returns a boolean specifying if an alpha test is needed.
  102493. */
  102494. needAlphaTesting(): boolean;
  102495. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  102496. /**
  102497. * Get the texture used for alpha test purpose.
  102498. * @returns the diffuse texture in case of the standard material.
  102499. */
  102500. getAlphaTestTexture(): Nullable<BaseTexture>;
  102501. /**
  102502. * Get if the submesh is ready to be used and all its information available.
  102503. * Child classes can use it to update shaders
  102504. * @param mesh defines the mesh to check
  102505. * @param subMesh defines which submesh to check
  102506. * @param useInstances specifies that instances should be used
  102507. * @returns a boolean indicating that the submesh is ready or not
  102508. */
  102509. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102510. /**
  102511. * Builds the material UBO layouts.
  102512. * Used internally during the effect preparation.
  102513. */
  102514. buildUniformLayout(): void;
  102515. /**
  102516. * Unbinds the material from the mesh
  102517. */
  102518. unbind(): void;
  102519. /**
  102520. * Binds the submesh to this material by preparing the effect and shader to draw
  102521. * @param world defines the world transformation matrix
  102522. * @param mesh defines the mesh containing the submesh
  102523. * @param subMesh defines the submesh to bind the material to
  102524. */
  102525. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102526. /**
  102527. * Get the list of animatables in the material.
  102528. * @returns the list of animatables object used in the material
  102529. */
  102530. getAnimatables(): IAnimatable[];
  102531. /**
  102532. * Gets the active textures from the material
  102533. * @returns an array of textures
  102534. */
  102535. getActiveTextures(): BaseTexture[];
  102536. /**
  102537. * Specifies if the material uses a texture
  102538. * @param texture defines the texture to check against the material
  102539. * @returns a boolean specifying if the material uses the texture
  102540. */
  102541. hasTexture(texture: BaseTexture): boolean;
  102542. /**
  102543. * Disposes the material
  102544. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102545. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102546. */
  102547. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102548. /**
  102549. * Makes a duplicate of the material, and gives it a new name
  102550. * @param name defines the new name for the duplicated material
  102551. * @returns the cloned material
  102552. */
  102553. clone(name: string): StandardMaterial;
  102554. /**
  102555. * Serializes this material in a JSON representation
  102556. * @returns the serialized material object
  102557. */
  102558. serialize(): any;
  102559. /**
  102560. * Creates a standard material from parsed material data
  102561. * @param source defines the JSON representation of the material
  102562. * @param scene defines the hosting scene
  102563. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102564. * @returns a new standard material
  102565. */
  102566. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  102567. /**
  102568. * Are diffuse textures enabled in the application.
  102569. */
  102570. static DiffuseTextureEnabled: boolean;
  102571. /**
  102572. * Are ambient textures enabled in the application.
  102573. */
  102574. static AmbientTextureEnabled: boolean;
  102575. /**
  102576. * Are opacity textures enabled in the application.
  102577. */
  102578. static OpacityTextureEnabled: boolean;
  102579. /**
  102580. * Are reflection textures enabled in the application.
  102581. */
  102582. static ReflectionTextureEnabled: boolean;
  102583. /**
  102584. * Are emissive textures enabled in the application.
  102585. */
  102586. static EmissiveTextureEnabled: boolean;
  102587. /**
  102588. * Are specular textures enabled in the application.
  102589. */
  102590. static SpecularTextureEnabled: boolean;
  102591. /**
  102592. * Are bump textures enabled in the application.
  102593. */
  102594. static BumpTextureEnabled: boolean;
  102595. /**
  102596. * Are lightmap textures enabled in the application.
  102597. */
  102598. static LightmapTextureEnabled: boolean;
  102599. /**
  102600. * Are refraction textures enabled in the application.
  102601. */
  102602. static RefractionTextureEnabled: boolean;
  102603. /**
  102604. * Are color grading textures enabled in the application.
  102605. */
  102606. static ColorGradingTextureEnabled: boolean;
  102607. /**
  102608. * Are fresnels enabled in the application.
  102609. */
  102610. static FresnelEnabled: boolean;
  102611. }
  102612. }
  102613. declare module BABYLON {
  102614. /**
  102615. * A class extending Texture allowing drawing on a texture
  102616. * @see http://doc.babylonjs.com/how_to/dynamictexture
  102617. */
  102618. export class DynamicTexture extends Texture {
  102619. private _generateMipMaps;
  102620. private _canvas;
  102621. private _context;
  102622. private _engine;
  102623. /**
  102624. * Creates a DynamicTexture
  102625. * @param name defines the name of the texture
  102626. * @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
  102627. * @param scene defines the scene where you want the texture
  102628. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  102629. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  102630. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  102631. */
  102632. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  102633. /**
  102634. * Get the current class name of the texture useful for serialization or dynamic coding.
  102635. * @returns "DynamicTexture"
  102636. */
  102637. getClassName(): string;
  102638. /**
  102639. * Gets the current state of canRescale
  102640. */
  102641. readonly canRescale: boolean;
  102642. private _recreate;
  102643. /**
  102644. * Scales the texture
  102645. * @param ratio the scale factor to apply to both width and height
  102646. */
  102647. scale(ratio: number): void;
  102648. /**
  102649. * Resizes the texture
  102650. * @param width the new width
  102651. * @param height the new height
  102652. */
  102653. scaleTo(width: number, height: number): void;
  102654. /**
  102655. * Gets the context of the canvas used by the texture
  102656. * @returns the canvas context of the dynamic texture
  102657. */
  102658. getContext(): CanvasRenderingContext2D;
  102659. /**
  102660. * Clears the texture
  102661. */
  102662. clear(): void;
  102663. /**
  102664. * Updates the texture
  102665. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102666. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  102667. */
  102668. update(invertY?: boolean, premulAlpha?: boolean): void;
  102669. /**
  102670. * Draws text onto the texture
  102671. * @param text defines the text to be drawn
  102672. * @param x defines the placement of the text from the left
  102673. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  102674. * @param font defines the font to be used with font-style, font-size, font-name
  102675. * @param color defines the color used for the text
  102676. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  102677. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102678. * @param update defines whether texture is immediately update (default is true)
  102679. */
  102680. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  102681. /**
  102682. * Clones the texture
  102683. * @returns the clone of the texture.
  102684. */
  102685. clone(): DynamicTexture;
  102686. /**
  102687. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  102688. * @returns a serialized dynamic texture object
  102689. */
  102690. serialize(): any;
  102691. /** @hidden */
  102692. _rebuild(): void;
  102693. }
  102694. }
  102695. declare module BABYLON {
  102696. /** @hidden */
  102697. export var imageProcessingPixelShader: {
  102698. name: string;
  102699. shader: string;
  102700. };
  102701. }
  102702. declare module BABYLON {
  102703. /**
  102704. * ImageProcessingPostProcess
  102705. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102706. */
  102707. export class ImageProcessingPostProcess extends PostProcess {
  102708. /**
  102709. * Default configuration related to image processing available in the PBR Material.
  102710. */
  102711. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102712. /**
  102713. * Gets the image processing configuration used either in this material.
  102714. */
  102715. /**
  102716. * Sets the Default image processing configuration used either in the this material.
  102717. *
  102718. * If sets to null, the scene one is in use.
  102719. */
  102720. imageProcessingConfiguration: ImageProcessingConfiguration;
  102721. /**
  102722. * Keep track of the image processing observer to allow dispose and replace.
  102723. */
  102724. private _imageProcessingObserver;
  102725. /**
  102726. * Attaches a new image processing configuration to the PBR Material.
  102727. * @param configuration
  102728. */
  102729. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102730. /**
  102731. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102732. */
  102733. /**
  102734. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102735. */
  102736. colorCurves: Nullable<ColorCurves>;
  102737. /**
  102738. * Gets wether the color curves effect is enabled.
  102739. */
  102740. /**
  102741. * Sets wether the color curves effect is enabled.
  102742. */
  102743. colorCurvesEnabled: boolean;
  102744. /**
  102745. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102746. */
  102747. /**
  102748. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102749. */
  102750. colorGradingTexture: Nullable<BaseTexture>;
  102751. /**
  102752. * Gets wether the color grading effect is enabled.
  102753. */
  102754. /**
  102755. * Gets wether the color grading effect is enabled.
  102756. */
  102757. colorGradingEnabled: boolean;
  102758. /**
  102759. * Gets exposure used in the effect.
  102760. */
  102761. /**
  102762. * Sets exposure used in the effect.
  102763. */
  102764. exposure: number;
  102765. /**
  102766. * Gets wether tonemapping is enabled or not.
  102767. */
  102768. /**
  102769. * Sets wether tonemapping is enabled or not
  102770. */
  102771. toneMappingEnabled: boolean;
  102772. /**
  102773. * Gets the type of tone mapping effect.
  102774. */
  102775. /**
  102776. * Sets the type of tone mapping effect.
  102777. */
  102778. toneMappingType: number;
  102779. /**
  102780. * Gets contrast used in the effect.
  102781. */
  102782. /**
  102783. * Sets contrast used in the effect.
  102784. */
  102785. contrast: number;
  102786. /**
  102787. * Gets Vignette stretch size.
  102788. */
  102789. /**
  102790. * Sets Vignette stretch size.
  102791. */
  102792. vignetteStretch: number;
  102793. /**
  102794. * Gets Vignette centre X Offset.
  102795. */
  102796. /**
  102797. * Sets Vignette centre X Offset.
  102798. */
  102799. vignetteCentreX: number;
  102800. /**
  102801. * Gets Vignette centre Y Offset.
  102802. */
  102803. /**
  102804. * Sets Vignette centre Y Offset.
  102805. */
  102806. vignetteCentreY: number;
  102807. /**
  102808. * Gets Vignette weight or intensity of the vignette effect.
  102809. */
  102810. /**
  102811. * Sets Vignette weight or intensity of the vignette effect.
  102812. */
  102813. vignetteWeight: number;
  102814. /**
  102815. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102816. * if vignetteEnabled is set to true.
  102817. */
  102818. /**
  102819. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102820. * if vignetteEnabled is set to true.
  102821. */
  102822. vignetteColor: Color4;
  102823. /**
  102824. * Gets Camera field of view used by the Vignette effect.
  102825. */
  102826. /**
  102827. * Sets Camera field of view used by the Vignette effect.
  102828. */
  102829. vignetteCameraFov: number;
  102830. /**
  102831. * Gets the vignette blend mode allowing different kind of effect.
  102832. */
  102833. /**
  102834. * Sets the vignette blend mode allowing different kind of effect.
  102835. */
  102836. vignetteBlendMode: number;
  102837. /**
  102838. * Gets wether the vignette effect is enabled.
  102839. */
  102840. /**
  102841. * Sets wether the vignette effect is enabled.
  102842. */
  102843. vignetteEnabled: boolean;
  102844. private _fromLinearSpace;
  102845. /**
  102846. * Gets wether the input of the processing is in Gamma or Linear Space.
  102847. */
  102848. /**
  102849. * Sets wether the input of the processing is in Gamma or Linear Space.
  102850. */
  102851. fromLinearSpace: boolean;
  102852. /**
  102853. * Defines cache preventing GC.
  102854. */
  102855. private _defines;
  102856. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102857. /**
  102858. * "ImageProcessingPostProcess"
  102859. * @returns "ImageProcessingPostProcess"
  102860. */
  102861. getClassName(): string;
  102862. protected _updateParameters(): void;
  102863. dispose(camera?: Camera): void;
  102864. }
  102865. }
  102866. declare module BABYLON {
  102867. /**
  102868. * Class containing static functions to help procedurally build meshes
  102869. */
  102870. export class GroundBuilder {
  102871. /**
  102872. * Creates a ground mesh
  102873. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102874. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102876. * @param name defines the name of the mesh
  102877. * @param options defines the options used to create the mesh
  102878. * @param scene defines the hosting scene
  102879. * @returns the ground mesh
  102880. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102881. */
  102882. static CreateGround(name: string, options: {
  102883. width?: number;
  102884. height?: number;
  102885. subdivisions?: number;
  102886. subdivisionsX?: number;
  102887. subdivisionsY?: number;
  102888. updatable?: boolean;
  102889. }, scene: any): Mesh;
  102890. /**
  102891. * Creates a tiled ground mesh
  102892. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102893. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102894. * * 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
  102895. * * 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
  102896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102897. * @param name defines the name of the mesh
  102898. * @param options defines the options used to create the mesh
  102899. * @param scene defines the hosting scene
  102900. * @returns the tiled ground mesh
  102901. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102902. */
  102903. static CreateTiledGround(name: string, options: {
  102904. xmin: number;
  102905. zmin: number;
  102906. xmax: number;
  102907. zmax: number;
  102908. subdivisions?: {
  102909. w: number;
  102910. h: number;
  102911. };
  102912. precision?: {
  102913. w: number;
  102914. h: number;
  102915. };
  102916. updatable?: boolean;
  102917. }, scene?: Nullable<Scene>): Mesh;
  102918. /**
  102919. * Creates a ground mesh from a height map
  102920. * * The parameter `url` sets the URL of the height map image resource.
  102921. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  102922. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  102923. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  102924. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  102925. * * 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.
  102926. * * 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).
  102927. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  102928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102929. * @param name defines the name of the mesh
  102930. * @param url defines the url to the height map
  102931. * @param options defines the options used to create the mesh
  102932. * @param scene defines the hosting scene
  102933. * @returns the ground mesh
  102934. * @see https://doc.babylonjs.com/babylon101/height_map
  102935. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  102936. */
  102937. static CreateGroundFromHeightMap(name: string, url: string, options: {
  102938. width?: number;
  102939. height?: number;
  102940. subdivisions?: number;
  102941. minHeight?: number;
  102942. maxHeight?: number;
  102943. colorFilter?: Color3;
  102944. alphaFilter?: number;
  102945. updatable?: boolean;
  102946. onReady?: (mesh: GroundMesh) => void;
  102947. }, scene?: Nullable<Scene>): GroundMesh;
  102948. }
  102949. }
  102950. declare module BABYLON {
  102951. /**
  102952. * Class containing static functions to help procedurally build meshes
  102953. */
  102954. export class TorusBuilder {
  102955. /**
  102956. * Creates a torus mesh
  102957. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  102958. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  102959. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  102960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102963. * @param name defines the name of the mesh
  102964. * @param options defines the options used to create the mesh
  102965. * @param scene defines the hosting scene
  102966. * @returns the torus mesh
  102967. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  102968. */
  102969. static CreateTorus(name: string, options: {
  102970. diameter?: number;
  102971. thickness?: number;
  102972. tessellation?: number;
  102973. updatable?: boolean;
  102974. sideOrientation?: number;
  102975. frontUVs?: Vector4;
  102976. backUVs?: Vector4;
  102977. }, scene: any): Mesh;
  102978. }
  102979. }
  102980. declare module BABYLON {
  102981. /**
  102982. * Class containing static functions to help procedurally build meshes
  102983. */
  102984. export class CylinderBuilder {
  102985. /**
  102986. * Creates a cylinder or a cone mesh
  102987. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  102988. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  102989. * * 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.
  102990. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  102991. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  102992. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  102993. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  102994. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  102995. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  102996. * * 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).
  102997. * * 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
  102998. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  102999. * * 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
  103000. * * 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.
  103001. * * If `enclose` is false, a ring surface is one element.
  103002. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  103003. * * 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
  103004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103007. * @param name defines the name of the mesh
  103008. * @param options defines the options used to create the mesh
  103009. * @param scene defines the hosting scene
  103010. * @returns the cylinder mesh
  103011. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  103012. */
  103013. static CreateCylinder(name: string, options: {
  103014. height?: number;
  103015. diameterTop?: number;
  103016. diameterBottom?: number;
  103017. diameter?: number;
  103018. tessellation?: number;
  103019. subdivisions?: number;
  103020. arc?: number;
  103021. faceColors?: Color4[];
  103022. faceUV?: Vector4[];
  103023. updatable?: boolean;
  103024. hasRings?: boolean;
  103025. enclose?: boolean;
  103026. cap?: number;
  103027. sideOrientation?: number;
  103028. frontUVs?: Vector4;
  103029. backUVs?: Vector4;
  103030. }, scene: any): Mesh;
  103031. }
  103032. }
  103033. declare module BABYLON {
  103034. /**
  103035. * Options to modify the vr teleportation behavior.
  103036. */
  103037. export interface VRTeleportationOptions {
  103038. /**
  103039. * The name of the mesh which should be used as the teleportation floor. (default: null)
  103040. */
  103041. floorMeshName?: string;
  103042. /**
  103043. * A list of meshes to be used as the teleportation floor. (default: empty)
  103044. */
  103045. floorMeshes?: Mesh[];
  103046. }
  103047. /**
  103048. * Options to modify the vr experience helper's behavior.
  103049. */
  103050. export interface VRExperienceHelperOptions extends WebVROptions {
  103051. /**
  103052. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  103053. */
  103054. createDeviceOrientationCamera?: boolean;
  103055. /**
  103056. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  103057. */
  103058. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  103059. /**
  103060. * Uses the main button on the controller to toggle the laser casted. (default: true)
  103061. */
  103062. laserToggle?: boolean;
  103063. /**
  103064. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  103065. */
  103066. floorMeshes?: Mesh[];
  103067. /**
  103068. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  103069. */
  103070. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  103071. }
  103072. /**
  103073. * Event containing information after VR has been entered
  103074. */
  103075. export class OnAfterEnteringVRObservableEvent {
  103076. /**
  103077. * If entering vr was successful
  103078. */
  103079. success: boolean;
  103080. }
  103081. /**
  103082. * Helps to quickly add VR support to an existing scene.
  103083. * See http://doc.babylonjs.com/how_to/webvr_helper
  103084. */
  103085. export class VRExperienceHelper {
  103086. /** Options to modify the vr experience helper's behavior. */
  103087. webVROptions: VRExperienceHelperOptions;
  103088. private _scene;
  103089. private _position;
  103090. private _btnVR;
  103091. private _btnVRDisplayed;
  103092. private _webVRsupported;
  103093. private _webVRready;
  103094. private _webVRrequesting;
  103095. private _webVRpresenting;
  103096. private _hasEnteredVR;
  103097. private _fullscreenVRpresenting;
  103098. private _canvas;
  103099. private _webVRCamera;
  103100. private _vrDeviceOrientationCamera;
  103101. private _deviceOrientationCamera;
  103102. private _existingCamera;
  103103. private _onKeyDown;
  103104. private _onVrDisplayPresentChange;
  103105. private _onVRDisplayChanged;
  103106. private _onVRRequestPresentStart;
  103107. private _onVRRequestPresentComplete;
  103108. /**
  103109. * Observable raised right before entering VR.
  103110. */
  103111. onEnteringVRObservable: Observable<VRExperienceHelper>;
  103112. /**
  103113. * Observable raised when entering VR has completed.
  103114. */
  103115. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  103116. /**
  103117. * Observable raised when exiting VR.
  103118. */
  103119. onExitingVRObservable: Observable<VRExperienceHelper>;
  103120. /**
  103121. * Observable raised when controller mesh is loaded.
  103122. */
  103123. onControllerMeshLoadedObservable: Observable<WebVRController>;
  103124. /** Return this.onEnteringVRObservable
  103125. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  103126. */
  103127. readonly onEnteringVR: Observable<VRExperienceHelper>;
  103128. /** Return this.onExitingVRObservable
  103129. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  103130. */
  103131. readonly onExitingVR: Observable<VRExperienceHelper>;
  103132. /** Return this.onControllerMeshLoadedObservable
  103133. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  103134. */
  103135. readonly onControllerMeshLoaded: Observable<WebVRController>;
  103136. private _rayLength;
  103137. private _useCustomVRButton;
  103138. private _teleportationRequested;
  103139. private _teleportActive;
  103140. private _floorMeshName;
  103141. private _floorMeshesCollection;
  103142. private _rotationAllowed;
  103143. private _teleportBackwardsVector;
  103144. private _teleportationTarget;
  103145. private _isDefaultTeleportationTarget;
  103146. private _postProcessMove;
  103147. private _teleportationFillColor;
  103148. private _teleportationBorderColor;
  103149. private _rotationAngle;
  103150. private _haloCenter;
  103151. private _cameraGazer;
  103152. private _padSensibilityUp;
  103153. private _padSensibilityDown;
  103154. private _leftController;
  103155. private _rightController;
  103156. /**
  103157. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  103158. */
  103159. onNewMeshSelected: Observable<AbstractMesh>;
  103160. /**
  103161. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  103162. */
  103163. onNewMeshPicked: Observable<PickingInfo>;
  103164. private _circleEase;
  103165. /**
  103166. * Observable raised before camera teleportation
  103167. */
  103168. onBeforeCameraTeleport: Observable<Vector3>;
  103169. /**
  103170. * Observable raised after camera teleportation
  103171. */
  103172. onAfterCameraTeleport: Observable<Vector3>;
  103173. /**
  103174. * Observable raised when current selected mesh gets unselected
  103175. */
  103176. onSelectedMeshUnselected: Observable<AbstractMesh>;
  103177. private _raySelectionPredicate;
  103178. /**
  103179. * To be optionaly changed by user to define custom ray selection
  103180. */
  103181. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  103182. /**
  103183. * To be optionaly changed by user to define custom selection logic (after ray selection)
  103184. */
  103185. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103186. /**
  103187. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  103188. */
  103189. teleportationEnabled: boolean;
  103190. private _defaultHeight;
  103191. private _teleportationInitialized;
  103192. private _interactionsEnabled;
  103193. private _interactionsRequested;
  103194. private _displayGaze;
  103195. private _displayLaserPointer;
  103196. /**
  103197. * The mesh used to display where the user is going to teleport.
  103198. */
  103199. /**
  103200. * Sets the mesh to be used to display where the user is going to teleport.
  103201. */
  103202. teleportationTarget: Mesh;
  103203. /**
  103204. * 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
  103205. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  103206. * See http://doc.babylonjs.com/resources/baking_transformations
  103207. */
  103208. gazeTrackerMesh: Mesh;
  103209. /**
  103210. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  103211. */
  103212. updateGazeTrackerScale: boolean;
  103213. /**
  103214. * If the gaze trackers color should be updated when selecting meshes
  103215. */
  103216. updateGazeTrackerColor: boolean;
  103217. /**
  103218. * The gaze tracking mesh corresponding to the left controller
  103219. */
  103220. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  103221. /**
  103222. * The gaze tracking mesh corresponding to the right controller
  103223. */
  103224. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  103225. /**
  103226. * If the ray of the gaze should be displayed.
  103227. */
  103228. /**
  103229. * Sets if the ray of the gaze should be displayed.
  103230. */
  103231. displayGaze: boolean;
  103232. /**
  103233. * If the ray of the LaserPointer should be displayed.
  103234. */
  103235. /**
  103236. * Sets if the ray of the LaserPointer should be displayed.
  103237. */
  103238. displayLaserPointer: boolean;
  103239. /**
  103240. * The deviceOrientationCamera used as the camera when not in VR.
  103241. */
  103242. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  103243. /**
  103244. * Based on the current WebVR support, returns the current VR camera used.
  103245. */
  103246. readonly currentVRCamera: Nullable<Camera>;
  103247. /**
  103248. * The webVRCamera which is used when in VR.
  103249. */
  103250. readonly webVRCamera: WebVRFreeCamera;
  103251. /**
  103252. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  103253. */
  103254. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  103255. private readonly _teleportationRequestInitiated;
  103256. /**
  103257. * Defines wether or not Pointer lock should be requested when switching to
  103258. * full screen.
  103259. */
  103260. requestPointerLockOnFullScreen: boolean;
  103261. /**
  103262. * Instantiates a VRExperienceHelper.
  103263. * Helps to quickly add VR support to an existing scene.
  103264. * @param scene The scene the VRExperienceHelper belongs to.
  103265. * @param webVROptions Options to modify the vr experience helper's behavior.
  103266. */
  103267. constructor(scene: Scene,
  103268. /** Options to modify the vr experience helper's behavior. */
  103269. webVROptions?: VRExperienceHelperOptions);
  103270. private _onDefaultMeshLoaded;
  103271. private _onResize;
  103272. private _onFullscreenChange;
  103273. /**
  103274. * Gets a value indicating if we are currently in VR mode.
  103275. */
  103276. readonly isInVRMode: boolean;
  103277. private onVrDisplayPresentChange;
  103278. private onVRDisplayChanged;
  103279. private moveButtonToBottomRight;
  103280. private displayVRButton;
  103281. private updateButtonVisibility;
  103282. private _cachedAngularSensibility;
  103283. /**
  103284. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  103285. * Otherwise, will use the fullscreen API.
  103286. */
  103287. enterVR(): void;
  103288. /**
  103289. * Attempt to exit VR, or fullscreen.
  103290. */
  103291. exitVR(): void;
  103292. /**
  103293. * The position of the vr experience helper.
  103294. */
  103295. /**
  103296. * Sets the position of the vr experience helper.
  103297. */
  103298. position: Vector3;
  103299. /**
  103300. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  103301. */
  103302. enableInteractions(): void;
  103303. private readonly _noControllerIsActive;
  103304. private beforeRender;
  103305. private _isTeleportationFloor;
  103306. /**
  103307. * Adds a floor mesh to be used for teleportation.
  103308. * @param floorMesh the mesh to be used for teleportation.
  103309. */
  103310. addFloorMesh(floorMesh: Mesh): void;
  103311. /**
  103312. * Removes a floor mesh from being used for teleportation.
  103313. * @param floorMesh the mesh to be removed.
  103314. */
  103315. removeFloorMesh(floorMesh: Mesh): void;
  103316. /**
  103317. * Enables interactions and teleportation using the VR controllers and gaze.
  103318. * @param vrTeleportationOptions options to modify teleportation behavior.
  103319. */
  103320. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  103321. private _onNewGamepadConnected;
  103322. private _tryEnableInteractionOnController;
  103323. private _onNewGamepadDisconnected;
  103324. private _enableInteractionOnController;
  103325. private _checkTeleportWithRay;
  103326. private _checkRotate;
  103327. private _checkTeleportBackwards;
  103328. private _enableTeleportationOnController;
  103329. private _createTeleportationCircles;
  103330. private _displayTeleportationTarget;
  103331. private _hideTeleportationTarget;
  103332. private _rotateCamera;
  103333. private _moveTeleportationSelectorTo;
  103334. private _workingVector;
  103335. private _workingQuaternion;
  103336. private _workingMatrix;
  103337. /**
  103338. * Teleports the users feet to the desired location
  103339. * @param location The location where the user's feet should be placed
  103340. */
  103341. teleportCamera(location: Vector3): void;
  103342. private _convertNormalToDirectionOfRay;
  103343. private _castRayAndSelectObject;
  103344. private _notifySelectedMeshUnselected;
  103345. /**
  103346. * Sets the color of the laser ray from the vr controllers.
  103347. * @param color new color for the ray.
  103348. */
  103349. changeLaserColor(color: Color3): void;
  103350. /**
  103351. * Sets the color of the ray from the vr headsets gaze.
  103352. * @param color new color for the ray.
  103353. */
  103354. changeGazeColor(color: Color3): void;
  103355. /**
  103356. * Exits VR and disposes of the vr experience helper
  103357. */
  103358. dispose(): void;
  103359. /**
  103360. * Gets the name of the VRExperienceHelper class
  103361. * @returns "VRExperienceHelper"
  103362. */
  103363. getClassName(): string;
  103364. }
  103365. }
  103366. declare module BABYLON {
  103367. /**
  103368. * Manages an XRSession
  103369. * @see https://doc.babylonjs.com/how_to/webxr
  103370. */
  103371. export class WebXRSessionManager implements IDisposable {
  103372. private scene;
  103373. /**
  103374. * Fires every time a new xrFrame arrives which can be used to update the camera
  103375. */
  103376. onXRFrameObservable: Observable<any>;
  103377. /**
  103378. * Fires when the xr session is ended either by the device or manually done
  103379. */
  103380. onXRSessionEnded: Observable<any>;
  103381. /** @hidden */
  103382. _xrSession: XRSession;
  103383. /** @hidden */
  103384. _frameOfReference: XRFrameOfReference;
  103385. /** @hidden */
  103386. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  103387. /** @hidden */
  103388. _currentXRFrame: Nullable<XRFrame>;
  103389. private _xrNavigator;
  103390. private _xrDevice;
  103391. private _tmpMatrix;
  103392. /**
  103393. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  103394. * @param scene The scene which the session should be created for
  103395. */
  103396. constructor(scene: Scene);
  103397. /**
  103398. * Initializes the manager
  103399. * After initialization enterXR can be called to start an XR session
  103400. * @returns Promise which resolves after it is initialized
  103401. */
  103402. initializeAsync(): Promise<void>;
  103403. /**
  103404. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  103405. * @param sessionCreationOptions xr options to create the session with
  103406. * @param frameOfReferenceType option to configure how the xr pose is expressed
  103407. * @returns Promise which resolves after it enters XR
  103408. */
  103409. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  103410. /**
  103411. * Stops the xrSession and restores the renderloop
  103412. * @returns Promise which resolves after it exits XR
  103413. */
  103414. exitXRAsync(): Promise<void>;
  103415. /**
  103416. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  103417. * @param ray ray to cast into the environment
  103418. * @returns Promise which resolves with a collision point in the environment if it exists
  103419. */
  103420. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  103421. /**
  103422. * Checks if a session would be supported for the creation options specified
  103423. * @param options creation options to check if they are supported
  103424. * @returns true if supported
  103425. */
  103426. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  103427. /**
  103428. * @hidden
  103429. * Converts the render layer of xrSession to a render target
  103430. * @param session session to create render target for
  103431. * @param scene scene the new render target should be created for
  103432. */
  103433. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  103434. /**
  103435. * Disposes of the session manager
  103436. */
  103437. dispose(): void;
  103438. }
  103439. }
  103440. declare module BABYLON {
  103441. /**
  103442. * WebXR Camera which holds the views for the xrSession
  103443. * @see https://doc.babylonjs.com/how_to/webxr
  103444. */
  103445. export class WebXRCamera extends FreeCamera {
  103446. private static _TmpMatrix;
  103447. /**
  103448. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  103449. * @param name the name of the camera
  103450. * @param scene the scene to add the camera to
  103451. */
  103452. constructor(name: string, scene: Scene);
  103453. private _updateNumberOfRigCameras;
  103454. /** @hidden */
  103455. _updateForDualEyeDebugging(pupilDistance?: number): void;
  103456. /**
  103457. * Updates the cameras position from the current pose information of the XR session
  103458. * @param xrSessionManager the session containing pose information
  103459. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  103460. */
  103461. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  103462. }
  103463. }
  103464. declare module BABYLON {
  103465. /**
  103466. * States of the webXR experience
  103467. */
  103468. export enum WebXRState {
  103469. /**
  103470. * Transitioning to being in XR mode
  103471. */
  103472. ENTERING_XR = 0,
  103473. /**
  103474. * Transitioning to non XR mode
  103475. */
  103476. EXITING_XR = 1,
  103477. /**
  103478. * In XR mode and presenting
  103479. */
  103480. IN_XR = 2,
  103481. /**
  103482. * Not entered XR mode
  103483. */
  103484. NOT_IN_XR = 3
  103485. }
  103486. /**
  103487. * Helper class used to enable XR
  103488. * @see https://doc.babylonjs.com/how_to/webxr
  103489. */
  103490. export class WebXRExperienceHelper implements IDisposable {
  103491. private scene;
  103492. /**
  103493. * 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
  103494. */
  103495. container: AbstractMesh;
  103496. /**
  103497. * Camera used to render xr content
  103498. */
  103499. camera: WebXRCamera;
  103500. /**
  103501. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  103502. */
  103503. state: WebXRState;
  103504. private _setState;
  103505. private static _TmpVector;
  103506. /**
  103507. * Fires when the state of the experience helper has changed
  103508. */
  103509. onStateChangedObservable: Observable<WebXRState>;
  103510. /** @hidden */
  103511. _sessionManager: WebXRSessionManager;
  103512. private _nonVRCamera;
  103513. private _originalSceneAutoClear;
  103514. private _supported;
  103515. /**
  103516. * Creates the experience helper
  103517. * @param scene the scene to attach the experience helper to
  103518. * @returns a promise for the experience helper
  103519. */
  103520. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  103521. /**
  103522. * Creates a WebXRExperienceHelper
  103523. * @param scene The scene the helper should be created in
  103524. */
  103525. private constructor();
  103526. /**
  103527. * Exits XR mode and returns the scene to its original state
  103528. * @returns promise that resolves after xr mode has exited
  103529. */
  103530. exitXRAsync(): Promise<void>;
  103531. /**
  103532. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  103533. * @param sessionCreationOptions options for the XR session
  103534. * @param frameOfReference frame of reference of the XR session
  103535. * @returns promise that resolves after xr mode has entered
  103536. */
  103537. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  103538. /**
  103539. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  103540. * @param ray ray to cast into the environment
  103541. * @returns Promise which resolves with a collision point in the environment if it exists
  103542. */
  103543. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  103544. /**
  103545. * Updates the global position of the camera by moving the camera's container
  103546. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  103547. * @param position The desired global position of the camera
  103548. */
  103549. setPositionOfCameraUsingContainer(position: Vector3): void;
  103550. /**
  103551. * Rotates the xr camera by rotating the camera's container around the camera's position
  103552. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  103553. * @param rotation the desired quaternion rotation to apply to the camera
  103554. */
  103555. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  103556. /**
  103557. * Checks if the creation options are supported by the xr session
  103558. * @param options creation options
  103559. * @returns true if supported
  103560. */
  103561. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  103562. /**
  103563. * Disposes of the experience helper
  103564. */
  103565. dispose(): void;
  103566. }
  103567. }
  103568. declare module BABYLON {
  103569. /**
  103570. * Button which can be used to enter a different mode of XR
  103571. */
  103572. export class WebXREnterExitUIButton {
  103573. /** button element */
  103574. element: HTMLElement;
  103575. /** XR initialization options for the button */
  103576. initializationOptions: XRSessionCreationOptions;
  103577. /**
  103578. * Creates a WebXREnterExitUIButton
  103579. * @param element button element
  103580. * @param initializationOptions XR initialization options for the button
  103581. */
  103582. constructor(
  103583. /** button element */
  103584. element: HTMLElement,
  103585. /** XR initialization options for the button */
  103586. initializationOptions: XRSessionCreationOptions);
  103587. /**
  103588. * Overwritable function which can be used to update the button's visuals when the state changes
  103589. * @param activeButton the current active button in the UI
  103590. */
  103591. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  103592. }
  103593. /**
  103594. * Options to create the webXR UI
  103595. */
  103596. export class WebXREnterExitUIOptions {
  103597. /**
  103598. * Context to enter xr with
  103599. */
  103600. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  103601. /**
  103602. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  103603. */
  103604. customButtons?: Array<WebXREnterExitUIButton>;
  103605. }
  103606. /**
  103607. * UI to allow the user to enter/exit XR mode
  103608. */
  103609. export class WebXREnterExitUI implements IDisposable {
  103610. private scene;
  103611. private _overlay;
  103612. private _buttons;
  103613. private _activeButton;
  103614. /**
  103615. * Fired every time the active button is changed.
  103616. *
  103617. * When xr is entered via a button that launches xr that button will be the callback parameter
  103618. *
  103619. * When exiting xr the callback parameter will be null)
  103620. */
  103621. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  103622. /**
  103623. * Creates UI to allow the user to enter/exit XR mode
  103624. * @param scene the scene to add the ui to
  103625. * @param helper the xr experience helper to enter/exit xr with
  103626. * @param options options to configure the UI
  103627. * @returns the created ui
  103628. */
  103629. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  103630. private constructor();
  103631. private _updateButtons;
  103632. /**
  103633. * Disposes of the object
  103634. */
  103635. dispose(): void;
  103636. }
  103637. }
  103638. declare module BABYLON {
  103639. /**
  103640. * Represents an XR input
  103641. */
  103642. export class WebXRController {
  103643. /**
  103644. * 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
  103645. */
  103646. grip?: AbstractMesh;
  103647. /**
  103648. * Pointer which can be used to select objects or attach a visible laser to
  103649. */
  103650. pointer: AbstractMesh;
  103651. /**
  103652. * Creates the controller
  103653. * @see https://doc.babylonjs.com/how_to/webxr
  103654. * @param scene the scene which the controller should be associated to
  103655. */
  103656. constructor(scene: Scene);
  103657. /**
  103658. * Disposes of the object
  103659. */
  103660. dispose(): void;
  103661. }
  103662. /**
  103663. * XR input used to track XR inputs such as controllers/rays
  103664. */
  103665. export class WebXRInput implements IDisposable {
  103666. private helper;
  103667. /**
  103668. * XR controllers being tracked
  103669. */
  103670. controllers: Array<WebXRController>;
  103671. private _tmpMatrix;
  103672. private _frameObserver;
  103673. /**
  103674. * Initializes the WebXRInput
  103675. * @param helper experience helper which the input should be created for
  103676. */
  103677. constructor(helper: WebXRExperienceHelper);
  103678. /**
  103679. * Disposes of the object
  103680. */
  103681. dispose(): void;
  103682. }
  103683. }
  103684. declare module BABYLON {
  103685. /**
  103686. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  103687. */
  103688. export class WebXRManagedOutputCanvas implements IDisposable {
  103689. private _canvas;
  103690. /**
  103691. * xrpresent context of the canvas which can be used to display/mirror xr content
  103692. */
  103693. canvasContext: Nullable<WebGLRenderingContext>;
  103694. /**
  103695. * Initializes the canvas to be added/removed upon entering/exiting xr
  103696. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  103697. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  103698. */
  103699. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  103700. /**
  103701. * Disposes of the object
  103702. */
  103703. dispose(): void;
  103704. private _setManagedOutputCanvas;
  103705. private _addCanvas;
  103706. private _removeCanvas;
  103707. }
  103708. }
  103709. declare module BABYLON {
  103710. /**
  103711. * Contains an array of blocks representing the octree
  103712. */
  103713. export interface IOctreeContainer<T> {
  103714. /**
  103715. * Blocks within the octree
  103716. */
  103717. blocks: Array<OctreeBlock<T>>;
  103718. }
  103719. /**
  103720. * Class used to store a cell in an octree
  103721. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103722. */
  103723. export class OctreeBlock<T> {
  103724. /**
  103725. * Gets the content of the current block
  103726. */
  103727. entries: T[];
  103728. /**
  103729. * Gets the list of block children
  103730. */
  103731. blocks: Array<OctreeBlock<T>>;
  103732. private _depth;
  103733. private _maxDepth;
  103734. private _capacity;
  103735. private _minPoint;
  103736. private _maxPoint;
  103737. private _boundingVectors;
  103738. private _creationFunc;
  103739. /**
  103740. * Creates a new block
  103741. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  103742. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  103743. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103744. * @param depth defines the current depth of this block in the octree
  103745. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  103746. * @param creationFunc defines a callback to call when an element is added to the block
  103747. */
  103748. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  103749. /**
  103750. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103751. */
  103752. readonly capacity: number;
  103753. /**
  103754. * Gets the minimum vector (in world space) of the block's bounding box
  103755. */
  103756. readonly minPoint: Vector3;
  103757. /**
  103758. * Gets the maximum vector (in world space) of the block's bounding box
  103759. */
  103760. readonly maxPoint: Vector3;
  103761. /**
  103762. * Add a new element to this block
  103763. * @param entry defines the element to add
  103764. */
  103765. addEntry(entry: T): void;
  103766. /**
  103767. * Remove an element from this block
  103768. * @param entry defines the element to remove
  103769. */
  103770. removeEntry(entry: T): void;
  103771. /**
  103772. * Add an array of elements to this block
  103773. * @param entries defines the array of elements to add
  103774. */
  103775. addEntries(entries: T[]): void;
  103776. /**
  103777. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  103778. * @param frustumPlanes defines the frustum planes to test
  103779. * @param selection defines the array to store current content if selection is positive
  103780. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103781. */
  103782. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103783. /**
  103784. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  103785. * @param sphereCenter defines the bounding sphere center
  103786. * @param sphereRadius defines the bounding sphere radius
  103787. * @param selection defines the array to store current content if selection is positive
  103788. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103789. */
  103790. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103791. /**
  103792. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  103793. * @param ray defines the ray to test with
  103794. * @param selection defines the array to store current content if selection is positive
  103795. */
  103796. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  103797. /**
  103798. * Subdivide the content into child blocks (this block will then be empty)
  103799. */
  103800. createInnerBlocks(): void;
  103801. /**
  103802. * @hidden
  103803. */
  103804. 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;
  103805. }
  103806. }
  103807. declare module BABYLON {
  103808. /**
  103809. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  103810. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103811. */
  103812. export class Octree<T> {
  103813. /** 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.) */
  103814. maxDepth: number;
  103815. /**
  103816. * Blocks within the octree containing objects
  103817. */
  103818. blocks: Array<OctreeBlock<T>>;
  103819. /**
  103820. * Content stored in the octree
  103821. */
  103822. dynamicContent: T[];
  103823. private _maxBlockCapacity;
  103824. private _selectionContent;
  103825. private _creationFunc;
  103826. /**
  103827. * Creates a octree
  103828. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103829. * @param creationFunc function to be used to instatiate the octree
  103830. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  103831. * @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.)
  103832. */
  103833. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  103834. /** 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.) */
  103835. maxDepth?: number);
  103836. /**
  103837. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  103838. * @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);
  103839. * @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);
  103840. * @param entries meshes to be added to the octree blocks
  103841. */
  103842. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  103843. /**
  103844. * Adds a mesh to the octree
  103845. * @param entry Mesh to add to the octree
  103846. */
  103847. addMesh(entry: T): void;
  103848. /**
  103849. * Remove an element from the octree
  103850. * @param entry defines the element to remove
  103851. */
  103852. removeMesh(entry: T): void;
  103853. /**
  103854. * Selects an array of meshes within the frustum
  103855. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  103856. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  103857. * @returns array of meshes within the frustum
  103858. */
  103859. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  103860. /**
  103861. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  103862. * @param sphereCenter defines the bounding sphere center
  103863. * @param sphereRadius defines the bounding sphere radius
  103864. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103865. * @returns an array of objects that intersect the sphere
  103866. */
  103867. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  103868. /**
  103869. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  103870. * @param ray defines the ray to test with
  103871. * @returns array of intersected objects
  103872. */
  103873. intersectsRay(ray: Ray): SmartArray<T>;
  103874. /**
  103875. * Adds a mesh into the octree block if it intersects the block
  103876. */
  103877. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  103878. /**
  103879. * Adds a submesh into the octree block if it intersects the block
  103880. */
  103881. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  103882. }
  103883. }
  103884. declare module BABYLON {
  103885. interface Scene {
  103886. /**
  103887. * @hidden
  103888. * Backing Filed
  103889. */
  103890. _selectionOctree: Octree<AbstractMesh>;
  103891. /**
  103892. * Gets the octree used to boost mesh selection (picking)
  103893. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103894. */
  103895. selectionOctree: Octree<AbstractMesh>;
  103896. /**
  103897. * Creates or updates the octree used to boost selection (picking)
  103898. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103899. * @param maxCapacity defines the maximum capacity per leaf
  103900. * @param maxDepth defines the maximum depth of the octree
  103901. * @returns an octree of AbstractMesh
  103902. */
  103903. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  103904. }
  103905. interface AbstractMesh {
  103906. /**
  103907. * @hidden
  103908. * Backing Field
  103909. */
  103910. _submeshesOctree: Octree<SubMesh>;
  103911. /**
  103912. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  103913. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103914. * @param maxCapacity defines the maximum size of each block (64 by default)
  103915. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  103916. * @returns the new octree
  103917. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  103918. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103919. */
  103920. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  103921. }
  103922. /**
  103923. * Defines the octree scene component responsible to manage any octrees
  103924. * in a given scene.
  103925. */
  103926. export class OctreeSceneComponent {
  103927. /**
  103928. * The component name help to identify the component in the list of scene components.
  103929. */
  103930. readonly name: string;
  103931. /**
  103932. * The scene the component belongs to.
  103933. */
  103934. scene: Scene;
  103935. /**
  103936. * Indicates if the meshes have been checked to make sure they are isEnabled()
  103937. */
  103938. readonly checksIsEnabled: boolean;
  103939. /**
  103940. * Creates a new instance of the component for the given scene
  103941. * @param scene Defines the scene to register the component in
  103942. */
  103943. constructor(scene: Scene);
  103944. /**
  103945. * Registers the component in a given scene
  103946. */
  103947. register(): void;
  103948. /**
  103949. * Return the list of active meshes
  103950. * @returns the list of active meshes
  103951. */
  103952. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  103953. /**
  103954. * Return the list of active sub meshes
  103955. * @param mesh The mesh to get the candidates sub meshes from
  103956. * @returns the list of active sub meshes
  103957. */
  103958. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  103959. private _tempRay;
  103960. /**
  103961. * Return the list of sub meshes intersecting with a given local ray
  103962. * @param mesh defines the mesh to find the submesh for
  103963. * @param localRay defines the ray in local space
  103964. * @returns the list of intersecting sub meshes
  103965. */
  103966. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  103967. /**
  103968. * Return the list of sub meshes colliding with a collider
  103969. * @param mesh defines the mesh to find the submesh for
  103970. * @param collider defines the collider to evaluate the collision against
  103971. * @returns the list of colliding sub meshes
  103972. */
  103973. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  103974. /**
  103975. * Rebuilds the elements related to this component in case of
  103976. * context lost for instance.
  103977. */
  103978. rebuild(): void;
  103979. /**
  103980. * Disposes the component and the associated ressources.
  103981. */
  103982. dispose(): void;
  103983. }
  103984. }
  103985. declare module BABYLON {
  103986. /**
  103987. * Renders a layer on top of an existing scene
  103988. */
  103989. export class UtilityLayerRenderer implements IDisposable {
  103990. /** the original scene that will be rendered on top of */
  103991. originalScene: Scene;
  103992. private _pointerCaptures;
  103993. private _lastPointerEvents;
  103994. private static _DefaultUtilityLayer;
  103995. private static _DefaultKeepDepthUtilityLayer;
  103996. private _sharedGizmoLight;
  103997. private _renderCamera;
  103998. /**
  103999. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  104000. * @returns the camera that is used when rendering the utility layer
  104001. */
  104002. getRenderCamera(): Nullable<Camera>;
  104003. /**
  104004. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  104005. * @param cam the camera that should be used when rendering the utility layer
  104006. */
  104007. setRenderCamera(cam: Nullable<Camera>): void;
  104008. /**
  104009. * @hidden
  104010. * Light which used by gizmos to get light shading
  104011. */
  104012. _getSharedGizmoLight(): HemisphericLight;
  104013. /**
  104014. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  104015. */
  104016. pickUtilitySceneFirst: boolean;
  104017. /**
  104018. * 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)
  104019. */
  104020. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  104021. /**
  104022. * 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)
  104023. */
  104024. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  104025. /**
  104026. * The scene that is rendered on top of the original scene
  104027. */
  104028. utilityLayerScene: Scene;
  104029. /**
  104030. * If the utility layer should automatically be rendered on top of existing scene
  104031. */
  104032. shouldRender: boolean;
  104033. /**
  104034. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  104035. */
  104036. onlyCheckPointerDownEvents: boolean;
  104037. /**
  104038. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  104039. */
  104040. processAllEvents: boolean;
  104041. /**
  104042. * Observable raised when the pointer move from the utility layer scene to the main scene
  104043. */
  104044. onPointerOutObservable: Observable<number>;
  104045. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  104046. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  104047. private _afterRenderObserver;
  104048. private _sceneDisposeObserver;
  104049. private _originalPointerObserver;
  104050. /**
  104051. * Instantiates a UtilityLayerRenderer
  104052. * @param originalScene the original scene that will be rendered on top of
  104053. * @param handleEvents boolean indicating if the utility layer should handle events
  104054. */
  104055. constructor(
  104056. /** the original scene that will be rendered on top of */
  104057. originalScene: Scene, handleEvents?: boolean);
  104058. private _notifyObservers;
  104059. /**
  104060. * Renders the utility layers scene on top of the original scene
  104061. */
  104062. render(): void;
  104063. /**
  104064. * Disposes of the renderer
  104065. */
  104066. dispose(): void;
  104067. private _updateCamera;
  104068. }
  104069. }
  104070. declare module BABYLON {
  104071. /**
  104072. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  104073. */
  104074. export class Gizmo implements IDisposable {
  104075. /** The utility layer the gizmo will be added to */
  104076. gizmoLayer: UtilityLayerRenderer;
  104077. /**
  104078. * The root mesh of the gizmo
  104079. */
  104080. _rootMesh: Mesh;
  104081. private _attachedMesh;
  104082. /**
  104083. * Ratio for the scale of the gizmo (Default: 1)
  104084. */
  104085. scaleRatio: number;
  104086. /**
  104087. * If a custom mesh has been set (Default: false)
  104088. */
  104089. protected _customMeshSet: boolean;
  104090. /**
  104091. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  104092. * * When set, interactions will be enabled
  104093. */
  104094. attachedMesh: Nullable<AbstractMesh>;
  104095. /**
  104096. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  104097. * @param mesh The mesh to replace the default mesh of the gizmo
  104098. */
  104099. setCustomMesh(mesh: Mesh): void;
  104100. /**
  104101. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  104102. */
  104103. updateGizmoRotationToMatchAttachedMesh: boolean;
  104104. /**
  104105. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  104106. */
  104107. updateGizmoPositionToMatchAttachedMesh: boolean;
  104108. /**
  104109. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  104110. */
  104111. protected _updateScale: boolean;
  104112. protected _interactionsEnabled: boolean;
  104113. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104114. private _beforeRenderObserver;
  104115. private _tempVector;
  104116. /**
  104117. * Creates a gizmo
  104118. * @param gizmoLayer The utility layer the gizmo will be added to
  104119. */
  104120. constructor(
  104121. /** The utility layer the gizmo will be added to */
  104122. gizmoLayer?: UtilityLayerRenderer);
  104123. /**
  104124. * Updates the gizmo to match the attached mesh's position/rotation
  104125. */
  104126. protected _update(): void;
  104127. /**
  104128. * Disposes of the gizmo
  104129. */
  104130. dispose(): void;
  104131. }
  104132. }
  104133. declare module BABYLON {
  104134. /**
  104135. * Single plane drag gizmo
  104136. */
  104137. export class PlaneDragGizmo extends Gizmo {
  104138. /**
  104139. * Drag behavior responsible for the gizmos dragging interactions
  104140. */
  104141. dragBehavior: PointerDragBehavior;
  104142. private _pointerObserver;
  104143. /**
  104144. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104145. */
  104146. snapDistance: number;
  104147. /**
  104148. * Event that fires each time the gizmo snaps to a new location.
  104149. * * snapDistance is the the change in distance
  104150. */
  104151. onSnapObservable: Observable<{
  104152. snapDistance: number;
  104153. }>;
  104154. private _plane;
  104155. private _coloredMaterial;
  104156. private _hoverMaterial;
  104157. private _isEnabled;
  104158. private _parent;
  104159. /** @hidden */
  104160. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  104161. /** @hidden */
  104162. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  104163. /**
  104164. * Creates a PlaneDragGizmo
  104165. * @param gizmoLayer The utility layer the gizmo will be added to
  104166. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  104167. * @param color The color of the gizmo
  104168. */
  104169. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  104170. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104171. /**
  104172. * If the gizmo is enabled
  104173. */
  104174. isEnabled: boolean;
  104175. /**
  104176. * Disposes of the gizmo
  104177. */
  104178. dispose(): void;
  104179. }
  104180. }
  104181. declare module BABYLON {
  104182. /**
  104183. * Gizmo that enables dragging a mesh along 3 axis
  104184. */
  104185. export class PositionGizmo extends Gizmo {
  104186. /**
  104187. * Internal gizmo used for interactions on the x axis
  104188. */
  104189. xGizmo: AxisDragGizmo;
  104190. /**
  104191. * Internal gizmo used for interactions on the y axis
  104192. */
  104193. yGizmo: AxisDragGizmo;
  104194. /**
  104195. * Internal gizmo used for interactions on the z axis
  104196. */
  104197. zGizmo: AxisDragGizmo;
  104198. /**
  104199. * Internal gizmo used for interactions on the yz plane
  104200. */
  104201. xPlaneGizmo: PlaneDragGizmo;
  104202. /**
  104203. * Internal gizmo used for interactions on the xz plane
  104204. */
  104205. yPlaneGizmo: PlaneDragGizmo;
  104206. /**
  104207. * Internal gizmo used for interactions on the xy plane
  104208. */
  104209. zPlaneGizmo: PlaneDragGizmo;
  104210. /**
  104211. * private variables
  104212. */
  104213. private _meshAttached;
  104214. private _updateGizmoRotationToMatchAttachedMesh;
  104215. private _snapDistance;
  104216. private _scaleRatio;
  104217. /** Fires an event when any of it's sub gizmos are dragged */
  104218. onDragStartObservable: Observable<unknown>;
  104219. /** Fires an event when any of it's sub gizmos are released from dragging */
  104220. onDragEndObservable: Observable<unknown>;
  104221. /**
  104222. * If set to true, planar drag is enabled
  104223. */
  104224. private _planarGizmoEnabled;
  104225. attachedMesh: Nullable<AbstractMesh>;
  104226. /**
  104227. * Creates a PositionGizmo
  104228. * @param gizmoLayer The utility layer the gizmo will be added to
  104229. */
  104230. constructor(gizmoLayer?: UtilityLayerRenderer);
  104231. /**
  104232. * If the planar drag gizmo is enabled
  104233. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  104234. */
  104235. planarGizmoEnabled: boolean;
  104236. updateGizmoRotationToMatchAttachedMesh: boolean;
  104237. /**
  104238. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104239. */
  104240. snapDistance: number;
  104241. /**
  104242. * Ratio for the scale of the gizmo (Default: 1)
  104243. */
  104244. scaleRatio: number;
  104245. /**
  104246. * Disposes of the gizmo
  104247. */
  104248. dispose(): void;
  104249. /**
  104250. * CustomMeshes are not supported by this gizmo
  104251. * @param mesh The mesh to replace the default mesh of the gizmo
  104252. */
  104253. setCustomMesh(mesh: Mesh): void;
  104254. }
  104255. }
  104256. declare module BABYLON {
  104257. /**
  104258. * Single axis drag gizmo
  104259. */
  104260. export class AxisDragGizmo extends Gizmo {
  104261. /**
  104262. * Drag behavior responsible for the gizmos dragging interactions
  104263. */
  104264. dragBehavior: PointerDragBehavior;
  104265. private _pointerObserver;
  104266. /**
  104267. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104268. */
  104269. snapDistance: number;
  104270. /**
  104271. * Event that fires each time the gizmo snaps to a new location.
  104272. * * snapDistance is the the change in distance
  104273. */
  104274. onSnapObservable: Observable<{
  104275. snapDistance: number;
  104276. }>;
  104277. private _isEnabled;
  104278. private _parent;
  104279. private _arrow;
  104280. private _coloredMaterial;
  104281. private _hoverMaterial;
  104282. /** @hidden */
  104283. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  104284. /** @hidden */
  104285. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  104286. /**
  104287. * Creates an AxisDragGizmo
  104288. * @param gizmoLayer The utility layer the gizmo will be added to
  104289. * @param dragAxis The axis which the gizmo will be able to drag on
  104290. * @param color The color of the gizmo
  104291. */
  104292. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  104293. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104294. /**
  104295. * If the gizmo is enabled
  104296. */
  104297. isEnabled: boolean;
  104298. /**
  104299. * Disposes of the gizmo
  104300. */
  104301. dispose(): void;
  104302. }
  104303. }
  104304. declare module BABYLON.Debug {
  104305. /**
  104306. * The Axes viewer will show 3 axes in a specific point in space
  104307. */
  104308. export class AxesViewer {
  104309. private _xAxis;
  104310. private _yAxis;
  104311. private _zAxis;
  104312. private _scaleLinesFactor;
  104313. private _instanced;
  104314. /**
  104315. * Gets the hosting scene
  104316. */
  104317. scene: Scene;
  104318. /**
  104319. * Gets or sets a number used to scale line length
  104320. */
  104321. scaleLines: number;
  104322. /** Gets the node hierarchy used to render x-axis */
  104323. readonly xAxis: TransformNode;
  104324. /** Gets the node hierarchy used to render y-axis */
  104325. readonly yAxis: TransformNode;
  104326. /** Gets the node hierarchy used to render z-axis */
  104327. readonly zAxis: TransformNode;
  104328. /**
  104329. * Creates a new AxesViewer
  104330. * @param scene defines the hosting scene
  104331. * @param scaleLines defines a number used to scale line length (1 by default)
  104332. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  104333. * @param xAxis defines the node hierarchy used to render the x-axis
  104334. * @param yAxis defines the node hierarchy used to render the y-axis
  104335. * @param zAxis defines the node hierarchy used to render the z-axis
  104336. */
  104337. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  104338. /**
  104339. * Force the viewer to update
  104340. * @param position defines the position of the viewer
  104341. * @param xaxis defines the x axis of the viewer
  104342. * @param yaxis defines the y axis of the viewer
  104343. * @param zaxis defines the z axis of the viewer
  104344. */
  104345. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  104346. /**
  104347. * Creates an instance of this axes viewer.
  104348. * @returns a new axes viewer with instanced meshes
  104349. */
  104350. createInstance(): AxesViewer;
  104351. /** Releases resources */
  104352. dispose(): void;
  104353. private static _SetRenderingGroupId;
  104354. }
  104355. }
  104356. declare module BABYLON.Debug {
  104357. /**
  104358. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  104359. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  104360. */
  104361. export class BoneAxesViewer extends AxesViewer {
  104362. /**
  104363. * Gets or sets the target mesh where to display the axes viewer
  104364. */
  104365. mesh: Nullable<Mesh>;
  104366. /**
  104367. * Gets or sets the target bone where to display the axes viewer
  104368. */
  104369. bone: Nullable<Bone>;
  104370. /** Gets current position */
  104371. pos: Vector3;
  104372. /** Gets direction of X axis */
  104373. xaxis: Vector3;
  104374. /** Gets direction of Y axis */
  104375. yaxis: Vector3;
  104376. /** Gets direction of Z axis */
  104377. zaxis: Vector3;
  104378. /**
  104379. * Creates a new BoneAxesViewer
  104380. * @param scene defines the hosting scene
  104381. * @param bone defines the target bone
  104382. * @param mesh defines the target mesh
  104383. * @param scaleLines defines a scaling factor for line length (1 by default)
  104384. */
  104385. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  104386. /**
  104387. * Force the viewer to update
  104388. */
  104389. update(): void;
  104390. /** Releases resources */
  104391. dispose(): void;
  104392. }
  104393. }
  104394. declare module BABYLON {
  104395. /**
  104396. * Interface used to define scene explorer extensibility option
  104397. */
  104398. export interface IExplorerExtensibilityOption {
  104399. /**
  104400. * Define the option label
  104401. */
  104402. label: string;
  104403. /**
  104404. * Defines the action to execute on click
  104405. */
  104406. action: (entity: any) => void;
  104407. }
  104408. /**
  104409. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  104410. */
  104411. export interface IExplorerExtensibilityGroup {
  104412. /**
  104413. * Defines a predicate to test if a given type mut be extended
  104414. */
  104415. predicate: (entity: any) => boolean;
  104416. /**
  104417. * Gets the list of options added to a type
  104418. */
  104419. entries: IExplorerExtensibilityOption[];
  104420. }
  104421. /**
  104422. * Interface used to define the options to use to create the Inspector
  104423. */
  104424. export interface IInspectorOptions {
  104425. /**
  104426. * Display in overlay mode (default: false)
  104427. */
  104428. overlay?: boolean;
  104429. /**
  104430. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  104431. */
  104432. globalRoot?: HTMLElement;
  104433. /**
  104434. * Display the Scene explorer
  104435. */
  104436. showExplorer?: boolean;
  104437. /**
  104438. * Display the property inspector
  104439. */
  104440. showInspector?: boolean;
  104441. /**
  104442. * Display in embed mode (both panes on the right)
  104443. */
  104444. embedMode?: boolean;
  104445. /**
  104446. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  104447. */
  104448. handleResize?: boolean;
  104449. /**
  104450. * Allow the panes to popup (default: true)
  104451. */
  104452. enablePopup?: boolean;
  104453. /**
  104454. * Allow the panes to be closed by users (default: true)
  104455. */
  104456. enableClose?: boolean;
  104457. /**
  104458. * Optional list of extensibility entries
  104459. */
  104460. explorerExtensibility?: IExplorerExtensibilityGroup[];
  104461. /**
  104462. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  104463. */
  104464. inspectorURL?: string;
  104465. }
  104466. interface Scene {
  104467. /**
  104468. * @hidden
  104469. * Backing field
  104470. */
  104471. _debugLayer: DebugLayer;
  104472. /**
  104473. * Gets the debug layer (aka Inspector) associated with the scene
  104474. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104475. */
  104476. debugLayer: DebugLayer;
  104477. }
  104478. /**
  104479. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104480. * what is happening in your scene
  104481. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104482. */
  104483. export class DebugLayer {
  104484. /**
  104485. * Define the url to get the inspector script from.
  104486. * By default it uses the babylonjs CDN.
  104487. * @ignoreNaming
  104488. */
  104489. static InspectorURL: string;
  104490. private _scene;
  104491. private BJSINSPECTOR;
  104492. /**
  104493. * Observable triggered when a property is changed through the inspector.
  104494. */
  104495. onPropertyChangedObservable: Observable<{
  104496. object: any;
  104497. property: string;
  104498. value: any;
  104499. initialValue: any;
  104500. }>;
  104501. /**
  104502. * Instantiates a new debug layer.
  104503. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104504. * what is happening in your scene
  104505. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104506. * @param scene Defines the scene to inspect
  104507. */
  104508. constructor(scene: Scene);
  104509. /** Creates the inspector window. */
  104510. private _createInspector;
  104511. /**
  104512. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  104513. * @param entity defines the entity to select
  104514. * @param lineContainerTitle defines the specific block to highlight
  104515. */
  104516. select(entity: any, lineContainerTitle?: string): void;
  104517. /** Get the inspector from bundle or global */
  104518. private _getGlobalInspector;
  104519. /**
  104520. * Get if the inspector is visible or not.
  104521. * @returns true if visible otherwise, false
  104522. */
  104523. isVisible(): boolean;
  104524. /**
  104525. * Hide the inspector and close its window.
  104526. */
  104527. hide(): void;
  104528. /**
  104529. * Launch the debugLayer.
  104530. * @param config Define the configuration of the inspector
  104531. * @return a promise fulfilled when the debug layer is visible
  104532. */
  104533. show(config?: IInspectorOptions): Promise<DebugLayer>;
  104534. }
  104535. }
  104536. declare module BABYLON {
  104537. /**
  104538. * Class containing static functions to help procedurally build meshes
  104539. */
  104540. export class BoxBuilder {
  104541. /**
  104542. * Creates a box mesh
  104543. * * The parameter `size` sets the size (float) of each box side (default 1)
  104544. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  104545. * * 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)
  104546. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104550. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  104551. * @param name defines the name of the mesh
  104552. * @param options defines the options used to create the mesh
  104553. * @param scene defines the hosting scene
  104554. * @returns the box mesh
  104555. */
  104556. static CreateBox(name: string, options: {
  104557. size?: number;
  104558. width?: number;
  104559. height?: number;
  104560. depth?: number;
  104561. faceUV?: Vector4[];
  104562. faceColors?: Color4[];
  104563. sideOrientation?: number;
  104564. frontUVs?: Vector4;
  104565. backUVs?: Vector4;
  104566. wrap?: boolean;
  104567. topBaseAt?: number;
  104568. bottomBaseAt?: number;
  104569. updatable?: boolean;
  104570. }, scene?: Nullable<Scene>): Mesh;
  104571. }
  104572. }
  104573. declare module BABYLON {
  104574. /**
  104575. * Class containing static functions to help procedurally build meshes
  104576. */
  104577. export class SphereBuilder {
  104578. /**
  104579. * Creates a sphere mesh
  104580. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  104581. * * 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`)
  104582. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  104583. * * 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
  104584. * * 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)
  104585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104586. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104588. * @param name defines the name of the mesh
  104589. * @param options defines the options used to create the mesh
  104590. * @param scene defines the hosting scene
  104591. * @returns the sphere mesh
  104592. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  104593. */
  104594. static CreateSphere(name: string, options: {
  104595. segments?: number;
  104596. diameter?: number;
  104597. diameterX?: number;
  104598. diameterY?: number;
  104599. diameterZ?: number;
  104600. arc?: number;
  104601. slice?: number;
  104602. sideOrientation?: number;
  104603. frontUVs?: Vector4;
  104604. backUVs?: Vector4;
  104605. updatable?: boolean;
  104606. }, scene: any): Mesh;
  104607. }
  104608. }
  104609. declare module BABYLON.Debug {
  104610. /**
  104611. * Used to show the physics impostor around the specific mesh
  104612. */
  104613. export class PhysicsViewer {
  104614. /** @hidden */
  104615. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  104616. /** @hidden */
  104617. protected _meshes: Array<Nullable<AbstractMesh>>;
  104618. /** @hidden */
  104619. protected _scene: Nullable<Scene>;
  104620. /** @hidden */
  104621. protected _numMeshes: number;
  104622. /** @hidden */
  104623. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  104624. private _renderFunction;
  104625. private _utilityLayer;
  104626. private _debugBoxMesh;
  104627. private _debugSphereMesh;
  104628. private _debugCylinderMesh;
  104629. private _debugMaterial;
  104630. private _debugMeshMeshes;
  104631. /**
  104632. * Creates a new PhysicsViewer
  104633. * @param scene defines the hosting scene
  104634. */
  104635. constructor(scene: Scene);
  104636. /** @hidden */
  104637. protected _updateDebugMeshes(): void;
  104638. /**
  104639. * Renders a specified physic impostor
  104640. * @param impostor defines the impostor to render
  104641. * @param targetMesh defines the mesh represented by the impostor
  104642. * @returns the new debug mesh used to render the impostor
  104643. */
  104644. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  104645. /**
  104646. * Hides a specified physic impostor
  104647. * @param impostor defines the impostor to hide
  104648. */
  104649. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  104650. private _getDebugMaterial;
  104651. private _getDebugBoxMesh;
  104652. private _getDebugSphereMesh;
  104653. private _getDebugCylinderMesh;
  104654. private _getDebugMeshMesh;
  104655. private _getDebugMesh;
  104656. /** Releases all resources */
  104657. dispose(): void;
  104658. }
  104659. }
  104660. declare module BABYLON {
  104661. /**
  104662. * Class containing static functions to help procedurally build meshes
  104663. */
  104664. export class LinesBuilder {
  104665. /**
  104666. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  104667. * * 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
  104668. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  104669. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  104670. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  104671. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  104672. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  104673. * * 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
  104674. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  104675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104676. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  104677. * @param name defines the name of the new line system
  104678. * @param options defines the options used to create the line system
  104679. * @param scene defines the hosting scene
  104680. * @returns a new line system mesh
  104681. */
  104682. static CreateLineSystem(name: string, options: {
  104683. lines: Vector3[][];
  104684. updatable?: boolean;
  104685. instance?: Nullable<LinesMesh>;
  104686. colors?: Nullable<Color4[][]>;
  104687. useVertexAlpha?: boolean;
  104688. }, scene: Nullable<Scene>): LinesMesh;
  104689. /**
  104690. * Creates a line mesh
  104691. * 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
  104692. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104693. * * The parameter `points` is an array successive Vector3
  104694. * * 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
  104695. * * The optional parameter `colors` is an array of successive Color4, one per line point
  104696. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  104697. * * When updating an instance, remember that only point positions can change, not the number of points
  104698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104699. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  104700. * @param name defines the name of the new line system
  104701. * @param options defines the options used to create the line system
  104702. * @param scene defines the hosting scene
  104703. * @returns a new line mesh
  104704. */
  104705. static CreateLines(name: string, options: {
  104706. points: Vector3[];
  104707. updatable?: boolean;
  104708. instance?: Nullable<LinesMesh>;
  104709. colors?: Color4[];
  104710. useVertexAlpha?: boolean;
  104711. }, scene?: Nullable<Scene>): LinesMesh;
  104712. /**
  104713. * Creates a dashed line mesh
  104714. * * 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
  104715. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104716. * * The parameter `points` is an array successive Vector3
  104717. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  104718. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  104719. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104720. * * 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
  104721. * * When updating an instance, remember that only point positions can change, not the number of points
  104722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104723. * @param name defines the name of the mesh
  104724. * @param options defines the options used to create the mesh
  104725. * @param scene defines the hosting scene
  104726. * @returns the dashed line mesh
  104727. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104728. */
  104729. static CreateDashedLines(name: string, options: {
  104730. points: Vector3[];
  104731. dashSize?: number;
  104732. gapSize?: number;
  104733. dashNb?: number;
  104734. updatable?: boolean;
  104735. instance?: LinesMesh;
  104736. }, scene?: Nullable<Scene>): LinesMesh;
  104737. }
  104738. }
  104739. declare module BABYLON {
  104740. /**
  104741. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104742. * in order to better appreciate the issue one might have.
  104743. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104744. */
  104745. export class RayHelper {
  104746. /**
  104747. * Defines the ray we are currently tryin to visualize.
  104748. */
  104749. ray: Nullable<Ray>;
  104750. private _renderPoints;
  104751. private _renderLine;
  104752. private _renderFunction;
  104753. private _scene;
  104754. private _updateToMeshFunction;
  104755. private _attachedToMesh;
  104756. private _meshSpaceDirection;
  104757. private _meshSpaceOrigin;
  104758. /**
  104759. * Helper function to create a colored helper in a scene in one line.
  104760. * @param ray Defines the ray we are currently tryin to visualize
  104761. * @param scene Defines the scene the ray is used in
  104762. * @param color Defines the color we want to see the ray in
  104763. * @returns The newly created ray helper.
  104764. */
  104765. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  104766. /**
  104767. * Instantiate a new ray helper.
  104768. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104769. * in order to better appreciate the issue one might have.
  104770. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104771. * @param ray Defines the ray we are currently tryin to visualize
  104772. */
  104773. constructor(ray: Ray);
  104774. /**
  104775. * Shows the ray we are willing to debug.
  104776. * @param scene Defines the scene the ray needs to be rendered in
  104777. * @param color Defines the color the ray needs to be rendered in
  104778. */
  104779. show(scene: Scene, color?: Color3): void;
  104780. /**
  104781. * Hides the ray we are debugging.
  104782. */
  104783. hide(): void;
  104784. private _render;
  104785. /**
  104786. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  104787. * @param mesh Defines the mesh we want the helper attached to
  104788. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  104789. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  104790. * @param length Defines the length of the ray
  104791. */
  104792. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  104793. /**
  104794. * Detach the ray helper from the mesh it has previously been attached to.
  104795. */
  104796. detachFromMesh(): void;
  104797. private _updateToMesh;
  104798. /**
  104799. * Dispose the helper and release its associated resources.
  104800. */
  104801. dispose(): void;
  104802. }
  104803. }
  104804. declare module BABYLON.Debug {
  104805. /**
  104806. * Class used to render a debug view of a given skeleton
  104807. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  104808. */
  104809. export class SkeletonViewer {
  104810. /** defines the skeleton to render */
  104811. skeleton: Skeleton;
  104812. /** defines the mesh attached to the skeleton */
  104813. mesh: AbstractMesh;
  104814. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104815. autoUpdateBonesMatrices: boolean;
  104816. /** defines the rendering group id to use with the viewer */
  104817. renderingGroupId: number;
  104818. /** Gets or sets the color used to render the skeleton */
  104819. color: Color3;
  104820. private _scene;
  104821. private _debugLines;
  104822. private _debugMesh;
  104823. private _isEnabled;
  104824. private _renderFunction;
  104825. private _utilityLayer;
  104826. /**
  104827. * Returns the mesh used to render the bones
  104828. */
  104829. readonly debugMesh: Nullable<LinesMesh>;
  104830. /**
  104831. * Creates a new SkeletonViewer
  104832. * @param skeleton defines the skeleton to render
  104833. * @param mesh defines the mesh attached to the skeleton
  104834. * @param scene defines the hosting scene
  104835. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  104836. * @param renderingGroupId defines the rendering group id to use with the viewer
  104837. */
  104838. constructor(
  104839. /** defines the skeleton to render */
  104840. skeleton: Skeleton,
  104841. /** defines the mesh attached to the skeleton */
  104842. mesh: AbstractMesh, scene: Scene,
  104843. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104844. autoUpdateBonesMatrices?: boolean,
  104845. /** defines the rendering group id to use with the viewer */
  104846. renderingGroupId?: number);
  104847. /** Gets or sets a boolean indicating if the viewer is enabled */
  104848. isEnabled: boolean;
  104849. private _getBonePosition;
  104850. private _getLinesForBonesWithLength;
  104851. private _getLinesForBonesNoLength;
  104852. /** Update the viewer to sync with current skeleton state */
  104853. update(): void;
  104854. /** Release associated resources */
  104855. dispose(): void;
  104856. }
  104857. }
  104858. declare module BABYLON {
  104859. /**
  104860. * Options to create the null engine
  104861. */
  104862. export class NullEngineOptions {
  104863. /**
  104864. * Render width (Default: 512)
  104865. */
  104866. renderWidth: number;
  104867. /**
  104868. * Render height (Default: 256)
  104869. */
  104870. renderHeight: number;
  104871. /**
  104872. * Texture size (Default: 512)
  104873. */
  104874. textureSize: number;
  104875. /**
  104876. * If delta time between frames should be constant
  104877. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104878. */
  104879. deterministicLockstep: boolean;
  104880. /**
  104881. * Maximum about of steps between frames (Default: 4)
  104882. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104883. */
  104884. lockstepMaxSteps: number;
  104885. }
  104886. /**
  104887. * The null engine class provides support for headless version of babylon.js.
  104888. * This can be used in server side scenario or for testing purposes
  104889. */
  104890. export class NullEngine extends Engine {
  104891. private _options;
  104892. /**
  104893. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104894. */
  104895. isDeterministicLockStep(): boolean;
  104896. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  104897. getLockstepMaxSteps(): number;
  104898. /**
  104899. * Sets hardware scaling, used to save performance if needed
  104900. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  104901. */
  104902. getHardwareScalingLevel(): number;
  104903. constructor(options?: NullEngineOptions);
  104904. createVertexBuffer(vertices: FloatArray): DataBuffer;
  104905. createIndexBuffer(indices: IndicesArray): DataBuffer;
  104906. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104907. getRenderWidth(useScreen?: boolean): number;
  104908. getRenderHeight(useScreen?: boolean): number;
  104909. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  104910. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  104911. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104912. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104913. bindSamplers(effect: Effect): void;
  104914. enableEffect(effect: Effect): void;
  104915. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104916. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  104917. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  104918. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  104919. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  104920. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  104921. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  104922. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  104923. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  104924. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  104925. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  104926. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  104927. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  104928. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  104929. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  104930. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104931. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104932. setFloat(uniform: WebGLUniformLocation, value: number): void;
  104933. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  104934. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  104935. setBool(uniform: WebGLUniformLocation, bool: number): void;
  104936. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  104937. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  104938. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  104939. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104940. bindBuffers(vertexBuffers: {
  104941. [key: string]: VertexBuffer;
  104942. }, indexBuffer: DataBuffer, effect: Effect): void;
  104943. wipeCaches(bruteForce?: boolean): void;
  104944. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104945. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104946. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104947. /** @hidden */
  104948. _createTexture(): WebGLTexture;
  104949. /** @hidden */
  104950. _releaseTexture(texture: InternalTexture): void;
  104951. 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;
  104952. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  104953. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  104954. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  104955. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104956. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  104957. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  104958. areAllEffectsReady(): boolean;
  104959. /**
  104960. * @hidden
  104961. * Get the current error code of the webGL context
  104962. * @returns the error code
  104963. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104964. */
  104965. getError(): number;
  104966. /** @hidden */
  104967. _getUnpackAlignement(): number;
  104968. /** @hidden */
  104969. _unpackFlipY(value: boolean): void;
  104970. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  104971. /**
  104972. * Updates a dynamic vertex buffer.
  104973. * @param vertexBuffer the vertex buffer to update
  104974. * @param data the data used to update the vertex buffer
  104975. * @param byteOffset the byte offset of the data (optional)
  104976. * @param byteLength the byte length of the data (optional)
  104977. */
  104978. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  104979. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  104980. /** @hidden */
  104981. _bindTexture(channel: number, texture: InternalTexture): void;
  104982. /** @hidden */
  104983. _releaseBuffer(buffer: DataBuffer): boolean;
  104984. releaseEffects(): void;
  104985. displayLoadingUI(): void;
  104986. hideLoadingUI(): void;
  104987. /** @hidden */
  104988. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104989. /** @hidden */
  104990. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104991. /** @hidden */
  104992. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104993. /** @hidden */
  104994. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  104995. }
  104996. }
  104997. declare module BABYLON {
  104998. /** @hidden */
  104999. export class _OcclusionDataStorage {
  105000. /** @hidden */
  105001. occlusionInternalRetryCounter: number;
  105002. /** @hidden */
  105003. isOcclusionQueryInProgress: boolean;
  105004. /** @hidden */
  105005. isOccluded: boolean;
  105006. /** @hidden */
  105007. occlusionRetryCount: number;
  105008. /** @hidden */
  105009. occlusionType: number;
  105010. /** @hidden */
  105011. occlusionQueryAlgorithmType: number;
  105012. }
  105013. interface Engine {
  105014. /**
  105015. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  105016. * @return the new query
  105017. */
  105018. createQuery(): WebGLQuery;
  105019. /**
  105020. * Delete and release a webGL query
  105021. * @param query defines the query to delete
  105022. * @return the current engine
  105023. */
  105024. deleteQuery(query: WebGLQuery): Engine;
  105025. /**
  105026. * Check if a given query has resolved and got its value
  105027. * @param query defines the query to check
  105028. * @returns true if the query got its value
  105029. */
  105030. isQueryResultAvailable(query: WebGLQuery): boolean;
  105031. /**
  105032. * Gets the value of a given query
  105033. * @param query defines the query to check
  105034. * @returns the value of the query
  105035. */
  105036. getQueryResult(query: WebGLQuery): number;
  105037. /**
  105038. * Initiates an occlusion query
  105039. * @param algorithmType defines the algorithm to use
  105040. * @param query defines the query to use
  105041. * @returns the current engine
  105042. * @see http://doc.babylonjs.com/features/occlusionquery
  105043. */
  105044. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  105045. /**
  105046. * Ends an occlusion query
  105047. * @see http://doc.babylonjs.com/features/occlusionquery
  105048. * @param algorithmType defines the algorithm to use
  105049. * @returns the current engine
  105050. */
  105051. endOcclusionQuery(algorithmType: number): Engine;
  105052. /**
  105053. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  105054. * Please note that only one query can be issued at a time
  105055. * @returns a time token used to track the time span
  105056. */
  105057. startTimeQuery(): Nullable<_TimeToken>;
  105058. /**
  105059. * Ends a time query
  105060. * @param token defines the token used to measure the time span
  105061. * @returns the time spent (in ns)
  105062. */
  105063. endTimeQuery(token: _TimeToken): int;
  105064. /** @hidden */
  105065. _currentNonTimestampToken: Nullable<_TimeToken>;
  105066. /** @hidden */
  105067. _createTimeQuery(): WebGLQuery;
  105068. /** @hidden */
  105069. _deleteTimeQuery(query: WebGLQuery): void;
  105070. /** @hidden */
  105071. _getGlAlgorithmType(algorithmType: number): number;
  105072. /** @hidden */
  105073. _getTimeQueryResult(query: WebGLQuery): any;
  105074. /** @hidden */
  105075. _getTimeQueryAvailability(query: WebGLQuery): any;
  105076. }
  105077. interface AbstractMesh {
  105078. /**
  105079. * Backing filed
  105080. * @hidden
  105081. */
  105082. __occlusionDataStorage: _OcclusionDataStorage;
  105083. /**
  105084. * Access property
  105085. * @hidden
  105086. */
  105087. _occlusionDataStorage: _OcclusionDataStorage;
  105088. /**
  105089. * 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.
  105090. * The default value is -1 which means don't break the query and wait till the result
  105091. * @see http://doc.babylonjs.com/features/occlusionquery
  105092. */
  105093. occlusionRetryCount: number;
  105094. /**
  105095. * 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:
  105096. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  105097. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  105098. * * 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.
  105099. * @see http://doc.babylonjs.com/features/occlusionquery
  105100. */
  105101. occlusionType: number;
  105102. /**
  105103. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  105104. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  105105. * * 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.
  105106. * @see http://doc.babylonjs.com/features/occlusionquery
  105107. */
  105108. occlusionQueryAlgorithmType: number;
  105109. /**
  105110. * 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
  105111. * @see http://doc.babylonjs.com/features/occlusionquery
  105112. */
  105113. isOccluded: boolean;
  105114. /**
  105115. * Flag to check the progress status of the query
  105116. * @see http://doc.babylonjs.com/features/occlusionquery
  105117. */
  105118. isOcclusionQueryInProgress: boolean;
  105119. }
  105120. }
  105121. declare module BABYLON {
  105122. /** @hidden */
  105123. export var _forceTransformFeedbackToBundle: boolean;
  105124. interface Engine {
  105125. /**
  105126. * Creates a webGL transform feedback object
  105127. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  105128. * @returns the webGL transform feedback object
  105129. */
  105130. createTransformFeedback(): WebGLTransformFeedback;
  105131. /**
  105132. * Delete a webGL transform feedback object
  105133. * @param value defines the webGL transform feedback object to delete
  105134. */
  105135. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  105136. /**
  105137. * Bind a webGL transform feedback object to the webgl context
  105138. * @param value defines the webGL transform feedback object to bind
  105139. */
  105140. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  105141. /**
  105142. * Begins a transform feedback operation
  105143. * @param usePoints defines if points or triangles must be used
  105144. */
  105145. beginTransformFeedback(usePoints: boolean): void;
  105146. /**
  105147. * Ends a transform feedback operation
  105148. */
  105149. endTransformFeedback(): void;
  105150. /**
  105151. * Specify the varyings to use with transform feedback
  105152. * @param program defines the associated webGL program
  105153. * @param value defines the list of strings representing the varying names
  105154. */
  105155. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  105156. /**
  105157. * Bind a webGL buffer for a transform feedback operation
  105158. * @param value defines the webGL buffer to bind
  105159. */
  105160. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  105161. }
  105162. }
  105163. declare module BABYLON {
  105164. /**
  105165. * Creation options of the multi render target texture.
  105166. */
  105167. export interface IMultiRenderTargetOptions {
  105168. /**
  105169. * Define if the texture needs to create mip maps after render.
  105170. */
  105171. generateMipMaps?: boolean;
  105172. /**
  105173. * Define the types of all the draw buffers we want to create
  105174. */
  105175. types?: number[];
  105176. /**
  105177. * Define the sampling modes of all the draw buffers we want to create
  105178. */
  105179. samplingModes?: number[];
  105180. /**
  105181. * Define if a depth buffer is required
  105182. */
  105183. generateDepthBuffer?: boolean;
  105184. /**
  105185. * Define if a stencil buffer is required
  105186. */
  105187. generateStencilBuffer?: boolean;
  105188. /**
  105189. * Define if a depth texture is required instead of a depth buffer
  105190. */
  105191. generateDepthTexture?: boolean;
  105192. /**
  105193. * Define the number of desired draw buffers
  105194. */
  105195. textureCount?: number;
  105196. /**
  105197. * Define if aspect ratio should be adapted to the texture or stay the scene one
  105198. */
  105199. doNotChangeAspectRatio?: boolean;
  105200. /**
  105201. * Define the default type of the buffers we are creating
  105202. */
  105203. defaultType?: number;
  105204. }
  105205. /**
  105206. * A multi render target, like a render target provides the ability to render to a texture.
  105207. * Unlike the render target, it can render to several draw buffers in one draw.
  105208. * This is specially interesting in deferred rendering or for any effects requiring more than
  105209. * just one color from a single pass.
  105210. */
  105211. export class MultiRenderTarget extends RenderTargetTexture {
  105212. private _internalTextures;
  105213. private _textures;
  105214. private _multiRenderTargetOptions;
  105215. /**
  105216. * Get if draw buffers are currently supported by the used hardware and browser.
  105217. */
  105218. readonly isSupported: boolean;
  105219. /**
  105220. * Get the list of textures generated by the multi render target.
  105221. */
  105222. readonly textures: Texture[];
  105223. /**
  105224. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  105225. */
  105226. readonly depthTexture: Texture;
  105227. /**
  105228. * Set the wrapping mode on U of all the textures we are rendering to.
  105229. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  105230. */
  105231. wrapU: number;
  105232. /**
  105233. * Set the wrapping mode on V of all the textures we are rendering to.
  105234. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  105235. */
  105236. wrapV: number;
  105237. /**
  105238. * Instantiate a new multi render target texture.
  105239. * A multi render target, like a render target provides the ability to render to a texture.
  105240. * Unlike the render target, it can render to several draw buffers in one draw.
  105241. * This is specially interesting in deferred rendering or for any effects requiring more than
  105242. * just one color from a single pass.
  105243. * @param name Define the name of the texture
  105244. * @param size Define the size of the buffers to render to
  105245. * @param count Define the number of target we are rendering into
  105246. * @param scene Define the scene the texture belongs to
  105247. * @param options Define the options used to create the multi render target
  105248. */
  105249. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  105250. /** @hidden */
  105251. _rebuild(): void;
  105252. private _createInternalTextures;
  105253. private _createTextures;
  105254. /**
  105255. * Define the number of samples used if MSAA is enabled.
  105256. */
  105257. samples: number;
  105258. /**
  105259. * Resize all the textures in the multi render target.
  105260. * Be carrefull as it will recreate all the data in the new texture.
  105261. * @param size Define the new size
  105262. */
  105263. resize(size: any): void;
  105264. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  105265. /**
  105266. * Dispose the render targets and their associated resources
  105267. */
  105268. dispose(): void;
  105269. /**
  105270. * Release all the underlying texture used as draw buffers.
  105271. */
  105272. releaseInternalTextures(): void;
  105273. }
  105274. }
  105275. declare module BABYLON {
  105276. interface Engine {
  105277. /**
  105278. * Unbind a list of render target textures from the webGL context
  105279. * This is used only when drawBuffer extension or webGL2 are active
  105280. * @param textures defines the render target textures to unbind
  105281. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105282. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105283. */
  105284. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  105285. /**
  105286. * Create a multi render target texture
  105287. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  105288. * @param size defines the size of the texture
  105289. * @param options defines the creation options
  105290. * @returns the cube texture as an InternalTexture
  105291. */
  105292. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  105293. /**
  105294. * Update the sample count for a given multiple render target texture
  105295. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  105296. * @param textures defines the textures to update
  105297. * @param samples defines the sample count to set
  105298. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  105299. */
  105300. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  105301. }
  105302. }
  105303. declare module BABYLON {
  105304. /**
  105305. * Gather the list of clipboard event types as constants.
  105306. */
  105307. export class ClipboardEventTypes {
  105308. /**
  105309. * The clipboard event is fired when a copy command is active (pressed).
  105310. */
  105311. static readonly COPY: number;
  105312. /**
  105313. * The clipboard event is fired when a cut command is active (pressed).
  105314. */
  105315. static readonly CUT: number;
  105316. /**
  105317. * The clipboard event is fired when a paste command is active (pressed).
  105318. */
  105319. static readonly PASTE: number;
  105320. }
  105321. /**
  105322. * This class is used to store clipboard related info for the onClipboardObservable event.
  105323. */
  105324. export class ClipboardInfo {
  105325. /**
  105326. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105327. */
  105328. type: number;
  105329. /**
  105330. * Defines the related dom event
  105331. */
  105332. event: ClipboardEvent;
  105333. /**
  105334. *Creates an instance of ClipboardInfo.
  105335. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  105336. * @param event Defines the related dom event
  105337. */
  105338. constructor(
  105339. /**
  105340. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105341. */
  105342. type: number,
  105343. /**
  105344. * Defines the related dom event
  105345. */
  105346. event: ClipboardEvent);
  105347. /**
  105348. * Get the clipboard event's type from the keycode.
  105349. * @param keyCode Defines the keyCode for the current keyboard event.
  105350. * @return {number}
  105351. */
  105352. static GetTypeFromCharacter(keyCode: number): number;
  105353. }
  105354. }
  105355. declare module BABYLON {
  105356. /**
  105357. * Class used to represent data loading progression
  105358. */
  105359. export class SceneLoaderProgressEvent {
  105360. /** defines if data length to load can be evaluated */
  105361. readonly lengthComputable: boolean;
  105362. /** defines the loaded data length */
  105363. readonly loaded: number;
  105364. /** defines the data length to load */
  105365. readonly total: number;
  105366. /**
  105367. * Create a new progress event
  105368. * @param lengthComputable defines if data length to load can be evaluated
  105369. * @param loaded defines the loaded data length
  105370. * @param total defines the data length to load
  105371. */
  105372. constructor(
  105373. /** defines if data length to load can be evaluated */
  105374. lengthComputable: boolean,
  105375. /** defines the loaded data length */
  105376. loaded: number,
  105377. /** defines the data length to load */
  105378. total: number);
  105379. /**
  105380. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  105381. * @param event defines the source event
  105382. * @returns a new SceneLoaderProgressEvent
  105383. */
  105384. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  105385. }
  105386. /**
  105387. * Interface used by SceneLoader plugins to define supported file extensions
  105388. */
  105389. export interface ISceneLoaderPluginExtensions {
  105390. /**
  105391. * Defines the list of supported extensions
  105392. */
  105393. [extension: string]: {
  105394. isBinary: boolean;
  105395. };
  105396. }
  105397. /**
  105398. * Interface used by SceneLoader plugin factory
  105399. */
  105400. export interface ISceneLoaderPluginFactory {
  105401. /**
  105402. * Defines the name of the factory
  105403. */
  105404. name: string;
  105405. /**
  105406. * Function called to create a new plugin
  105407. * @return the new plugin
  105408. */
  105409. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  105410. /**
  105411. * Boolean indicating if the plugin can direct load specific data
  105412. */
  105413. canDirectLoad?: (data: string) => boolean;
  105414. }
  105415. /**
  105416. * Interface used to define a SceneLoader plugin
  105417. */
  105418. export interface ISceneLoaderPlugin {
  105419. /**
  105420. * The friendly name of this plugin.
  105421. */
  105422. name: string;
  105423. /**
  105424. * The file extensions supported by this plugin.
  105425. */
  105426. extensions: string | ISceneLoaderPluginExtensions;
  105427. /**
  105428. * Import meshes into a scene.
  105429. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105430. * @param scene The scene to import into
  105431. * @param data The data to import
  105432. * @param rootUrl The root url for scene and resources
  105433. * @param meshes The meshes array to import into
  105434. * @param particleSystems The particle systems array to import into
  105435. * @param skeletons The skeletons array to import into
  105436. * @param onError The callback when import fails
  105437. * @returns True if successful or false otherwise
  105438. */
  105439. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105440. /**
  105441. * Load into a scene.
  105442. * @param scene The scene to load into
  105443. * @param data The data to import
  105444. * @param rootUrl The root url for scene and resources
  105445. * @param onError The callback when import fails
  105446. * @returns true if successful or false otherwise
  105447. */
  105448. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105449. /**
  105450. * The callback that returns true if the data can be directly loaded.
  105451. */
  105452. canDirectLoad?: (data: string) => boolean;
  105453. /**
  105454. * The callback that allows custom handling of the root url based on the response url.
  105455. */
  105456. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105457. /**
  105458. * Load into an asset container.
  105459. * @param scene The scene to load into
  105460. * @param data The data to import
  105461. * @param rootUrl The root url for scene and resources
  105462. * @param onError The callback when import fails
  105463. * @returns The loaded asset container
  105464. */
  105465. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105466. }
  105467. /**
  105468. * Interface used to define an async SceneLoader plugin
  105469. */
  105470. export interface ISceneLoaderPluginAsync {
  105471. /**
  105472. * The friendly name of this plugin.
  105473. */
  105474. name: string;
  105475. /**
  105476. * The file extensions supported by this plugin.
  105477. */
  105478. extensions: string | ISceneLoaderPluginExtensions;
  105479. /**
  105480. * Import meshes into a scene.
  105481. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105482. * @param scene The scene to import into
  105483. * @param data The data to import
  105484. * @param rootUrl The root url for scene and resources
  105485. * @param onProgress The callback when the load progresses
  105486. * @param fileName Defines the name of the file to load
  105487. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105488. */
  105489. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105490. meshes: AbstractMesh[];
  105491. particleSystems: IParticleSystem[];
  105492. skeletons: Skeleton[];
  105493. animationGroups: AnimationGroup[];
  105494. }>;
  105495. /**
  105496. * Load into a scene.
  105497. * @param scene The scene to load into
  105498. * @param data The data to import
  105499. * @param rootUrl The root url for scene and resources
  105500. * @param onProgress The callback when the load progresses
  105501. * @param fileName Defines the name of the file to load
  105502. * @returns Nothing
  105503. */
  105504. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105505. /**
  105506. * The callback that returns true if the data can be directly loaded.
  105507. */
  105508. canDirectLoad?: (data: string) => boolean;
  105509. /**
  105510. * The callback that allows custom handling of the root url based on the response url.
  105511. */
  105512. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105513. /**
  105514. * Load into an asset container.
  105515. * @param scene The scene to load into
  105516. * @param data The data to import
  105517. * @param rootUrl The root url for scene and resources
  105518. * @param onProgress The callback when the load progresses
  105519. * @param fileName Defines the name of the file to load
  105520. * @returns The loaded asset container
  105521. */
  105522. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105523. }
  105524. /**
  105525. * Class used to load scene from various file formats using registered plugins
  105526. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105527. */
  105528. export class SceneLoader {
  105529. /**
  105530. * No logging while loading
  105531. */
  105532. static readonly NO_LOGGING: number;
  105533. /**
  105534. * Minimal logging while loading
  105535. */
  105536. static readonly MINIMAL_LOGGING: number;
  105537. /**
  105538. * Summary logging while loading
  105539. */
  105540. static readonly SUMMARY_LOGGING: number;
  105541. /**
  105542. * Detailled logging while loading
  105543. */
  105544. static readonly DETAILED_LOGGING: number;
  105545. /**
  105546. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105547. */
  105548. static ForceFullSceneLoadingForIncremental: boolean;
  105549. /**
  105550. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105551. */
  105552. static ShowLoadingScreen: boolean;
  105553. /**
  105554. * Defines the current logging level (while loading the scene)
  105555. * @ignorenaming
  105556. */
  105557. static loggingLevel: number;
  105558. /**
  105559. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105560. */
  105561. static CleanBoneMatrixWeights: boolean;
  105562. /**
  105563. * Event raised when a plugin is used to load a scene
  105564. */
  105565. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105566. private static _registeredPlugins;
  105567. private static _getDefaultPlugin;
  105568. private static _getPluginForExtension;
  105569. private static _getPluginForDirectLoad;
  105570. private static _getPluginForFilename;
  105571. private static _getDirectLoad;
  105572. private static _loadData;
  105573. private static _getFileInfo;
  105574. /**
  105575. * Gets a plugin that can load the given extension
  105576. * @param extension defines the extension to load
  105577. * @returns a plugin or null if none works
  105578. */
  105579. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105580. /**
  105581. * Gets a boolean indicating that the given extension can be loaded
  105582. * @param extension defines the extension to load
  105583. * @returns true if the extension is supported
  105584. */
  105585. static IsPluginForExtensionAvailable(extension: string): boolean;
  105586. /**
  105587. * Adds a new plugin to the list of registered plugins
  105588. * @param plugin defines the plugin to add
  105589. */
  105590. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105591. /**
  105592. * Import meshes into a scene
  105593. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105594. * @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)
  105595. * @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)
  105596. * @param scene the instance of BABYLON.Scene to append to
  105597. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105598. * @param onProgress a callback with a progress event for each file being loaded
  105599. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105600. * @param pluginExtension the extension used to determine the plugin
  105601. * @returns The loaded plugin
  105602. */
  105603. 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>;
  105604. /**
  105605. * Import meshes into a scene
  105606. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105607. * @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)
  105608. * @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)
  105609. * @param scene the instance of BABYLON.Scene to append to
  105610. * @param onProgress a callback with a progress event for each file being loaded
  105611. * @param pluginExtension the extension used to determine the plugin
  105612. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105613. */
  105614. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105615. meshes: AbstractMesh[];
  105616. particleSystems: IParticleSystem[];
  105617. skeletons: Skeleton[];
  105618. animationGroups: AnimationGroup[];
  105619. }>;
  105620. /**
  105621. * Load a scene
  105622. * @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)
  105623. * @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)
  105624. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105625. * @param onSuccess a callback with the scene when import succeeds
  105626. * @param onProgress a callback with a progress event for each file being loaded
  105627. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105628. * @param pluginExtension the extension used to determine the plugin
  105629. * @returns The loaded plugin
  105630. */
  105631. 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>;
  105632. /**
  105633. * Load a scene
  105634. * @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)
  105635. * @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)
  105636. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105637. * @param onProgress a callback with a progress event for each file being loaded
  105638. * @param pluginExtension the extension used to determine the plugin
  105639. * @returns The loaded scene
  105640. */
  105641. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105642. /**
  105643. * Append a scene
  105644. * @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)
  105645. * @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)
  105646. * @param scene is the instance of BABYLON.Scene to append to
  105647. * @param onSuccess a callback with the scene when import succeeds
  105648. * @param onProgress a callback with a progress event for each file being loaded
  105649. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105650. * @param pluginExtension the extension used to determine the plugin
  105651. * @returns The loaded plugin
  105652. */
  105653. 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>;
  105654. /**
  105655. * Append a scene
  105656. * @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)
  105657. * @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)
  105658. * @param scene is the instance of BABYLON.Scene to append to
  105659. * @param onProgress a callback with a progress event for each file being loaded
  105660. * @param pluginExtension the extension used to determine the plugin
  105661. * @returns The given scene
  105662. */
  105663. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105664. /**
  105665. * Load a scene into an asset container
  105666. * @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)
  105667. * @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)
  105668. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105669. * @param onSuccess a callback with the scene when import succeeds
  105670. * @param onProgress a callback with a progress event for each file being loaded
  105671. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105672. * @param pluginExtension the extension used to determine the plugin
  105673. * @returns The loaded plugin
  105674. */
  105675. 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>;
  105676. /**
  105677. * Load a scene into an asset container
  105678. * @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)
  105679. * @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)
  105680. * @param scene is the instance of Scene to append to
  105681. * @param onProgress a callback with a progress event for each file being loaded
  105682. * @param pluginExtension the extension used to determine the plugin
  105683. * @returns The loaded asset container
  105684. */
  105685. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105686. }
  105687. }
  105688. declare module BABYLON {
  105689. /**
  105690. * Google Daydream controller
  105691. */
  105692. export class DaydreamController extends WebVRController {
  105693. /**
  105694. * Base Url for the controller model.
  105695. */
  105696. static MODEL_BASE_URL: string;
  105697. /**
  105698. * File name for the controller model.
  105699. */
  105700. static MODEL_FILENAME: string;
  105701. /**
  105702. * Gamepad Id prefix used to identify Daydream Controller.
  105703. */
  105704. static readonly GAMEPAD_ID_PREFIX: string;
  105705. /**
  105706. * Creates a new DaydreamController from a gamepad
  105707. * @param vrGamepad the gamepad that the controller should be created from
  105708. */
  105709. constructor(vrGamepad: any);
  105710. /**
  105711. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105712. * @param scene scene in which to add meshes
  105713. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105714. */
  105715. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105716. /**
  105717. * Called once for each button that changed state since the last frame
  105718. * @param buttonIdx Which button index changed
  105719. * @param state New state of the button
  105720. * @param changes Which properties on the state changed since last frame
  105721. */
  105722. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105723. }
  105724. }
  105725. declare module BABYLON {
  105726. /**
  105727. * Gear VR Controller
  105728. */
  105729. export class GearVRController extends WebVRController {
  105730. /**
  105731. * Base Url for the controller model.
  105732. */
  105733. static MODEL_BASE_URL: string;
  105734. /**
  105735. * File name for the controller model.
  105736. */
  105737. static MODEL_FILENAME: string;
  105738. /**
  105739. * Gamepad Id prefix used to identify this controller.
  105740. */
  105741. static readonly GAMEPAD_ID_PREFIX: string;
  105742. private readonly _buttonIndexToObservableNameMap;
  105743. /**
  105744. * Creates a new GearVRController from a gamepad
  105745. * @param vrGamepad the gamepad that the controller should be created from
  105746. */
  105747. constructor(vrGamepad: any);
  105748. /**
  105749. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105750. * @param scene scene in which to add meshes
  105751. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105752. */
  105753. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105754. /**
  105755. * Called once for each button that changed state since the last frame
  105756. * @param buttonIdx Which button index changed
  105757. * @param state New state of the button
  105758. * @param changes Which properties on the state changed since last frame
  105759. */
  105760. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105761. }
  105762. }
  105763. declare module BABYLON {
  105764. /**
  105765. * Generic Controller
  105766. */
  105767. export class GenericController extends WebVRController {
  105768. /**
  105769. * Base Url for the controller model.
  105770. */
  105771. static readonly MODEL_BASE_URL: string;
  105772. /**
  105773. * File name for the controller model.
  105774. */
  105775. static readonly MODEL_FILENAME: string;
  105776. /**
  105777. * Creates a new GenericController from a gamepad
  105778. * @param vrGamepad the gamepad that the controller should be created from
  105779. */
  105780. constructor(vrGamepad: any);
  105781. /**
  105782. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105783. * @param scene scene in which to add meshes
  105784. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105785. */
  105786. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105787. /**
  105788. * Called once for each button that changed state since the last frame
  105789. * @param buttonIdx Which button index changed
  105790. * @param state New state of the button
  105791. * @param changes Which properties on the state changed since last frame
  105792. */
  105793. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105794. }
  105795. }
  105796. declare module BABYLON {
  105797. /**
  105798. * Oculus Touch Controller
  105799. */
  105800. export class OculusTouchController extends WebVRController {
  105801. /**
  105802. * Base Url for the controller model.
  105803. */
  105804. static MODEL_BASE_URL: string;
  105805. /**
  105806. * File name for the left controller model.
  105807. */
  105808. static MODEL_LEFT_FILENAME: string;
  105809. /**
  105810. * File name for the right controller model.
  105811. */
  105812. static MODEL_RIGHT_FILENAME: string;
  105813. /**
  105814. * Base Url for the Quest controller model.
  105815. */
  105816. static QUEST_MODEL_BASE_URL: string;
  105817. /**
  105818. * @hidden
  105819. * If the controllers are running on a device that needs the updated Quest controller models
  105820. */
  105821. static _IsQuest: boolean;
  105822. /**
  105823. * Fired when the secondary trigger on this controller is modified
  105824. */
  105825. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105826. /**
  105827. * Fired when the thumb rest on this controller is modified
  105828. */
  105829. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105830. /**
  105831. * Creates a new OculusTouchController from a gamepad
  105832. * @param vrGamepad the gamepad that the controller should be created from
  105833. */
  105834. constructor(vrGamepad: any);
  105835. /**
  105836. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105837. * @param scene scene in which to add meshes
  105838. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105839. */
  105840. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105841. /**
  105842. * Fired when the A button on this controller is modified
  105843. */
  105844. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105845. /**
  105846. * Fired when the B button on this controller is modified
  105847. */
  105848. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105849. /**
  105850. * Fired when the X button on this controller is modified
  105851. */
  105852. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105853. /**
  105854. * Fired when the Y button on this controller is modified
  105855. */
  105856. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105857. /**
  105858. * Called once for each button that changed state since the last frame
  105859. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105860. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105861. * 2) secondary trigger (same)
  105862. * 3) A (right) X (left), touch, pressed = value
  105863. * 4) B / Y
  105864. * 5) thumb rest
  105865. * @param buttonIdx Which button index changed
  105866. * @param state New state of the button
  105867. * @param changes Which properties on the state changed since last frame
  105868. */
  105869. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105870. }
  105871. }
  105872. declare module BABYLON {
  105873. /**
  105874. * Vive Controller
  105875. */
  105876. export class ViveController extends WebVRController {
  105877. /**
  105878. * Base Url for the controller model.
  105879. */
  105880. static MODEL_BASE_URL: string;
  105881. /**
  105882. * File name for the controller model.
  105883. */
  105884. static MODEL_FILENAME: string;
  105885. /**
  105886. * Creates a new ViveController from a gamepad
  105887. * @param vrGamepad the gamepad that the controller should be created from
  105888. */
  105889. constructor(vrGamepad: any);
  105890. /**
  105891. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105892. * @param scene scene in which to add meshes
  105893. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105894. */
  105895. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105896. /**
  105897. * Fired when the left button on this controller is modified
  105898. */
  105899. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105900. /**
  105901. * Fired when the right button on this controller is modified
  105902. */
  105903. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105904. /**
  105905. * Fired when the menu button on this controller is modified
  105906. */
  105907. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105908. /**
  105909. * Called once for each button that changed state since the last frame
  105910. * Vive mapping:
  105911. * 0: touchpad
  105912. * 1: trigger
  105913. * 2: left AND right buttons
  105914. * 3: menu button
  105915. * @param buttonIdx Which button index changed
  105916. * @param state New state of the button
  105917. * @param changes Which properties on the state changed since last frame
  105918. */
  105919. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105920. }
  105921. }
  105922. declare module BABYLON {
  105923. /**
  105924. * Defines the WindowsMotionController object that the state of the windows motion controller
  105925. */
  105926. export class WindowsMotionController extends WebVRController {
  105927. /**
  105928. * The base url used to load the left and right controller models
  105929. */
  105930. static MODEL_BASE_URL: string;
  105931. /**
  105932. * The name of the left controller model file
  105933. */
  105934. static MODEL_LEFT_FILENAME: string;
  105935. /**
  105936. * The name of the right controller model file
  105937. */
  105938. static MODEL_RIGHT_FILENAME: string;
  105939. /**
  105940. * The controller name prefix for this controller type
  105941. */
  105942. static readonly GAMEPAD_ID_PREFIX: string;
  105943. /**
  105944. * The controller id pattern for this controller type
  105945. */
  105946. private static readonly GAMEPAD_ID_PATTERN;
  105947. private _loadedMeshInfo;
  105948. private readonly _mapping;
  105949. /**
  105950. * Fired when the trackpad on this controller is clicked
  105951. */
  105952. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105953. /**
  105954. * Fired when the trackpad on this controller is modified
  105955. */
  105956. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105957. /**
  105958. * The current x and y values of this controller's trackpad
  105959. */
  105960. trackpad: StickValues;
  105961. /**
  105962. * Creates a new WindowsMotionController from a gamepad
  105963. * @param vrGamepad the gamepad that the controller should be created from
  105964. */
  105965. constructor(vrGamepad: any);
  105966. /**
  105967. * Fired when the trigger on this controller is modified
  105968. */
  105969. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105970. /**
  105971. * Fired when the menu button on this controller is modified
  105972. */
  105973. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105974. /**
  105975. * Fired when the grip button on this controller is modified
  105976. */
  105977. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105978. /**
  105979. * Fired when the thumbstick button on this controller is modified
  105980. */
  105981. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105982. /**
  105983. * Fired when the touchpad button on this controller is modified
  105984. */
  105985. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105986. /**
  105987. * Fired when the touchpad values on this controller are modified
  105988. */
  105989. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105990. private _updateTrackpad;
  105991. /**
  105992. * Called once per frame by the engine.
  105993. */
  105994. update(): void;
  105995. /**
  105996. * Called once for each button that changed state since the last frame
  105997. * @param buttonIdx Which button index changed
  105998. * @param state New state of the button
  105999. * @param changes Which properties on the state changed since last frame
  106000. */
  106001. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106002. /**
  106003. * Moves the buttons on the controller mesh based on their current state
  106004. * @param buttonName the name of the button to move
  106005. * @param buttonValue the value of the button which determines the buttons new position
  106006. */
  106007. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  106008. /**
  106009. * Moves the axis on the controller mesh based on its current state
  106010. * @param axis the index of the axis
  106011. * @param axisValue the value of the axis which determines the meshes new position
  106012. * @hidden
  106013. */
  106014. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  106015. /**
  106016. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106017. * @param scene scene in which to add meshes
  106018. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106019. */
  106020. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  106021. /**
  106022. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  106023. * can be transformed by button presses and axes values, based on this._mapping.
  106024. *
  106025. * @param scene scene in which the meshes exist
  106026. * @param meshes list of meshes that make up the controller model to process
  106027. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  106028. */
  106029. private processModel;
  106030. private createMeshInfo;
  106031. /**
  106032. * Gets the ray of the controller in the direction the controller is pointing
  106033. * @param length the length the resulting ray should be
  106034. * @returns a ray in the direction the controller is pointing
  106035. */
  106036. getForwardRay(length?: number): Ray;
  106037. /**
  106038. * Disposes of the controller
  106039. */
  106040. dispose(): void;
  106041. }
  106042. }
  106043. declare module BABYLON {
  106044. /**
  106045. * Class containing static functions to help procedurally build meshes
  106046. */
  106047. export class PolyhedronBuilder {
  106048. /**
  106049. * Creates a polyhedron mesh
  106050. * * 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
  106051. * * The parameter `size` (positive float, default 1) sets the polygon size
  106052. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106053. * * 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`
  106054. * * 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
  106055. * * 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)`)
  106056. * * 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
  106057. * * 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
  106058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106059. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106061. * @param name defines the name of the mesh
  106062. * @param options defines the options used to create the mesh
  106063. * @param scene defines the hosting scene
  106064. * @returns the polyhedron mesh
  106065. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106066. */
  106067. static CreatePolyhedron(name: string, options: {
  106068. type?: number;
  106069. size?: number;
  106070. sizeX?: number;
  106071. sizeY?: number;
  106072. sizeZ?: number;
  106073. custom?: any;
  106074. faceUV?: Vector4[];
  106075. faceColors?: Color4[];
  106076. flat?: boolean;
  106077. updatable?: boolean;
  106078. sideOrientation?: number;
  106079. frontUVs?: Vector4;
  106080. backUVs?: Vector4;
  106081. }, scene?: Nullable<Scene>): Mesh;
  106082. }
  106083. }
  106084. declare module BABYLON {
  106085. /**
  106086. * Gizmo that enables scaling a mesh along 3 axis
  106087. */
  106088. export class ScaleGizmo extends Gizmo {
  106089. /**
  106090. * Internal gizmo used for interactions on the x axis
  106091. */
  106092. xGizmo: AxisScaleGizmo;
  106093. /**
  106094. * Internal gizmo used for interactions on the y axis
  106095. */
  106096. yGizmo: AxisScaleGizmo;
  106097. /**
  106098. * Internal gizmo used for interactions on the z axis
  106099. */
  106100. zGizmo: AxisScaleGizmo;
  106101. /**
  106102. * Internal gizmo used to scale all axis equally
  106103. */
  106104. uniformScaleGizmo: AxisScaleGizmo;
  106105. private _meshAttached;
  106106. private _updateGizmoRotationToMatchAttachedMesh;
  106107. private _snapDistance;
  106108. private _scaleRatio;
  106109. private _uniformScalingMesh;
  106110. private _octahedron;
  106111. /** Fires an event when any of it's sub gizmos are dragged */
  106112. onDragStartObservable: Observable<unknown>;
  106113. /** Fires an event when any of it's sub gizmos are released from dragging */
  106114. onDragEndObservable: Observable<unknown>;
  106115. attachedMesh: Nullable<AbstractMesh>;
  106116. /**
  106117. * Creates a ScaleGizmo
  106118. * @param gizmoLayer The utility layer the gizmo will be added to
  106119. */
  106120. constructor(gizmoLayer?: UtilityLayerRenderer);
  106121. updateGizmoRotationToMatchAttachedMesh: boolean;
  106122. /**
  106123. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106124. */
  106125. snapDistance: number;
  106126. /**
  106127. * Ratio for the scale of the gizmo (Default: 1)
  106128. */
  106129. scaleRatio: number;
  106130. /**
  106131. * Disposes of the gizmo
  106132. */
  106133. dispose(): void;
  106134. }
  106135. }
  106136. declare module BABYLON {
  106137. /**
  106138. * Single axis scale gizmo
  106139. */
  106140. export class AxisScaleGizmo extends Gizmo {
  106141. /**
  106142. * Drag behavior responsible for the gizmos dragging interactions
  106143. */
  106144. dragBehavior: PointerDragBehavior;
  106145. private _pointerObserver;
  106146. /**
  106147. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106148. */
  106149. snapDistance: number;
  106150. /**
  106151. * Event that fires each time the gizmo snaps to a new location.
  106152. * * snapDistance is the the change in distance
  106153. */
  106154. onSnapObservable: Observable<{
  106155. snapDistance: number;
  106156. }>;
  106157. /**
  106158. * If the scaling operation should be done on all axis (default: false)
  106159. */
  106160. uniformScaling: boolean;
  106161. private _isEnabled;
  106162. private _parent;
  106163. private _arrow;
  106164. private _coloredMaterial;
  106165. private _hoverMaterial;
  106166. /**
  106167. * Creates an AxisScaleGizmo
  106168. * @param gizmoLayer The utility layer the gizmo will be added to
  106169. * @param dragAxis The axis which the gizmo will be able to scale on
  106170. * @param color The color of the gizmo
  106171. */
  106172. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  106173. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106174. /**
  106175. * If the gizmo is enabled
  106176. */
  106177. isEnabled: boolean;
  106178. /**
  106179. * Disposes of the gizmo
  106180. */
  106181. dispose(): void;
  106182. /**
  106183. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  106184. * @param mesh The mesh to replace the default mesh of the gizmo
  106185. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  106186. */
  106187. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  106188. }
  106189. }
  106190. declare module BABYLON {
  106191. /**
  106192. * Bounding box gizmo
  106193. */
  106194. export class BoundingBoxGizmo extends Gizmo {
  106195. private _lineBoundingBox;
  106196. private _rotateSpheresParent;
  106197. private _scaleBoxesParent;
  106198. private _boundingDimensions;
  106199. private _renderObserver;
  106200. private _pointerObserver;
  106201. private _scaleDragSpeed;
  106202. private _tmpQuaternion;
  106203. private _tmpVector;
  106204. private _tmpRotationMatrix;
  106205. /**
  106206. * 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)
  106207. */
  106208. ignoreChildren: boolean;
  106209. /**
  106210. * 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)
  106211. */
  106212. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  106213. /**
  106214. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  106215. */
  106216. rotationSphereSize: number;
  106217. /**
  106218. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  106219. */
  106220. scaleBoxSize: number;
  106221. /**
  106222. * 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)
  106223. */
  106224. fixedDragMeshScreenSize: boolean;
  106225. /**
  106226. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  106227. */
  106228. fixedDragMeshScreenSizeDistanceFactor: number;
  106229. /**
  106230. * Fired when a rotation sphere or scale box is dragged
  106231. */
  106232. onDragStartObservable: Observable<{}>;
  106233. /**
  106234. * Fired when a scale box is dragged
  106235. */
  106236. onScaleBoxDragObservable: Observable<{}>;
  106237. /**
  106238. * Fired when a scale box drag is ended
  106239. */
  106240. onScaleBoxDragEndObservable: Observable<{}>;
  106241. /**
  106242. * Fired when a rotation sphere is dragged
  106243. */
  106244. onRotationSphereDragObservable: Observable<{}>;
  106245. /**
  106246. * Fired when a rotation sphere drag is ended
  106247. */
  106248. onRotationSphereDragEndObservable: Observable<{}>;
  106249. /**
  106250. * 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)
  106251. */
  106252. scalePivot: Nullable<Vector3>;
  106253. /**
  106254. * Mesh used as a pivot to rotate the attached mesh
  106255. */
  106256. private _anchorMesh;
  106257. private _existingMeshScale;
  106258. private _dragMesh;
  106259. private pointerDragBehavior;
  106260. private coloredMaterial;
  106261. private hoverColoredMaterial;
  106262. /**
  106263. * Sets the color of the bounding box gizmo
  106264. * @param color the color to set
  106265. */
  106266. setColor(color: Color3): void;
  106267. /**
  106268. * Creates an BoundingBoxGizmo
  106269. * @param gizmoLayer The utility layer the gizmo will be added to
  106270. * @param color The color of the gizmo
  106271. */
  106272. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  106273. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106274. private _selectNode;
  106275. /**
  106276. * Updates the bounding box information for the Gizmo
  106277. */
  106278. updateBoundingBox(): void;
  106279. private _updateRotationSpheres;
  106280. private _updateScaleBoxes;
  106281. /**
  106282. * Enables rotation on the specified axis and disables rotation on the others
  106283. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  106284. */
  106285. setEnabledRotationAxis(axis: string): void;
  106286. /**
  106287. * Enables/disables scaling
  106288. * @param enable if scaling should be enabled
  106289. */
  106290. setEnabledScaling(enable: boolean): void;
  106291. private _updateDummy;
  106292. /**
  106293. * Enables a pointer drag behavior on the bounding box of the gizmo
  106294. */
  106295. enableDragBehavior(): void;
  106296. /**
  106297. * Disposes of the gizmo
  106298. */
  106299. dispose(): void;
  106300. /**
  106301. * 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)
  106302. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  106303. * @returns the bounding box mesh with the passed in mesh as a child
  106304. */
  106305. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  106306. /**
  106307. * CustomMeshes are not supported by this gizmo
  106308. * @param mesh The mesh to replace the default mesh of the gizmo
  106309. */
  106310. setCustomMesh(mesh: Mesh): void;
  106311. }
  106312. }
  106313. declare module BABYLON {
  106314. /**
  106315. * Single plane rotation gizmo
  106316. */
  106317. export class PlaneRotationGizmo extends Gizmo {
  106318. /**
  106319. * Drag behavior responsible for the gizmos dragging interactions
  106320. */
  106321. dragBehavior: PointerDragBehavior;
  106322. private _pointerObserver;
  106323. /**
  106324. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  106325. */
  106326. snapDistance: number;
  106327. /**
  106328. * Event that fires each time the gizmo snaps to a new location.
  106329. * * snapDistance is the the change in distance
  106330. */
  106331. onSnapObservable: Observable<{
  106332. snapDistance: number;
  106333. }>;
  106334. private _isEnabled;
  106335. private _parent;
  106336. /**
  106337. * Creates a PlaneRotationGizmo
  106338. * @param gizmoLayer The utility layer the gizmo will be added to
  106339. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  106340. * @param color The color of the gizmo
  106341. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106342. */
  106343. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  106344. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106345. /**
  106346. * If the gizmo is enabled
  106347. */
  106348. isEnabled: boolean;
  106349. /**
  106350. * Disposes of the gizmo
  106351. */
  106352. dispose(): void;
  106353. }
  106354. }
  106355. declare module BABYLON {
  106356. /**
  106357. * Gizmo that enables rotating a mesh along 3 axis
  106358. */
  106359. export class RotationGizmo extends Gizmo {
  106360. /**
  106361. * Internal gizmo used for interactions on the x axis
  106362. */
  106363. xGizmo: PlaneRotationGizmo;
  106364. /**
  106365. * Internal gizmo used for interactions on the y axis
  106366. */
  106367. yGizmo: PlaneRotationGizmo;
  106368. /**
  106369. * Internal gizmo used for interactions on the z axis
  106370. */
  106371. zGizmo: PlaneRotationGizmo;
  106372. /** Fires an event when any of it's sub gizmos are dragged */
  106373. onDragStartObservable: Observable<unknown>;
  106374. /** Fires an event when any of it's sub gizmos are released from dragging */
  106375. onDragEndObservable: Observable<unknown>;
  106376. private _meshAttached;
  106377. attachedMesh: Nullable<AbstractMesh>;
  106378. /**
  106379. * Creates a RotationGizmo
  106380. * @param gizmoLayer The utility layer the gizmo will be added to
  106381. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106382. */
  106383. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  106384. updateGizmoRotationToMatchAttachedMesh: boolean;
  106385. /**
  106386. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106387. */
  106388. snapDistance: number;
  106389. /**
  106390. * Ratio for the scale of the gizmo (Default: 1)
  106391. */
  106392. scaleRatio: number;
  106393. /**
  106394. * Disposes of the gizmo
  106395. */
  106396. dispose(): void;
  106397. /**
  106398. * CustomMeshes are not supported by this gizmo
  106399. * @param mesh The mesh to replace the default mesh of the gizmo
  106400. */
  106401. setCustomMesh(mesh: Mesh): void;
  106402. }
  106403. }
  106404. declare module BABYLON {
  106405. /**
  106406. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  106407. */
  106408. export class GizmoManager implements IDisposable {
  106409. private scene;
  106410. /**
  106411. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  106412. */
  106413. gizmos: {
  106414. positionGizmo: Nullable<PositionGizmo>;
  106415. rotationGizmo: Nullable<RotationGizmo>;
  106416. scaleGizmo: Nullable<ScaleGizmo>;
  106417. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  106418. };
  106419. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  106420. clearGizmoOnEmptyPointerEvent: boolean;
  106421. /** Fires an event when the manager is attached to a mesh */
  106422. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  106423. private _gizmosEnabled;
  106424. private _pointerObserver;
  106425. private _attachedMesh;
  106426. private _boundingBoxColor;
  106427. private _defaultUtilityLayer;
  106428. private _defaultKeepDepthUtilityLayer;
  106429. /**
  106430. * When bounding box gizmo is enabled, this can be used to track drag/end events
  106431. */
  106432. boundingBoxDragBehavior: SixDofDragBehavior;
  106433. /**
  106434. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  106435. */
  106436. attachableMeshes: Nullable<Array<AbstractMesh>>;
  106437. /**
  106438. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  106439. */
  106440. usePointerToAttachGizmos: boolean;
  106441. /**
  106442. * Utility layer that the bounding box gizmo belongs to
  106443. */
  106444. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  106445. /**
  106446. * Utility layer that all gizmos besides bounding box belong to
  106447. */
  106448. readonly utilityLayer: UtilityLayerRenderer;
  106449. /**
  106450. * Instatiates a gizmo manager
  106451. * @param scene the scene to overlay the gizmos on top of
  106452. */
  106453. constructor(scene: Scene);
  106454. /**
  106455. * Attaches a set of gizmos to the specified mesh
  106456. * @param mesh The mesh the gizmo's should be attached to
  106457. */
  106458. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  106459. /**
  106460. * If the position gizmo is enabled
  106461. */
  106462. positionGizmoEnabled: boolean;
  106463. /**
  106464. * If the rotation gizmo is enabled
  106465. */
  106466. rotationGizmoEnabled: boolean;
  106467. /**
  106468. * If the scale gizmo is enabled
  106469. */
  106470. scaleGizmoEnabled: boolean;
  106471. /**
  106472. * If the boundingBox gizmo is enabled
  106473. */
  106474. boundingBoxGizmoEnabled: boolean;
  106475. /**
  106476. * Disposes of the gizmo manager
  106477. */
  106478. dispose(): void;
  106479. }
  106480. }
  106481. declare module BABYLON {
  106482. /**
  106483. * A directional light is defined by a direction (what a surprise!).
  106484. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  106485. * 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.
  106486. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106487. */
  106488. export class DirectionalLight extends ShadowLight {
  106489. private _shadowFrustumSize;
  106490. /**
  106491. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  106492. */
  106493. /**
  106494. * Specifies a fix frustum size for the shadow generation.
  106495. */
  106496. shadowFrustumSize: number;
  106497. private _shadowOrthoScale;
  106498. /**
  106499. * Gets the shadow projection scale against the optimal computed one.
  106500. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106501. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106502. */
  106503. /**
  106504. * Sets the shadow projection scale against the optimal computed one.
  106505. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106506. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106507. */
  106508. shadowOrthoScale: number;
  106509. /**
  106510. * Automatically compute the projection matrix to best fit (including all the casters)
  106511. * on each frame.
  106512. */
  106513. autoUpdateExtends: boolean;
  106514. private _orthoLeft;
  106515. private _orthoRight;
  106516. private _orthoTop;
  106517. private _orthoBottom;
  106518. /**
  106519. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  106520. * The directional light is emitted from everywhere in the given direction.
  106521. * It can cast shadows.
  106522. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106523. * @param name The friendly name of the light
  106524. * @param direction The direction of the light
  106525. * @param scene The scene the light belongs to
  106526. */
  106527. constructor(name: string, direction: Vector3, scene: Scene);
  106528. /**
  106529. * Returns the string "DirectionalLight".
  106530. * @return The class name
  106531. */
  106532. getClassName(): string;
  106533. /**
  106534. * Returns the integer 1.
  106535. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106536. */
  106537. getTypeID(): number;
  106538. /**
  106539. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  106540. * Returns the DirectionalLight Shadow projection matrix.
  106541. */
  106542. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106543. /**
  106544. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  106545. * Returns the DirectionalLight Shadow projection matrix.
  106546. */
  106547. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  106548. /**
  106549. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  106550. * Returns the DirectionalLight Shadow projection matrix.
  106551. */
  106552. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106553. protected _buildUniformLayout(): void;
  106554. /**
  106555. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  106556. * @param effect The effect to update
  106557. * @param lightIndex The index of the light in the effect to update
  106558. * @returns The directional light
  106559. */
  106560. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  106561. /**
  106562. * Gets the minZ used for shadow according to both the scene and the light.
  106563. *
  106564. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106565. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106566. * @param activeCamera The camera we are returning the min for
  106567. * @returns the depth min z
  106568. */
  106569. getDepthMinZ(activeCamera: Camera): number;
  106570. /**
  106571. * Gets the maxZ used for shadow according to both the scene and the light.
  106572. *
  106573. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106574. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106575. * @param activeCamera The camera we are returning the max for
  106576. * @returns the depth max z
  106577. */
  106578. getDepthMaxZ(activeCamera: Camera): number;
  106579. /**
  106580. * Prepares the list of defines specific to the light type.
  106581. * @param defines the list of defines
  106582. * @param lightIndex defines the index of the light for the effect
  106583. */
  106584. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106585. }
  106586. }
  106587. declare module BABYLON {
  106588. /**
  106589. * Class containing static functions to help procedurally build meshes
  106590. */
  106591. export class HemisphereBuilder {
  106592. /**
  106593. * Creates a hemisphere mesh
  106594. * @param name defines the name of the mesh
  106595. * @param options defines the options used to create the mesh
  106596. * @param scene defines the hosting scene
  106597. * @returns the hemisphere mesh
  106598. */
  106599. static CreateHemisphere(name: string, options: {
  106600. segments?: number;
  106601. diameter?: number;
  106602. sideOrientation?: number;
  106603. }, scene: any): Mesh;
  106604. }
  106605. }
  106606. declare module BABYLON {
  106607. /**
  106608. * A spot light is defined by a position, a direction, an angle, and an exponent.
  106609. * These values define a cone of light starting from the position, emitting toward the direction.
  106610. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  106611. * and the exponent defines the speed of the decay of the light with distance (reach).
  106612. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106613. */
  106614. export class SpotLight extends ShadowLight {
  106615. private _angle;
  106616. private _innerAngle;
  106617. private _cosHalfAngle;
  106618. private _lightAngleScale;
  106619. private _lightAngleOffset;
  106620. /**
  106621. * Gets the cone angle of the spot light in Radians.
  106622. */
  106623. /**
  106624. * Sets the cone angle of the spot light in Radians.
  106625. */
  106626. angle: number;
  106627. /**
  106628. * Only used in gltf falloff mode, this defines the angle where
  106629. * the directional falloff will start before cutting at angle which could be seen
  106630. * as outer angle.
  106631. */
  106632. /**
  106633. * Only used in gltf falloff mode, this defines the angle where
  106634. * the directional falloff will start before cutting at angle which could be seen
  106635. * as outer angle.
  106636. */
  106637. innerAngle: number;
  106638. private _shadowAngleScale;
  106639. /**
  106640. * Allows scaling the angle of the light for shadow generation only.
  106641. */
  106642. /**
  106643. * Allows scaling the angle of the light for shadow generation only.
  106644. */
  106645. shadowAngleScale: number;
  106646. /**
  106647. * The light decay speed with the distance from the emission spot.
  106648. */
  106649. exponent: number;
  106650. private _projectionTextureMatrix;
  106651. /**
  106652. * Allows reading the projecton texture
  106653. */
  106654. readonly projectionTextureMatrix: Matrix;
  106655. protected _projectionTextureLightNear: number;
  106656. /**
  106657. * Gets the near clip of the Spotlight for texture projection.
  106658. */
  106659. /**
  106660. * Sets the near clip of the Spotlight for texture projection.
  106661. */
  106662. projectionTextureLightNear: number;
  106663. protected _projectionTextureLightFar: number;
  106664. /**
  106665. * Gets the far clip of the Spotlight for texture projection.
  106666. */
  106667. /**
  106668. * Sets the far clip of the Spotlight for texture projection.
  106669. */
  106670. projectionTextureLightFar: number;
  106671. protected _projectionTextureUpDirection: Vector3;
  106672. /**
  106673. * Gets the Up vector of the Spotlight for texture projection.
  106674. */
  106675. /**
  106676. * Sets the Up vector of the Spotlight for texture projection.
  106677. */
  106678. projectionTextureUpDirection: Vector3;
  106679. private _projectionTexture;
  106680. /**
  106681. * Gets the projection texture of the light.
  106682. */
  106683. /**
  106684. * Sets the projection texture of the light.
  106685. */
  106686. projectionTexture: Nullable<BaseTexture>;
  106687. private _projectionTextureViewLightDirty;
  106688. private _projectionTextureProjectionLightDirty;
  106689. private _projectionTextureDirty;
  106690. private _projectionTextureViewTargetVector;
  106691. private _projectionTextureViewLightMatrix;
  106692. private _projectionTextureProjectionLightMatrix;
  106693. private _projectionTextureScalingMatrix;
  106694. /**
  106695. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  106696. * It can cast shadows.
  106697. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106698. * @param name The light friendly name
  106699. * @param position The position of the spot light in the scene
  106700. * @param direction The direction of the light in the scene
  106701. * @param angle The cone angle of the light in Radians
  106702. * @param exponent The light decay speed with the distance from the emission spot
  106703. * @param scene The scene the lights belongs to
  106704. */
  106705. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  106706. /**
  106707. * Returns the string "SpotLight".
  106708. * @returns the class name
  106709. */
  106710. getClassName(): string;
  106711. /**
  106712. * Returns the integer 2.
  106713. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106714. */
  106715. getTypeID(): number;
  106716. /**
  106717. * Overrides the direction setter to recompute the projection texture view light Matrix.
  106718. */
  106719. protected _setDirection(value: Vector3): void;
  106720. /**
  106721. * Overrides the position setter to recompute the projection texture view light Matrix.
  106722. */
  106723. protected _setPosition(value: Vector3): void;
  106724. /**
  106725. * 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.
  106726. * Returns the SpotLight.
  106727. */
  106728. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106729. protected _computeProjectionTextureViewLightMatrix(): void;
  106730. protected _computeProjectionTextureProjectionLightMatrix(): void;
  106731. /**
  106732. * Main function for light texture projection matrix computing.
  106733. */
  106734. protected _computeProjectionTextureMatrix(): void;
  106735. protected _buildUniformLayout(): void;
  106736. private _computeAngleValues;
  106737. /**
  106738. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  106739. * @param effect The effect to update
  106740. * @param lightIndex The index of the light in the effect to update
  106741. * @returns The spot light
  106742. */
  106743. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  106744. /**
  106745. * Disposes the light and the associated resources.
  106746. */
  106747. dispose(): void;
  106748. /**
  106749. * Prepares the list of defines specific to the light type.
  106750. * @param defines the list of defines
  106751. * @param lightIndex defines the index of the light for the effect
  106752. */
  106753. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106754. }
  106755. }
  106756. declare module BABYLON {
  106757. /**
  106758. * Gizmo that enables viewing a light
  106759. */
  106760. export class LightGizmo extends Gizmo {
  106761. private _lightMesh;
  106762. private _material;
  106763. private cachedPosition;
  106764. private cachedForward;
  106765. /**
  106766. * Creates a LightGizmo
  106767. * @param gizmoLayer The utility layer the gizmo will be added to
  106768. */
  106769. constructor(gizmoLayer?: UtilityLayerRenderer);
  106770. private _light;
  106771. /**
  106772. * The light that the gizmo is attached to
  106773. */
  106774. light: Nullable<Light>;
  106775. /**
  106776. * @hidden
  106777. * Updates the gizmo to match the attached mesh's position/rotation
  106778. */
  106779. protected _update(): void;
  106780. private static _Scale;
  106781. /**
  106782. * Creates the lines for a light mesh
  106783. */
  106784. private static _createLightLines;
  106785. /**
  106786. * Disposes of the light gizmo
  106787. */
  106788. dispose(): void;
  106789. private static _CreateHemisphericLightMesh;
  106790. private static _CreatePointLightMesh;
  106791. private static _CreateSpotLightMesh;
  106792. private static _CreateDirectionalLightMesh;
  106793. }
  106794. }
  106795. declare module BABYLON {
  106796. /** @hidden */
  106797. export var backgroundFragmentDeclaration: {
  106798. name: string;
  106799. shader: string;
  106800. };
  106801. }
  106802. declare module BABYLON {
  106803. /** @hidden */
  106804. export var backgroundUboDeclaration: {
  106805. name: string;
  106806. shader: string;
  106807. };
  106808. }
  106809. declare module BABYLON {
  106810. /** @hidden */
  106811. export var backgroundPixelShader: {
  106812. name: string;
  106813. shader: string;
  106814. };
  106815. }
  106816. declare module BABYLON {
  106817. /** @hidden */
  106818. export var backgroundVertexDeclaration: {
  106819. name: string;
  106820. shader: string;
  106821. };
  106822. }
  106823. declare module BABYLON {
  106824. /** @hidden */
  106825. export var backgroundVertexShader: {
  106826. name: string;
  106827. shader: string;
  106828. };
  106829. }
  106830. declare module BABYLON {
  106831. /**
  106832. * Background material used to create an efficient environement around your scene.
  106833. */
  106834. export class BackgroundMaterial extends PushMaterial {
  106835. /**
  106836. * Standard reflectance value at parallel view angle.
  106837. */
  106838. static StandardReflectance0: number;
  106839. /**
  106840. * Standard reflectance value at grazing angle.
  106841. */
  106842. static StandardReflectance90: number;
  106843. protected _primaryColor: Color3;
  106844. /**
  106845. * Key light Color (multiply against the environement texture)
  106846. */
  106847. primaryColor: Color3;
  106848. protected __perceptualColor: Nullable<Color3>;
  106849. /**
  106850. * Experimental Internal Use Only.
  106851. *
  106852. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106853. * This acts as a helper to set the primary color to a more "human friendly" value.
  106854. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106855. * output color as close as possible from the chosen value.
  106856. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106857. * part of lighting setup.)
  106858. */
  106859. _perceptualColor: Nullable<Color3>;
  106860. protected _primaryColorShadowLevel: float;
  106861. /**
  106862. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106863. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106864. */
  106865. primaryColorShadowLevel: float;
  106866. protected _primaryColorHighlightLevel: float;
  106867. /**
  106868. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106869. * The primary color is used at the level chosen to define what the white area would look.
  106870. */
  106871. primaryColorHighlightLevel: float;
  106872. protected _reflectionTexture: Nullable<BaseTexture>;
  106873. /**
  106874. * Reflection Texture used in the material.
  106875. * Should be author in a specific way for the best result (refer to the documentation).
  106876. */
  106877. reflectionTexture: Nullable<BaseTexture>;
  106878. protected _reflectionBlur: float;
  106879. /**
  106880. * Reflection Texture level of blur.
  106881. *
  106882. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106883. * texture twice.
  106884. */
  106885. reflectionBlur: float;
  106886. protected _diffuseTexture: Nullable<BaseTexture>;
  106887. /**
  106888. * Diffuse Texture used in the material.
  106889. * Should be author in a specific way for the best result (refer to the documentation).
  106890. */
  106891. diffuseTexture: Nullable<BaseTexture>;
  106892. protected _shadowLights: Nullable<IShadowLight[]>;
  106893. /**
  106894. * Specify the list of lights casting shadow on the material.
  106895. * All scene shadow lights will be included if null.
  106896. */
  106897. shadowLights: Nullable<IShadowLight[]>;
  106898. protected _shadowLevel: float;
  106899. /**
  106900. * Helps adjusting the shadow to a softer level if required.
  106901. * 0 means black shadows and 1 means no shadows.
  106902. */
  106903. shadowLevel: float;
  106904. protected _sceneCenter: Vector3;
  106905. /**
  106906. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106907. * It is usually zero but might be interesting to modify according to your setup.
  106908. */
  106909. sceneCenter: Vector3;
  106910. protected _opacityFresnel: boolean;
  106911. /**
  106912. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106913. * This helps ensuring a nice transition when the camera goes under the ground.
  106914. */
  106915. opacityFresnel: boolean;
  106916. protected _reflectionFresnel: boolean;
  106917. /**
  106918. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  106919. * This helps adding a mirror texture on the ground.
  106920. */
  106921. reflectionFresnel: boolean;
  106922. protected _reflectionFalloffDistance: number;
  106923. /**
  106924. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  106925. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  106926. */
  106927. reflectionFalloffDistance: number;
  106928. protected _reflectionAmount: number;
  106929. /**
  106930. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  106931. */
  106932. reflectionAmount: number;
  106933. protected _reflectionReflectance0: number;
  106934. /**
  106935. * This specifies the weight of the reflection at grazing angle.
  106936. */
  106937. reflectionReflectance0: number;
  106938. protected _reflectionReflectance90: number;
  106939. /**
  106940. * This specifies the weight of the reflection at a perpendicular point of view.
  106941. */
  106942. reflectionReflectance90: number;
  106943. /**
  106944. * Sets the reflection reflectance fresnel values according to the default standard
  106945. * empirically know to work well :-)
  106946. */
  106947. reflectionStandardFresnelWeight: number;
  106948. protected _useRGBColor: boolean;
  106949. /**
  106950. * Helps to directly use the maps channels instead of their level.
  106951. */
  106952. useRGBColor: boolean;
  106953. protected _enableNoise: boolean;
  106954. /**
  106955. * This helps reducing the banding effect that could occur on the background.
  106956. */
  106957. enableNoise: boolean;
  106958. /**
  106959. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106960. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  106961. * Recommended to be keep at 1.0 except for special cases.
  106962. */
  106963. fovMultiplier: number;
  106964. private _fovMultiplier;
  106965. /**
  106966. * Enable the FOV adjustment feature controlled by fovMultiplier.
  106967. */
  106968. useEquirectangularFOV: boolean;
  106969. private _maxSimultaneousLights;
  106970. /**
  106971. * Number of Simultaneous lights allowed on the material.
  106972. */
  106973. maxSimultaneousLights: int;
  106974. /**
  106975. * Default configuration related to image processing available in the Background Material.
  106976. */
  106977. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106978. /**
  106979. * Keep track of the image processing observer to allow dispose and replace.
  106980. */
  106981. private _imageProcessingObserver;
  106982. /**
  106983. * Attaches a new image processing configuration to the PBR Material.
  106984. * @param configuration (if null the scene configuration will be use)
  106985. */
  106986. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106987. /**
  106988. * Gets the image processing configuration used either in this material.
  106989. */
  106990. /**
  106991. * Sets the Default image processing configuration used either in the this material.
  106992. *
  106993. * If sets to null, the scene one is in use.
  106994. */
  106995. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  106996. /**
  106997. * Gets wether the color curves effect is enabled.
  106998. */
  106999. /**
  107000. * Sets wether the color curves effect is enabled.
  107001. */
  107002. cameraColorCurvesEnabled: boolean;
  107003. /**
  107004. * Gets wether the color grading effect is enabled.
  107005. */
  107006. /**
  107007. * Gets wether the color grading effect is enabled.
  107008. */
  107009. cameraColorGradingEnabled: boolean;
  107010. /**
  107011. * Gets wether tonemapping is enabled or not.
  107012. */
  107013. /**
  107014. * Sets wether tonemapping is enabled or not
  107015. */
  107016. cameraToneMappingEnabled: boolean;
  107017. /**
  107018. * The camera exposure used on this material.
  107019. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107020. * This corresponds to a photographic exposure.
  107021. */
  107022. /**
  107023. * The camera exposure used on this material.
  107024. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107025. * This corresponds to a photographic exposure.
  107026. */
  107027. cameraExposure: float;
  107028. /**
  107029. * Gets The camera contrast used on this material.
  107030. */
  107031. /**
  107032. * Sets The camera contrast used on this material.
  107033. */
  107034. cameraContrast: float;
  107035. /**
  107036. * Gets the Color Grading 2D Lookup Texture.
  107037. */
  107038. /**
  107039. * Sets the Color Grading 2D Lookup Texture.
  107040. */
  107041. cameraColorGradingTexture: Nullable<BaseTexture>;
  107042. /**
  107043. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107044. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107045. * 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;
  107046. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107047. */
  107048. /**
  107049. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107050. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107051. * 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;
  107052. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107053. */
  107054. cameraColorCurves: Nullable<ColorCurves>;
  107055. /**
  107056. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  107057. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  107058. */
  107059. switchToBGR: boolean;
  107060. private _renderTargets;
  107061. private _reflectionControls;
  107062. private _white;
  107063. private _primaryShadowColor;
  107064. private _primaryHighlightColor;
  107065. /**
  107066. * Instantiates a Background Material in the given scene
  107067. * @param name The friendly name of the material
  107068. * @param scene The scene to add the material to
  107069. */
  107070. constructor(name: string, scene: Scene);
  107071. /**
  107072. * Gets a boolean indicating that current material needs to register RTT
  107073. */
  107074. readonly hasRenderTargetTextures: boolean;
  107075. /**
  107076. * The entire material has been created in order to prevent overdraw.
  107077. * @returns false
  107078. */
  107079. needAlphaTesting(): boolean;
  107080. /**
  107081. * The entire material has been created in order to prevent overdraw.
  107082. * @returns true if blending is enable
  107083. */
  107084. needAlphaBlending(): boolean;
  107085. /**
  107086. * Checks wether the material is ready to be rendered for a given mesh.
  107087. * @param mesh The mesh to render
  107088. * @param subMesh The submesh to check against
  107089. * @param useInstances Specify wether or not the material is used with instances
  107090. * @returns true if all the dependencies are ready (Textures, Effects...)
  107091. */
  107092. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107093. /**
  107094. * Compute the primary color according to the chosen perceptual color.
  107095. */
  107096. private _computePrimaryColorFromPerceptualColor;
  107097. /**
  107098. * Compute the highlights and shadow colors according to their chosen levels.
  107099. */
  107100. private _computePrimaryColors;
  107101. /**
  107102. * Build the uniform buffer used in the material.
  107103. */
  107104. buildUniformLayout(): void;
  107105. /**
  107106. * Unbind the material.
  107107. */
  107108. unbind(): void;
  107109. /**
  107110. * Bind only the world matrix to the material.
  107111. * @param world The world matrix to bind.
  107112. */
  107113. bindOnlyWorldMatrix(world: Matrix): void;
  107114. /**
  107115. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  107116. * @param world The world matrix to bind.
  107117. * @param subMesh The submesh to bind for.
  107118. */
  107119. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107120. /**
  107121. * Dispose the material.
  107122. * @param forceDisposeEffect Force disposal of the associated effect.
  107123. * @param forceDisposeTextures Force disposal of the associated textures.
  107124. */
  107125. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107126. /**
  107127. * Clones the material.
  107128. * @param name The cloned name.
  107129. * @returns The cloned material.
  107130. */
  107131. clone(name: string): BackgroundMaterial;
  107132. /**
  107133. * Serializes the current material to its JSON representation.
  107134. * @returns The JSON representation.
  107135. */
  107136. serialize(): any;
  107137. /**
  107138. * Gets the class name of the material
  107139. * @returns "BackgroundMaterial"
  107140. */
  107141. getClassName(): string;
  107142. /**
  107143. * Parse a JSON input to create back a background material.
  107144. * @param source The JSON data to parse
  107145. * @param scene The scene to create the parsed material in
  107146. * @param rootUrl The root url of the assets the material depends upon
  107147. * @returns the instantiated BackgroundMaterial.
  107148. */
  107149. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  107150. }
  107151. }
  107152. declare module BABYLON {
  107153. /**
  107154. * Represents the different options available during the creation of
  107155. * a Environment helper.
  107156. *
  107157. * This can control the default ground, skybox and image processing setup of your scene.
  107158. */
  107159. export interface IEnvironmentHelperOptions {
  107160. /**
  107161. * Specifies wether or not to create a ground.
  107162. * True by default.
  107163. */
  107164. createGround: boolean;
  107165. /**
  107166. * Specifies the ground size.
  107167. * 15 by default.
  107168. */
  107169. groundSize: number;
  107170. /**
  107171. * The texture used on the ground for the main color.
  107172. * Comes from the BabylonJS CDN by default.
  107173. *
  107174. * Remarks: Can be either a texture or a url.
  107175. */
  107176. groundTexture: string | BaseTexture;
  107177. /**
  107178. * The color mixed in the ground texture by default.
  107179. * BabylonJS clearColor by default.
  107180. */
  107181. groundColor: Color3;
  107182. /**
  107183. * Specifies the ground opacity.
  107184. * 1 by default.
  107185. */
  107186. groundOpacity: number;
  107187. /**
  107188. * Enables the ground to receive shadows.
  107189. * True by default.
  107190. */
  107191. enableGroundShadow: boolean;
  107192. /**
  107193. * Helps preventing the shadow to be fully black on the ground.
  107194. * 0.5 by default.
  107195. */
  107196. groundShadowLevel: number;
  107197. /**
  107198. * Creates a mirror texture attach to the ground.
  107199. * false by default.
  107200. */
  107201. enableGroundMirror: boolean;
  107202. /**
  107203. * Specifies the ground mirror size ratio.
  107204. * 0.3 by default as the default kernel is 64.
  107205. */
  107206. groundMirrorSizeRatio: number;
  107207. /**
  107208. * Specifies the ground mirror blur kernel size.
  107209. * 64 by default.
  107210. */
  107211. groundMirrorBlurKernel: number;
  107212. /**
  107213. * Specifies the ground mirror visibility amount.
  107214. * 1 by default
  107215. */
  107216. groundMirrorAmount: number;
  107217. /**
  107218. * Specifies the ground mirror reflectance weight.
  107219. * This uses the standard weight of the background material to setup the fresnel effect
  107220. * of the mirror.
  107221. * 1 by default.
  107222. */
  107223. groundMirrorFresnelWeight: number;
  107224. /**
  107225. * Specifies the ground mirror Falloff distance.
  107226. * This can helps reducing the size of the reflection.
  107227. * 0 by Default.
  107228. */
  107229. groundMirrorFallOffDistance: number;
  107230. /**
  107231. * Specifies the ground mirror texture type.
  107232. * Unsigned Int by Default.
  107233. */
  107234. groundMirrorTextureType: number;
  107235. /**
  107236. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  107237. * the shown objects.
  107238. */
  107239. groundYBias: number;
  107240. /**
  107241. * Specifies wether or not to create a skybox.
  107242. * True by default.
  107243. */
  107244. createSkybox: boolean;
  107245. /**
  107246. * Specifies the skybox size.
  107247. * 20 by default.
  107248. */
  107249. skyboxSize: number;
  107250. /**
  107251. * The texture used on the skybox for the main color.
  107252. * Comes from the BabylonJS CDN by default.
  107253. *
  107254. * Remarks: Can be either a texture or a url.
  107255. */
  107256. skyboxTexture: string | BaseTexture;
  107257. /**
  107258. * The color mixed in the skybox texture by default.
  107259. * BabylonJS clearColor by default.
  107260. */
  107261. skyboxColor: Color3;
  107262. /**
  107263. * The background rotation around the Y axis of the scene.
  107264. * This helps aligning the key lights of your scene with the background.
  107265. * 0 by default.
  107266. */
  107267. backgroundYRotation: number;
  107268. /**
  107269. * Compute automatically the size of the elements to best fit with the scene.
  107270. */
  107271. sizeAuto: boolean;
  107272. /**
  107273. * Default position of the rootMesh if autoSize is not true.
  107274. */
  107275. rootPosition: Vector3;
  107276. /**
  107277. * Sets up the image processing in the scene.
  107278. * true by default.
  107279. */
  107280. setupImageProcessing: boolean;
  107281. /**
  107282. * The texture used as your environment texture in the scene.
  107283. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  107284. *
  107285. * Remarks: Can be either a texture or a url.
  107286. */
  107287. environmentTexture: string | BaseTexture;
  107288. /**
  107289. * The value of the exposure to apply to the scene.
  107290. * 0.6 by default if setupImageProcessing is true.
  107291. */
  107292. cameraExposure: number;
  107293. /**
  107294. * The value of the contrast to apply to the scene.
  107295. * 1.6 by default if setupImageProcessing is true.
  107296. */
  107297. cameraContrast: number;
  107298. /**
  107299. * Specifies wether or not tonemapping should be enabled in the scene.
  107300. * true by default if setupImageProcessing is true.
  107301. */
  107302. toneMappingEnabled: boolean;
  107303. }
  107304. /**
  107305. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  107306. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  107307. * It also helps with the default setup of your imageProcessing configuration.
  107308. */
  107309. export class EnvironmentHelper {
  107310. /**
  107311. * Default ground texture URL.
  107312. */
  107313. private static _groundTextureCDNUrl;
  107314. /**
  107315. * Default skybox texture URL.
  107316. */
  107317. private static _skyboxTextureCDNUrl;
  107318. /**
  107319. * Default environment texture URL.
  107320. */
  107321. private static _environmentTextureCDNUrl;
  107322. /**
  107323. * Creates the default options for the helper.
  107324. */
  107325. private static _getDefaultOptions;
  107326. private _rootMesh;
  107327. /**
  107328. * Gets the root mesh created by the helper.
  107329. */
  107330. readonly rootMesh: Mesh;
  107331. private _skybox;
  107332. /**
  107333. * Gets the skybox created by the helper.
  107334. */
  107335. readonly skybox: Nullable<Mesh>;
  107336. private _skyboxTexture;
  107337. /**
  107338. * Gets the skybox texture created by the helper.
  107339. */
  107340. readonly skyboxTexture: Nullable<BaseTexture>;
  107341. private _skyboxMaterial;
  107342. /**
  107343. * Gets the skybox material created by the helper.
  107344. */
  107345. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  107346. private _ground;
  107347. /**
  107348. * Gets the ground mesh created by the helper.
  107349. */
  107350. readonly ground: Nullable<Mesh>;
  107351. private _groundTexture;
  107352. /**
  107353. * Gets the ground texture created by the helper.
  107354. */
  107355. readonly groundTexture: Nullable<BaseTexture>;
  107356. private _groundMirror;
  107357. /**
  107358. * Gets the ground mirror created by the helper.
  107359. */
  107360. readonly groundMirror: Nullable<MirrorTexture>;
  107361. /**
  107362. * Gets the ground mirror render list to helps pushing the meshes
  107363. * you wish in the ground reflection.
  107364. */
  107365. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  107366. private _groundMaterial;
  107367. /**
  107368. * Gets the ground material created by the helper.
  107369. */
  107370. readonly groundMaterial: Nullable<BackgroundMaterial>;
  107371. /**
  107372. * Stores the creation options.
  107373. */
  107374. private readonly _scene;
  107375. private _options;
  107376. /**
  107377. * This observable will be notified with any error during the creation of the environment,
  107378. * mainly texture creation errors.
  107379. */
  107380. onErrorObservable: Observable<{
  107381. message?: string;
  107382. exception?: any;
  107383. }>;
  107384. /**
  107385. * constructor
  107386. * @param options Defines the options we want to customize the helper
  107387. * @param scene The scene to add the material to
  107388. */
  107389. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  107390. /**
  107391. * Updates the background according to the new options
  107392. * @param options
  107393. */
  107394. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  107395. /**
  107396. * Sets the primary color of all the available elements.
  107397. * @param color the main color to affect to the ground and the background
  107398. */
  107399. setMainColor(color: Color3): void;
  107400. /**
  107401. * Setup the image processing according to the specified options.
  107402. */
  107403. private _setupImageProcessing;
  107404. /**
  107405. * Setup the environment texture according to the specified options.
  107406. */
  107407. private _setupEnvironmentTexture;
  107408. /**
  107409. * Setup the background according to the specified options.
  107410. */
  107411. private _setupBackground;
  107412. /**
  107413. * Get the scene sizes according to the setup.
  107414. */
  107415. private _getSceneSize;
  107416. /**
  107417. * Setup the ground according to the specified options.
  107418. */
  107419. private _setupGround;
  107420. /**
  107421. * Setup the ground material according to the specified options.
  107422. */
  107423. private _setupGroundMaterial;
  107424. /**
  107425. * Setup the ground diffuse texture according to the specified options.
  107426. */
  107427. private _setupGroundDiffuseTexture;
  107428. /**
  107429. * Setup the ground mirror texture according to the specified options.
  107430. */
  107431. private _setupGroundMirrorTexture;
  107432. /**
  107433. * Setup the ground to receive the mirror texture.
  107434. */
  107435. private _setupMirrorInGroundMaterial;
  107436. /**
  107437. * Setup the skybox according to the specified options.
  107438. */
  107439. private _setupSkybox;
  107440. /**
  107441. * Setup the skybox material according to the specified options.
  107442. */
  107443. private _setupSkyboxMaterial;
  107444. /**
  107445. * Setup the skybox reflection texture according to the specified options.
  107446. */
  107447. private _setupSkyboxReflectionTexture;
  107448. private _errorHandler;
  107449. /**
  107450. * Dispose all the elements created by the Helper.
  107451. */
  107452. dispose(): void;
  107453. }
  107454. }
  107455. declare module BABYLON {
  107456. /**
  107457. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  107458. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  107459. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  107460. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  107461. */
  107462. export class PhotoDome extends TransformNode {
  107463. /**
  107464. * Define the image as a Monoscopic panoramic 360 image.
  107465. */
  107466. static readonly MODE_MONOSCOPIC: number;
  107467. /**
  107468. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107469. */
  107470. static readonly MODE_TOPBOTTOM: number;
  107471. /**
  107472. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107473. */
  107474. static readonly MODE_SIDEBYSIDE: number;
  107475. private _useDirectMapping;
  107476. /**
  107477. * The texture being displayed on the sphere
  107478. */
  107479. protected _photoTexture: Texture;
  107480. /**
  107481. * Gets or sets the texture being displayed on the sphere
  107482. */
  107483. photoTexture: Texture;
  107484. /**
  107485. * Observable raised when an error occured while loading the 360 image
  107486. */
  107487. onLoadErrorObservable: Observable<string>;
  107488. /**
  107489. * The skybox material
  107490. */
  107491. protected _material: BackgroundMaterial;
  107492. /**
  107493. * The surface used for the skybox
  107494. */
  107495. protected _mesh: Mesh;
  107496. /**
  107497. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  107498. * Also see the options.resolution property.
  107499. */
  107500. fovMultiplier: number;
  107501. private _imageMode;
  107502. /**
  107503. * Gets or set the current video mode for the video. It can be:
  107504. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  107505. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107506. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107507. */
  107508. imageMode: number;
  107509. /**
  107510. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  107511. * @param name Element's name, child elements will append suffixes for their own names.
  107512. * @param urlsOfPhoto defines the url of the photo to display
  107513. * @param options defines an object containing optional or exposed sub element properties
  107514. * @param onError defines a callback called when an error occured while loading the texture
  107515. */
  107516. constructor(name: string, urlOfPhoto: string, options: {
  107517. resolution?: number;
  107518. size?: number;
  107519. useDirectMapping?: boolean;
  107520. faceForward?: boolean;
  107521. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  107522. private _onBeforeCameraRenderObserver;
  107523. private _changeImageMode;
  107524. /**
  107525. * Releases resources associated with this node.
  107526. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107527. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107528. */
  107529. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107530. }
  107531. }
  107532. declare module BABYLON {
  107533. /** @hidden */
  107534. export var rgbdDecodePixelShader: {
  107535. name: string;
  107536. shader: string;
  107537. };
  107538. }
  107539. declare module BABYLON {
  107540. /**
  107541. * Class used to host texture specific utilities
  107542. */
  107543. export class BRDFTextureTools {
  107544. /**
  107545. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  107546. * @param texture the texture to expand.
  107547. */
  107548. private static _ExpandDefaultBRDFTexture;
  107549. /**
  107550. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  107551. * @param scene defines the hosting scene
  107552. * @returns the environment BRDF texture
  107553. */
  107554. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  107555. private static _environmentBRDFBase64Texture;
  107556. }
  107557. }
  107558. declare module BABYLON {
  107559. /**
  107560. * @hidden
  107561. */
  107562. export interface IMaterialClearCoatDefines {
  107563. CLEARCOAT: boolean;
  107564. CLEARCOAT_DEFAULTIOR: boolean;
  107565. CLEARCOAT_TEXTURE: boolean;
  107566. CLEARCOAT_TEXTUREDIRECTUV: number;
  107567. CLEARCOAT_BUMP: boolean;
  107568. CLEARCOAT_BUMPDIRECTUV: number;
  107569. CLEARCOAT_TINT: boolean;
  107570. CLEARCOAT_TINT_TEXTURE: boolean;
  107571. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107572. /** @hidden */
  107573. _areTexturesDirty: boolean;
  107574. }
  107575. /**
  107576. * Define the code related to the clear coat parameters of the pbr material.
  107577. */
  107578. export class PBRClearCoatConfiguration {
  107579. /**
  107580. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107581. * The default fits with a polyurethane material.
  107582. */
  107583. private static readonly _DefaultIndexOfRefraction;
  107584. private _isEnabled;
  107585. /**
  107586. * Defines if the clear coat is enabled in the material.
  107587. */
  107588. isEnabled: boolean;
  107589. /**
  107590. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  107591. */
  107592. intensity: number;
  107593. /**
  107594. * Defines the clear coat layer roughness.
  107595. */
  107596. roughness: number;
  107597. private _indexOfRefraction;
  107598. /**
  107599. * Defines the index of refraction of the clear coat.
  107600. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107601. * The default fits with a polyurethane material.
  107602. * Changing the default value is more performance intensive.
  107603. */
  107604. indexOfRefraction: number;
  107605. private _texture;
  107606. /**
  107607. * Stores the clear coat values in a texture.
  107608. */
  107609. texture: Nullable<BaseTexture>;
  107610. private _bumpTexture;
  107611. /**
  107612. * Define the clear coat specific bump texture.
  107613. */
  107614. bumpTexture: Nullable<BaseTexture>;
  107615. private _isTintEnabled;
  107616. /**
  107617. * Defines if the clear coat tint is enabled in the material.
  107618. */
  107619. isTintEnabled: boolean;
  107620. /**
  107621. * Defines the clear coat tint of the material.
  107622. * This is only use if tint is enabled
  107623. */
  107624. tintColor: Color3;
  107625. /**
  107626. * Defines the distance at which the tint color should be found in the
  107627. * clear coat media.
  107628. * This is only use if tint is enabled
  107629. */
  107630. tintColorAtDistance: number;
  107631. /**
  107632. * Defines the clear coat layer thickness.
  107633. * This is only use if tint is enabled
  107634. */
  107635. tintThickness: number;
  107636. private _tintTexture;
  107637. /**
  107638. * Stores the clear tint values in a texture.
  107639. * rgb is tint
  107640. * a is a thickness factor
  107641. */
  107642. tintTexture: Nullable<BaseTexture>;
  107643. /** @hidden */
  107644. private _internalMarkAllSubMeshesAsTexturesDirty;
  107645. /** @hidden */
  107646. _markAllSubMeshesAsTexturesDirty(): void;
  107647. /**
  107648. * Instantiate a new istance of clear coat configuration.
  107649. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107650. */
  107651. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107652. /**
  107653. * Gets wehter the submesh is ready to be used or not.
  107654. * @param defines the list of "defines" to update.
  107655. * @param scene defines the scene the material belongs to.
  107656. * @param engine defines the engine the material belongs to.
  107657. * @param disableBumpMap defines wether the material disables bump or not.
  107658. * @returns - boolean indicating that the submesh is ready or not.
  107659. */
  107660. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  107661. /**
  107662. * Checks to see if a texture is used in the material.
  107663. * @param defines the list of "defines" to update.
  107664. * @param scene defines the scene to the material belongs to.
  107665. */
  107666. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  107667. /**
  107668. * Binds the material data.
  107669. * @param uniformBuffer defines the Uniform buffer to fill in.
  107670. * @param scene defines the scene the material belongs to.
  107671. * @param engine defines the engine the material belongs to.
  107672. * @param disableBumpMap defines wether the material disables bump or not.
  107673. * @param isFrozen defines wether the material is frozen or not.
  107674. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107675. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107676. */
  107677. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  107678. /**
  107679. * Checks to see if a texture is used in the material.
  107680. * @param texture - Base texture to use.
  107681. * @returns - Boolean specifying if a texture is used in the material.
  107682. */
  107683. hasTexture(texture: BaseTexture): boolean;
  107684. /**
  107685. * Returns an array of the actively used textures.
  107686. * @param activeTextures Array of BaseTextures
  107687. */
  107688. getActiveTextures(activeTextures: BaseTexture[]): void;
  107689. /**
  107690. * Returns the animatable textures.
  107691. * @param animatables Array of animatable textures.
  107692. */
  107693. getAnimatables(animatables: IAnimatable[]): void;
  107694. /**
  107695. * Disposes the resources of the material.
  107696. * @param forceDisposeTextures - Forces the disposal of all textures.
  107697. */
  107698. dispose(forceDisposeTextures?: boolean): void;
  107699. /**
  107700. * Get the current class name of the texture useful for serialization or dynamic coding.
  107701. * @returns "PBRClearCoatConfiguration"
  107702. */
  107703. getClassName(): string;
  107704. /**
  107705. * Add fallbacks to the effect fallbacks list.
  107706. * @param defines defines the Base texture to use.
  107707. * @param fallbacks defines the current fallback list.
  107708. * @param currentRank defines the current fallback rank.
  107709. * @returns the new fallback rank.
  107710. */
  107711. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107712. /**
  107713. * Add the required uniforms to the current list.
  107714. * @param uniforms defines the current uniform list.
  107715. */
  107716. static AddUniforms(uniforms: string[]): void;
  107717. /**
  107718. * Add the required samplers to the current list.
  107719. * @param samplers defines the current sampler list.
  107720. */
  107721. static AddSamplers(samplers: string[]): void;
  107722. /**
  107723. * Add the required uniforms to the current buffer.
  107724. * @param uniformBuffer defines the current uniform buffer.
  107725. */
  107726. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107727. /**
  107728. * Makes a duplicate of the current configuration into another one.
  107729. * @param clearCoatConfiguration define the config where to copy the info
  107730. */
  107731. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  107732. /**
  107733. * Serializes this clear coat configuration.
  107734. * @returns - An object with the serialized config.
  107735. */
  107736. serialize(): any;
  107737. /**
  107738. * Parses a anisotropy Configuration from a serialized object.
  107739. * @param source - Serialized object.
  107740. * @param scene Defines the scene we are parsing for
  107741. * @param rootUrl Defines the rootUrl to load from
  107742. */
  107743. parse(source: any, scene: Scene, rootUrl: string): void;
  107744. }
  107745. }
  107746. declare module BABYLON {
  107747. /**
  107748. * @hidden
  107749. */
  107750. export interface IMaterialAnisotropicDefines {
  107751. ANISOTROPIC: boolean;
  107752. ANISOTROPIC_TEXTURE: boolean;
  107753. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107754. MAINUV1: boolean;
  107755. _areTexturesDirty: boolean;
  107756. _needUVs: boolean;
  107757. }
  107758. /**
  107759. * Define the code related to the anisotropic parameters of the pbr material.
  107760. */
  107761. export class PBRAnisotropicConfiguration {
  107762. private _isEnabled;
  107763. /**
  107764. * Defines if the anisotropy is enabled in the material.
  107765. */
  107766. isEnabled: boolean;
  107767. /**
  107768. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  107769. */
  107770. intensity: number;
  107771. /**
  107772. * Defines if the effect is along the tangents, bitangents or in between.
  107773. * By default, the effect is "strectching" the highlights along the tangents.
  107774. */
  107775. direction: Vector2;
  107776. private _texture;
  107777. /**
  107778. * Stores the anisotropy values in a texture.
  107779. * rg is direction (like normal from -1 to 1)
  107780. * b is a intensity
  107781. */
  107782. texture: Nullable<BaseTexture>;
  107783. /** @hidden */
  107784. private _internalMarkAllSubMeshesAsTexturesDirty;
  107785. /** @hidden */
  107786. _markAllSubMeshesAsTexturesDirty(): void;
  107787. /**
  107788. * Instantiate a new istance of anisotropy configuration.
  107789. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107790. */
  107791. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107792. /**
  107793. * Specifies that the submesh is ready to be used.
  107794. * @param defines the list of "defines" to update.
  107795. * @param scene defines the scene the material belongs to.
  107796. * @returns - boolean indicating that the submesh is ready or not.
  107797. */
  107798. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  107799. /**
  107800. * Checks to see if a texture is used in the material.
  107801. * @param defines the list of "defines" to update.
  107802. * @param mesh the mesh we are preparing the defines for.
  107803. * @param scene defines the scene the material belongs to.
  107804. */
  107805. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  107806. /**
  107807. * Binds the material data.
  107808. * @param uniformBuffer defines the Uniform buffer to fill in.
  107809. * @param scene defines the scene the material belongs to.
  107810. * @param isFrozen defines wether the material is frozen or not.
  107811. */
  107812. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107813. /**
  107814. * Checks to see if a texture is used in the material.
  107815. * @param texture - Base texture to use.
  107816. * @returns - Boolean specifying if a texture is used in the material.
  107817. */
  107818. hasTexture(texture: BaseTexture): boolean;
  107819. /**
  107820. * Returns an array of the actively used textures.
  107821. * @param activeTextures Array of BaseTextures
  107822. */
  107823. getActiveTextures(activeTextures: BaseTexture[]): void;
  107824. /**
  107825. * Returns the animatable textures.
  107826. * @param animatables Array of animatable textures.
  107827. */
  107828. getAnimatables(animatables: IAnimatable[]): void;
  107829. /**
  107830. * Disposes the resources of the material.
  107831. * @param forceDisposeTextures - Forces the disposal of all textures.
  107832. */
  107833. dispose(forceDisposeTextures?: boolean): void;
  107834. /**
  107835. * Get the current class name of the texture useful for serialization or dynamic coding.
  107836. * @returns "PBRAnisotropicConfiguration"
  107837. */
  107838. getClassName(): string;
  107839. /**
  107840. * Add fallbacks to the effect fallbacks list.
  107841. * @param defines defines the Base texture to use.
  107842. * @param fallbacks defines the current fallback list.
  107843. * @param currentRank defines the current fallback rank.
  107844. * @returns the new fallback rank.
  107845. */
  107846. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107847. /**
  107848. * Add the required uniforms to the current list.
  107849. * @param uniforms defines the current uniform list.
  107850. */
  107851. static AddUniforms(uniforms: string[]): void;
  107852. /**
  107853. * Add the required uniforms to the current buffer.
  107854. * @param uniformBuffer defines the current uniform buffer.
  107855. */
  107856. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107857. /**
  107858. * Add the required samplers to the current list.
  107859. * @param samplers defines the current sampler list.
  107860. */
  107861. static AddSamplers(samplers: string[]): void;
  107862. /**
  107863. * Makes a duplicate of the current configuration into another one.
  107864. * @param anisotropicConfiguration define the config where to copy the info
  107865. */
  107866. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107867. /**
  107868. * Serializes this anisotropy configuration.
  107869. * @returns - An object with the serialized config.
  107870. */
  107871. serialize(): any;
  107872. /**
  107873. * Parses a anisotropy Configuration from a serialized object.
  107874. * @param source - Serialized object.
  107875. * @param scene Defines the scene we are parsing for
  107876. * @param rootUrl Defines the rootUrl to load from
  107877. */
  107878. parse(source: any, scene: Scene, rootUrl: string): void;
  107879. }
  107880. }
  107881. declare module BABYLON {
  107882. /**
  107883. * @hidden
  107884. */
  107885. export interface IMaterialBRDFDefines {
  107886. BRDF_V_HEIGHT_CORRELATED: boolean;
  107887. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107888. SPHERICAL_HARMONICS: boolean;
  107889. /** @hidden */
  107890. _areMiscDirty: boolean;
  107891. }
  107892. /**
  107893. * Define the code related to the BRDF parameters of the pbr material.
  107894. */
  107895. export class PBRBRDFConfiguration {
  107896. /**
  107897. * Default value used for the energy conservation.
  107898. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107899. */
  107900. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107901. /**
  107902. * Default value used for the Smith Visibility Height Correlated mode.
  107903. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107904. */
  107905. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107906. /**
  107907. * Default value used for the IBL diffuse part.
  107908. * This can help switching back to the polynomials mode globally which is a tiny bit
  107909. * less GPU intensive at the drawback of a lower quality.
  107910. */
  107911. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107912. private _useEnergyConservation;
  107913. /**
  107914. * Defines if the material uses energy conservation.
  107915. */
  107916. useEnergyConservation: boolean;
  107917. private _useSmithVisibilityHeightCorrelated;
  107918. /**
  107919. * LEGACY Mode set to false
  107920. * Defines if the material uses height smith correlated visibility term.
  107921. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  107922. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107923. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  107924. * Not relying on height correlated will also disable energy conservation.
  107925. */
  107926. useSmithVisibilityHeightCorrelated: boolean;
  107927. private _useSphericalHarmonics;
  107928. /**
  107929. * LEGACY Mode set to false
  107930. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  107931. * diffuse part of the IBL.
  107932. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  107933. * to the ground truth.
  107934. */
  107935. useSphericalHarmonics: boolean;
  107936. /** @hidden */
  107937. private _internalMarkAllSubMeshesAsMiscDirty;
  107938. /** @hidden */
  107939. _markAllSubMeshesAsMiscDirty(): void;
  107940. /**
  107941. * Instantiate a new istance of clear coat configuration.
  107942. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  107943. */
  107944. constructor(markAllSubMeshesAsMiscDirty: () => void);
  107945. /**
  107946. * Checks to see if a texture is used in the material.
  107947. * @param defines the list of "defines" to update.
  107948. */
  107949. prepareDefines(defines: IMaterialBRDFDefines): void;
  107950. /**
  107951. * Get the current class name of the texture useful for serialization or dynamic coding.
  107952. * @returns "PBRClearCoatConfiguration"
  107953. */
  107954. getClassName(): string;
  107955. /**
  107956. * Makes a duplicate of the current configuration into another one.
  107957. * @param brdfConfiguration define the config where to copy the info
  107958. */
  107959. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  107960. /**
  107961. * Serializes this BRDF configuration.
  107962. * @returns - An object with the serialized config.
  107963. */
  107964. serialize(): any;
  107965. /**
  107966. * Parses a anisotropy Configuration from a serialized object.
  107967. * @param source - Serialized object.
  107968. * @param scene Defines the scene we are parsing for
  107969. * @param rootUrl Defines the rootUrl to load from
  107970. */
  107971. parse(source: any, scene: Scene, rootUrl: string): void;
  107972. }
  107973. }
  107974. declare module BABYLON {
  107975. /**
  107976. * @hidden
  107977. */
  107978. export interface IMaterialSheenDefines {
  107979. SHEEN: boolean;
  107980. SHEEN_TEXTURE: boolean;
  107981. SHEEN_TEXTUREDIRECTUV: number;
  107982. SHEEN_LINKWITHALBEDO: boolean;
  107983. /** @hidden */
  107984. _areTexturesDirty: boolean;
  107985. }
  107986. /**
  107987. * Define the code related to the Sheen parameters of the pbr material.
  107988. */
  107989. export class PBRSheenConfiguration {
  107990. private _isEnabled;
  107991. /**
  107992. * Defines if the material uses sheen.
  107993. */
  107994. isEnabled: boolean;
  107995. private _linkSheenWithAlbedo;
  107996. /**
  107997. * Defines if the sheen is linked to the sheen color.
  107998. */
  107999. linkSheenWithAlbedo: boolean;
  108000. /**
  108001. * Defines the sheen intensity.
  108002. */
  108003. intensity: number;
  108004. /**
  108005. * Defines the sheen color.
  108006. */
  108007. color: Color3;
  108008. private _texture;
  108009. /**
  108010. * Stores the sheen tint values in a texture.
  108011. * rgb is tint
  108012. * a is a intensity
  108013. */
  108014. texture: Nullable<BaseTexture>;
  108015. /** @hidden */
  108016. private _internalMarkAllSubMeshesAsTexturesDirty;
  108017. /** @hidden */
  108018. _markAllSubMeshesAsTexturesDirty(): void;
  108019. /**
  108020. * Instantiate a new istance of clear coat configuration.
  108021. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108022. */
  108023. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108024. /**
  108025. * Specifies that the submesh is ready to be used.
  108026. * @param defines the list of "defines" to update.
  108027. * @param scene defines the scene the material belongs to.
  108028. * @returns - boolean indicating that the submesh is ready or not.
  108029. */
  108030. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  108031. /**
  108032. * Checks to see if a texture is used in the material.
  108033. * @param defines the list of "defines" to update.
  108034. * @param scene defines the scene the material belongs to.
  108035. */
  108036. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  108037. /**
  108038. * Binds the material data.
  108039. * @param uniformBuffer defines the Uniform buffer to fill in.
  108040. * @param scene defines the scene the material belongs to.
  108041. * @param isFrozen defines wether the material is frozen or not.
  108042. */
  108043. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  108044. /**
  108045. * Checks to see if a texture is used in the material.
  108046. * @param texture - Base texture to use.
  108047. * @returns - Boolean specifying if a texture is used in the material.
  108048. */
  108049. hasTexture(texture: BaseTexture): boolean;
  108050. /**
  108051. * Returns an array of the actively used textures.
  108052. * @param activeTextures Array of BaseTextures
  108053. */
  108054. getActiveTextures(activeTextures: BaseTexture[]): void;
  108055. /**
  108056. * Returns the animatable textures.
  108057. * @param animatables Array of animatable textures.
  108058. */
  108059. getAnimatables(animatables: IAnimatable[]): void;
  108060. /**
  108061. * Disposes the resources of the material.
  108062. * @param forceDisposeTextures - Forces the disposal of all textures.
  108063. */
  108064. dispose(forceDisposeTextures?: boolean): void;
  108065. /**
  108066. * Get the current class name of the texture useful for serialization or dynamic coding.
  108067. * @returns "PBRSheenConfiguration"
  108068. */
  108069. getClassName(): string;
  108070. /**
  108071. * Add fallbacks to the effect fallbacks list.
  108072. * @param defines defines the Base texture to use.
  108073. * @param fallbacks defines the current fallback list.
  108074. * @param currentRank defines the current fallback rank.
  108075. * @returns the new fallback rank.
  108076. */
  108077. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108078. /**
  108079. * Add the required uniforms to the current list.
  108080. * @param uniforms defines the current uniform list.
  108081. */
  108082. static AddUniforms(uniforms: string[]): void;
  108083. /**
  108084. * Add the required uniforms to the current buffer.
  108085. * @param uniformBuffer defines the current uniform buffer.
  108086. */
  108087. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108088. /**
  108089. * Add the required samplers to the current list.
  108090. * @param samplers defines the current sampler list.
  108091. */
  108092. static AddSamplers(samplers: string[]): void;
  108093. /**
  108094. * Makes a duplicate of the current configuration into another one.
  108095. * @param sheenConfiguration define the config where to copy the info
  108096. */
  108097. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  108098. /**
  108099. * Serializes this BRDF configuration.
  108100. * @returns - An object with the serialized config.
  108101. */
  108102. serialize(): any;
  108103. /**
  108104. * Parses a anisotropy Configuration from a serialized object.
  108105. * @param source - Serialized object.
  108106. * @param scene Defines the scene we are parsing for
  108107. * @param rootUrl Defines the rootUrl to load from
  108108. */
  108109. parse(source: any, scene: Scene, rootUrl: string): void;
  108110. }
  108111. }
  108112. declare module BABYLON {
  108113. /**
  108114. * @hidden
  108115. */
  108116. export interface IMaterialSubSurfaceDefines {
  108117. SUBSURFACE: boolean;
  108118. SS_REFRACTION: boolean;
  108119. SS_TRANSLUCENCY: boolean;
  108120. SS_SCATERRING: boolean;
  108121. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108122. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108123. SS_REFRACTIONMAP_3D: boolean;
  108124. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108125. SS_LODINREFRACTIONALPHA: boolean;
  108126. SS_GAMMAREFRACTION: boolean;
  108127. SS_RGBDREFRACTION: boolean;
  108128. SS_LINEARSPECULARREFRACTION: boolean;
  108129. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108130. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108131. /** @hidden */
  108132. _areTexturesDirty: boolean;
  108133. }
  108134. /**
  108135. * Define the code related to the sub surface parameters of the pbr material.
  108136. */
  108137. export class PBRSubSurfaceConfiguration {
  108138. private _isRefractionEnabled;
  108139. /**
  108140. * Defines if the refraction is enabled in the material.
  108141. */
  108142. isRefractionEnabled: boolean;
  108143. private _isTranslucencyEnabled;
  108144. /**
  108145. * Defines if the translucency is enabled in the material.
  108146. */
  108147. isTranslucencyEnabled: boolean;
  108148. private _isScatteringEnabled;
  108149. /**
  108150. * Defines the refraction intensity of the material.
  108151. * The refraction when enabled replaces the Diffuse part of the material.
  108152. * The intensity helps transitionning between diffuse and refraction.
  108153. */
  108154. refractionIntensity: number;
  108155. /**
  108156. * Defines the translucency intensity of the material.
  108157. * When translucency has been enabled, this defines how much of the "translucency"
  108158. * is addded to the diffuse part of the material.
  108159. */
  108160. translucencyIntensity: number;
  108161. /**
  108162. * Defines the scattering intensity of the material.
  108163. * When scattering has been enabled, this defines how much of the "scattered light"
  108164. * is addded to the diffuse part of the material.
  108165. */
  108166. scatteringIntensity: number;
  108167. private _thicknessTexture;
  108168. /**
  108169. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  108170. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  108171. * 0 would mean minimumThickness
  108172. * 1 would mean maximumThickness
  108173. * The other channels might be use as a mask to vary the different effects intensity.
  108174. */
  108175. thicknessTexture: Nullable<BaseTexture>;
  108176. private _refractionTexture;
  108177. /**
  108178. * Defines the texture to use for refraction.
  108179. */
  108180. refractionTexture: Nullable<BaseTexture>;
  108181. private _indexOfRefraction;
  108182. /**
  108183. * Defines the index of refraction used in the material.
  108184. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  108185. */
  108186. indexOfRefraction: number;
  108187. private _invertRefractionY;
  108188. /**
  108189. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108190. */
  108191. invertRefractionY: boolean;
  108192. private _linkRefractionWithTransparency;
  108193. /**
  108194. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108195. * Materials half opaque for instance using refraction could benefit from this control.
  108196. */
  108197. linkRefractionWithTransparency: boolean;
  108198. /**
  108199. * Defines the minimum thickness stored in the thickness map.
  108200. * If no thickness map is defined, this value will be used to simulate thickness.
  108201. */
  108202. minimumThickness: number;
  108203. /**
  108204. * Defines the maximum thickness stored in the thickness map.
  108205. */
  108206. maximumThickness: number;
  108207. /**
  108208. * Defines the volume tint of the material.
  108209. * This is used for both translucency and scattering.
  108210. */
  108211. tintColor: Color3;
  108212. /**
  108213. * Defines the distance at which the tint color should be found in the media.
  108214. * This is used for refraction only.
  108215. */
  108216. tintColorAtDistance: number;
  108217. /**
  108218. * Defines how far each channel transmit through the media.
  108219. * It is defined as a color to simplify it selection.
  108220. */
  108221. diffusionDistance: Color3;
  108222. private _useMaskFromThicknessTexture;
  108223. /**
  108224. * Stores the intensity of the different subsurface effects in the thickness texture.
  108225. * * the green channel is the translucency intensity.
  108226. * * the blue channel is the scattering intensity.
  108227. * * the alpha channel is the refraction intensity.
  108228. */
  108229. useMaskFromThicknessTexture: boolean;
  108230. /** @hidden */
  108231. private _internalMarkAllSubMeshesAsTexturesDirty;
  108232. /** @hidden */
  108233. _markAllSubMeshesAsTexturesDirty(): void;
  108234. /**
  108235. * Instantiate a new istance of sub surface configuration.
  108236. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108237. */
  108238. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108239. /**
  108240. * Gets wehter the submesh is ready to be used or not.
  108241. * @param defines the list of "defines" to update.
  108242. * @param scene defines the scene the material belongs to.
  108243. * @returns - boolean indicating that the submesh is ready or not.
  108244. */
  108245. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  108246. /**
  108247. * Checks to see if a texture is used in the material.
  108248. * @param defines the list of "defines" to update.
  108249. * @param scene defines the scene to the material belongs to.
  108250. */
  108251. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  108252. /**
  108253. * Binds the material data.
  108254. * @param uniformBuffer defines the Uniform buffer to fill in.
  108255. * @param scene defines the scene the material belongs to.
  108256. * @param engine defines the engine the material belongs to.
  108257. * @param isFrozen defines wether the material is frozen or not.
  108258. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  108259. */
  108260. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  108261. /**
  108262. * Unbinds the material from the mesh.
  108263. * @param activeEffect defines the effect that should be unbound from.
  108264. * @returns true if unbound, otherwise false
  108265. */
  108266. unbind(activeEffect: Effect): boolean;
  108267. /**
  108268. * Returns the texture used for refraction or null if none is used.
  108269. * @param scene defines the scene the material belongs to.
  108270. * @returns - Refraction texture if present. If no refraction texture and refraction
  108271. * is linked with transparency, returns environment texture. Otherwise, returns null.
  108272. */
  108273. private _getRefractionTexture;
  108274. /**
  108275. * Returns true if alpha blending should be disabled.
  108276. */
  108277. readonly disableAlphaBlending: boolean;
  108278. /**
  108279. * Fills the list of render target textures.
  108280. * @param renderTargets the list of render targets to update
  108281. */
  108282. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  108283. /**
  108284. * Checks to see if a texture is used in the material.
  108285. * @param texture - Base texture to use.
  108286. * @returns - Boolean specifying if a texture is used in the material.
  108287. */
  108288. hasTexture(texture: BaseTexture): boolean;
  108289. /**
  108290. * Gets a boolean indicating that current material needs to register RTT
  108291. * @returns true if this uses a render target otherwise false.
  108292. */
  108293. hasRenderTargetTextures(): boolean;
  108294. /**
  108295. * Returns an array of the actively used textures.
  108296. * @param activeTextures Array of BaseTextures
  108297. */
  108298. getActiveTextures(activeTextures: BaseTexture[]): void;
  108299. /**
  108300. * Returns the animatable textures.
  108301. * @param animatables Array of animatable textures.
  108302. */
  108303. getAnimatables(animatables: IAnimatable[]): void;
  108304. /**
  108305. * Disposes the resources of the material.
  108306. * @param forceDisposeTextures - Forces the disposal of all textures.
  108307. */
  108308. dispose(forceDisposeTextures?: boolean): void;
  108309. /**
  108310. * Get the current class name of the texture useful for serialization or dynamic coding.
  108311. * @returns "PBRSubSurfaceConfiguration"
  108312. */
  108313. getClassName(): string;
  108314. /**
  108315. * Add fallbacks to the effect fallbacks list.
  108316. * @param defines defines the Base texture to use.
  108317. * @param fallbacks defines the current fallback list.
  108318. * @param currentRank defines the current fallback rank.
  108319. * @returns the new fallback rank.
  108320. */
  108321. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108322. /**
  108323. * Add the required uniforms to the current list.
  108324. * @param uniforms defines the current uniform list.
  108325. */
  108326. static AddUniforms(uniforms: string[]): void;
  108327. /**
  108328. * Add the required samplers to the current list.
  108329. * @param samplers defines the current sampler list.
  108330. */
  108331. static AddSamplers(samplers: string[]): void;
  108332. /**
  108333. * Add the required uniforms to the current buffer.
  108334. * @param uniformBuffer defines the current uniform buffer.
  108335. */
  108336. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108337. /**
  108338. * Makes a duplicate of the current configuration into another one.
  108339. * @param configuration define the config where to copy the info
  108340. */
  108341. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  108342. /**
  108343. * Serializes this Sub Surface configuration.
  108344. * @returns - An object with the serialized config.
  108345. */
  108346. serialize(): any;
  108347. /**
  108348. * Parses a anisotropy Configuration from a serialized object.
  108349. * @param source - Serialized object.
  108350. * @param scene Defines the scene we are parsing for
  108351. * @param rootUrl Defines the rootUrl to load from
  108352. */
  108353. parse(source: any, scene: Scene, rootUrl: string): void;
  108354. }
  108355. }
  108356. declare module BABYLON {
  108357. /** @hidden */
  108358. export var pbrFragmentDeclaration: {
  108359. name: string;
  108360. shader: string;
  108361. };
  108362. }
  108363. declare module BABYLON {
  108364. /** @hidden */
  108365. export var pbrUboDeclaration: {
  108366. name: string;
  108367. shader: string;
  108368. };
  108369. }
  108370. declare module BABYLON {
  108371. /** @hidden */
  108372. export var pbrFragmentExtraDeclaration: {
  108373. name: string;
  108374. shader: string;
  108375. };
  108376. }
  108377. declare module BABYLON {
  108378. /** @hidden */
  108379. export var pbrFragmentSamplersDeclaration: {
  108380. name: string;
  108381. shader: string;
  108382. };
  108383. }
  108384. declare module BABYLON {
  108385. /** @hidden */
  108386. export var pbrHelperFunctions: {
  108387. name: string;
  108388. shader: string;
  108389. };
  108390. }
  108391. declare module BABYLON {
  108392. /** @hidden */
  108393. export var harmonicsFunctions: {
  108394. name: string;
  108395. shader: string;
  108396. };
  108397. }
  108398. declare module BABYLON {
  108399. /** @hidden */
  108400. export var pbrDirectLightingSetupFunctions: {
  108401. name: string;
  108402. shader: string;
  108403. };
  108404. }
  108405. declare module BABYLON {
  108406. /** @hidden */
  108407. export var pbrDirectLightingFalloffFunctions: {
  108408. name: string;
  108409. shader: string;
  108410. };
  108411. }
  108412. declare module BABYLON {
  108413. /** @hidden */
  108414. export var pbrBRDFFunctions: {
  108415. name: string;
  108416. shader: string;
  108417. };
  108418. }
  108419. declare module BABYLON {
  108420. /** @hidden */
  108421. export var pbrDirectLightingFunctions: {
  108422. name: string;
  108423. shader: string;
  108424. };
  108425. }
  108426. declare module BABYLON {
  108427. /** @hidden */
  108428. export var pbrIBLFunctions: {
  108429. name: string;
  108430. shader: string;
  108431. };
  108432. }
  108433. declare module BABYLON {
  108434. /** @hidden */
  108435. export var pbrDebug: {
  108436. name: string;
  108437. shader: string;
  108438. };
  108439. }
  108440. declare module BABYLON {
  108441. /** @hidden */
  108442. export var pbrPixelShader: {
  108443. name: string;
  108444. shader: string;
  108445. };
  108446. }
  108447. declare module BABYLON {
  108448. /** @hidden */
  108449. export var pbrVertexDeclaration: {
  108450. name: string;
  108451. shader: string;
  108452. };
  108453. }
  108454. declare module BABYLON {
  108455. /** @hidden */
  108456. export var pbrVertexShader: {
  108457. name: string;
  108458. shader: string;
  108459. };
  108460. }
  108461. declare module BABYLON {
  108462. /**
  108463. * Manages the defines for the PBR Material.
  108464. * @hidden
  108465. */
  108466. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  108467. PBR: boolean;
  108468. MAINUV1: boolean;
  108469. MAINUV2: boolean;
  108470. UV1: boolean;
  108471. UV2: boolean;
  108472. ALBEDO: boolean;
  108473. ALBEDODIRECTUV: number;
  108474. VERTEXCOLOR: boolean;
  108475. AMBIENT: boolean;
  108476. AMBIENTDIRECTUV: number;
  108477. AMBIENTINGRAYSCALE: boolean;
  108478. OPACITY: boolean;
  108479. VERTEXALPHA: boolean;
  108480. OPACITYDIRECTUV: number;
  108481. OPACITYRGB: boolean;
  108482. ALPHATEST: boolean;
  108483. DEPTHPREPASS: boolean;
  108484. ALPHABLEND: boolean;
  108485. ALPHAFROMALBEDO: boolean;
  108486. ALPHATESTVALUE: string;
  108487. SPECULAROVERALPHA: boolean;
  108488. RADIANCEOVERALPHA: boolean;
  108489. ALPHAFRESNEL: boolean;
  108490. LINEARALPHAFRESNEL: boolean;
  108491. PREMULTIPLYALPHA: boolean;
  108492. EMISSIVE: boolean;
  108493. EMISSIVEDIRECTUV: number;
  108494. REFLECTIVITY: boolean;
  108495. REFLECTIVITYDIRECTUV: number;
  108496. SPECULARTERM: boolean;
  108497. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  108498. MICROSURFACEAUTOMATIC: boolean;
  108499. LODBASEDMICROSFURACE: boolean;
  108500. MICROSURFACEMAP: boolean;
  108501. MICROSURFACEMAPDIRECTUV: number;
  108502. METALLICWORKFLOW: boolean;
  108503. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  108504. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  108505. METALLNESSSTOREINMETALMAPBLUE: boolean;
  108506. AOSTOREINMETALMAPRED: boolean;
  108507. ENVIRONMENTBRDF: boolean;
  108508. ENVIRONMENTBRDF_RGBD: boolean;
  108509. NORMAL: boolean;
  108510. TANGENT: boolean;
  108511. BUMP: boolean;
  108512. BUMPDIRECTUV: number;
  108513. OBJECTSPACE_NORMALMAP: boolean;
  108514. PARALLAX: boolean;
  108515. PARALLAXOCCLUSION: boolean;
  108516. NORMALXYSCALE: boolean;
  108517. LIGHTMAP: boolean;
  108518. LIGHTMAPDIRECTUV: number;
  108519. USELIGHTMAPASSHADOWMAP: boolean;
  108520. GAMMALIGHTMAP: boolean;
  108521. REFLECTION: boolean;
  108522. REFLECTIONMAP_3D: boolean;
  108523. REFLECTIONMAP_SPHERICAL: boolean;
  108524. REFLECTIONMAP_PLANAR: boolean;
  108525. REFLECTIONMAP_CUBIC: boolean;
  108526. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108527. REFLECTIONMAP_PROJECTION: boolean;
  108528. REFLECTIONMAP_SKYBOX: boolean;
  108529. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108530. REFLECTIONMAP_EXPLICIT: boolean;
  108531. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108532. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108533. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108534. INVERTCUBICMAP: boolean;
  108535. USESPHERICALFROMREFLECTIONMAP: boolean;
  108536. USEIRRADIANCEMAP: boolean;
  108537. SPHERICAL_HARMONICS: boolean;
  108538. USESPHERICALINVERTEX: boolean;
  108539. REFLECTIONMAP_OPPOSITEZ: boolean;
  108540. LODINREFLECTIONALPHA: boolean;
  108541. GAMMAREFLECTION: boolean;
  108542. RGBDREFLECTION: boolean;
  108543. LINEARSPECULARREFLECTION: boolean;
  108544. RADIANCEOCCLUSION: boolean;
  108545. HORIZONOCCLUSION: boolean;
  108546. INSTANCES: boolean;
  108547. NUM_BONE_INFLUENCERS: number;
  108548. BonesPerMesh: number;
  108549. BONETEXTURE: boolean;
  108550. NONUNIFORMSCALING: boolean;
  108551. MORPHTARGETS: boolean;
  108552. MORPHTARGETS_NORMAL: boolean;
  108553. MORPHTARGETS_TANGENT: boolean;
  108554. MORPHTARGETS_UV: boolean;
  108555. NUM_MORPH_INFLUENCERS: number;
  108556. IMAGEPROCESSING: boolean;
  108557. VIGNETTE: boolean;
  108558. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108559. VIGNETTEBLENDMODEOPAQUE: boolean;
  108560. TONEMAPPING: boolean;
  108561. TONEMAPPING_ACES: boolean;
  108562. CONTRAST: boolean;
  108563. COLORCURVES: boolean;
  108564. COLORGRADING: boolean;
  108565. COLORGRADING3D: boolean;
  108566. SAMPLER3DGREENDEPTH: boolean;
  108567. SAMPLER3DBGRMAP: boolean;
  108568. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108569. EXPOSURE: boolean;
  108570. MULTIVIEW: boolean;
  108571. USEPHYSICALLIGHTFALLOFF: boolean;
  108572. USEGLTFLIGHTFALLOFF: boolean;
  108573. TWOSIDEDLIGHTING: boolean;
  108574. SHADOWFLOAT: boolean;
  108575. CLIPPLANE: boolean;
  108576. CLIPPLANE2: boolean;
  108577. CLIPPLANE3: boolean;
  108578. CLIPPLANE4: boolean;
  108579. POINTSIZE: boolean;
  108580. FOG: boolean;
  108581. LOGARITHMICDEPTH: boolean;
  108582. FORCENORMALFORWARD: boolean;
  108583. SPECULARAA: boolean;
  108584. CLEARCOAT: boolean;
  108585. CLEARCOAT_DEFAULTIOR: boolean;
  108586. CLEARCOAT_TEXTURE: boolean;
  108587. CLEARCOAT_TEXTUREDIRECTUV: number;
  108588. CLEARCOAT_BUMP: boolean;
  108589. CLEARCOAT_BUMPDIRECTUV: number;
  108590. CLEARCOAT_TINT: boolean;
  108591. CLEARCOAT_TINT_TEXTURE: boolean;
  108592. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108593. ANISOTROPIC: boolean;
  108594. ANISOTROPIC_TEXTURE: boolean;
  108595. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108596. BRDF_V_HEIGHT_CORRELATED: boolean;
  108597. MS_BRDF_ENERGY_CONSERVATION: boolean;
  108598. SHEEN: boolean;
  108599. SHEEN_TEXTURE: boolean;
  108600. SHEEN_TEXTUREDIRECTUV: number;
  108601. SHEEN_LINKWITHALBEDO: boolean;
  108602. SUBSURFACE: boolean;
  108603. SS_REFRACTION: boolean;
  108604. SS_TRANSLUCENCY: boolean;
  108605. SS_SCATERRING: boolean;
  108606. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108607. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108608. SS_REFRACTIONMAP_3D: boolean;
  108609. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108610. SS_LODINREFRACTIONALPHA: boolean;
  108611. SS_GAMMAREFRACTION: boolean;
  108612. SS_RGBDREFRACTION: boolean;
  108613. SS_LINEARSPECULARREFRACTION: boolean;
  108614. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108615. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108616. UNLIT: boolean;
  108617. DEBUGMODE: number;
  108618. /**
  108619. * Initializes the PBR Material defines.
  108620. */
  108621. constructor();
  108622. /**
  108623. * Resets the PBR Material defines.
  108624. */
  108625. reset(): void;
  108626. }
  108627. /**
  108628. * The Physically based material base class of BJS.
  108629. *
  108630. * This offers the main features of a standard PBR material.
  108631. * For more information, please refer to the documentation :
  108632. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108633. */
  108634. export abstract class PBRBaseMaterial extends PushMaterial {
  108635. /**
  108636. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108637. */
  108638. static readonly PBRMATERIAL_OPAQUE: number;
  108639. /**
  108640. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108641. */
  108642. static readonly PBRMATERIAL_ALPHATEST: number;
  108643. /**
  108644. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108645. */
  108646. static readonly PBRMATERIAL_ALPHABLEND: number;
  108647. /**
  108648. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108649. * They are also discarded below the alpha cutoff threshold to improve performances.
  108650. */
  108651. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108652. /**
  108653. * Defines the default value of how much AO map is occluding the analytical lights
  108654. * (point spot...).
  108655. */
  108656. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108657. /**
  108658. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  108659. */
  108660. static readonly LIGHTFALLOFF_PHYSICAL: number;
  108661. /**
  108662. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  108663. * to enhance interoperability with other engines.
  108664. */
  108665. static readonly LIGHTFALLOFF_GLTF: number;
  108666. /**
  108667. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  108668. * to enhance interoperability with other materials.
  108669. */
  108670. static readonly LIGHTFALLOFF_STANDARD: number;
  108671. /**
  108672. * Intensity of the direct lights e.g. the four lights available in your scene.
  108673. * This impacts both the direct diffuse and specular highlights.
  108674. */
  108675. protected _directIntensity: number;
  108676. /**
  108677. * Intensity of the emissive part of the material.
  108678. * This helps controlling the emissive effect without modifying the emissive color.
  108679. */
  108680. protected _emissiveIntensity: number;
  108681. /**
  108682. * Intensity of the environment e.g. how much the environment will light the object
  108683. * either through harmonics for rough material or through the refelction for shiny ones.
  108684. */
  108685. protected _environmentIntensity: number;
  108686. /**
  108687. * This is a special control allowing the reduction of the specular highlights coming from the
  108688. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108689. */
  108690. protected _specularIntensity: number;
  108691. /**
  108692. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  108693. */
  108694. private _lightingInfos;
  108695. /**
  108696. * Debug Control allowing disabling the bump map on this material.
  108697. */
  108698. protected _disableBumpMap: boolean;
  108699. /**
  108700. * AKA Diffuse Texture in standard nomenclature.
  108701. */
  108702. protected _albedoTexture: Nullable<BaseTexture>;
  108703. /**
  108704. * AKA Occlusion Texture in other nomenclature.
  108705. */
  108706. protected _ambientTexture: Nullable<BaseTexture>;
  108707. /**
  108708. * AKA Occlusion Texture Intensity in other nomenclature.
  108709. */
  108710. protected _ambientTextureStrength: number;
  108711. /**
  108712. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108713. * 1 means it completely occludes it
  108714. * 0 mean it has no impact
  108715. */
  108716. protected _ambientTextureImpactOnAnalyticalLights: number;
  108717. /**
  108718. * Stores the alpha values in a texture.
  108719. */
  108720. protected _opacityTexture: Nullable<BaseTexture>;
  108721. /**
  108722. * Stores the reflection values in a texture.
  108723. */
  108724. protected _reflectionTexture: Nullable<BaseTexture>;
  108725. /**
  108726. * Stores the emissive values in a texture.
  108727. */
  108728. protected _emissiveTexture: Nullable<BaseTexture>;
  108729. /**
  108730. * AKA Specular texture in other nomenclature.
  108731. */
  108732. protected _reflectivityTexture: Nullable<BaseTexture>;
  108733. /**
  108734. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108735. */
  108736. protected _metallicTexture: Nullable<BaseTexture>;
  108737. /**
  108738. * Specifies the metallic scalar of the metallic/roughness workflow.
  108739. * Can also be used to scale the metalness values of the metallic texture.
  108740. */
  108741. protected _metallic: Nullable<number>;
  108742. /**
  108743. * Specifies the roughness scalar of the metallic/roughness workflow.
  108744. * Can also be used to scale the roughness values of the metallic texture.
  108745. */
  108746. protected _roughness: Nullable<number>;
  108747. /**
  108748. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108749. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108750. */
  108751. protected _microSurfaceTexture: Nullable<BaseTexture>;
  108752. /**
  108753. * Stores surface normal data used to displace a mesh in a texture.
  108754. */
  108755. protected _bumpTexture: Nullable<BaseTexture>;
  108756. /**
  108757. * Stores the pre-calculated light information of a mesh in a texture.
  108758. */
  108759. protected _lightmapTexture: Nullable<BaseTexture>;
  108760. /**
  108761. * The color of a material in ambient lighting.
  108762. */
  108763. protected _ambientColor: Color3;
  108764. /**
  108765. * AKA Diffuse Color in other nomenclature.
  108766. */
  108767. protected _albedoColor: Color3;
  108768. /**
  108769. * AKA Specular Color in other nomenclature.
  108770. */
  108771. protected _reflectivityColor: Color3;
  108772. /**
  108773. * The color applied when light is reflected from a material.
  108774. */
  108775. protected _reflectionColor: Color3;
  108776. /**
  108777. * The color applied when light is emitted from a material.
  108778. */
  108779. protected _emissiveColor: Color3;
  108780. /**
  108781. * AKA Glossiness in other nomenclature.
  108782. */
  108783. protected _microSurface: number;
  108784. /**
  108785. * Specifies that the material will use the light map as a show map.
  108786. */
  108787. protected _useLightmapAsShadowmap: boolean;
  108788. /**
  108789. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108790. * makes the reflect vector face the model (under horizon).
  108791. */
  108792. protected _useHorizonOcclusion: boolean;
  108793. /**
  108794. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108795. * too much the area relying on ambient texture to define their ambient occlusion.
  108796. */
  108797. protected _useRadianceOcclusion: boolean;
  108798. /**
  108799. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108800. */
  108801. protected _useAlphaFromAlbedoTexture: boolean;
  108802. /**
  108803. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  108804. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108805. */
  108806. protected _useSpecularOverAlpha: boolean;
  108807. /**
  108808. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108809. */
  108810. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108811. /**
  108812. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108813. */
  108814. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  108815. /**
  108816. * Specifies if the metallic texture contains the roughness information in its green channel.
  108817. */
  108818. protected _useRoughnessFromMetallicTextureGreen: boolean;
  108819. /**
  108820. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108821. */
  108822. protected _useMetallnessFromMetallicTextureBlue: boolean;
  108823. /**
  108824. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108825. */
  108826. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  108827. /**
  108828. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108829. */
  108830. protected _useAmbientInGrayScale: boolean;
  108831. /**
  108832. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108833. * The material will try to infer what glossiness each pixel should be.
  108834. */
  108835. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  108836. /**
  108837. * Defines the falloff type used in this material.
  108838. * It by default is Physical.
  108839. */
  108840. protected _lightFalloff: number;
  108841. /**
  108842. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108843. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108844. */
  108845. protected _useRadianceOverAlpha: boolean;
  108846. /**
  108847. * Allows using an object space normal map (instead of tangent space).
  108848. */
  108849. protected _useObjectSpaceNormalMap: boolean;
  108850. /**
  108851. * Allows using the bump map in parallax mode.
  108852. */
  108853. protected _useParallax: boolean;
  108854. /**
  108855. * Allows using the bump map in parallax occlusion mode.
  108856. */
  108857. protected _useParallaxOcclusion: boolean;
  108858. /**
  108859. * Controls the scale bias of the parallax mode.
  108860. */
  108861. protected _parallaxScaleBias: number;
  108862. /**
  108863. * If sets to true, disables all the lights affecting the material.
  108864. */
  108865. protected _disableLighting: boolean;
  108866. /**
  108867. * Number of Simultaneous lights allowed on the material.
  108868. */
  108869. protected _maxSimultaneousLights: number;
  108870. /**
  108871. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108872. */
  108873. protected _invertNormalMapX: boolean;
  108874. /**
  108875. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108876. */
  108877. protected _invertNormalMapY: boolean;
  108878. /**
  108879. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108880. */
  108881. protected _twoSidedLighting: boolean;
  108882. /**
  108883. * Defines the alpha limits in alpha test mode.
  108884. */
  108885. protected _alphaCutOff: number;
  108886. /**
  108887. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108888. */
  108889. protected _forceAlphaTest: boolean;
  108890. /**
  108891. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108892. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108893. */
  108894. protected _useAlphaFresnel: boolean;
  108895. /**
  108896. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108897. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108898. */
  108899. protected _useLinearAlphaFresnel: boolean;
  108900. /**
  108901. * The transparency mode of the material.
  108902. */
  108903. protected _transparencyMode: Nullable<number>;
  108904. /**
  108905. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108906. * from cos thetav and roughness:
  108907. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108908. */
  108909. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108910. /**
  108911. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108912. */
  108913. protected _forceIrradianceInFragment: boolean;
  108914. /**
  108915. * Force normal to face away from face.
  108916. */
  108917. protected _forceNormalForward: boolean;
  108918. /**
  108919. * Enables specular anti aliasing in the PBR shader.
  108920. * It will both interacts on the Geometry for analytical and IBL lighting.
  108921. * It also prefilter the roughness map based on the bump values.
  108922. */
  108923. protected _enableSpecularAntiAliasing: boolean;
  108924. /**
  108925. * Default configuration related to image processing available in the PBR Material.
  108926. */
  108927. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108928. /**
  108929. * Keep track of the image processing observer to allow dispose and replace.
  108930. */
  108931. private _imageProcessingObserver;
  108932. /**
  108933. * Attaches a new image processing configuration to the PBR Material.
  108934. * @param configuration
  108935. */
  108936. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108937. /**
  108938. * Stores the available render targets.
  108939. */
  108940. private _renderTargets;
  108941. /**
  108942. * Sets the global ambient color for the material used in lighting calculations.
  108943. */
  108944. private _globalAmbientColor;
  108945. /**
  108946. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  108947. */
  108948. private _useLogarithmicDepth;
  108949. /**
  108950. * If set to true, no lighting calculations will be applied.
  108951. */
  108952. private _unlit;
  108953. private _debugMode;
  108954. /**
  108955. * @hidden
  108956. * This is reserved for the inspector.
  108957. * Defines the material debug mode.
  108958. * It helps seeing only some components of the material while troubleshooting.
  108959. */
  108960. debugMode: number;
  108961. /**
  108962. * @hidden
  108963. * This is reserved for the inspector.
  108964. * Specify from where on screen the debug mode should start.
  108965. * The value goes from -1 (full screen) to 1 (not visible)
  108966. * It helps with side by side comparison against the final render
  108967. * This defaults to -1
  108968. */
  108969. private debugLimit;
  108970. /**
  108971. * @hidden
  108972. * This is reserved for the inspector.
  108973. * As the default viewing range might not be enough (if the ambient is really small for instance)
  108974. * You can use the factor to better multiply the final value.
  108975. */
  108976. private debugFactor;
  108977. /**
  108978. * Defines the clear coat layer parameters for the material.
  108979. */
  108980. readonly clearCoat: PBRClearCoatConfiguration;
  108981. /**
  108982. * Defines the anisotropic parameters for the material.
  108983. */
  108984. readonly anisotropy: PBRAnisotropicConfiguration;
  108985. /**
  108986. * Defines the BRDF parameters for the material.
  108987. */
  108988. readonly brdf: PBRBRDFConfiguration;
  108989. /**
  108990. * Defines the Sheen parameters for the material.
  108991. */
  108992. readonly sheen: PBRSheenConfiguration;
  108993. /**
  108994. * Defines the SubSurface parameters for the material.
  108995. */
  108996. readonly subSurface: PBRSubSurfaceConfiguration;
  108997. /**
  108998. * Custom callback helping to override the default shader used in the material.
  108999. */
  109000. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  109001. /**
  109002. * Instantiates a new PBRMaterial instance.
  109003. *
  109004. * @param name The material name
  109005. * @param scene The scene the material will be use in.
  109006. */
  109007. constructor(name: string, scene: Scene);
  109008. /**
  109009. * Gets a boolean indicating that current material needs to register RTT
  109010. */
  109011. readonly hasRenderTargetTextures: boolean;
  109012. /**
  109013. * Gets the name of the material class.
  109014. */
  109015. getClassName(): string;
  109016. /**
  109017. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  109018. */
  109019. /**
  109020. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  109021. */
  109022. useLogarithmicDepth: boolean;
  109023. /**
  109024. * Gets the current transparency mode.
  109025. */
  109026. /**
  109027. * Sets the transparency mode of the material.
  109028. *
  109029. * | Value | Type | Description |
  109030. * | ----- | ----------------------------------- | ----------- |
  109031. * | 0 | OPAQUE | |
  109032. * | 1 | ALPHATEST | |
  109033. * | 2 | ALPHABLEND | |
  109034. * | 3 | ALPHATESTANDBLEND | |
  109035. *
  109036. */
  109037. transparencyMode: Nullable<number>;
  109038. /**
  109039. * Returns true if alpha blending should be disabled.
  109040. */
  109041. private readonly _disableAlphaBlending;
  109042. /**
  109043. * Specifies whether or not this material should be rendered in alpha blend mode.
  109044. */
  109045. needAlphaBlending(): boolean;
  109046. /**
  109047. * Specifies if the mesh will require alpha blending.
  109048. * @param mesh - BJS mesh.
  109049. */
  109050. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  109051. /**
  109052. * Specifies whether or not this material should be rendered in alpha test mode.
  109053. */
  109054. needAlphaTesting(): boolean;
  109055. /**
  109056. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  109057. */
  109058. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  109059. /**
  109060. * Gets the texture used for the alpha test.
  109061. */
  109062. getAlphaTestTexture(): Nullable<BaseTexture>;
  109063. /**
  109064. * Specifies that the submesh is ready to be used.
  109065. * @param mesh - BJS mesh.
  109066. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  109067. * @param useInstances - Specifies that instances should be used.
  109068. * @returns - boolean indicating that the submesh is ready or not.
  109069. */
  109070. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109071. /**
  109072. * Specifies if the material uses metallic roughness workflow.
  109073. * @returns boolean specifiying if the material uses metallic roughness workflow.
  109074. */
  109075. isMetallicWorkflow(): boolean;
  109076. private _prepareEffect;
  109077. private _prepareDefines;
  109078. /**
  109079. * Force shader compilation
  109080. */
  109081. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  109082. clipPlane: boolean;
  109083. }>): void;
  109084. /**
  109085. * Initializes the uniform buffer layout for the shader.
  109086. */
  109087. buildUniformLayout(): void;
  109088. /**
  109089. * Unbinds the material from the mesh
  109090. */
  109091. unbind(): void;
  109092. /**
  109093. * Binds the submesh data.
  109094. * @param world - The world matrix.
  109095. * @param mesh - The BJS mesh.
  109096. * @param subMesh - A submesh of the BJS mesh.
  109097. */
  109098. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109099. /**
  109100. * Returns the animatable textures.
  109101. * @returns - Array of animatable textures.
  109102. */
  109103. getAnimatables(): IAnimatable[];
  109104. /**
  109105. * Returns the texture used for reflections.
  109106. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  109107. */
  109108. private _getReflectionTexture;
  109109. /**
  109110. * Returns an array of the actively used textures.
  109111. * @returns - Array of BaseTextures
  109112. */
  109113. getActiveTextures(): BaseTexture[];
  109114. /**
  109115. * Checks to see if a texture is used in the material.
  109116. * @param texture - Base texture to use.
  109117. * @returns - Boolean specifying if a texture is used in the material.
  109118. */
  109119. hasTexture(texture: BaseTexture): boolean;
  109120. /**
  109121. * Disposes the resources of the material.
  109122. * @param forceDisposeEffect - Forces the disposal of effects.
  109123. * @param forceDisposeTextures - Forces the disposal of all textures.
  109124. */
  109125. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109126. }
  109127. }
  109128. declare module BABYLON {
  109129. /**
  109130. * The Physically based material of BJS.
  109131. *
  109132. * This offers the main features of a standard PBR material.
  109133. * For more information, please refer to the documentation :
  109134. * https://doc.babylonjs.com/how_to/physically_based_rendering
  109135. */
  109136. export class PBRMaterial extends PBRBaseMaterial {
  109137. /**
  109138. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109139. */
  109140. static readonly PBRMATERIAL_OPAQUE: number;
  109141. /**
  109142. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109143. */
  109144. static readonly PBRMATERIAL_ALPHATEST: number;
  109145. /**
  109146. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109147. */
  109148. static readonly PBRMATERIAL_ALPHABLEND: number;
  109149. /**
  109150. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109151. * They are also discarded below the alpha cutoff threshold to improve performances.
  109152. */
  109153. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  109154. /**
  109155. * Defines the default value of how much AO map is occluding the analytical lights
  109156. * (point spot...).
  109157. */
  109158. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  109159. /**
  109160. * Intensity of the direct lights e.g. the four lights available in your scene.
  109161. * This impacts both the direct diffuse and specular highlights.
  109162. */
  109163. directIntensity: number;
  109164. /**
  109165. * Intensity of the emissive part of the material.
  109166. * This helps controlling the emissive effect without modifying the emissive color.
  109167. */
  109168. emissiveIntensity: number;
  109169. /**
  109170. * Intensity of the environment e.g. how much the environment will light the object
  109171. * either through harmonics for rough material or through the refelction for shiny ones.
  109172. */
  109173. environmentIntensity: number;
  109174. /**
  109175. * This is a special control allowing the reduction of the specular highlights coming from the
  109176. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  109177. */
  109178. specularIntensity: number;
  109179. /**
  109180. * Debug Control allowing disabling the bump map on this material.
  109181. */
  109182. disableBumpMap: boolean;
  109183. /**
  109184. * AKA Diffuse Texture in standard nomenclature.
  109185. */
  109186. albedoTexture: BaseTexture;
  109187. /**
  109188. * AKA Occlusion Texture in other nomenclature.
  109189. */
  109190. ambientTexture: BaseTexture;
  109191. /**
  109192. * AKA Occlusion Texture Intensity in other nomenclature.
  109193. */
  109194. ambientTextureStrength: number;
  109195. /**
  109196. * Defines how much the AO map is occluding the analytical lights (point spot...).
  109197. * 1 means it completely occludes it
  109198. * 0 mean it has no impact
  109199. */
  109200. ambientTextureImpactOnAnalyticalLights: number;
  109201. /**
  109202. * Stores the alpha values in a texture.
  109203. */
  109204. opacityTexture: BaseTexture;
  109205. /**
  109206. * Stores the reflection values in a texture.
  109207. */
  109208. reflectionTexture: Nullable<BaseTexture>;
  109209. /**
  109210. * Stores the emissive values in a texture.
  109211. */
  109212. emissiveTexture: BaseTexture;
  109213. /**
  109214. * AKA Specular texture in other nomenclature.
  109215. */
  109216. reflectivityTexture: BaseTexture;
  109217. /**
  109218. * Used to switch from specular/glossiness to metallic/roughness workflow.
  109219. */
  109220. metallicTexture: BaseTexture;
  109221. /**
  109222. * Specifies the metallic scalar of the metallic/roughness workflow.
  109223. * Can also be used to scale the metalness values of the metallic texture.
  109224. */
  109225. metallic: Nullable<number>;
  109226. /**
  109227. * Specifies the roughness scalar of the metallic/roughness workflow.
  109228. * Can also be used to scale the roughness values of the metallic texture.
  109229. */
  109230. roughness: Nullable<number>;
  109231. /**
  109232. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  109233. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  109234. */
  109235. microSurfaceTexture: BaseTexture;
  109236. /**
  109237. * Stores surface normal data used to displace a mesh in a texture.
  109238. */
  109239. bumpTexture: BaseTexture;
  109240. /**
  109241. * Stores the pre-calculated light information of a mesh in a texture.
  109242. */
  109243. lightmapTexture: BaseTexture;
  109244. /**
  109245. * Stores the refracted light information in a texture.
  109246. */
  109247. refractionTexture: Nullable<BaseTexture>;
  109248. /**
  109249. * The color of a material in ambient lighting.
  109250. */
  109251. ambientColor: Color3;
  109252. /**
  109253. * AKA Diffuse Color in other nomenclature.
  109254. */
  109255. albedoColor: Color3;
  109256. /**
  109257. * AKA Specular Color in other nomenclature.
  109258. */
  109259. reflectivityColor: Color3;
  109260. /**
  109261. * The color reflected from the material.
  109262. */
  109263. reflectionColor: Color3;
  109264. /**
  109265. * The color emitted from the material.
  109266. */
  109267. emissiveColor: Color3;
  109268. /**
  109269. * AKA Glossiness in other nomenclature.
  109270. */
  109271. microSurface: number;
  109272. /**
  109273. * source material index of refraction (IOR)' / 'destination material IOR.
  109274. */
  109275. indexOfRefraction: number;
  109276. /**
  109277. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  109278. */
  109279. invertRefractionY: boolean;
  109280. /**
  109281. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  109282. * Materials half opaque for instance using refraction could benefit from this control.
  109283. */
  109284. linkRefractionWithTransparency: boolean;
  109285. /**
  109286. * If true, the light map contains occlusion information instead of lighting info.
  109287. */
  109288. useLightmapAsShadowmap: boolean;
  109289. /**
  109290. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  109291. */
  109292. useAlphaFromAlbedoTexture: boolean;
  109293. /**
  109294. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109295. */
  109296. forceAlphaTest: boolean;
  109297. /**
  109298. * Defines the alpha limits in alpha test mode.
  109299. */
  109300. alphaCutOff: number;
  109301. /**
  109302. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109303. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109304. */
  109305. useSpecularOverAlpha: boolean;
  109306. /**
  109307. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  109308. */
  109309. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  109310. /**
  109311. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  109312. */
  109313. useRoughnessFromMetallicTextureAlpha: boolean;
  109314. /**
  109315. * Specifies if the metallic texture contains the roughness information in its green channel.
  109316. */
  109317. useRoughnessFromMetallicTextureGreen: boolean;
  109318. /**
  109319. * Specifies if the metallic texture contains the metallness information in its blue channel.
  109320. */
  109321. useMetallnessFromMetallicTextureBlue: boolean;
  109322. /**
  109323. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  109324. */
  109325. useAmbientOcclusionFromMetallicTextureRed: boolean;
  109326. /**
  109327. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  109328. */
  109329. useAmbientInGrayScale: boolean;
  109330. /**
  109331. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  109332. * The material will try to infer what glossiness each pixel should be.
  109333. */
  109334. useAutoMicroSurfaceFromReflectivityMap: boolean;
  109335. /**
  109336. * BJS is using an harcoded light falloff based on a manually sets up range.
  109337. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109338. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109339. */
  109340. /**
  109341. * BJS is using an harcoded light falloff based on a manually sets up range.
  109342. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109343. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109344. */
  109345. usePhysicalLightFalloff: boolean;
  109346. /**
  109347. * In order to support the falloff compatibility with gltf, a special mode has been added
  109348. * to reproduce the gltf light falloff.
  109349. */
  109350. /**
  109351. * In order to support the falloff compatibility with gltf, a special mode has been added
  109352. * to reproduce the gltf light falloff.
  109353. */
  109354. useGLTFLightFalloff: boolean;
  109355. /**
  109356. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109357. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109358. */
  109359. useRadianceOverAlpha: boolean;
  109360. /**
  109361. * Allows using an object space normal map (instead of tangent space).
  109362. */
  109363. useObjectSpaceNormalMap: boolean;
  109364. /**
  109365. * Allows using the bump map in parallax mode.
  109366. */
  109367. useParallax: boolean;
  109368. /**
  109369. * Allows using the bump map in parallax occlusion mode.
  109370. */
  109371. useParallaxOcclusion: boolean;
  109372. /**
  109373. * Controls the scale bias of the parallax mode.
  109374. */
  109375. parallaxScaleBias: number;
  109376. /**
  109377. * If sets to true, disables all the lights affecting the material.
  109378. */
  109379. disableLighting: boolean;
  109380. /**
  109381. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  109382. */
  109383. forceIrradianceInFragment: boolean;
  109384. /**
  109385. * Number of Simultaneous lights allowed on the material.
  109386. */
  109387. maxSimultaneousLights: number;
  109388. /**
  109389. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109390. */
  109391. invertNormalMapX: boolean;
  109392. /**
  109393. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109394. */
  109395. invertNormalMapY: boolean;
  109396. /**
  109397. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109398. */
  109399. twoSidedLighting: boolean;
  109400. /**
  109401. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109402. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  109403. */
  109404. useAlphaFresnel: boolean;
  109405. /**
  109406. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109407. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  109408. */
  109409. useLinearAlphaFresnel: boolean;
  109410. /**
  109411. * Let user defines the brdf lookup texture used for IBL.
  109412. * A default 8bit version is embedded but you could point at :
  109413. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  109414. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109415. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  109416. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109417. */
  109418. environmentBRDFTexture: Nullable<BaseTexture>;
  109419. /**
  109420. * Force normal to face away from face.
  109421. */
  109422. forceNormalForward: boolean;
  109423. /**
  109424. * Enables specular anti aliasing in the PBR shader.
  109425. * It will both interacts on the Geometry for analytical and IBL lighting.
  109426. * It also prefilter the roughness map based on the bump values.
  109427. */
  109428. enableSpecularAntiAliasing: boolean;
  109429. /**
  109430. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  109431. * makes the reflect vector face the model (under horizon).
  109432. */
  109433. useHorizonOcclusion: boolean;
  109434. /**
  109435. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  109436. * too much the area relying on ambient texture to define their ambient occlusion.
  109437. */
  109438. useRadianceOcclusion: boolean;
  109439. /**
  109440. * If set to true, no lighting calculations will be applied.
  109441. */
  109442. unlit: boolean;
  109443. /**
  109444. * Gets the image processing configuration used either in this material.
  109445. */
  109446. /**
  109447. * Sets the Default image processing configuration used either in the this material.
  109448. *
  109449. * If sets to null, the scene one is in use.
  109450. */
  109451. imageProcessingConfiguration: ImageProcessingConfiguration;
  109452. /**
  109453. * Gets wether the color curves effect is enabled.
  109454. */
  109455. /**
  109456. * Sets wether the color curves effect is enabled.
  109457. */
  109458. cameraColorCurvesEnabled: boolean;
  109459. /**
  109460. * Gets wether the color grading effect is enabled.
  109461. */
  109462. /**
  109463. * Gets wether the color grading effect is enabled.
  109464. */
  109465. cameraColorGradingEnabled: boolean;
  109466. /**
  109467. * Gets wether tonemapping is enabled or not.
  109468. */
  109469. /**
  109470. * Sets wether tonemapping is enabled or not
  109471. */
  109472. cameraToneMappingEnabled: boolean;
  109473. /**
  109474. * The camera exposure used on this material.
  109475. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109476. * This corresponds to a photographic exposure.
  109477. */
  109478. /**
  109479. * The camera exposure used on this material.
  109480. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109481. * This corresponds to a photographic exposure.
  109482. */
  109483. cameraExposure: number;
  109484. /**
  109485. * Gets The camera contrast used on this material.
  109486. */
  109487. /**
  109488. * Sets The camera contrast used on this material.
  109489. */
  109490. cameraContrast: number;
  109491. /**
  109492. * Gets the Color Grading 2D Lookup Texture.
  109493. */
  109494. /**
  109495. * Sets the Color Grading 2D Lookup Texture.
  109496. */
  109497. cameraColorGradingTexture: Nullable<BaseTexture>;
  109498. /**
  109499. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109500. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109501. * 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;
  109502. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109503. */
  109504. /**
  109505. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109506. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109507. * 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;
  109508. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109509. */
  109510. cameraColorCurves: Nullable<ColorCurves>;
  109511. /**
  109512. * Instantiates a new PBRMaterial instance.
  109513. *
  109514. * @param name The material name
  109515. * @param scene The scene the material will be use in.
  109516. */
  109517. constructor(name: string, scene: Scene);
  109518. /**
  109519. * Returns the name of this material class.
  109520. */
  109521. getClassName(): string;
  109522. /**
  109523. * Makes a duplicate of the current material.
  109524. * @param name - name to use for the new material.
  109525. */
  109526. clone(name: string): PBRMaterial;
  109527. /**
  109528. * Serializes this PBR Material.
  109529. * @returns - An object with the serialized material.
  109530. */
  109531. serialize(): any;
  109532. /**
  109533. * Parses a PBR Material from a serialized object.
  109534. * @param source - Serialized object.
  109535. * @param scene - BJS scene instance.
  109536. * @param rootUrl - url for the scene object
  109537. * @returns - PBRMaterial
  109538. */
  109539. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  109540. }
  109541. }
  109542. declare module BABYLON {
  109543. /**
  109544. * Direct draw surface info
  109545. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  109546. */
  109547. export interface DDSInfo {
  109548. /**
  109549. * Width of the texture
  109550. */
  109551. width: number;
  109552. /**
  109553. * Width of the texture
  109554. */
  109555. height: number;
  109556. /**
  109557. * Number of Mipmaps for the texture
  109558. * @see https://en.wikipedia.org/wiki/Mipmap
  109559. */
  109560. mipmapCount: number;
  109561. /**
  109562. * If the textures format is a known fourCC format
  109563. * @see https://www.fourcc.org/
  109564. */
  109565. isFourCC: boolean;
  109566. /**
  109567. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  109568. */
  109569. isRGB: boolean;
  109570. /**
  109571. * If the texture is a lumincance format
  109572. */
  109573. isLuminance: boolean;
  109574. /**
  109575. * If this is a cube texture
  109576. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  109577. */
  109578. isCube: boolean;
  109579. /**
  109580. * If the texture is a compressed format eg. FOURCC_DXT1
  109581. */
  109582. isCompressed: boolean;
  109583. /**
  109584. * The dxgiFormat of the texture
  109585. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  109586. */
  109587. dxgiFormat: number;
  109588. /**
  109589. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  109590. */
  109591. textureType: number;
  109592. /**
  109593. * Sphericle polynomial created for the dds texture
  109594. */
  109595. sphericalPolynomial?: SphericalPolynomial;
  109596. }
  109597. /**
  109598. * Class used to provide DDS decompression tools
  109599. */
  109600. export class DDSTools {
  109601. /**
  109602. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  109603. */
  109604. static StoreLODInAlphaChannel: boolean;
  109605. /**
  109606. * Gets DDS information from an array buffer
  109607. * @param arrayBuffer defines the array buffer to read data from
  109608. * @returns the DDS information
  109609. */
  109610. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  109611. private static _FloatView;
  109612. private static _Int32View;
  109613. private static _ToHalfFloat;
  109614. private static _FromHalfFloat;
  109615. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  109616. private static _GetHalfFloatRGBAArrayBuffer;
  109617. private static _GetFloatRGBAArrayBuffer;
  109618. private static _GetFloatAsUIntRGBAArrayBuffer;
  109619. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  109620. private static _GetRGBAArrayBuffer;
  109621. private static _ExtractLongWordOrder;
  109622. private static _GetRGBArrayBuffer;
  109623. private static _GetLuminanceArrayBuffer;
  109624. /**
  109625. * Uploads DDS Levels to a Babylon Texture
  109626. * @hidden
  109627. */
  109628. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  109629. }
  109630. interface Engine {
  109631. /**
  109632. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  109633. * @param rootUrl defines the url where the file to load is located
  109634. * @param scene defines the current scene
  109635. * @param lodScale defines scale to apply to the mip map selection
  109636. * @param lodOffset defines offset to apply to the mip map selection
  109637. * @param onLoad defines an optional callback raised when the texture is loaded
  109638. * @param onError defines an optional callback raised if there is an issue to load the texture
  109639. * @param format defines the format of the data
  109640. * @param forcedExtension defines the extension to use to pick the right loader
  109641. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  109642. * @returns the cube texture as an InternalTexture
  109643. */
  109644. 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;
  109645. }
  109646. }
  109647. declare module BABYLON {
  109648. /**
  109649. * Implementation of the DDS Texture Loader.
  109650. * @hidden
  109651. */
  109652. export class _DDSTextureLoader implements IInternalTextureLoader {
  109653. /**
  109654. * Defines wether the loader supports cascade loading the different faces.
  109655. */
  109656. readonly supportCascades: boolean;
  109657. /**
  109658. * This returns if the loader support the current file information.
  109659. * @param extension defines the file extension of the file being loaded
  109660. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109661. * @param fallback defines the fallback internal texture if any
  109662. * @param isBase64 defines whether the texture is encoded as a base64
  109663. * @param isBuffer defines whether the texture data are stored as a buffer
  109664. * @returns true if the loader can load the specified file
  109665. */
  109666. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109667. /**
  109668. * Transform the url before loading if required.
  109669. * @param rootUrl the url of the texture
  109670. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109671. * @returns the transformed texture
  109672. */
  109673. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109674. /**
  109675. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109676. * @param rootUrl the url of the texture
  109677. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109678. * @returns the fallback texture
  109679. */
  109680. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109681. /**
  109682. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109683. * @param data contains the texture data
  109684. * @param texture defines the BabylonJS internal texture
  109685. * @param createPolynomials will be true if polynomials have been requested
  109686. * @param onLoad defines the callback to trigger once the texture is ready
  109687. * @param onError defines the callback to trigger in case of error
  109688. */
  109689. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109690. /**
  109691. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109692. * @param data contains the texture data
  109693. * @param texture defines the BabylonJS internal texture
  109694. * @param callback defines the method to call once ready to upload
  109695. */
  109696. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109697. }
  109698. }
  109699. declare module BABYLON {
  109700. /** @hidden */
  109701. export var rgbdEncodePixelShader: {
  109702. name: string;
  109703. shader: string;
  109704. };
  109705. }
  109706. declare module BABYLON {
  109707. /**
  109708. * Raw texture data and descriptor sufficient for WebGL texture upload
  109709. */
  109710. export interface EnvironmentTextureInfo {
  109711. /**
  109712. * Version of the environment map
  109713. */
  109714. version: number;
  109715. /**
  109716. * Width of image
  109717. */
  109718. width: number;
  109719. /**
  109720. * Irradiance information stored in the file.
  109721. */
  109722. irradiance: any;
  109723. /**
  109724. * Specular information stored in the file.
  109725. */
  109726. specular: any;
  109727. }
  109728. /**
  109729. * Sets of helpers addressing the serialization and deserialization of environment texture
  109730. * stored in a BabylonJS env file.
  109731. * Those files are usually stored as .env files.
  109732. */
  109733. export class EnvironmentTextureTools {
  109734. /**
  109735. * Magic number identifying the env file.
  109736. */
  109737. private static _MagicBytes;
  109738. /**
  109739. * Gets the environment info from an env file.
  109740. * @param data The array buffer containing the .env bytes.
  109741. * @returns the environment file info (the json header) if successfully parsed.
  109742. */
  109743. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109744. /**
  109745. * Creates an environment texture from a loaded cube texture.
  109746. * @param texture defines the cube texture to convert in env file
  109747. * @return a promise containing the environment data if succesfull.
  109748. */
  109749. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109750. /**
  109751. * Creates a JSON representation of the spherical data.
  109752. * @param texture defines the texture containing the polynomials
  109753. * @return the JSON representation of the spherical info
  109754. */
  109755. private static _CreateEnvTextureIrradiance;
  109756. /**
  109757. * Uploads the texture info contained in the env file to the GPU.
  109758. * @param texture defines the internal texture to upload to
  109759. * @param arrayBuffer defines the buffer cotaining the data to load
  109760. * @param info defines the texture info retrieved through the GetEnvInfo method
  109761. * @returns a promise
  109762. */
  109763. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109764. /**
  109765. * Uploads the levels of image data to the GPU.
  109766. * @param texture defines the internal texture to upload to
  109767. * @param imageData defines the array buffer views of image data [mipmap][face]
  109768. * @returns a promise
  109769. */
  109770. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109771. /**
  109772. * Uploads spherical polynomials information to the texture.
  109773. * @param texture defines the texture we are trying to upload the information to
  109774. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109775. */
  109776. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109777. /** @hidden */
  109778. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109779. }
  109780. }
  109781. declare module BABYLON {
  109782. /**
  109783. * Implementation of the ENV Texture Loader.
  109784. * @hidden
  109785. */
  109786. export class _ENVTextureLoader implements IInternalTextureLoader {
  109787. /**
  109788. * Defines wether the loader supports cascade loading the different faces.
  109789. */
  109790. readonly supportCascades: boolean;
  109791. /**
  109792. * This returns if the loader support the current file information.
  109793. * @param extension defines the file extension of the file being loaded
  109794. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109795. * @param fallback defines the fallback internal texture if any
  109796. * @param isBase64 defines whether the texture is encoded as a base64
  109797. * @param isBuffer defines whether the texture data are stored as a buffer
  109798. * @returns true if the loader can load the specified file
  109799. */
  109800. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109801. /**
  109802. * Transform the url before loading if required.
  109803. * @param rootUrl the url of the texture
  109804. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109805. * @returns the transformed texture
  109806. */
  109807. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109808. /**
  109809. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109810. * @param rootUrl the url of the texture
  109811. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109812. * @returns the fallback texture
  109813. */
  109814. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109815. /**
  109816. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109817. * @param data contains the texture data
  109818. * @param texture defines the BabylonJS internal texture
  109819. * @param createPolynomials will be true if polynomials have been requested
  109820. * @param onLoad defines the callback to trigger once the texture is ready
  109821. * @param onError defines the callback to trigger in case of error
  109822. */
  109823. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109824. /**
  109825. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109826. * @param data contains the texture data
  109827. * @param texture defines the BabylonJS internal texture
  109828. * @param callback defines the method to call once ready to upload
  109829. */
  109830. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109831. }
  109832. }
  109833. declare module BABYLON {
  109834. /**
  109835. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  109836. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  109837. */
  109838. export class KhronosTextureContainer {
  109839. /** contents of the KTX container file */
  109840. arrayBuffer: any;
  109841. private static HEADER_LEN;
  109842. private static COMPRESSED_2D;
  109843. private static COMPRESSED_3D;
  109844. private static TEX_2D;
  109845. private static TEX_3D;
  109846. /**
  109847. * Gets the openGL type
  109848. */
  109849. glType: number;
  109850. /**
  109851. * Gets the openGL type size
  109852. */
  109853. glTypeSize: number;
  109854. /**
  109855. * Gets the openGL format
  109856. */
  109857. glFormat: number;
  109858. /**
  109859. * Gets the openGL internal format
  109860. */
  109861. glInternalFormat: number;
  109862. /**
  109863. * Gets the base internal format
  109864. */
  109865. glBaseInternalFormat: number;
  109866. /**
  109867. * Gets image width in pixel
  109868. */
  109869. pixelWidth: number;
  109870. /**
  109871. * Gets image height in pixel
  109872. */
  109873. pixelHeight: number;
  109874. /**
  109875. * Gets image depth in pixels
  109876. */
  109877. pixelDepth: number;
  109878. /**
  109879. * Gets the number of array elements
  109880. */
  109881. numberOfArrayElements: number;
  109882. /**
  109883. * Gets the number of faces
  109884. */
  109885. numberOfFaces: number;
  109886. /**
  109887. * Gets the number of mipmap levels
  109888. */
  109889. numberOfMipmapLevels: number;
  109890. /**
  109891. * Gets the bytes of key value data
  109892. */
  109893. bytesOfKeyValueData: number;
  109894. /**
  109895. * Gets the load type
  109896. */
  109897. loadType: number;
  109898. /**
  109899. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109900. */
  109901. isInvalid: boolean;
  109902. /**
  109903. * Creates a new KhronosTextureContainer
  109904. * @param arrayBuffer contents of the KTX container file
  109905. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109906. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109907. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109908. */
  109909. constructor(
  109910. /** contents of the KTX container file */
  109911. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109912. /**
  109913. * Uploads KTX content to a Babylon Texture.
  109914. * It is assumed that the texture has already been created & is currently bound
  109915. * @hidden
  109916. */
  109917. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  109918. private _upload2DCompressedLevels;
  109919. }
  109920. }
  109921. declare module BABYLON {
  109922. /**
  109923. * Implementation of the KTX Texture Loader.
  109924. * @hidden
  109925. */
  109926. export class _KTXTextureLoader implements IInternalTextureLoader {
  109927. /**
  109928. * Defines wether the loader supports cascade loading the different faces.
  109929. */
  109930. readonly supportCascades: boolean;
  109931. /**
  109932. * This returns if the loader support the current file information.
  109933. * @param extension defines the file extension of the file being loaded
  109934. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109935. * @param fallback defines the fallback internal texture if any
  109936. * @param isBase64 defines whether the texture is encoded as a base64
  109937. * @param isBuffer defines whether the texture data are stored as a buffer
  109938. * @returns true if the loader can load the specified file
  109939. */
  109940. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109941. /**
  109942. * Transform the url before loading if required.
  109943. * @param rootUrl the url of the texture
  109944. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109945. * @returns the transformed texture
  109946. */
  109947. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109948. /**
  109949. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109950. * @param rootUrl the url of the texture
  109951. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109952. * @returns the fallback texture
  109953. */
  109954. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109955. /**
  109956. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109957. * @param data contains the texture data
  109958. * @param texture defines the BabylonJS internal texture
  109959. * @param createPolynomials will be true if polynomials have been requested
  109960. * @param onLoad defines the callback to trigger once the texture is ready
  109961. * @param onError defines the callback to trigger in case of error
  109962. */
  109963. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109964. /**
  109965. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109966. * @param data contains the texture data
  109967. * @param texture defines the BabylonJS internal texture
  109968. * @param callback defines the method to call once ready to upload
  109969. */
  109970. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  109971. }
  109972. }
  109973. declare module BABYLON {
  109974. /** @hidden */
  109975. export var _forceSceneHelpersToBundle: boolean;
  109976. interface Scene {
  109977. /**
  109978. * Creates a default light for the scene.
  109979. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  109980. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  109981. */
  109982. createDefaultLight(replace?: boolean): void;
  109983. /**
  109984. * Creates a default camera for the scene.
  109985. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  109986. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109987. * @param replace has default false, when true replaces the active camera in the scene
  109988. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  109989. */
  109990. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109991. /**
  109992. * Creates a default camera and a default light.
  109993. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  109994. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109995. * @param replace has the default false, when true replaces the active camera/light in the scene
  109996. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  109997. */
  109998. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109999. /**
  110000. * Creates a new sky box
  110001. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  110002. * @param environmentTexture defines the texture to use as environment texture
  110003. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  110004. * @param scale defines the overall scale of the skybox
  110005. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  110006. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  110007. * @returns a new mesh holding the sky box
  110008. */
  110009. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  110010. /**
  110011. * Creates a new environment
  110012. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  110013. * @param options defines the options you can use to configure the environment
  110014. * @returns the new EnvironmentHelper
  110015. */
  110016. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  110017. /**
  110018. * Creates a new VREXperienceHelper
  110019. * @see http://doc.babylonjs.com/how_to/webvr_helper
  110020. * @param webVROptions defines the options used to create the new VREXperienceHelper
  110021. * @returns a new VREXperienceHelper
  110022. */
  110023. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  110024. /**
  110025. * Creates a new XREXperienceHelper
  110026. * @see http://doc.babylonjs.com/how_to/webxr
  110027. * @returns a promise for a new XREXperienceHelper
  110028. */
  110029. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  110030. }
  110031. }
  110032. declare module BABYLON {
  110033. /**
  110034. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  110035. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  110036. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  110037. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  110038. */
  110039. export class VideoDome extends TransformNode {
  110040. /**
  110041. * Define the video source as a Monoscopic panoramic 360 video.
  110042. */
  110043. static readonly MODE_MONOSCOPIC: number;
  110044. /**
  110045. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  110046. */
  110047. static readonly MODE_TOPBOTTOM: number;
  110048. /**
  110049. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  110050. */
  110051. static readonly MODE_SIDEBYSIDE: number;
  110052. private _useDirectMapping;
  110053. /**
  110054. * The video texture being displayed on the sphere
  110055. */
  110056. protected _videoTexture: VideoTexture;
  110057. /**
  110058. * Gets the video texture being displayed on the sphere
  110059. */
  110060. readonly videoTexture: VideoTexture;
  110061. /**
  110062. * The skybox material
  110063. */
  110064. protected _material: BackgroundMaterial;
  110065. /**
  110066. * The surface used for the skybox
  110067. */
  110068. protected _mesh: Mesh;
  110069. /**
  110070. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  110071. * Also see the options.resolution property.
  110072. */
  110073. fovMultiplier: number;
  110074. private _videoMode;
  110075. /**
  110076. * Gets or set the current video mode for the video. It can be:
  110077. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  110078. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  110079. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  110080. */
  110081. videoMode: number;
  110082. /**
  110083. * Oberserver used in Stereoscopic VR Mode.
  110084. */
  110085. private _onBeforeCameraRenderObserver;
  110086. /**
  110087. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  110088. * @param name Element's name, child elements will append suffixes for their own names.
  110089. * @param urlsOrVideo defines the url(s) or the video element to use
  110090. * @param options An object containing optional or exposed sub element properties
  110091. */
  110092. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  110093. resolution?: number;
  110094. clickToPlay?: boolean;
  110095. autoPlay?: boolean;
  110096. loop?: boolean;
  110097. size?: number;
  110098. poster?: string;
  110099. faceForward?: boolean;
  110100. useDirectMapping?: boolean;
  110101. }, scene: Scene);
  110102. private _changeVideoMode;
  110103. /**
  110104. * Releases resources associated with this node.
  110105. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110106. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110107. */
  110108. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110109. }
  110110. }
  110111. declare module BABYLON {
  110112. /**
  110113. * This class can be used to get instrumentation data from a Babylon engine
  110114. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  110115. */
  110116. export class EngineInstrumentation implements IDisposable {
  110117. /**
  110118. * Define the instrumented engine.
  110119. */
  110120. engine: Engine;
  110121. private _captureGPUFrameTime;
  110122. private _gpuFrameTimeToken;
  110123. private _gpuFrameTime;
  110124. private _captureShaderCompilationTime;
  110125. private _shaderCompilationTime;
  110126. private _onBeginFrameObserver;
  110127. private _onEndFrameObserver;
  110128. private _onBeforeShaderCompilationObserver;
  110129. private _onAfterShaderCompilationObserver;
  110130. /**
  110131. * Gets the perf counter used for GPU frame time
  110132. */
  110133. readonly gpuFrameTimeCounter: PerfCounter;
  110134. /**
  110135. * Gets the GPU frame time capture status
  110136. */
  110137. /**
  110138. * Enable or disable the GPU frame time capture
  110139. */
  110140. captureGPUFrameTime: boolean;
  110141. /**
  110142. * Gets the perf counter used for shader compilation time
  110143. */
  110144. readonly shaderCompilationTimeCounter: PerfCounter;
  110145. /**
  110146. * Gets the shader compilation time capture status
  110147. */
  110148. /**
  110149. * Enable or disable the shader compilation time capture
  110150. */
  110151. captureShaderCompilationTime: boolean;
  110152. /**
  110153. * Instantiates a new engine instrumentation.
  110154. * This class can be used to get instrumentation data from a Babylon engine
  110155. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  110156. * @param engine Defines the engine to instrument
  110157. */
  110158. constructor(
  110159. /**
  110160. * Define the instrumented engine.
  110161. */
  110162. engine: Engine);
  110163. /**
  110164. * Dispose and release associated resources.
  110165. */
  110166. dispose(): void;
  110167. }
  110168. }
  110169. declare module BABYLON {
  110170. /**
  110171. * This class can be used to get instrumentation data from a Babylon engine
  110172. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110173. */
  110174. export class SceneInstrumentation implements IDisposable {
  110175. /**
  110176. * Defines the scene to instrument
  110177. */
  110178. scene: Scene;
  110179. private _captureActiveMeshesEvaluationTime;
  110180. private _activeMeshesEvaluationTime;
  110181. private _captureRenderTargetsRenderTime;
  110182. private _renderTargetsRenderTime;
  110183. private _captureFrameTime;
  110184. private _frameTime;
  110185. private _captureRenderTime;
  110186. private _renderTime;
  110187. private _captureInterFrameTime;
  110188. private _interFrameTime;
  110189. private _captureParticlesRenderTime;
  110190. private _particlesRenderTime;
  110191. private _captureSpritesRenderTime;
  110192. private _spritesRenderTime;
  110193. private _capturePhysicsTime;
  110194. private _physicsTime;
  110195. private _captureAnimationsTime;
  110196. private _animationsTime;
  110197. private _captureCameraRenderTime;
  110198. private _cameraRenderTime;
  110199. private _onBeforeActiveMeshesEvaluationObserver;
  110200. private _onAfterActiveMeshesEvaluationObserver;
  110201. private _onBeforeRenderTargetsRenderObserver;
  110202. private _onAfterRenderTargetsRenderObserver;
  110203. private _onAfterRenderObserver;
  110204. private _onBeforeDrawPhaseObserver;
  110205. private _onAfterDrawPhaseObserver;
  110206. private _onBeforeAnimationsObserver;
  110207. private _onBeforeParticlesRenderingObserver;
  110208. private _onAfterParticlesRenderingObserver;
  110209. private _onBeforeSpritesRenderingObserver;
  110210. private _onAfterSpritesRenderingObserver;
  110211. private _onBeforePhysicsObserver;
  110212. private _onAfterPhysicsObserver;
  110213. private _onAfterAnimationsObserver;
  110214. private _onBeforeCameraRenderObserver;
  110215. private _onAfterCameraRenderObserver;
  110216. /**
  110217. * Gets the perf counter used for active meshes evaluation time
  110218. */
  110219. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  110220. /**
  110221. * Gets the active meshes evaluation time capture status
  110222. */
  110223. /**
  110224. * Enable or disable the active meshes evaluation time capture
  110225. */
  110226. captureActiveMeshesEvaluationTime: boolean;
  110227. /**
  110228. * Gets the perf counter used for render targets render time
  110229. */
  110230. readonly renderTargetsRenderTimeCounter: PerfCounter;
  110231. /**
  110232. * Gets the render targets render time capture status
  110233. */
  110234. /**
  110235. * Enable or disable the render targets render time capture
  110236. */
  110237. captureRenderTargetsRenderTime: boolean;
  110238. /**
  110239. * Gets the perf counter used for particles render time
  110240. */
  110241. readonly particlesRenderTimeCounter: PerfCounter;
  110242. /**
  110243. * Gets the particles render time capture status
  110244. */
  110245. /**
  110246. * Enable or disable the particles render time capture
  110247. */
  110248. captureParticlesRenderTime: boolean;
  110249. /**
  110250. * Gets the perf counter used for sprites render time
  110251. */
  110252. readonly spritesRenderTimeCounter: PerfCounter;
  110253. /**
  110254. * Gets the sprites render time capture status
  110255. */
  110256. /**
  110257. * Enable or disable the sprites render time capture
  110258. */
  110259. captureSpritesRenderTime: boolean;
  110260. /**
  110261. * Gets the perf counter used for physics time
  110262. */
  110263. readonly physicsTimeCounter: PerfCounter;
  110264. /**
  110265. * Gets the physics time capture status
  110266. */
  110267. /**
  110268. * Enable or disable the physics time capture
  110269. */
  110270. capturePhysicsTime: boolean;
  110271. /**
  110272. * Gets the perf counter used for animations time
  110273. */
  110274. readonly animationsTimeCounter: PerfCounter;
  110275. /**
  110276. * Gets the animations time capture status
  110277. */
  110278. /**
  110279. * Enable or disable the animations time capture
  110280. */
  110281. captureAnimationsTime: boolean;
  110282. /**
  110283. * Gets the perf counter used for frame time capture
  110284. */
  110285. readonly frameTimeCounter: PerfCounter;
  110286. /**
  110287. * Gets the frame time capture status
  110288. */
  110289. /**
  110290. * Enable or disable the frame time capture
  110291. */
  110292. captureFrameTime: boolean;
  110293. /**
  110294. * Gets the perf counter used for inter-frames time capture
  110295. */
  110296. readonly interFrameTimeCounter: PerfCounter;
  110297. /**
  110298. * Gets the inter-frames time capture status
  110299. */
  110300. /**
  110301. * Enable or disable the inter-frames time capture
  110302. */
  110303. captureInterFrameTime: boolean;
  110304. /**
  110305. * Gets the perf counter used for render time capture
  110306. */
  110307. readonly renderTimeCounter: PerfCounter;
  110308. /**
  110309. * Gets the render time capture status
  110310. */
  110311. /**
  110312. * Enable or disable the render time capture
  110313. */
  110314. captureRenderTime: boolean;
  110315. /**
  110316. * Gets the perf counter used for camera render time capture
  110317. */
  110318. readonly cameraRenderTimeCounter: PerfCounter;
  110319. /**
  110320. * Gets the camera render time capture status
  110321. */
  110322. /**
  110323. * Enable or disable the camera render time capture
  110324. */
  110325. captureCameraRenderTime: boolean;
  110326. /**
  110327. * Gets the perf counter used for draw calls
  110328. */
  110329. readonly drawCallsCounter: PerfCounter;
  110330. /**
  110331. * Instantiates a new scene instrumentation.
  110332. * This class can be used to get instrumentation data from a Babylon engine
  110333. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110334. * @param scene Defines the scene to instrument
  110335. */
  110336. constructor(
  110337. /**
  110338. * Defines the scene to instrument
  110339. */
  110340. scene: Scene);
  110341. /**
  110342. * Dispose and release associated resources.
  110343. */
  110344. dispose(): void;
  110345. }
  110346. }
  110347. declare module BABYLON {
  110348. /** @hidden */
  110349. export var glowMapGenerationPixelShader: {
  110350. name: string;
  110351. shader: string;
  110352. };
  110353. }
  110354. declare module BABYLON {
  110355. /** @hidden */
  110356. export var glowMapGenerationVertexShader: {
  110357. name: string;
  110358. shader: string;
  110359. };
  110360. }
  110361. declare module BABYLON {
  110362. /**
  110363. * Effect layer options. This helps customizing the behaviour
  110364. * of the effect layer.
  110365. */
  110366. export interface IEffectLayerOptions {
  110367. /**
  110368. * Multiplication factor apply to the canvas size to compute the render target size
  110369. * used to generated the objects (the smaller the faster).
  110370. */
  110371. mainTextureRatio: number;
  110372. /**
  110373. * Enforces a fixed size texture to ensure effect stability across devices.
  110374. */
  110375. mainTextureFixedSize?: number;
  110376. /**
  110377. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  110378. */
  110379. alphaBlendingMode: number;
  110380. /**
  110381. * The camera attached to the layer.
  110382. */
  110383. camera: Nullable<Camera>;
  110384. /**
  110385. * The rendering group to draw the layer in.
  110386. */
  110387. renderingGroupId: number;
  110388. }
  110389. /**
  110390. * The effect layer Helps adding post process effect blended with the main pass.
  110391. *
  110392. * This can be for instance use to generate glow or higlight effects on the scene.
  110393. *
  110394. * The effect layer class can not be used directly and is intented to inherited from to be
  110395. * customized per effects.
  110396. */
  110397. export abstract class EffectLayer {
  110398. private _vertexBuffers;
  110399. private _indexBuffer;
  110400. private _cachedDefines;
  110401. private _effectLayerMapGenerationEffect;
  110402. private _effectLayerOptions;
  110403. private _mergeEffect;
  110404. protected _scene: Scene;
  110405. protected _engine: Engine;
  110406. protected _maxSize: number;
  110407. protected _mainTextureDesiredSize: ISize;
  110408. protected _mainTexture: RenderTargetTexture;
  110409. protected _shouldRender: boolean;
  110410. protected _postProcesses: PostProcess[];
  110411. protected _textures: BaseTexture[];
  110412. protected _emissiveTextureAndColor: {
  110413. texture: Nullable<BaseTexture>;
  110414. color: Color4;
  110415. };
  110416. /**
  110417. * The name of the layer
  110418. */
  110419. name: string;
  110420. /**
  110421. * The clear color of the texture used to generate the glow map.
  110422. */
  110423. neutralColor: Color4;
  110424. /**
  110425. * Specifies wether the highlight layer is enabled or not.
  110426. */
  110427. isEnabled: boolean;
  110428. /**
  110429. * Gets the camera attached to the layer.
  110430. */
  110431. readonly camera: Nullable<Camera>;
  110432. /**
  110433. * Gets the rendering group id the layer should render in.
  110434. */
  110435. readonly renderingGroupId: number;
  110436. /**
  110437. * An event triggered when the effect layer has been disposed.
  110438. */
  110439. onDisposeObservable: Observable<EffectLayer>;
  110440. /**
  110441. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  110442. */
  110443. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  110444. /**
  110445. * An event triggered when the generated texture is being merged in the scene.
  110446. */
  110447. onBeforeComposeObservable: Observable<EffectLayer>;
  110448. /**
  110449. * An event triggered when the generated texture has been merged in the scene.
  110450. */
  110451. onAfterComposeObservable: Observable<EffectLayer>;
  110452. /**
  110453. * An event triggered when the efffect layer changes its size.
  110454. */
  110455. onSizeChangedObservable: Observable<EffectLayer>;
  110456. /** @hidden */
  110457. static _SceneComponentInitialization: (scene: Scene) => void;
  110458. /**
  110459. * Instantiates a new effect Layer and references it in the scene.
  110460. * @param name The name of the layer
  110461. * @param scene The scene to use the layer in
  110462. */
  110463. constructor(
  110464. /** The Friendly of the effect in the scene */
  110465. name: string, scene: Scene);
  110466. /**
  110467. * Get the effect name of the layer.
  110468. * @return The effect name
  110469. */
  110470. abstract getEffectName(): string;
  110471. /**
  110472. * Checks for the readiness of the element composing the layer.
  110473. * @param subMesh the mesh to check for
  110474. * @param useInstances specify wether or not to use instances to render the mesh
  110475. * @return true if ready otherwise, false
  110476. */
  110477. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110478. /**
  110479. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110480. * @returns true if the effect requires stencil during the main canvas render pass.
  110481. */
  110482. abstract needStencil(): boolean;
  110483. /**
  110484. * Create the merge effect. This is the shader use to blit the information back
  110485. * to the main canvas at the end of the scene rendering.
  110486. * @returns The effect containing the shader used to merge the effect on the main canvas
  110487. */
  110488. protected abstract _createMergeEffect(): Effect;
  110489. /**
  110490. * Creates the render target textures and post processes used in the effect layer.
  110491. */
  110492. protected abstract _createTextureAndPostProcesses(): void;
  110493. /**
  110494. * Implementation specific of rendering the generating effect on the main canvas.
  110495. * @param effect The effect used to render through
  110496. */
  110497. protected abstract _internalRender(effect: Effect): void;
  110498. /**
  110499. * Sets the required values for both the emissive texture and and the main color.
  110500. */
  110501. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110502. /**
  110503. * Free any resources and references associated to a mesh.
  110504. * Internal use
  110505. * @param mesh The mesh to free.
  110506. */
  110507. abstract _disposeMesh(mesh: Mesh): void;
  110508. /**
  110509. * Serializes this layer (Glow or Highlight for example)
  110510. * @returns a serialized layer object
  110511. */
  110512. abstract serialize?(): any;
  110513. /**
  110514. * Initializes the effect layer with the required options.
  110515. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  110516. */
  110517. protected _init(options: Partial<IEffectLayerOptions>): void;
  110518. /**
  110519. * Generates the index buffer of the full screen quad blending to the main canvas.
  110520. */
  110521. private _generateIndexBuffer;
  110522. /**
  110523. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  110524. */
  110525. private _generateVertexBuffer;
  110526. /**
  110527. * Sets the main texture desired size which is the closest power of two
  110528. * of the engine canvas size.
  110529. */
  110530. private _setMainTextureSize;
  110531. /**
  110532. * Creates the main texture for the effect layer.
  110533. */
  110534. protected _createMainTexture(): void;
  110535. /**
  110536. * Adds specific effects defines.
  110537. * @param defines The defines to add specifics to.
  110538. */
  110539. protected _addCustomEffectDefines(defines: string[]): void;
  110540. /**
  110541. * Checks for the readiness of the element composing the layer.
  110542. * @param subMesh the mesh to check for
  110543. * @param useInstances specify wether or not to use instances to render the mesh
  110544. * @param emissiveTexture the associated emissive texture used to generate the glow
  110545. * @return true if ready otherwise, false
  110546. */
  110547. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  110548. /**
  110549. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  110550. */
  110551. render(): void;
  110552. /**
  110553. * Determine if a given mesh will be used in the current effect.
  110554. * @param mesh mesh to test
  110555. * @returns true if the mesh will be used
  110556. */
  110557. hasMesh(mesh: AbstractMesh): boolean;
  110558. /**
  110559. * Returns true if the layer contains information to display, otherwise false.
  110560. * @returns true if the glow layer should be rendered
  110561. */
  110562. shouldRender(): boolean;
  110563. /**
  110564. * Returns true if the mesh should render, otherwise false.
  110565. * @param mesh The mesh to render
  110566. * @returns true if it should render otherwise false
  110567. */
  110568. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  110569. /**
  110570. * Returns true if the mesh can be rendered, otherwise false.
  110571. * @param mesh The mesh to render
  110572. * @param material The material used on the mesh
  110573. * @returns true if it can be rendered otherwise false
  110574. */
  110575. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110576. /**
  110577. * Returns true if the mesh should render, otherwise false.
  110578. * @param mesh The mesh to render
  110579. * @returns true if it should render otherwise false
  110580. */
  110581. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  110582. /**
  110583. * Renders the submesh passed in parameter to the generation map.
  110584. */
  110585. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  110586. /**
  110587. * Rebuild the required buffers.
  110588. * @hidden Internal use only.
  110589. */
  110590. _rebuild(): void;
  110591. /**
  110592. * Dispose only the render target textures and post process.
  110593. */
  110594. private _disposeTextureAndPostProcesses;
  110595. /**
  110596. * Dispose the highlight layer and free resources.
  110597. */
  110598. dispose(): void;
  110599. /**
  110600. * Gets the class name of the effect layer
  110601. * @returns the string with the class name of the effect layer
  110602. */
  110603. getClassName(): string;
  110604. /**
  110605. * Creates an effect layer from parsed effect layer data
  110606. * @param parsedEffectLayer defines effect layer data
  110607. * @param scene defines the current scene
  110608. * @param rootUrl defines the root URL containing the effect layer information
  110609. * @returns a parsed effect Layer
  110610. */
  110611. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  110612. }
  110613. }
  110614. declare module BABYLON {
  110615. interface AbstractScene {
  110616. /**
  110617. * The list of effect layers (highlights/glow) added to the scene
  110618. * @see http://doc.babylonjs.com/how_to/highlight_layer
  110619. * @see http://doc.babylonjs.com/how_to/glow_layer
  110620. */
  110621. effectLayers: Array<EffectLayer>;
  110622. /**
  110623. * Removes the given effect layer from this scene.
  110624. * @param toRemove defines the effect layer to remove
  110625. * @returns the index of the removed effect layer
  110626. */
  110627. removeEffectLayer(toRemove: EffectLayer): number;
  110628. /**
  110629. * Adds the given effect layer to this scene
  110630. * @param newEffectLayer defines the effect layer to add
  110631. */
  110632. addEffectLayer(newEffectLayer: EffectLayer): void;
  110633. }
  110634. /**
  110635. * Defines the layer scene component responsible to manage any effect layers
  110636. * in a given scene.
  110637. */
  110638. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  110639. /**
  110640. * The component name helpfull to identify the component in the list of scene components.
  110641. */
  110642. readonly name: string;
  110643. /**
  110644. * The scene the component belongs to.
  110645. */
  110646. scene: Scene;
  110647. private _engine;
  110648. private _renderEffects;
  110649. private _needStencil;
  110650. private _previousStencilState;
  110651. /**
  110652. * Creates a new instance of the component for the given scene
  110653. * @param scene Defines the scene to register the component in
  110654. */
  110655. constructor(scene: Scene);
  110656. /**
  110657. * Registers the component in a given scene
  110658. */
  110659. register(): void;
  110660. /**
  110661. * Rebuilds the elements related to this component in case of
  110662. * context lost for instance.
  110663. */
  110664. rebuild(): void;
  110665. /**
  110666. * Serializes the component data to the specified json object
  110667. * @param serializationObject The object to serialize to
  110668. */
  110669. serialize(serializationObject: any): void;
  110670. /**
  110671. * Adds all the elements from the container to the scene
  110672. * @param container the container holding the elements
  110673. */
  110674. addFromContainer(container: AbstractScene): void;
  110675. /**
  110676. * Removes all the elements in the container from the scene
  110677. * @param container contains the elements to remove
  110678. * @param dispose if the removed element should be disposed (default: false)
  110679. */
  110680. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110681. /**
  110682. * Disposes the component and the associated ressources.
  110683. */
  110684. dispose(): void;
  110685. private _isReadyForMesh;
  110686. private _renderMainTexture;
  110687. private _setStencil;
  110688. private _setStencilBack;
  110689. private _draw;
  110690. private _drawCamera;
  110691. private _drawRenderingGroup;
  110692. }
  110693. }
  110694. declare module BABYLON {
  110695. /** @hidden */
  110696. export var glowMapMergePixelShader: {
  110697. name: string;
  110698. shader: string;
  110699. };
  110700. }
  110701. declare module BABYLON {
  110702. /** @hidden */
  110703. export var glowMapMergeVertexShader: {
  110704. name: string;
  110705. shader: string;
  110706. };
  110707. }
  110708. declare module BABYLON {
  110709. interface AbstractScene {
  110710. /**
  110711. * Return a the first highlight layer of the scene with a given name.
  110712. * @param name The name of the highlight layer to look for.
  110713. * @return The highlight layer if found otherwise null.
  110714. */
  110715. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  110716. }
  110717. /**
  110718. * Glow layer options. This helps customizing the behaviour
  110719. * of the glow layer.
  110720. */
  110721. export interface IGlowLayerOptions {
  110722. /**
  110723. * Multiplication factor apply to the canvas size to compute the render target size
  110724. * used to generated the glowing objects (the smaller the faster).
  110725. */
  110726. mainTextureRatio: number;
  110727. /**
  110728. * Enforces a fixed size texture to ensure resize independant blur.
  110729. */
  110730. mainTextureFixedSize?: number;
  110731. /**
  110732. * How big is the kernel of the blur texture.
  110733. */
  110734. blurKernelSize: number;
  110735. /**
  110736. * The camera attached to the layer.
  110737. */
  110738. camera: Nullable<Camera>;
  110739. /**
  110740. * Enable MSAA by chosing the number of samples.
  110741. */
  110742. mainTextureSamples?: number;
  110743. /**
  110744. * The rendering group to draw the layer in.
  110745. */
  110746. renderingGroupId: number;
  110747. }
  110748. /**
  110749. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  110750. *
  110751. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110752. * glowy meshes to your scene.
  110753. *
  110754. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  110755. */
  110756. export class GlowLayer extends EffectLayer {
  110757. /**
  110758. * Effect Name of the layer.
  110759. */
  110760. static readonly EffectName: string;
  110761. /**
  110762. * The default blur kernel size used for the glow.
  110763. */
  110764. static DefaultBlurKernelSize: number;
  110765. /**
  110766. * The default texture size ratio used for the glow.
  110767. */
  110768. static DefaultTextureRatio: number;
  110769. /**
  110770. * Sets the kernel size of the blur.
  110771. */
  110772. /**
  110773. * Gets the kernel size of the blur.
  110774. */
  110775. blurKernelSize: number;
  110776. /**
  110777. * Sets the glow intensity.
  110778. */
  110779. /**
  110780. * Gets the glow intensity.
  110781. */
  110782. intensity: number;
  110783. private _options;
  110784. private _intensity;
  110785. private _horizontalBlurPostprocess1;
  110786. private _verticalBlurPostprocess1;
  110787. private _horizontalBlurPostprocess2;
  110788. private _verticalBlurPostprocess2;
  110789. private _blurTexture1;
  110790. private _blurTexture2;
  110791. private _postProcesses1;
  110792. private _postProcesses2;
  110793. private _includedOnlyMeshes;
  110794. private _excludedMeshes;
  110795. /**
  110796. * Callback used to let the user override the color selection on a per mesh basis
  110797. */
  110798. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  110799. /**
  110800. * Callback used to let the user override the texture selection on a per mesh basis
  110801. */
  110802. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  110803. /**
  110804. * Instantiates a new glow Layer and references it to the scene.
  110805. * @param name The name of the layer
  110806. * @param scene The scene to use the layer in
  110807. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  110808. */
  110809. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  110810. /**
  110811. * Get the effect name of the layer.
  110812. * @return The effect name
  110813. */
  110814. getEffectName(): string;
  110815. /**
  110816. * Create the merge effect. This is the shader use to blit the information back
  110817. * to the main canvas at the end of the scene rendering.
  110818. */
  110819. protected _createMergeEffect(): Effect;
  110820. /**
  110821. * Creates the render target textures and post processes used in the glow layer.
  110822. */
  110823. protected _createTextureAndPostProcesses(): void;
  110824. /**
  110825. * Checks for the readiness of the element composing the layer.
  110826. * @param subMesh the mesh to check for
  110827. * @param useInstances specify wether or not to use instances to render the mesh
  110828. * @param emissiveTexture the associated emissive texture used to generate the glow
  110829. * @return true if ready otherwise, false
  110830. */
  110831. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110832. /**
  110833. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110834. */
  110835. needStencil(): boolean;
  110836. /**
  110837. * Returns true if the mesh can be rendered, otherwise false.
  110838. * @param mesh The mesh to render
  110839. * @param material The material used on the mesh
  110840. * @returns true if it can be rendered otherwise false
  110841. */
  110842. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110843. /**
  110844. * Implementation specific of rendering the generating effect on the main canvas.
  110845. * @param effect The effect used to render through
  110846. */
  110847. protected _internalRender(effect: Effect): void;
  110848. /**
  110849. * Sets the required values for both the emissive texture and and the main color.
  110850. */
  110851. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110852. /**
  110853. * Returns true if the mesh should render, otherwise false.
  110854. * @param mesh The mesh to render
  110855. * @returns true if it should render otherwise false
  110856. */
  110857. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110858. /**
  110859. * Adds specific effects defines.
  110860. * @param defines The defines to add specifics to.
  110861. */
  110862. protected _addCustomEffectDefines(defines: string[]): void;
  110863. /**
  110864. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110865. * @param mesh The mesh to exclude from the glow layer
  110866. */
  110867. addExcludedMesh(mesh: Mesh): void;
  110868. /**
  110869. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110870. * @param mesh The mesh to remove
  110871. */
  110872. removeExcludedMesh(mesh: Mesh): void;
  110873. /**
  110874. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110875. * @param mesh The mesh to include in the glow layer
  110876. */
  110877. addIncludedOnlyMesh(mesh: Mesh): void;
  110878. /**
  110879. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110880. * @param mesh The mesh to remove
  110881. */
  110882. removeIncludedOnlyMesh(mesh: Mesh): void;
  110883. /**
  110884. * Determine if a given mesh will be used in the glow layer
  110885. * @param mesh The mesh to test
  110886. * @returns true if the mesh will be highlighted by the current glow layer
  110887. */
  110888. hasMesh(mesh: AbstractMesh): boolean;
  110889. /**
  110890. * Free any resources and references associated to a mesh.
  110891. * Internal use
  110892. * @param mesh The mesh to free.
  110893. * @hidden
  110894. */
  110895. _disposeMesh(mesh: Mesh): void;
  110896. /**
  110897. * Gets the class name of the effect layer
  110898. * @returns the string with the class name of the effect layer
  110899. */
  110900. getClassName(): string;
  110901. /**
  110902. * Serializes this glow layer
  110903. * @returns a serialized glow layer object
  110904. */
  110905. serialize(): any;
  110906. /**
  110907. * Creates a Glow Layer from parsed glow layer data
  110908. * @param parsedGlowLayer defines glow layer data
  110909. * @param scene defines the current scene
  110910. * @param rootUrl defines the root URL containing the glow layer information
  110911. * @returns a parsed Glow Layer
  110912. */
  110913. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  110914. }
  110915. }
  110916. declare module BABYLON {
  110917. /** @hidden */
  110918. export var glowBlurPostProcessPixelShader: {
  110919. name: string;
  110920. shader: string;
  110921. };
  110922. }
  110923. declare module BABYLON {
  110924. interface AbstractScene {
  110925. /**
  110926. * Return a the first highlight layer of the scene with a given name.
  110927. * @param name The name of the highlight layer to look for.
  110928. * @return The highlight layer if found otherwise null.
  110929. */
  110930. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  110931. }
  110932. /**
  110933. * Highlight layer options. This helps customizing the behaviour
  110934. * of the highlight layer.
  110935. */
  110936. export interface IHighlightLayerOptions {
  110937. /**
  110938. * Multiplication factor apply to the canvas size to compute the render target size
  110939. * used to generated the glowing objects (the smaller the faster).
  110940. */
  110941. mainTextureRatio: number;
  110942. /**
  110943. * Enforces a fixed size texture to ensure resize independant blur.
  110944. */
  110945. mainTextureFixedSize?: number;
  110946. /**
  110947. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  110948. * of the picture to blur (the smaller the faster).
  110949. */
  110950. blurTextureSizeRatio: number;
  110951. /**
  110952. * How big in texel of the blur texture is the vertical blur.
  110953. */
  110954. blurVerticalSize: number;
  110955. /**
  110956. * How big in texel of the blur texture is the horizontal blur.
  110957. */
  110958. blurHorizontalSize: number;
  110959. /**
  110960. * Alpha blending mode used to apply the blur. Default is combine.
  110961. */
  110962. alphaBlendingMode: number;
  110963. /**
  110964. * The camera attached to the layer.
  110965. */
  110966. camera: Nullable<Camera>;
  110967. /**
  110968. * Should we display highlight as a solid stroke?
  110969. */
  110970. isStroke?: boolean;
  110971. /**
  110972. * The rendering group to draw the layer in.
  110973. */
  110974. renderingGroupId: number;
  110975. }
  110976. /**
  110977. * The highlight layer Helps adding a glow effect around a mesh.
  110978. *
  110979. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110980. * glowy meshes to your scene.
  110981. *
  110982. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  110983. */
  110984. export class HighlightLayer extends EffectLayer {
  110985. name: string;
  110986. /**
  110987. * Effect Name of the highlight layer.
  110988. */
  110989. static readonly EffectName: string;
  110990. /**
  110991. * The neutral color used during the preparation of the glow effect.
  110992. * This is black by default as the blend operation is a blend operation.
  110993. */
  110994. static NeutralColor: Color4;
  110995. /**
  110996. * Stencil value used for glowing meshes.
  110997. */
  110998. static GlowingMeshStencilReference: number;
  110999. /**
  111000. * Stencil value used for the other meshes in the scene.
  111001. */
  111002. static NormalMeshStencilReference: number;
  111003. /**
  111004. * Specifies whether or not the inner glow is ACTIVE in the layer.
  111005. */
  111006. innerGlow: boolean;
  111007. /**
  111008. * Specifies whether or not the outer glow is ACTIVE in the layer.
  111009. */
  111010. outerGlow: boolean;
  111011. /**
  111012. * Specifies the horizontal size of the blur.
  111013. */
  111014. /**
  111015. * Gets the horizontal size of the blur.
  111016. */
  111017. blurHorizontalSize: number;
  111018. /**
  111019. * Specifies the vertical size of the blur.
  111020. */
  111021. /**
  111022. * Gets the vertical size of the blur.
  111023. */
  111024. blurVerticalSize: number;
  111025. /**
  111026. * An event triggered when the highlight layer is being blurred.
  111027. */
  111028. onBeforeBlurObservable: Observable<HighlightLayer>;
  111029. /**
  111030. * An event triggered when the highlight layer has been blurred.
  111031. */
  111032. onAfterBlurObservable: Observable<HighlightLayer>;
  111033. private _instanceGlowingMeshStencilReference;
  111034. private _options;
  111035. private _downSamplePostprocess;
  111036. private _horizontalBlurPostprocess;
  111037. private _verticalBlurPostprocess;
  111038. private _blurTexture;
  111039. private _meshes;
  111040. private _excludedMeshes;
  111041. /**
  111042. * Instantiates a new highlight Layer and references it to the scene..
  111043. * @param name The name of the layer
  111044. * @param scene The scene to use the layer in
  111045. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  111046. */
  111047. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  111048. /**
  111049. * Get the effect name of the layer.
  111050. * @return The effect name
  111051. */
  111052. getEffectName(): string;
  111053. /**
  111054. * Create the merge effect. This is the shader use to blit the information back
  111055. * to the main canvas at the end of the scene rendering.
  111056. */
  111057. protected _createMergeEffect(): Effect;
  111058. /**
  111059. * Creates the render target textures and post processes used in the highlight layer.
  111060. */
  111061. protected _createTextureAndPostProcesses(): void;
  111062. /**
  111063. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  111064. */
  111065. needStencil(): boolean;
  111066. /**
  111067. * Checks for the readiness of the element composing the layer.
  111068. * @param subMesh the mesh to check for
  111069. * @param useInstances specify wether or not to use instances to render the mesh
  111070. * @param emissiveTexture the associated emissive texture used to generate the glow
  111071. * @return true if ready otherwise, false
  111072. */
  111073. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111074. /**
  111075. * Implementation specific of rendering the generating effect on the main canvas.
  111076. * @param effect The effect used to render through
  111077. */
  111078. protected _internalRender(effect: Effect): void;
  111079. /**
  111080. * Returns true if the layer contains information to display, otherwise false.
  111081. */
  111082. shouldRender(): boolean;
  111083. /**
  111084. * Returns true if the mesh should render, otherwise false.
  111085. * @param mesh The mesh to render
  111086. * @returns true if it should render otherwise false
  111087. */
  111088. protected _shouldRenderMesh(mesh: Mesh): boolean;
  111089. /**
  111090. * Sets the required values for both the emissive texture and and the main color.
  111091. */
  111092. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  111093. /**
  111094. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  111095. * @param mesh The mesh to exclude from the highlight layer
  111096. */
  111097. addExcludedMesh(mesh: Mesh): void;
  111098. /**
  111099. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  111100. * @param mesh The mesh to highlight
  111101. */
  111102. removeExcludedMesh(mesh: Mesh): void;
  111103. /**
  111104. * Determine if a given mesh will be highlighted by the current HighlightLayer
  111105. * @param mesh mesh to test
  111106. * @returns true if the mesh will be highlighted by the current HighlightLayer
  111107. */
  111108. hasMesh(mesh: AbstractMesh): boolean;
  111109. /**
  111110. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  111111. * @param mesh The mesh to highlight
  111112. * @param color The color of the highlight
  111113. * @param glowEmissiveOnly Extract the glow from the emissive texture
  111114. */
  111115. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  111116. /**
  111117. * Remove a mesh from the highlight layer in order to make it stop glowing.
  111118. * @param mesh The mesh to highlight
  111119. */
  111120. removeMesh(mesh: Mesh): void;
  111121. /**
  111122. * Force the stencil to the normal expected value for none glowing parts
  111123. */
  111124. private _defaultStencilReference;
  111125. /**
  111126. * Free any resources and references associated to a mesh.
  111127. * Internal use
  111128. * @param mesh The mesh to free.
  111129. * @hidden
  111130. */
  111131. _disposeMesh(mesh: Mesh): void;
  111132. /**
  111133. * Dispose the highlight layer and free resources.
  111134. */
  111135. dispose(): void;
  111136. /**
  111137. * Gets the class name of the effect layer
  111138. * @returns the string with the class name of the effect layer
  111139. */
  111140. getClassName(): string;
  111141. /**
  111142. * Serializes this Highlight layer
  111143. * @returns a serialized Highlight layer object
  111144. */
  111145. serialize(): any;
  111146. /**
  111147. * Creates a Highlight layer from parsed Highlight layer data
  111148. * @param parsedHightlightLayer defines the Highlight layer data
  111149. * @param scene defines the current scene
  111150. * @param rootUrl defines the root URL containing the Highlight layer information
  111151. * @returns a parsed Highlight layer
  111152. */
  111153. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  111154. }
  111155. }
  111156. declare module BABYLON {
  111157. interface AbstractScene {
  111158. /**
  111159. * The list of layers (background and foreground) of the scene
  111160. */
  111161. layers: Array<Layer>;
  111162. }
  111163. /**
  111164. * Defines the layer scene component responsible to manage any layers
  111165. * in a given scene.
  111166. */
  111167. export class LayerSceneComponent implements ISceneComponent {
  111168. /**
  111169. * The component name helpfull to identify the component in the list of scene components.
  111170. */
  111171. readonly name: string;
  111172. /**
  111173. * The scene the component belongs to.
  111174. */
  111175. scene: Scene;
  111176. private _engine;
  111177. /**
  111178. * Creates a new instance of the component for the given scene
  111179. * @param scene Defines the scene to register the component in
  111180. */
  111181. constructor(scene: Scene);
  111182. /**
  111183. * Registers the component in a given scene
  111184. */
  111185. register(): void;
  111186. /**
  111187. * Rebuilds the elements related to this component in case of
  111188. * context lost for instance.
  111189. */
  111190. rebuild(): void;
  111191. /**
  111192. * Disposes the component and the associated ressources.
  111193. */
  111194. dispose(): void;
  111195. private _draw;
  111196. private _drawCameraPredicate;
  111197. private _drawCameraBackground;
  111198. private _drawCameraForeground;
  111199. private _drawRenderTargetPredicate;
  111200. private _drawRenderTargetBackground;
  111201. private _drawRenderTargetForeground;
  111202. /**
  111203. * Adds all the elements from the container to the scene
  111204. * @param container the container holding the elements
  111205. */
  111206. addFromContainer(container: AbstractScene): void;
  111207. /**
  111208. * Removes all the elements in the container from the scene
  111209. * @param container contains the elements to remove
  111210. * @param dispose if the removed element should be disposed (default: false)
  111211. */
  111212. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111213. }
  111214. }
  111215. declare module BABYLON {
  111216. /** @hidden */
  111217. export var layerPixelShader: {
  111218. name: string;
  111219. shader: string;
  111220. };
  111221. }
  111222. declare module BABYLON {
  111223. /** @hidden */
  111224. export var layerVertexShader: {
  111225. name: string;
  111226. shader: string;
  111227. };
  111228. }
  111229. declare module BABYLON {
  111230. /**
  111231. * This represents a full screen 2d layer.
  111232. * This can be useful to display a picture in the background of your scene for instance.
  111233. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111234. */
  111235. export class Layer {
  111236. /**
  111237. * Define the name of the layer.
  111238. */
  111239. name: string;
  111240. /**
  111241. * Define the texture the layer should display.
  111242. */
  111243. texture: Nullable<Texture>;
  111244. /**
  111245. * Is the layer in background or foreground.
  111246. */
  111247. isBackground: boolean;
  111248. /**
  111249. * Define the color of the layer (instead of texture).
  111250. */
  111251. color: Color4;
  111252. /**
  111253. * Define the scale of the layer in order to zoom in out of the texture.
  111254. */
  111255. scale: Vector2;
  111256. /**
  111257. * Define an offset for the layer in order to shift the texture.
  111258. */
  111259. offset: Vector2;
  111260. /**
  111261. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  111262. */
  111263. alphaBlendingMode: number;
  111264. /**
  111265. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  111266. * Alpha test will not mix with the background color in case of transparency.
  111267. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  111268. */
  111269. alphaTest: boolean;
  111270. /**
  111271. * Define a mask to restrict the layer to only some of the scene cameras.
  111272. */
  111273. layerMask: number;
  111274. /**
  111275. * Define the list of render target the layer is visible into.
  111276. */
  111277. renderTargetTextures: RenderTargetTexture[];
  111278. /**
  111279. * Define if the layer is only used in renderTarget or if it also
  111280. * renders in the main frame buffer of the canvas.
  111281. */
  111282. renderOnlyInRenderTargetTextures: boolean;
  111283. private _scene;
  111284. private _vertexBuffers;
  111285. private _indexBuffer;
  111286. private _effect;
  111287. private _alphaTestEffect;
  111288. /**
  111289. * An event triggered when the layer is disposed.
  111290. */
  111291. onDisposeObservable: Observable<Layer>;
  111292. private _onDisposeObserver;
  111293. /**
  111294. * Back compatibility with callback before the onDisposeObservable existed.
  111295. * The set callback will be triggered when the layer has been disposed.
  111296. */
  111297. onDispose: () => void;
  111298. /**
  111299. * An event triggered before rendering the scene
  111300. */
  111301. onBeforeRenderObservable: Observable<Layer>;
  111302. private _onBeforeRenderObserver;
  111303. /**
  111304. * Back compatibility with callback before the onBeforeRenderObservable existed.
  111305. * The set callback will be triggered just before rendering the layer.
  111306. */
  111307. onBeforeRender: () => void;
  111308. /**
  111309. * An event triggered after rendering the scene
  111310. */
  111311. onAfterRenderObservable: Observable<Layer>;
  111312. private _onAfterRenderObserver;
  111313. /**
  111314. * Back compatibility with callback before the onAfterRenderObservable existed.
  111315. * The set callback will be triggered just after rendering the layer.
  111316. */
  111317. onAfterRender: () => void;
  111318. /**
  111319. * Instantiates a new layer.
  111320. * This represents a full screen 2d layer.
  111321. * This can be useful to display a picture in the background of your scene for instance.
  111322. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111323. * @param name Define the name of the layer in the scene
  111324. * @param imgUrl Define the url of the texture to display in the layer
  111325. * @param scene Define the scene the layer belongs to
  111326. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  111327. * @param color Defines a color for the layer
  111328. */
  111329. constructor(
  111330. /**
  111331. * Define the name of the layer.
  111332. */
  111333. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  111334. private _createIndexBuffer;
  111335. /** @hidden */
  111336. _rebuild(): void;
  111337. /**
  111338. * Renders the layer in the scene.
  111339. */
  111340. render(): void;
  111341. /**
  111342. * Disposes and releases the associated ressources.
  111343. */
  111344. dispose(): void;
  111345. }
  111346. }
  111347. declare module BABYLON {
  111348. /** @hidden */
  111349. export var lensFlarePixelShader: {
  111350. name: string;
  111351. shader: string;
  111352. };
  111353. }
  111354. declare module BABYLON {
  111355. /** @hidden */
  111356. export var lensFlareVertexShader: {
  111357. name: string;
  111358. shader: string;
  111359. };
  111360. }
  111361. declare module BABYLON {
  111362. /**
  111363. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111364. * It is usually composed of several `lensFlare`.
  111365. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111366. */
  111367. export class LensFlareSystem {
  111368. /**
  111369. * Define the name of the lens flare system
  111370. */
  111371. name: string;
  111372. /**
  111373. * List of lens flares used in this system.
  111374. */
  111375. lensFlares: LensFlare[];
  111376. /**
  111377. * Define a limit from the border the lens flare can be visible.
  111378. */
  111379. borderLimit: number;
  111380. /**
  111381. * Define a viewport border we do not want to see the lens flare in.
  111382. */
  111383. viewportBorder: number;
  111384. /**
  111385. * Define a predicate which could limit the list of meshes able to occlude the effect.
  111386. */
  111387. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  111388. /**
  111389. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  111390. */
  111391. layerMask: number;
  111392. /**
  111393. * Define the id of the lens flare system in the scene.
  111394. * (equal to name by default)
  111395. */
  111396. id: string;
  111397. private _scene;
  111398. private _emitter;
  111399. private _vertexBuffers;
  111400. private _indexBuffer;
  111401. private _effect;
  111402. private _positionX;
  111403. private _positionY;
  111404. private _isEnabled;
  111405. /** @hidden */
  111406. static _SceneComponentInitialization: (scene: Scene) => void;
  111407. /**
  111408. * Instantiates a lens flare system.
  111409. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111410. * It is usually composed of several `lensFlare`.
  111411. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111412. * @param name Define the name of the lens flare system in the scene
  111413. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  111414. * @param scene Define the scene the lens flare system belongs to
  111415. */
  111416. constructor(
  111417. /**
  111418. * Define the name of the lens flare system
  111419. */
  111420. name: string, emitter: any, scene: Scene);
  111421. /**
  111422. * Define if the lens flare system is enabled.
  111423. */
  111424. isEnabled: boolean;
  111425. /**
  111426. * Get the scene the effects belongs to.
  111427. * @returns the scene holding the lens flare system
  111428. */
  111429. getScene(): Scene;
  111430. /**
  111431. * Get the emitter of the lens flare system.
  111432. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111433. * @returns the emitter of the lens flare system
  111434. */
  111435. getEmitter(): any;
  111436. /**
  111437. * Set the emitter of the lens flare system.
  111438. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111439. * @param newEmitter Define the new emitter of the system
  111440. */
  111441. setEmitter(newEmitter: any): void;
  111442. /**
  111443. * Get the lens flare system emitter position.
  111444. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  111445. * @returns the position
  111446. */
  111447. getEmitterPosition(): Vector3;
  111448. /**
  111449. * @hidden
  111450. */
  111451. computeEffectivePosition(globalViewport: Viewport): boolean;
  111452. /** @hidden */
  111453. _isVisible(): boolean;
  111454. /**
  111455. * @hidden
  111456. */
  111457. render(): boolean;
  111458. /**
  111459. * Dispose and release the lens flare with its associated resources.
  111460. */
  111461. dispose(): void;
  111462. /**
  111463. * Parse a lens flare system from a JSON repressentation
  111464. * @param parsedLensFlareSystem Define the JSON to parse
  111465. * @param scene Define the scene the parsed system should be instantiated in
  111466. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  111467. * @returns the parsed system
  111468. */
  111469. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  111470. /**
  111471. * Serialize the current Lens Flare System into a JSON representation.
  111472. * @returns the serialized JSON
  111473. */
  111474. serialize(): any;
  111475. }
  111476. }
  111477. declare module BABYLON {
  111478. /**
  111479. * This represents one of the lens effect in a `lensFlareSystem`.
  111480. * It controls one of the indiviual texture used in the effect.
  111481. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111482. */
  111483. export class LensFlare {
  111484. /**
  111485. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111486. */
  111487. size: number;
  111488. /**
  111489. * 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.
  111490. */
  111491. position: number;
  111492. /**
  111493. * Define the lens color.
  111494. */
  111495. color: Color3;
  111496. /**
  111497. * Define the lens texture.
  111498. */
  111499. texture: Nullable<Texture>;
  111500. /**
  111501. * Define the alpha mode to render this particular lens.
  111502. */
  111503. alphaMode: number;
  111504. private _system;
  111505. /**
  111506. * Creates a new Lens Flare.
  111507. * This represents one of the lens effect in a `lensFlareSystem`.
  111508. * It controls one of the indiviual texture used in the effect.
  111509. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111510. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  111511. * @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.
  111512. * @param color Define the lens color
  111513. * @param imgUrl Define the lens texture url
  111514. * @param system Define the `lensFlareSystem` this flare is part of
  111515. * @returns The newly created Lens Flare
  111516. */
  111517. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  111518. /**
  111519. * Instantiates a new Lens Flare.
  111520. * This represents one of the lens effect in a `lensFlareSystem`.
  111521. * It controls one of the indiviual texture used in the effect.
  111522. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111523. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  111524. * @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.
  111525. * @param color Define the lens color
  111526. * @param imgUrl Define the lens texture url
  111527. * @param system Define the `lensFlareSystem` this flare is part of
  111528. */
  111529. constructor(
  111530. /**
  111531. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111532. */
  111533. size: number,
  111534. /**
  111535. * 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.
  111536. */
  111537. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  111538. /**
  111539. * Dispose and release the lens flare with its associated resources.
  111540. */
  111541. dispose(): void;
  111542. }
  111543. }
  111544. declare module BABYLON {
  111545. interface AbstractScene {
  111546. /**
  111547. * The list of lens flare system added to the scene
  111548. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111549. */
  111550. lensFlareSystems: Array<LensFlareSystem>;
  111551. /**
  111552. * Removes the given lens flare system from this scene.
  111553. * @param toRemove The lens flare system to remove
  111554. * @returns The index of the removed lens flare system
  111555. */
  111556. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  111557. /**
  111558. * Adds the given lens flare system to this scene
  111559. * @param newLensFlareSystem The lens flare system to add
  111560. */
  111561. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  111562. /**
  111563. * Gets a lens flare system using its name
  111564. * @param name defines the name to look for
  111565. * @returns the lens flare system or null if not found
  111566. */
  111567. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  111568. /**
  111569. * Gets a lens flare system using its id
  111570. * @param id defines the id to look for
  111571. * @returns the lens flare system or null if not found
  111572. */
  111573. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  111574. }
  111575. /**
  111576. * Defines the lens flare scene component responsible to manage any lens flares
  111577. * in a given scene.
  111578. */
  111579. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  111580. /**
  111581. * The component name helpfull to identify the component in the list of scene components.
  111582. */
  111583. readonly name: string;
  111584. /**
  111585. * The scene the component belongs to.
  111586. */
  111587. scene: Scene;
  111588. /**
  111589. * Creates a new instance of the component for the given scene
  111590. * @param scene Defines the scene to register the component in
  111591. */
  111592. constructor(scene: Scene);
  111593. /**
  111594. * Registers the component in a given scene
  111595. */
  111596. register(): void;
  111597. /**
  111598. * Rebuilds the elements related to this component in case of
  111599. * context lost for instance.
  111600. */
  111601. rebuild(): void;
  111602. /**
  111603. * Adds all the elements from the container to the scene
  111604. * @param container the container holding the elements
  111605. */
  111606. addFromContainer(container: AbstractScene): void;
  111607. /**
  111608. * Removes all the elements in the container from the scene
  111609. * @param container contains the elements to remove
  111610. * @param dispose if the removed element should be disposed (default: false)
  111611. */
  111612. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111613. /**
  111614. * Serializes the component data to the specified json object
  111615. * @param serializationObject The object to serialize to
  111616. */
  111617. serialize(serializationObject: any): void;
  111618. /**
  111619. * Disposes the component and the associated ressources.
  111620. */
  111621. dispose(): void;
  111622. private _draw;
  111623. }
  111624. }
  111625. declare module BABYLON {
  111626. /**
  111627. * Defines the shadow generator component responsible to manage any shadow generators
  111628. * in a given scene.
  111629. */
  111630. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  111631. /**
  111632. * The component name helpfull to identify the component in the list of scene components.
  111633. */
  111634. readonly name: string;
  111635. /**
  111636. * The scene the component belongs to.
  111637. */
  111638. scene: Scene;
  111639. /**
  111640. * Creates a new instance of the component for the given scene
  111641. * @param scene Defines the scene to register the component in
  111642. */
  111643. constructor(scene: Scene);
  111644. /**
  111645. * Registers the component in a given scene
  111646. */
  111647. register(): void;
  111648. /**
  111649. * Rebuilds the elements related to this component in case of
  111650. * context lost for instance.
  111651. */
  111652. rebuild(): void;
  111653. /**
  111654. * Serializes the component data to the specified json object
  111655. * @param serializationObject The object to serialize to
  111656. */
  111657. serialize(serializationObject: any): void;
  111658. /**
  111659. * Adds all the elements from the container to the scene
  111660. * @param container the container holding the elements
  111661. */
  111662. addFromContainer(container: AbstractScene): void;
  111663. /**
  111664. * Removes all the elements in the container from the scene
  111665. * @param container contains the elements to remove
  111666. * @param dispose if the removed element should be disposed (default: false)
  111667. */
  111668. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111669. /**
  111670. * Rebuilds the elements related to this component in case of
  111671. * context lost for instance.
  111672. */
  111673. dispose(): void;
  111674. private _gatherRenderTargets;
  111675. }
  111676. }
  111677. declare module BABYLON {
  111678. /**
  111679. * A point light is a light defined by an unique point in world space.
  111680. * The light is emitted in every direction from this point.
  111681. * A good example of a point light is a standard light bulb.
  111682. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111683. */
  111684. export class PointLight extends ShadowLight {
  111685. private _shadowAngle;
  111686. /**
  111687. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111688. * This specifies what angle the shadow will use to be created.
  111689. *
  111690. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111691. */
  111692. /**
  111693. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111694. * This specifies what angle the shadow will use to be created.
  111695. *
  111696. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111697. */
  111698. shadowAngle: number;
  111699. /**
  111700. * Gets the direction if it has been set.
  111701. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111702. */
  111703. /**
  111704. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111705. */
  111706. direction: Vector3;
  111707. /**
  111708. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  111709. * A PointLight emits the light in every direction.
  111710. * It can cast shadows.
  111711. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  111712. * ```javascript
  111713. * var pointLight = new PointLight("pl", camera.position, scene);
  111714. * ```
  111715. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111716. * @param name The light friendly name
  111717. * @param position The position of the point light in the scene
  111718. * @param scene The scene the lights belongs to
  111719. */
  111720. constructor(name: string, position: Vector3, scene: Scene);
  111721. /**
  111722. * Returns the string "PointLight"
  111723. * @returns the class name
  111724. */
  111725. getClassName(): string;
  111726. /**
  111727. * Returns the integer 0.
  111728. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111729. */
  111730. getTypeID(): number;
  111731. /**
  111732. * Specifies wether or not the shadowmap should be a cube texture.
  111733. * @returns true if the shadowmap needs to be a cube texture.
  111734. */
  111735. needCube(): boolean;
  111736. /**
  111737. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  111738. * @param faceIndex The index of the face we are computed the direction to generate shadow
  111739. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  111740. */
  111741. getShadowDirection(faceIndex?: number): Vector3;
  111742. /**
  111743. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  111744. * - fov = PI / 2
  111745. * - aspect ratio : 1.0
  111746. * - z-near and far equal to the active camera minZ and maxZ.
  111747. * Returns the PointLight.
  111748. */
  111749. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111750. protected _buildUniformLayout(): void;
  111751. /**
  111752. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  111753. * @param effect The effect to update
  111754. * @param lightIndex The index of the light in the effect to update
  111755. * @returns The point light
  111756. */
  111757. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  111758. /**
  111759. * Prepares the list of defines specific to the light type.
  111760. * @param defines the list of defines
  111761. * @param lightIndex defines the index of the light for the effect
  111762. */
  111763. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111764. }
  111765. }
  111766. declare module BABYLON {
  111767. /**
  111768. * Header information of HDR texture files.
  111769. */
  111770. export interface HDRInfo {
  111771. /**
  111772. * The height of the texture in pixels.
  111773. */
  111774. height: number;
  111775. /**
  111776. * The width of the texture in pixels.
  111777. */
  111778. width: number;
  111779. /**
  111780. * The index of the beginning of the data in the binary file.
  111781. */
  111782. dataPosition: number;
  111783. }
  111784. /**
  111785. * This groups tools to convert HDR texture to native colors array.
  111786. */
  111787. export class HDRTools {
  111788. private static Ldexp;
  111789. private static Rgbe2float;
  111790. private static readStringLine;
  111791. /**
  111792. * Reads header information from an RGBE texture stored in a native array.
  111793. * More information on this format are available here:
  111794. * https://en.wikipedia.org/wiki/RGBE_image_format
  111795. *
  111796. * @param uint8array The binary file stored in native array.
  111797. * @return The header information.
  111798. */
  111799. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  111800. /**
  111801. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  111802. * This RGBE texture needs to store the information as a panorama.
  111803. *
  111804. * More information on this format are available here:
  111805. * https://en.wikipedia.org/wiki/RGBE_image_format
  111806. *
  111807. * @param buffer The binary file stored in an array buffer.
  111808. * @param size The expected size of the extracted cubemap.
  111809. * @return The Cube Map information.
  111810. */
  111811. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  111812. /**
  111813. * Returns the pixels data extracted from an RGBE texture.
  111814. * This pixels will be stored left to right up to down in the R G B order in one array.
  111815. *
  111816. * More information on this format are available here:
  111817. * https://en.wikipedia.org/wiki/RGBE_image_format
  111818. *
  111819. * @param uint8array The binary file stored in an array buffer.
  111820. * @param hdrInfo The header information of the file.
  111821. * @return The pixels data in RGB right to left up to down order.
  111822. */
  111823. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  111824. private static RGBE_ReadPixels_RLE;
  111825. }
  111826. }
  111827. declare module BABYLON {
  111828. /**
  111829. * This represents a texture coming from an HDR input.
  111830. *
  111831. * The only supported format is currently panorama picture stored in RGBE format.
  111832. * Example of such files can be found on HDRLib: http://hdrlib.com/
  111833. */
  111834. export class HDRCubeTexture extends BaseTexture {
  111835. private static _facesMapping;
  111836. private _generateHarmonics;
  111837. private _noMipmap;
  111838. private _textureMatrix;
  111839. private _size;
  111840. private _onLoad;
  111841. private _onError;
  111842. /**
  111843. * The texture URL.
  111844. */
  111845. url: string;
  111846. /**
  111847. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  111848. */
  111849. coordinatesMode: number;
  111850. protected _isBlocking: boolean;
  111851. /**
  111852. * Sets wether or not the texture is blocking during loading.
  111853. */
  111854. /**
  111855. * Gets wether or not the texture is blocking during loading.
  111856. */
  111857. isBlocking: boolean;
  111858. protected _rotationY: number;
  111859. /**
  111860. * Sets texture matrix rotation angle around Y axis in radians.
  111861. */
  111862. /**
  111863. * Gets texture matrix rotation angle around Y axis radians.
  111864. */
  111865. rotationY: number;
  111866. /**
  111867. * Gets or sets the center of the bounding box associated with the cube texture
  111868. * It must define where the camera used to render the texture was set
  111869. */
  111870. boundingBoxPosition: Vector3;
  111871. private _boundingBoxSize;
  111872. /**
  111873. * Gets or sets the size of the bounding box associated with the cube texture
  111874. * When defined, the cubemap will switch to local mode
  111875. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111876. * @example https://www.babylonjs-playground.com/#RNASML
  111877. */
  111878. boundingBoxSize: Vector3;
  111879. /**
  111880. * Instantiates an HDRTexture from the following parameters.
  111881. *
  111882. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  111883. * @param scene The scene the texture will be used in
  111884. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111885. * @param noMipmap Forces to not generate the mipmap if true
  111886. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  111887. * @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)
  111888. * @param reserved Reserved flag for internal use.
  111889. */
  111890. 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>);
  111891. /**
  111892. * Get the current class name of the texture useful for serialization or dynamic coding.
  111893. * @returns "HDRCubeTexture"
  111894. */
  111895. getClassName(): string;
  111896. /**
  111897. * Occurs when the file is raw .hdr file.
  111898. */
  111899. private loadTexture;
  111900. clone(): HDRCubeTexture;
  111901. delayLoad(): void;
  111902. /**
  111903. * Get the texture reflection matrix used to rotate/transform the reflection.
  111904. * @returns the reflection matrix
  111905. */
  111906. getReflectionTextureMatrix(): Matrix;
  111907. /**
  111908. * Set the texture reflection matrix used to rotate/transform the reflection.
  111909. * @param value Define the reflection matrix to set
  111910. */
  111911. setReflectionTextureMatrix(value: Matrix): void;
  111912. /**
  111913. * Parses a JSON representation of an HDR Texture in order to create the texture
  111914. * @param parsedTexture Define the JSON representation
  111915. * @param scene Define the scene the texture should be created in
  111916. * @param rootUrl Define the root url in case we need to load relative dependencies
  111917. * @returns the newly created texture after parsing
  111918. */
  111919. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  111920. serialize(): any;
  111921. }
  111922. }
  111923. declare module BABYLON {
  111924. /**
  111925. * Class used to control physics engine
  111926. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111927. */
  111928. export class PhysicsEngine implements IPhysicsEngine {
  111929. private _physicsPlugin;
  111930. /**
  111931. * Global value used to control the smallest number supported by the simulation
  111932. */
  111933. static Epsilon: number;
  111934. private _impostors;
  111935. private _joints;
  111936. /**
  111937. * Gets the gravity vector used by the simulation
  111938. */
  111939. gravity: Vector3;
  111940. /**
  111941. * Factory used to create the default physics plugin.
  111942. * @returns The default physics plugin
  111943. */
  111944. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  111945. /**
  111946. * Creates a new Physics Engine
  111947. * @param gravity defines the gravity vector used by the simulation
  111948. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  111949. */
  111950. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  111951. /**
  111952. * Sets the gravity vector used by the simulation
  111953. * @param gravity defines the gravity vector to use
  111954. */
  111955. setGravity(gravity: Vector3): void;
  111956. /**
  111957. * Set the time step of the physics engine.
  111958. * Default is 1/60.
  111959. * To slow it down, enter 1/600 for example.
  111960. * To speed it up, 1/30
  111961. * @param newTimeStep defines the new timestep to apply to this world.
  111962. */
  111963. setTimeStep(newTimeStep?: number): void;
  111964. /**
  111965. * Get the time step of the physics engine.
  111966. * @returns the current time step
  111967. */
  111968. getTimeStep(): number;
  111969. /**
  111970. * Release all resources
  111971. */
  111972. dispose(): void;
  111973. /**
  111974. * Gets the name of the current physics plugin
  111975. * @returns the name of the plugin
  111976. */
  111977. getPhysicsPluginName(): string;
  111978. /**
  111979. * Adding a new impostor for the impostor tracking.
  111980. * This will be done by the impostor itself.
  111981. * @param impostor the impostor to add
  111982. */
  111983. addImpostor(impostor: PhysicsImpostor): void;
  111984. /**
  111985. * Remove an impostor from the engine.
  111986. * This impostor and its mesh will not longer be updated by the physics engine.
  111987. * @param impostor the impostor to remove
  111988. */
  111989. removeImpostor(impostor: PhysicsImpostor): void;
  111990. /**
  111991. * Add a joint to the physics engine
  111992. * @param mainImpostor defines the main impostor to which the joint is added.
  111993. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111994. * @param joint defines the joint that will connect both impostors.
  111995. */
  111996. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111997. /**
  111998. * Removes a joint from the simulation
  111999. * @param mainImpostor defines the impostor used with the joint
  112000. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112001. * @param joint defines the joint to remove
  112002. */
  112003. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112004. /**
  112005. * Called by the scene. No need to call it.
  112006. * @param delta defines the timespam between frames
  112007. */
  112008. _step(delta: number): void;
  112009. /**
  112010. * Gets the current plugin used to run the simulation
  112011. * @returns current plugin
  112012. */
  112013. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112014. /**
  112015. * Gets the list of physic impostors
  112016. * @returns an array of PhysicsImpostor
  112017. */
  112018. getImpostors(): Array<PhysicsImpostor>;
  112019. /**
  112020. * Gets the impostor for a physics enabled object
  112021. * @param object defines the object impersonated by the impostor
  112022. * @returns the PhysicsImpostor or null if not found
  112023. */
  112024. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112025. /**
  112026. * Gets the impostor for a physics body object
  112027. * @param body defines physics body used by the impostor
  112028. * @returns the PhysicsImpostor or null if not found
  112029. */
  112030. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112031. /**
  112032. * Does a raycast in the physics world
  112033. * @param from when should the ray start?
  112034. * @param to when should the ray end?
  112035. * @returns PhysicsRaycastResult
  112036. */
  112037. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112038. }
  112039. }
  112040. declare module BABYLON {
  112041. /** @hidden */
  112042. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  112043. private _useDeltaForWorldStep;
  112044. world: any;
  112045. name: string;
  112046. private _physicsMaterials;
  112047. private _fixedTimeStep;
  112048. private _cannonRaycastResult;
  112049. private _raycastResult;
  112050. private _physicsBodysToRemoveAfterStep;
  112051. BJSCANNON: any;
  112052. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  112053. setGravity(gravity: Vector3): void;
  112054. setTimeStep(timeStep: number): void;
  112055. getTimeStep(): number;
  112056. executeStep(delta: number): void;
  112057. private _removeMarkedPhysicsBodiesFromWorld;
  112058. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112059. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112060. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112061. private _processChildMeshes;
  112062. removePhysicsBody(impostor: PhysicsImpostor): void;
  112063. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112064. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112065. private _addMaterial;
  112066. private _checkWithEpsilon;
  112067. private _createShape;
  112068. private _createHeightmap;
  112069. private _minus90X;
  112070. private _plus90X;
  112071. private _tmpPosition;
  112072. private _tmpDeltaPosition;
  112073. private _tmpUnityRotation;
  112074. private _updatePhysicsBodyTransformation;
  112075. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112076. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112077. isSupported(): boolean;
  112078. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112079. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112080. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112081. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112082. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112083. getBodyMass(impostor: PhysicsImpostor): number;
  112084. getBodyFriction(impostor: PhysicsImpostor): number;
  112085. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112086. getBodyRestitution(impostor: PhysicsImpostor): number;
  112087. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112088. sleepBody(impostor: PhysicsImpostor): void;
  112089. wakeUpBody(impostor: PhysicsImpostor): void;
  112090. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  112091. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112092. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112093. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112094. getRadius(impostor: PhysicsImpostor): number;
  112095. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112096. dispose(): void;
  112097. private _extendNamespace;
  112098. /**
  112099. * Does a raycast in the physics world
  112100. * @param from when should the ray start?
  112101. * @param to when should the ray end?
  112102. * @returns PhysicsRaycastResult
  112103. */
  112104. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112105. }
  112106. }
  112107. declare module BABYLON {
  112108. /** @hidden */
  112109. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  112110. world: any;
  112111. name: string;
  112112. BJSOIMO: any;
  112113. private _raycastResult;
  112114. constructor(iterations?: number, oimoInjection?: any);
  112115. setGravity(gravity: Vector3): void;
  112116. setTimeStep(timeStep: number): void;
  112117. getTimeStep(): number;
  112118. private _tmpImpostorsArray;
  112119. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112120. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112121. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112122. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112123. private _tmpPositionVector;
  112124. removePhysicsBody(impostor: PhysicsImpostor): void;
  112125. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112126. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112127. isSupported(): boolean;
  112128. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112129. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112130. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112131. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112132. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112133. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112134. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112135. getBodyMass(impostor: PhysicsImpostor): number;
  112136. getBodyFriction(impostor: PhysicsImpostor): number;
  112137. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112138. getBodyRestitution(impostor: PhysicsImpostor): number;
  112139. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112140. sleepBody(impostor: PhysicsImpostor): void;
  112141. wakeUpBody(impostor: PhysicsImpostor): void;
  112142. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112143. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  112144. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112145. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112146. getRadius(impostor: PhysicsImpostor): number;
  112147. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112148. dispose(): void;
  112149. /**
  112150. * Does a raycast in the physics world
  112151. * @param from when should the ray start?
  112152. * @param to when should the ray end?
  112153. * @returns PhysicsRaycastResult
  112154. */
  112155. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112156. }
  112157. }
  112158. declare module BABYLON {
  112159. /**
  112160. * Class containing static functions to help procedurally build meshes
  112161. */
  112162. export class RibbonBuilder {
  112163. /**
  112164. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  112165. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  112166. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  112167. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  112168. * * 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
  112169. * * 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
  112170. * * 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
  112171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112172. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112173. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112174. * * 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
  112175. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  112176. * * 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
  112177. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  112178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112179. * @param name defines the name of the mesh
  112180. * @param options defines the options used to create the mesh
  112181. * @param scene defines the hosting scene
  112182. * @returns the ribbon mesh
  112183. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  112184. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112185. */
  112186. static CreateRibbon(name: string, options: {
  112187. pathArray: Vector3[][];
  112188. closeArray?: boolean;
  112189. closePath?: boolean;
  112190. offset?: number;
  112191. updatable?: boolean;
  112192. sideOrientation?: number;
  112193. frontUVs?: Vector4;
  112194. backUVs?: Vector4;
  112195. instance?: Mesh;
  112196. invertUV?: boolean;
  112197. uvs?: Vector2[];
  112198. colors?: Color4[];
  112199. }, scene?: Nullable<Scene>): Mesh;
  112200. }
  112201. }
  112202. declare module BABYLON {
  112203. /**
  112204. * Class containing static functions to help procedurally build meshes
  112205. */
  112206. export class ShapeBuilder {
  112207. /**
  112208. * 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.
  112209. * * 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.
  112210. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112211. * * 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.
  112212. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  112213. * * 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
  112214. * * 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
  112215. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  112216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112218. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  112219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112220. * @param name defines the name of the mesh
  112221. * @param options defines the options used to create the mesh
  112222. * @param scene defines the hosting scene
  112223. * @returns the extruded shape mesh
  112224. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112226. */
  112227. static ExtrudeShape(name: string, options: {
  112228. shape: Vector3[];
  112229. path: Vector3[];
  112230. scale?: number;
  112231. rotation?: number;
  112232. cap?: number;
  112233. updatable?: boolean;
  112234. sideOrientation?: number;
  112235. frontUVs?: Vector4;
  112236. backUVs?: Vector4;
  112237. instance?: Mesh;
  112238. invertUV?: boolean;
  112239. }, scene?: Nullable<Scene>): Mesh;
  112240. /**
  112241. * Creates an custom extruded shape mesh.
  112242. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  112243. * * 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.
  112244. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112245. * * 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
  112246. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  112247. * * 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
  112248. * * It must returns a float value that will be the scale value applied to the shape on each path point
  112249. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  112250. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  112251. * * 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
  112252. * * 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
  112253. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  112254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112255. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112256. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112258. * @param name defines the name of the mesh
  112259. * @param options defines the options used to create the mesh
  112260. * @param scene defines the hosting scene
  112261. * @returns the custom extruded shape mesh
  112262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  112263. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112265. */
  112266. static ExtrudeShapeCustom(name: string, options: {
  112267. shape: Vector3[];
  112268. path: Vector3[];
  112269. scaleFunction?: any;
  112270. rotationFunction?: any;
  112271. ribbonCloseArray?: boolean;
  112272. ribbonClosePath?: boolean;
  112273. cap?: number;
  112274. updatable?: boolean;
  112275. sideOrientation?: number;
  112276. frontUVs?: Vector4;
  112277. backUVs?: Vector4;
  112278. instance?: Mesh;
  112279. invertUV?: boolean;
  112280. }, scene?: Nullable<Scene>): Mesh;
  112281. private static _ExtrudeShapeGeneric;
  112282. }
  112283. }
  112284. declare module BABYLON {
  112285. /**
  112286. * AmmoJS Physics plugin
  112287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112288. * @see https://github.com/kripken/ammo.js/
  112289. */
  112290. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  112291. private _useDeltaForWorldStep;
  112292. /**
  112293. * Reference to the Ammo library
  112294. */
  112295. bjsAMMO: any;
  112296. /**
  112297. * Created ammoJS world which physics bodies are added to
  112298. */
  112299. world: any;
  112300. /**
  112301. * Name of the plugin
  112302. */
  112303. name: string;
  112304. private _timeStep;
  112305. private _fixedTimeStep;
  112306. private _maxSteps;
  112307. private _tmpQuaternion;
  112308. private _tmpAmmoTransform;
  112309. private _tmpAmmoQuaternion;
  112310. private _tmpAmmoConcreteContactResultCallback;
  112311. private _collisionConfiguration;
  112312. private _dispatcher;
  112313. private _overlappingPairCache;
  112314. private _solver;
  112315. private _softBodySolver;
  112316. private _tmpAmmoVectorA;
  112317. private _tmpAmmoVectorB;
  112318. private _tmpAmmoVectorC;
  112319. private _tmpAmmoVectorD;
  112320. private _tmpContactCallbackResult;
  112321. private _tmpAmmoVectorRCA;
  112322. private _tmpAmmoVectorRCB;
  112323. private _raycastResult;
  112324. private static readonly DISABLE_COLLISION_FLAG;
  112325. private static readonly KINEMATIC_FLAG;
  112326. private static readonly DISABLE_DEACTIVATION_FLAG;
  112327. /**
  112328. * Initializes the ammoJS plugin
  112329. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  112330. * @param ammoInjection can be used to inject your own ammo reference
  112331. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  112332. */
  112333. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  112334. /**
  112335. * Sets the gravity of the physics world (m/(s^2))
  112336. * @param gravity Gravity to set
  112337. */
  112338. setGravity(gravity: Vector3): void;
  112339. /**
  112340. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  112341. * @param timeStep timestep to use in seconds
  112342. */
  112343. setTimeStep(timeStep: number): void;
  112344. /**
  112345. * 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)
  112346. * @param fixedTimeStep fixedTimeStep to use in seconds
  112347. */
  112348. setFixedTimeStep(fixedTimeStep: number): void;
  112349. /**
  112350. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  112351. * @param maxSteps the maximum number of steps by the physics engine per frame
  112352. */
  112353. setMaxSteps(maxSteps: number): void;
  112354. /**
  112355. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  112356. * @returns the current timestep in seconds
  112357. */
  112358. getTimeStep(): number;
  112359. private _isImpostorInContact;
  112360. private _isImpostorPairInContact;
  112361. private _stepSimulation;
  112362. /**
  112363. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  112364. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  112365. * After the step the babylon meshes are set to the position of the physics imposters
  112366. * @param delta amount of time to step forward
  112367. * @param impostors array of imposters to update before/after the step
  112368. */
  112369. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112370. /**
  112371. * Update babylon mesh to match physics world object
  112372. * @param impostor imposter to match
  112373. */
  112374. private _afterSoftStep;
  112375. /**
  112376. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112377. * @param impostor imposter to match
  112378. */
  112379. private _ropeStep;
  112380. /**
  112381. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112382. * @param impostor imposter to match
  112383. */
  112384. private _softbodyOrClothStep;
  112385. private _tmpVector;
  112386. private _tmpMatrix;
  112387. /**
  112388. * Applies an impulse on the imposter
  112389. * @param impostor imposter to apply impulse to
  112390. * @param force amount of force to be applied to the imposter
  112391. * @param contactPoint the location to apply the impulse on the imposter
  112392. */
  112393. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112394. /**
  112395. * Applies a force on the imposter
  112396. * @param impostor imposter to apply force
  112397. * @param force amount of force to be applied to the imposter
  112398. * @param contactPoint the location to apply the force on the imposter
  112399. */
  112400. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112401. /**
  112402. * Creates a physics body using the plugin
  112403. * @param impostor the imposter to create the physics body on
  112404. */
  112405. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112406. /**
  112407. * Removes the physics body from the imposter and disposes of the body's memory
  112408. * @param impostor imposter to remove the physics body from
  112409. */
  112410. removePhysicsBody(impostor: PhysicsImpostor): void;
  112411. /**
  112412. * Generates a joint
  112413. * @param impostorJoint the imposter joint to create the joint with
  112414. */
  112415. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112416. /**
  112417. * Removes a joint
  112418. * @param impostorJoint the imposter joint to remove the joint from
  112419. */
  112420. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112421. private _addMeshVerts;
  112422. /**
  112423. * Initialise the soft body vertices to match its object's (mesh) vertices
  112424. * Softbody vertices (nodes) are in world space and to match this
  112425. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  112426. * @param impostor to create the softbody for
  112427. */
  112428. private _softVertexData;
  112429. /**
  112430. * Create an impostor's soft body
  112431. * @param impostor to create the softbody for
  112432. */
  112433. private _createSoftbody;
  112434. /**
  112435. * Create cloth for an impostor
  112436. * @param impostor to create the softbody for
  112437. */
  112438. private _createCloth;
  112439. /**
  112440. * Create rope for an impostor
  112441. * @param impostor to create the softbody for
  112442. */
  112443. private _createRope;
  112444. private _addHullVerts;
  112445. private _createShape;
  112446. /**
  112447. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  112448. * @param impostor imposter containing the physics body and babylon object
  112449. */
  112450. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112451. /**
  112452. * Sets the babylon object's position/rotation from the physics body's position/rotation
  112453. * @param impostor imposter containing the physics body and babylon object
  112454. * @param newPosition new position
  112455. * @param newRotation new rotation
  112456. */
  112457. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112458. /**
  112459. * If this plugin is supported
  112460. * @returns true if its supported
  112461. */
  112462. isSupported(): boolean;
  112463. /**
  112464. * Sets the linear velocity of the physics body
  112465. * @param impostor imposter to set the velocity on
  112466. * @param velocity velocity to set
  112467. */
  112468. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112469. /**
  112470. * Sets the angular velocity of the physics body
  112471. * @param impostor imposter to set the velocity on
  112472. * @param velocity velocity to set
  112473. */
  112474. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112475. /**
  112476. * gets the linear velocity
  112477. * @param impostor imposter to get linear velocity from
  112478. * @returns linear velocity
  112479. */
  112480. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112481. /**
  112482. * gets the angular velocity
  112483. * @param impostor imposter to get angular velocity from
  112484. * @returns angular velocity
  112485. */
  112486. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112487. /**
  112488. * Sets the mass of physics body
  112489. * @param impostor imposter to set the mass on
  112490. * @param mass mass to set
  112491. */
  112492. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112493. /**
  112494. * Gets the mass of the physics body
  112495. * @param impostor imposter to get the mass from
  112496. * @returns mass
  112497. */
  112498. getBodyMass(impostor: PhysicsImpostor): number;
  112499. /**
  112500. * Gets friction of the impostor
  112501. * @param impostor impostor to get friction from
  112502. * @returns friction value
  112503. */
  112504. getBodyFriction(impostor: PhysicsImpostor): number;
  112505. /**
  112506. * Sets friction of the impostor
  112507. * @param impostor impostor to set friction on
  112508. * @param friction friction value
  112509. */
  112510. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112511. /**
  112512. * Gets restitution of the impostor
  112513. * @param impostor impostor to get restitution from
  112514. * @returns restitution value
  112515. */
  112516. getBodyRestitution(impostor: PhysicsImpostor): number;
  112517. /**
  112518. * Sets resitution of the impostor
  112519. * @param impostor impostor to set resitution on
  112520. * @param restitution resitution value
  112521. */
  112522. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112523. /**
  112524. * Gets pressure inside the impostor
  112525. * @param impostor impostor to get pressure from
  112526. * @returns pressure value
  112527. */
  112528. getBodyPressure(impostor: PhysicsImpostor): number;
  112529. /**
  112530. * Sets pressure inside a soft body impostor
  112531. * Cloth and rope must remain 0 pressure
  112532. * @param impostor impostor to set pressure on
  112533. * @param pressure pressure value
  112534. */
  112535. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  112536. /**
  112537. * Gets stiffness of the impostor
  112538. * @param impostor impostor to get stiffness from
  112539. * @returns pressure value
  112540. */
  112541. getBodyStiffness(impostor: PhysicsImpostor): number;
  112542. /**
  112543. * Sets stiffness of the impostor
  112544. * @param impostor impostor to set stiffness on
  112545. * @param stiffness stiffness value from 0 to 1
  112546. */
  112547. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  112548. /**
  112549. * Gets velocityIterations of the impostor
  112550. * @param impostor impostor to get velocity iterations from
  112551. * @returns velocityIterations value
  112552. */
  112553. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  112554. /**
  112555. * Sets velocityIterations of the impostor
  112556. * @param impostor impostor to set velocity iterations on
  112557. * @param velocityIterations velocityIterations value
  112558. */
  112559. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  112560. /**
  112561. * Gets positionIterations of the impostor
  112562. * @param impostor impostor to get position iterations from
  112563. * @returns positionIterations value
  112564. */
  112565. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  112566. /**
  112567. * Sets positionIterations of the impostor
  112568. * @param impostor impostor to set position on
  112569. * @param positionIterations positionIterations value
  112570. */
  112571. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  112572. /**
  112573. * Append an anchor to a cloth object
  112574. * @param impostor is the cloth impostor to add anchor to
  112575. * @param otherImpostor is the rigid impostor to anchor to
  112576. * @param width ratio across width from 0 to 1
  112577. * @param height ratio up height from 0 to 1
  112578. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112579. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112580. */
  112581. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112582. /**
  112583. * Append an hook to a rope object
  112584. * @param impostor is the rope impostor to add hook to
  112585. * @param otherImpostor is the rigid impostor to hook to
  112586. * @param length ratio along the rope from 0 to 1
  112587. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  112588. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112589. */
  112590. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112591. /**
  112592. * Sleeps the physics body and stops it from being active
  112593. * @param impostor impostor to sleep
  112594. */
  112595. sleepBody(impostor: PhysicsImpostor): void;
  112596. /**
  112597. * Activates the physics body
  112598. * @param impostor impostor to activate
  112599. */
  112600. wakeUpBody(impostor: PhysicsImpostor): void;
  112601. /**
  112602. * Updates the distance parameters of the joint
  112603. * @param joint joint to update
  112604. * @param maxDistance maximum distance of the joint
  112605. * @param minDistance minimum distance of the joint
  112606. */
  112607. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112608. /**
  112609. * Sets a motor on the joint
  112610. * @param joint joint to set motor on
  112611. * @param speed speed of the motor
  112612. * @param maxForce maximum force of the motor
  112613. * @param motorIndex index of the motor
  112614. */
  112615. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112616. /**
  112617. * Sets the motors limit
  112618. * @param joint joint to set limit on
  112619. * @param upperLimit upper limit
  112620. * @param lowerLimit lower limit
  112621. */
  112622. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112623. /**
  112624. * Syncs the position and rotation of a mesh with the impostor
  112625. * @param mesh mesh to sync
  112626. * @param impostor impostor to update the mesh with
  112627. */
  112628. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112629. /**
  112630. * Gets the radius of the impostor
  112631. * @param impostor impostor to get radius from
  112632. * @returns the radius
  112633. */
  112634. getRadius(impostor: PhysicsImpostor): number;
  112635. /**
  112636. * Gets the box size of the impostor
  112637. * @param impostor impostor to get box size from
  112638. * @param result the resulting box size
  112639. */
  112640. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112641. /**
  112642. * Disposes of the impostor
  112643. */
  112644. dispose(): void;
  112645. /**
  112646. * Does a raycast in the physics world
  112647. * @param from when should the ray start?
  112648. * @param to when should the ray end?
  112649. * @returns PhysicsRaycastResult
  112650. */
  112651. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112652. }
  112653. }
  112654. declare module BABYLON {
  112655. interface AbstractScene {
  112656. /**
  112657. * The list of reflection probes added to the scene
  112658. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112659. */
  112660. reflectionProbes: Array<ReflectionProbe>;
  112661. /**
  112662. * Removes the given reflection probe from this scene.
  112663. * @param toRemove The reflection probe to remove
  112664. * @returns The index of the removed reflection probe
  112665. */
  112666. removeReflectionProbe(toRemove: ReflectionProbe): number;
  112667. /**
  112668. * Adds the given reflection probe to this scene.
  112669. * @param newReflectionProbe The reflection probe to add
  112670. */
  112671. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  112672. }
  112673. /**
  112674. * Class used to generate realtime reflection / refraction cube textures
  112675. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112676. */
  112677. export class ReflectionProbe {
  112678. /** defines the name of the probe */
  112679. name: string;
  112680. private _scene;
  112681. private _renderTargetTexture;
  112682. private _projectionMatrix;
  112683. private _viewMatrix;
  112684. private _target;
  112685. private _add;
  112686. private _attachedMesh;
  112687. private _invertYAxis;
  112688. /** Gets or sets probe position (center of the cube map) */
  112689. position: Vector3;
  112690. /**
  112691. * Creates a new reflection probe
  112692. * @param name defines the name of the probe
  112693. * @param size defines the texture resolution (for each face)
  112694. * @param scene defines the hosting scene
  112695. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  112696. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  112697. */
  112698. constructor(
  112699. /** defines the name of the probe */
  112700. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  112701. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  112702. samples: number;
  112703. /** Gets or sets the refresh rate to use (on every frame by default) */
  112704. refreshRate: number;
  112705. /**
  112706. * Gets the hosting scene
  112707. * @returns a Scene
  112708. */
  112709. getScene(): Scene;
  112710. /** Gets the internal CubeTexture used to render to */
  112711. readonly cubeTexture: RenderTargetTexture;
  112712. /** Gets the list of meshes to render */
  112713. readonly renderList: Nullable<AbstractMesh[]>;
  112714. /**
  112715. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  112716. * @param mesh defines the mesh to attach to
  112717. */
  112718. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112719. /**
  112720. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  112721. * @param renderingGroupId The rendering group id corresponding to its index
  112722. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  112723. */
  112724. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  112725. /**
  112726. * Clean all associated resources
  112727. */
  112728. dispose(): void;
  112729. /**
  112730. * Converts the reflection probe information to a readable string for debug purpose.
  112731. * @param fullDetails Supports for multiple levels of logging within scene loading
  112732. * @returns the human readable reflection probe info
  112733. */
  112734. toString(fullDetails?: boolean): string;
  112735. /**
  112736. * Get the class name of the relfection probe.
  112737. * @returns "ReflectionProbe"
  112738. */
  112739. getClassName(): string;
  112740. /**
  112741. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  112742. * @returns The JSON representation of the texture
  112743. */
  112744. serialize(): any;
  112745. /**
  112746. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  112747. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  112748. * @param scene Define the scene the parsed reflection probe should be instantiated in
  112749. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  112750. * @returns The parsed reflection probe if successful
  112751. */
  112752. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  112753. }
  112754. }
  112755. declare module BABYLON {
  112756. /** @hidden */
  112757. export var _BabylonLoaderRegistered: boolean;
  112758. }
  112759. declare module BABYLON {
  112760. /**
  112761. * The Physically based simple base material of BJS.
  112762. *
  112763. * This enables better naming and convention enforcements on top of the pbrMaterial.
  112764. * It is used as the base class for both the specGloss and metalRough conventions.
  112765. */
  112766. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  112767. /**
  112768. * Number of Simultaneous lights allowed on the material.
  112769. */
  112770. maxSimultaneousLights: number;
  112771. /**
  112772. * If sets to true, disables all the lights affecting the material.
  112773. */
  112774. disableLighting: boolean;
  112775. /**
  112776. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  112777. */
  112778. environmentTexture: BaseTexture;
  112779. /**
  112780. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112781. */
  112782. invertNormalMapX: boolean;
  112783. /**
  112784. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112785. */
  112786. invertNormalMapY: boolean;
  112787. /**
  112788. * Normal map used in the model.
  112789. */
  112790. normalTexture: BaseTexture;
  112791. /**
  112792. * Emissivie color used to self-illuminate the model.
  112793. */
  112794. emissiveColor: Color3;
  112795. /**
  112796. * Emissivie texture used to self-illuminate the model.
  112797. */
  112798. emissiveTexture: BaseTexture;
  112799. /**
  112800. * Occlusion Channel Strenght.
  112801. */
  112802. occlusionStrength: number;
  112803. /**
  112804. * Occlusion Texture of the material (adding extra occlusion effects).
  112805. */
  112806. occlusionTexture: BaseTexture;
  112807. /**
  112808. * Defines the alpha limits in alpha test mode.
  112809. */
  112810. alphaCutOff: number;
  112811. /**
  112812. * Gets the current double sided mode.
  112813. */
  112814. /**
  112815. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112816. */
  112817. doubleSided: boolean;
  112818. /**
  112819. * Stores the pre-calculated light information of a mesh in a texture.
  112820. */
  112821. lightmapTexture: BaseTexture;
  112822. /**
  112823. * If true, the light map contains occlusion information instead of lighting info.
  112824. */
  112825. useLightmapAsShadowmap: boolean;
  112826. /**
  112827. * Instantiates a new PBRMaterial instance.
  112828. *
  112829. * @param name The material name
  112830. * @param scene The scene the material will be use in.
  112831. */
  112832. constructor(name: string, scene: Scene);
  112833. getClassName(): string;
  112834. }
  112835. }
  112836. declare module BABYLON {
  112837. /**
  112838. * The PBR material of BJS following the metal roughness convention.
  112839. *
  112840. * This fits to the PBR convention in the GLTF definition:
  112841. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  112842. */
  112843. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  112844. /**
  112845. * The base color has two different interpretations depending on the value of metalness.
  112846. * When the material is a metal, the base color is the specific measured reflectance value
  112847. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  112848. * of the material.
  112849. */
  112850. baseColor: Color3;
  112851. /**
  112852. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  112853. * well as opacity information in the alpha channel.
  112854. */
  112855. baseTexture: BaseTexture;
  112856. /**
  112857. * Specifies the metallic scalar value of the material.
  112858. * Can also be used to scale the metalness values of the metallic texture.
  112859. */
  112860. metallic: number;
  112861. /**
  112862. * Specifies the roughness scalar value of the material.
  112863. * Can also be used to scale the roughness values of the metallic texture.
  112864. */
  112865. roughness: number;
  112866. /**
  112867. * Texture containing both the metallic value in the B channel and the
  112868. * roughness value in the G channel to keep better precision.
  112869. */
  112870. metallicRoughnessTexture: BaseTexture;
  112871. /**
  112872. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112873. *
  112874. * @param name The material name
  112875. * @param scene The scene the material will be use in.
  112876. */
  112877. constructor(name: string, scene: Scene);
  112878. /**
  112879. * Return the currrent class name of the material.
  112880. */
  112881. getClassName(): string;
  112882. /**
  112883. * Makes a duplicate of the current material.
  112884. * @param name - name to use for the new material.
  112885. */
  112886. clone(name: string): PBRMetallicRoughnessMaterial;
  112887. /**
  112888. * Serialize the material to a parsable JSON object.
  112889. */
  112890. serialize(): any;
  112891. /**
  112892. * Parses a JSON object correponding to the serialize function.
  112893. */
  112894. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  112895. }
  112896. }
  112897. declare module BABYLON {
  112898. /**
  112899. * The PBR material of BJS following the specular glossiness convention.
  112900. *
  112901. * This fits to the PBR convention in the GLTF definition:
  112902. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  112903. */
  112904. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  112905. /**
  112906. * Specifies the diffuse color of the material.
  112907. */
  112908. diffuseColor: Color3;
  112909. /**
  112910. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  112911. * channel.
  112912. */
  112913. diffuseTexture: BaseTexture;
  112914. /**
  112915. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  112916. */
  112917. specularColor: Color3;
  112918. /**
  112919. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  112920. */
  112921. glossiness: number;
  112922. /**
  112923. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  112924. */
  112925. specularGlossinessTexture: BaseTexture;
  112926. /**
  112927. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  112928. *
  112929. * @param name The material name
  112930. * @param scene The scene the material will be use in.
  112931. */
  112932. constructor(name: string, scene: Scene);
  112933. /**
  112934. * Return the currrent class name of the material.
  112935. */
  112936. getClassName(): string;
  112937. /**
  112938. * Makes a duplicate of the current material.
  112939. * @param name - name to use for the new material.
  112940. */
  112941. clone(name: string): PBRSpecularGlossinessMaterial;
  112942. /**
  112943. * Serialize the material to a parsable JSON object.
  112944. */
  112945. serialize(): any;
  112946. /**
  112947. * Parses a JSON object correponding to the serialize function.
  112948. */
  112949. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  112950. }
  112951. }
  112952. declare module BABYLON {
  112953. /**
  112954. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  112955. * It can help converting any input color in a desired output one. This can then be used to create effects
  112956. * from sepia, black and white to sixties or futuristic rendering...
  112957. *
  112958. * The only supported format is currently 3dl.
  112959. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  112960. */
  112961. export class ColorGradingTexture extends BaseTexture {
  112962. /**
  112963. * The current texture matrix. (will always be identity in color grading texture)
  112964. */
  112965. private _textureMatrix;
  112966. /**
  112967. * The texture URL.
  112968. */
  112969. url: string;
  112970. /**
  112971. * Empty line regex stored for GC.
  112972. */
  112973. private static _noneEmptyLineRegex;
  112974. private _engine;
  112975. /**
  112976. * Instantiates a ColorGradingTexture from the following parameters.
  112977. *
  112978. * @param url The location of the color gradind data (currently only supporting 3dl)
  112979. * @param scene The scene the texture will be used in
  112980. */
  112981. constructor(url: string, scene: Scene);
  112982. /**
  112983. * Returns the texture matrix used in most of the material.
  112984. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  112985. */
  112986. getTextureMatrix(): Matrix;
  112987. /**
  112988. * Occurs when the file being loaded is a .3dl LUT file.
  112989. */
  112990. private load3dlTexture;
  112991. /**
  112992. * Starts the loading process of the texture.
  112993. */
  112994. private loadTexture;
  112995. /**
  112996. * Clones the color gradind texture.
  112997. */
  112998. clone(): ColorGradingTexture;
  112999. /**
  113000. * Called during delayed load for textures.
  113001. */
  113002. delayLoad(): void;
  113003. /**
  113004. * Parses a color grading texture serialized by Babylon.
  113005. * @param parsedTexture The texture information being parsedTexture
  113006. * @param scene The scene to load the texture in
  113007. * @param rootUrl The root url of the data assets to load
  113008. * @return A color gradind texture
  113009. */
  113010. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  113011. /**
  113012. * Serializes the LUT texture to json format.
  113013. */
  113014. serialize(): any;
  113015. }
  113016. }
  113017. declare module BABYLON {
  113018. /**
  113019. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  113020. */
  113021. export class EquiRectangularCubeTexture extends BaseTexture {
  113022. /** The six faces of the cube. */
  113023. private static _FacesMapping;
  113024. private _noMipmap;
  113025. private _onLoad;
  113026. private _onError;
  113027. /** The size of the cubemap. */
  113028. private _size;
  113029. /** The buffer of the image. */
  113030. private _buffer;
  113031. /** The width of the input image. */
  113032. private _width;
  113033. /** The height of the input image. */
  113034. private _height;
  113035. /** The URL to the image. */
  113036. url: string;
  113037. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  113038. coordinatesMode: number;
  113039. /**
  113040. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  113041. * @param url The location of the image
  113042. * @param scene The scene the texture will be used in
  113043. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  113044. * @param noMipmap Forces to not generate the mipmap if true
  113045. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  113046. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  113047. * @param onLoad — defines a callback called when texture is loaded
  113048. * @param onError — defines a callback called if there is an error
  113049. */
  113050. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  113051. /**
  113052. * Load the image data, by putting the image on a canvas and extracting its buffer.
  113053. */
  113054. private loadImage;
  113055. /**
  113056. * Convert the image buffer into a cubemap and create a CubeTexture.
  113057. */
  113058. private loadTexture;
  113059. /**
  113060. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  113061. * @param buffer The ArrayBuffer that should be converted.
  113062. * @returns The buffer as Float32Array.
  113063. */
  113064. private getFloat32ArrayFromArrayBuffer;
  113065. /**
  113066. * Get the current class name of the texture useful for serialization or dynamic coding.
  113067. * @returns "EquiRectangularCubeTexture"
  113068. */
  113069. getClassName(): string;
  113070. /**
  113071. * Create a clone of the current EquiRectangularCubeTexture and return it.
  113072. * @returns A clone of the current EquiRectangularCubeTexture.
  113073. */
  113074. clone(): EquiRectangularCubeTexture;
  113075. }
  113076. }
  113077. declare module BABYLON {
  113078. /**
  113079. * Based on jsTGALoader - Javascript loader for TGA file
  113080. * By Vincent Thibault
  113081. * @see http://blog.robrowser.com/javascript-tga-loader.html
  113082. */
  113083. export class TGATools {
  113084. private static _TYPE_INDEXED;
  113085. private static _TYPE_RGB;
  113086. private static _TYPE_GREY;
  113087. private static _TYPE_RLE_INDEXED;
  113088. private static _TYPE_RLE_RGB;
  113089. private static _TYPE_RLE_GREY;
  113090. private static _ORIGIN_MASK;
  113091. private static _ORIGIN_SHIFT;
  113092. private static _ORIGIN_BL;
  113093. private static _ORIGIN_BR;
  113094. private static _ORIGIN_UL;
  113095. private static _ORIGIN_UR;
  113096. /**
  113097. * Gets the header of a TGA file
  113098. * @param data defines the TGA data
  113099. * @returns the header
  113100. */
  113101. static GetTGAHeader(data: Uint8Array): any;
  113102. /**
  113103. * Uploads TGA content to a Babylon Texture
  113104. * @hidden
  113105. */
  113106. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  113107. /** @hidden */
  113108. 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;
  113109. /** @hidden */
  113110. 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;
  113111. /** @hidden */
  113112. 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;
  113113. /** @hidden */
  113114. 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;
  113115. /** @hidden */
  113116. 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;
  113117. /** @hidden */
  113118. 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;
  113119. }
  113120. }
  113121. declare module BABYLON {
  113122. /**
  113123. * Implementation of the TGA Texture Loader.
  113124. * @hidden
  113125. */
  113126. export class _TGATextureLoader implements IInternalTextureLoader {
  113127. /**
  113128. * Defines wether the loader supports cascade loading the different faces.
  113129. */
  113130. readonly supportCascades: boolean;
  113131. /**
  113132. * This returns if the loader support the current file information.
  113133. * @param extension defines the file extension of the file being loaded
  113134. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113135. * @param fallback defines the fallback internal texture if any
  113136. * @param isBase64 defines whether the texture is encoded as a base64
  113137. * @param isBuffer defines whether the texture data are stored as a buffer
  113138. * @returns true if the loader can load the specified file
  113139. */
  113140. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113141. /**
  113142. * Transform the url before loading if required.
  113143. * @param rootUrl the url of the texture
  113144. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113145. * @returns the transformed texture
  113146. */
  113147. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113148. /**
  113149. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113150. * @param rootUrl the url of the texture
  113151. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113152. * @returns the fallback texture
  113153. */
  113154. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113155. /**
  113156. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113157. * @param data contains the texture data
  113158. * @param texture defines the BabylonJS internal texture
  113159. * @param createPolynomials will be true if polynomials have been requested
  113160. * @param onLoad defines the callback to trigger once the texture is ready
  113161. * @param onError defines the callback to trigger in case of error
  113162. */
  113163. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113164. /**
  113165. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113166. * @param data contains the texture data
  113167. * @param texture defines the BabylonJS internal texture
  113168. * @param callback defines the method to call once ready to upload
  113169. */
  113170. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113171. }
  113172. }
  113173. declare module BABYLON {
  113174. /**
  113175. * Info about the .basis files
  113176. */
  113177. class BasisFileInfo {
  113178. /**
  113179. * If the file has alpha
  113180. */
  113181. hasAlpha: boolean;
  113182. /**
  113183. * Info about each image of the basis file
  113184. */
  113185. images: Array<{
  113186. levels: Array<{
  113187. width: number;
  113188. height: number;
  113189. transcodedPixels: ArrayBufferView;
  113190. }>;
  113191. }>;
  113192. }
  113193. /**
  113194. * Result of transcoding a basis file
  113195. */
  113196. class TranscodeResult {
  113197. /**
  113198. * Info about the .basis file
  113199. */
  113200. fileInfo: BasisFileInfo;
  113201. /**
  113202. * Format to use when loading the file
  113203. */
  113204. format: number;
  113205. }
  113206. /**
  113207. * Configuration options for the Basis transcoder
  113208. */
  113209. export class BasisTranscodeConfiguration {
  113210. /**
  113211. * Supported compression formats used to determine the supported output format of the transcoder
  113212. */
  113213. supportedCompressionFormats?: {
  113214. /**
  113215. * etc1 compression format
  113216. */
  113217. etc1?: boolean;
  113218. /**
  113219. * s3tc compression format
  113220. */
  113221. s3tc?: boolean;
  113222. /**
  113223. * pvrtc compression format
  113224. */
  113225. pvrtc?: boolean;
  113226. /**
  113227. * etc2 compression format
  113228. */
  113229. etc2?: boolean;
  113230. };
  113231. /**
  113232. * If mipmap levels should be loaded for transcoded images (Default: true)
  113233. */
  113234. loadMipmapLevels?: boolean;
  113235. /**
  113236. * Index of a single image to load (Default: all images)
  113237. */
  113238. loadSingleImage?: number;
  113239. }
  113240. /**
  113241. * Used to load .Basis files
  113242. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  113243. */
  113244. export class BasisTools {
  113245. private static _IgnoreSupportedFormats;
  113246. /**
  113247. * URL to use when loading the basis transcoder
  113248. */
  113249. static JSModuleURL: string;
  113250. /**
  113251. * URL to use when loading the wasm module for the transcoder
  113252. */
  113253. static WasmModuleURL: string;
  113254. /**
  113255. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  113256. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  113257. * @returns internal format corresponding to the Basis format
  113258. */
  113259. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  113260. private static _WorkerPromise;
  113261. private static _Worker;
  113262. private static _actionId;
  113263. private static _CreateWorkerAsync;
  113264. /**
  113265. * Transcodes a loaded image file to compressed pixel data
  113266. * @param imageData image data to transcode
  113267. * @param config configuration options for the transcoding
  113268. * @returns a promise resulting in the transcoded image
  113269. */
  113270. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  113271. /**
  113272. * Loads a texture from the transcode result
  113273. * @param texture texture load to
  113274. * @param transcodeResult the result of transcoding the basis file to load from
  113275. */
  113276. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  113277. }
  113278. }
  113279. declare module BABYLON {
  113280. /**
  113281. * Loader for .basis file format
  113282. */
  113283. export class _BasisTextureLoader implements IInternalTextureLoader {
  113284. /**
  113285. * Defines whether the loader supports cascade loading the different faces.
  113286. */
  113287. readonly supportCascades: boolean;
  113288. /**
  113289. * This returns if the loader support the current file information.
  113290. * @param extension defines the file extension of the file being loaded
  113291. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113292. * @param fallback defines the fallback internal texture if any
  113293. * @param isBase64 defines whether the texture is encoded as a base64
  113294. * @param isBuffer defines whether the texture data are stored as a buffer
  113295. * @returns true if the loader can load the specified file
  113296. */
  113297. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113298. /**
  113299. * Transform the url before loading if required.
  113300. * @param rootUrl the url of the texture
  113301. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113302. * @returns the transformed texture
  113303. */
  113304. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113305. /**
  113306. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113307. * @param rootUrl the url of the texture
  113308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113309. * @returns the fallback texture
  113310. */
  113311. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113312. /**
  113313. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  113314. * @param data contains the texture data
  113315. * @param texture defines the BabylonJS internal texture
  113316. * @param createPolynomials will be true if polynomials have been requested
  113317. * @param onLoad defines the callback to trigger once the texture is ready
  113318. * @param onError defines the callback to trigger in case of error
  113319. */
  113320. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113321. /**
  113322. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113323. * @param data contains the texture data
  113324. * @param texture defines the BabylonJS internal texture
  113325. * @param callback defines the method to call once ready to upload
  113326. */
  113327. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113328. }
  113329. }
  113330. declare module BABYLON {
  113331. /**
  113332. * 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.
  113333. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113334. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113335. */
  113336. export class CustomProceduralTexture extends ProceduralTexture {
  113337. private _animate;
  113338. private _time;
  113339. private _config;
  113340. private _texturePath;
  113341. /**
  113342. * Instantiates a new Custom Procedural Texture.
  113343. * 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.
  113344. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113345. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113346. * @param name Define the name of the texture
  113347. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  113348. * @param size Define the size of the texture to create
  113349. * @param scene Define the scene the texture belongs to
  113350. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  113351. * @param generateMipMaps Define if the texture should creates mip maps or not
  113352. */
  113353. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113354. private _loadJson;
  113355. /**
  113356. * Is the texture ready to be used ? (rendered at least once)
  113357. * @returns true if ready, otherwise, false.
  113358. */
  113359. isReady(): boolean;
  113360. /**
  113361. * Render the texture to its associated render target.
  113362. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  113363. */
  113364. render(useCameraPostProcess?: boolean): void;
  113365. /**
  113366. * Update the list of dependant textures samplers in the shader.
  113367. */
  113368. updateTextures(): void;
  113369. /**
  113370. * Update the uniform values of the procedural texture in the shader.
  113371. */
  113372. updateShaderUniforms(): void;
  113373. /**
  113374. * Define if the texture animates or not.
  113375. */
  113376. animate: boolean;
  113377. }
  113378. }
  113379. declare module BABYLON {
  113380. /** @hidden */
  113381. export var noisePixelShader: {
  113382. name: string;
  113383. shader: string;
  113384. };
  113385. }
  113386. declare module BABYLON {
  113387. /**
  113388. * Class used to generate noise procedural textures
  113389. */
  113390. export class NoiseProceduralTexture extends ProceduralTexture {
  113391. private _time;
  113392. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  113393. brightness: number;
  113394. /** Defines the number of octaves to process */
  113395. octaves: number;
  113396. /** Defines the level of persistence (0.8 by default) */
  113397. persistence: number;
  113398. /** Gets or sets animation speed factor (default is 1) */
  113399. animationSpeedFactor: number;
  113400. /**
  113401. * Creates a new NoiseProceduralTexture
  113402. * @param name defines the name fo the texture
  113403. * @param size defines the size of the texture (default is 256)
  113404. * @param scene defines the hosting scene
  113405. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  113406. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  113407. */
  113408. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113409. private _updateShaderUniforms;
  113410. protected _getDefines(): string;
  113411. /** Generate the current state of the procedural texture */
  113412. render(useCameraPostProcess?: boolean): void;
  113413. /**
  113414. * Serializes this noise procedural texture
  113415. * @returns a serialized noise procedural texture object
  113416. */
  113417. serialize(): any;
  113418. /**
  113419. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  113420. * @param parsedTexture defines parsed texture data
  113421. * @param scene defines the current scene
  113422. * @param rootUrl defines the root URL containing noise procedural texture information
  113423. * @returns a parsed NoiseProceduralTexture
  113424. */
  113425. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  113426. }
  113427. }
  113428. declare module BABYLON {
  113429. /**
  113430. * Raw cube texture where the raw buffers are passed in
  113431. */
  113432. export class RawCubeTexture extends CubeTexture {
  113433. /**
  113434. * Creates a cube texture where the raw buffers are passed in.
  113435. * @param scene defines the scene the texture is attached to
  113436. * @param data defines the array of data to use to create each face
  113437. * @param size defines the size of the textures
  113438. * @param format defines the format of the data
  113439. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  113440. * @param generateMipMaps defines if the engine should generate the mip levels
  113441. * @param invertY defines if data must be stored with Y axis inverted
  113442. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  113443. * @param compression defines the compression used (null by default)
  113444. */
  113445. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  113446. /**
  113447. * Updates the raw cube texture.
  113448. * @param data defines the data to store
  113449. * @param format defines the data format
  113450. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113451. * @param invertY defines if data must be stored with Y axis inverted
  113452. * @param compression defines the compression used (null by default)
  113453. * @param level defines which level of the texture to update
  113454. */
  113455. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  113456. /**
  113457. * Updates a raw cube texture with RGBD encoded data.
  113458. * @param data defines the array of data [mipmap][face] to use to create each face
  113459. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  113460. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113461. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113462. * @returns a promsie that resolves when the operation is complete
  113463. */
  113464. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  113465. /**
  113466. * Clones the raw cube texture.
  113467. * @return a new cube texture
  113468. */
  113469. clone(): CubeTexture;
  113470. /** @hidden */
  113471. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113472. }
  113473. }
  113474. declare module BABYLON {
  113475. /**
  113476. * Class used to store 3D textures containing user data
  113477. */
  113478. export class RawTexture3D extends Texture {
  113479. /** Gets or sets the texture format to use */
  113480. format: number;
  113481. private _engine;
  113482. /**
  113483. * Create a new RawTexture3D
  113484. * @param data defines the data of the texture
  113485. * @param width defines the width of the texture
  113486. * @param height defines the height of the texture
  113487. * @param depth defines the depth of the texture
  113488. * @param format defines the texture format to use
  113489. * @param scene defines the hosting scene
  113490. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  113491. * @param invertY defines if texture must be stored with Y axis inverted
  113492. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  113493. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  113494. */
  113495. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  113496. /** Gets or sets the texture format to use */
  113497. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  113498. /**
  113499. * Update the texture with new data
  113500. * @param data defines the data to store in the texture
  113501. */
  113502. update(data: ArrayBufferView): void;
  113503. }
  113504. }
  113505. declare module BABYLON {
  113506. /**
  113507. * Creates a refraction texture used by refraction channel of the standard material.
  113508. * It is like a mirror but to see through a material.
  113509. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113510. */
  113511. export class RefractionTexture extends RenderTargetTexture {
  113512. /**
  113513. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  113514. * 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.
  113515. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113516. */
  113517. refractionPlane: Plane;
  113518. /**
  113519. * Define how deep under the surface we should see.
  113520. */
  113521. depth: number;
  113522. /**
  113523. * Creates a refraction texture used by refraction channel of the standard material.
  113524. * It is like a mirror but to see through a material.
  113525. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113526. * @param name Define the texture name
  113527. * @param size Define the size of the underlying texture
  113528. * @param scene Define the scene the refraction belongs to
  113529. * @param generateMipMaps Define if we need to generate mips level for the refraction
  113530. */
  113531. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  113532. /**
  113533. * Clone the refraction texture.
  113534. * @returns the cloned texture
  113535. */
  113536. clone(): RefractionTexture;
  113537. /**
  113538. * Serialize the texture to a JSON representation you could use in Parse later on
  113539. * @returns the serialized JSON representation
  113540. */
  113541. serialize(): any;
  113542. }
  113543. }
  113544. declare module BABYLON {
  113545. /**
  113546. * Defines the options related to the creation of an HtmlElementTexture
  113547. */
  113548. export interface IHtmlElementTextureOptions {
  113549. /**
  113550. * Defines wether mip maps should be created or not.
  113551. */
  113552. generateMipMaps?: boolean;
  113553. /**
  113554. * Defines the sampling mode of the texture.
  113555. */
  113556. samplingMode?: number;
  113557. /**
  113558. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  113559. */
  113560. engine: Nullable<Engine>;
  113561. /**
  113562. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  113563. */
  113564. scene: Nullable<Scene>;
  113565. }
  113566. /**
  113567. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  113568. * To be as efficient as possible depending on your constraints nothing aside the first upload
  113569. * is automatically managed.
  113570. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  113571. * in your application.
  113572. *
  113573. * As the update is not automatic, you need to call them manually.
  113574. */
  113575. export class HtmlElementTexture extends BaseTexture {
  113576. /**
  113577. * The texture URL.
  113578. */
  113579. element: HTMLVideoElement | HTMLCanvasElement;
  113580. private static readonly DefaultOptions;
  113581. private _textureMatrix;
  113582. private _engine;
  113583. private _isVideo;
  113584. private _generateMipMaps;
  113585. private _samplingMode;
  113586. /**
  113587. * Instantiates a HtmlElementTexture from the following parameters.
  113588. *
  113589. * @param name Defines the name of the texture
  113590. * @param element Defines the video or canvas the texture is filled with
  113591. * @param options Defines the other none mandatory texture creation options
  113592. */
  113593. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  113594. private _createInternalTexture;
  113595. /**
  113596. * Returns the texture matrix used in most of the material.
  113597. */
  113598. getTextureMatrix(): Matrix;
  113599. /**
  113600. * Updates the content of the texture.
  113601. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  113602. */
  113603. update(invertY?: Nullable<boolean>): void;
  113604. }
  113605. }
  113606. declare module BABYLON {
  113607. /**
  113608. * Enum used to define the target of a block
  113609. */
  113610. export enum NodeMaterialBlockTargets {
  113611. /** Vertex shader */
  113612. Vertex = 1,
  113613. /** Fragment shader */
  113614. Fragment = 2,
  113615. /** Vertex and Fragment */
  113616. VertexAndFragment = 3
  113617. }
  113618. }
  113619. declare module BABYLON {
  113620. /**
  113621. * Defines the kind of connection point for node based material
  113622. */
  113623. export enum NodeMaterialBlockConnectionPointTypes {
  113624. /** Float */
  113625. Float = 1,
  113626. /** Int */
  113627. Int = 2,
  113628. /** Vector2 */
  113629. Vector2 = 4,
  113630. /** Vector3 */
  113631. Vector3 = 8,
  113632. /** Vector4 */
  113633. Vector4 = 16,
  113634. /** Color3 */
  113635. Color3 = 32,
  113636. /** Color4 */
  113637. Color4 = 64,
  113638. /** Matrix */
  113639. Matrix = 128,
  113640. /** Texture */
  113641. Texture = 256,
  113642. /** Texture3D */
  113643. Texture3D = 512,
  113644. /** Vector3 or Color3 */
  113645. Vector3OrColor3 = 40,
  113646. /** Vector3 or Vector4 */
  113647. Vector3OrVector4 = 24,
  113648. /** Vector4 or Color4 */
  113649. Vector4OrColor4 = 80,
  113650. /** Color3 or Color4 */
  113651. Color3OrColor4 = 96,
  113652. /** Vector3 or Color3 */
  113653. Vector3OrColor3OrVector4OrColor4 = 120,
  113654. /** Detect type based on connection */
  113655. AutoDetect = 1024,
  113656. /** Output type that will be defined by input type */
  113657. BasedOnInput = 2048,
  113658. /** Light */
  113659. Light = 4096
  113660. }
  113661. }
  113662. declare module BABYLON {
  113663. /**
  113664. * Enum used to define well known values e.g. values automatically provided by the system
  113665. */
  113666. export enum NodeMaterialWellKnownValues {
  113667. /** World */
  113668. World = 1,
  113669. /** View */
  113670. View = 2,
  113671. /** Projection */
  113672. Projection = 3,
  113673. /** ViewProjection */
  113674. ViewProjection = 4,
  113675. /** WorldView */
  113676. WorldView = 5,
  113677. /** WorldViewProjection */
  113678. WorldViewProjection = 6,
  113679. /** CameraPosition */
  113680. CameraPosition = 7,
  113681. /** Will be filled by the block itself */
  113682. Automatic = 8
  113683. }
  113684. }
  113685. declare module BABYLON {
  113686. /**
  113687. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  113688. */
  113689. export enum NodeMaterialBlockConnectionPointMode {
  113690. /** Value is an uniform */
  113691. Uniform = 0,
  113692. /** Value is a mesh attribute */
  113693. Attribute = 1,
  113694. /** Value is a varying between vertex and fragment shaders */
  113695. Varying = 2,
  113696. /** Mode is undefined */
  113697. Undefined = 3
  113698. }
  113699. }
  113700. declare module BABYLON {
  113701. /**
  113702. * Class used to store shared data between 2 NodeMaterialBuildState
  113703. */
  113704. export class NodeMaterialBuildStateSharedData {
  113705. /**
  113706. * Gets the list of emitted varyings
  113707. */
  113708. varyings: string[];
  113709. /**
  113710. * Gets the varying declaration string
  113711. */
  113712. varyingDeclaration: string;
  113713. /**
  113714. * Uniform connection points
  113715. */
  113716. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  113717. /**
  113718. * Bindable blocks (Blocks that need to set data to the effect)
  113719. */
  113720. bindableBlocks: NodeMaterialBlock[];
  113721. /**
  113722. * List of blocks that can provide a compilation fallback
  113723. */
  113724. blocksWithFallbacks: NodeMaterialBlock[];
  113725. /**
  113726. * List of blocks that can provide a define update
  113727. */
  113728. blocksWithDefines: NodeMaterialBlock[];
  113729. /**
  113730. * List of blocks that can provide a repeatable content
  113731. */
  113732. repeatableContentBlocks: NodeMaterialBlock[];
  113733. /**
  113734. * List of blocks that can block the isReady function for the material
  113735. */
  113736. blockingBlocks: NodeMaterialBlock[];
  113737. /**
  113738. * Build Id used to avoid multiple recompilations
  113739. */
  113740. buildId: number;
  113741. /** List of emitted variables */
  113742. variableNames: {
  113743. [key: string]: number;
  113744. };
  113745. /** List of emitted defines */
  113746. defineNames: {
  113747. [key: string]: number;
  113748. };
  113749. /** Should emit comments? */
  113750. emitComments: boolean;
  113751. /** Emit build activity */
  113752. verbose: boolean;
  113753. /**
  113754. * Gets the compilation hints emitted at compilation time
  113755. */
  113756. hints: {
  113757. needWorldViewMatrix: boolean;
  113758. needWorldViewProjectionMatrix: boolean;
  113759. needAlphaBlending: boolean;
  113760. needAlphaTesting: boolean;
  113761. };
  113762. /**
  113763. * List of compilation checks
  113764. */
  113765. checks: {
  113766. emitVertex: boolean;
  113767. emitFragment: boolean;
  113768. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  113769. };
  113770. /** Creates a new shared data */
  113771. constructor();
  113772. /**
  113773. * Emits console errors and exceptions if there is a failing check
  113774. */
  113775. emitErrors(): void;
  113776. }
  113777. }
  113778. declare module BABYLON {
  113779. /**
  113780. * Class used to store node based material build state
  113781. */
  113782. export class NodeMaterialBuildState {
  113783. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  113784. supportUniformBuffers: boolean;
  113785. /**
  113786. * Gets the list of emitted attributes
  113787. */
  113788. attributes: string[];
  113789. /**
  113790. * Gets the list of emitted uniforms
  113791. */
  113792. uniforms: string[];
  113793. /**
  113794. * Gets the list of emitted uniform buffers
  113795. */
  113796. uniformBuffers: string[];
  113797. /**
  113798. * Gets the list of emitted samplers
  113799. */
  113800. samplers: string[];
  113801. /**
  113802. * Gets the list of emitted functions
  113803. */
  113804. functions: {
  113805. [key: string]: string;
  113806. };
  113807. /**
  113808. * Gets the target of the compilation state
  113809. */
  113810. target: NodeMaterialBlockTargets;
  113811. /**
  113812. * Gets the list of emitted counters
  113813. */
  113814. counters: {
  113815. [key: string]: number;
  113816. };
  113817. /**
  113818. * Shared data between multiple NodeMaterialBuildState instances
  113819. */
  113820. sharedData: NodeMaterialBuildStateSharedData;
  113821. /** @hidden */
  113822. _vertexState: NodeMaterialBuildState;
  113823. private _attributeDeclaration;
  113824. private _uniformDeclaration;
  113825. private _samplerDeclaration;
  113826. private _varyingTransfer;
  113827. private _repeatableContentAnchorIndex;
  113828. /** @hidden */
  113829. _builtCompilationString: string;
  113830. /**
  113831. * Gets the emitted compilation strings
  113832. */
  113833. compilationString: string;
  113834. /**
  113835. * Finalize the compilation strings
  113836. * @param state defines the current compilation state
  113837. */
  113838. finalize(state: NodeMaterialBuildState): void;
  113839. /** @hidden */
  113840. readonly _repeatableContentAnchor: string;
  113841. /** @hidden */
  113842. _getFreeVariableName(prefix: string): string;
  113843. /** @hidden */
  113844. _getFreeDefineName(prefix: string): string;
  113845. /** @hidden */
  113846. _excludeVariableName(name: string): void;
  113847. /** @hidden */
  113848. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  113849. /** @hidden */
  113850. _emitFunction(name: string, code: string, comments: string): void;
  113851. /** @hidden */
  113852. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  113853. replaceStrings?: {
  113854. search: RegExp;
  113855. replace: string;
  113856. }[];
  113857. }): string;
  113858. /** @hidden */
  113859. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  113860. repeatKey?: string;
  113861. removeAttributes?: boolean;
  113862. removeUniforms?: boolean;
  113863. removeVaryings?: boolean;
  113864. removeIfDef?: boolean;
  113865. replaceStrings?: {
  113866. search: RegExp;
  113867. replace: string;
  113868. }[];
  113869. }, storeKey?: string): void;
  113870. /** @hidden */
  113871. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  113872. private _emitDefine;
  113873. /** @hidden */
  113874. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  113875. }
  113876. }
  113877. declare module BABYLON {
  113878. /**
  113879. * Root class for all node material optimizers
  113880. */
  113881. export class NodeMaterialOptimizer {
  113882. /**
  113883. * Function used to optimize a NodeMaterial graph
  113884. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  113885. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  113886. */
  113887. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  113888. }
  113889. }
  113890. declare module BABYLON {
  113891. /**
  113892. * Block used to transform a vector4 with a matrix
  113893. */
  113894. export class Vector4TransformBlock extends NodeMaterialBlock {
  113895. /**
  113896. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113897. */
  113898. complementW: number;
  113899. /**
  113900. * Creates a new Vector4TransformBlock
  113901. * @param name defines the block name
  113902. */
  113903. constructor(name: string);
  113904. /**
  113905. * Gets the current class name
  113906. * @returns the class name
  113907. */
  113908. getClassName(): string;
  113909. /**
  113910. * Gets the vector input
  113911. */
  113912. readonly vector: NodeMaterialConnectionPoint;
  113913. /**
  113914. * Gets the output component
  113915. */
  113916. readonly output: NodeMaterialConnectionPoint;
  113917. /**
  113918. * Gets the matrix transform input
  113919. */
  113920. readonly transform: NodeMaterialConnectionPoint;
  113921. protected _buildBlock(state: NodeMaterialBuildState): this;
  113922. }
  113923. }
  113924. declare module BABYLON {
  113925. /**
  113926. * Block used to output the vertex position
  113927. */
  113928. export class VertexOutputBlock extends NodeMaterialBlock {
  113929. /**
  113930. * Creates a new VertexOutputBlock
  113931. * @param name defines the block name
  113932. */
  113933. constructor(name: string);
  113934. /**
  113935. * Gets the current class name
  113936. * @returns the class name
  113937. */
  113938. getClassName(): string;
  113939. /**
  113940. * Gets the vector input component
  113941. */
  113942. readonly vector: NodeMaterialConnectionPoint;
  113943. protected _buildBlock(state: NodeMaterialBuildState): this;
  113944. }
  113945. }
  113946. declare module BABYLON {
  113947. /**
  113948. * Block used to output the final color
  113949. */
  113950. export class FragmentOutputBlock extends NodeMaterialBlock {
  113951. /**
  113952. * Gets or sets a boolean indicating if this block will output an alpha value
  113953. */
  113954. alphaBlendingEnabled: boolean;
  113955. /**
  113956. * Create a new FragmentOutputBlock
  113957. * @param name defines the block name
  113958. */
  113959. constructor(name: string);
  113960. /**
  113961. * Gets the current class name
  113962. * @returns the class name
  113963. */
  113964. getClassName(): string;
  113965. /**
  113966. * Gets the color input component
  113967. */
  113968. readonly color: NodeMaterialConnectionPoint;
  113969. protected _buildBlock(state: NodeMaterialBuildState): this;
  113970. }
  113971. }
  113972. declare module BABYLON {
  113973. /**
  113974. * Interface used to configure the node material editor
  113975. */
  113976. export interface INodeMaterialEditorOptions {
  113977. /** Define the URl to load node editor script */
  113978. editorURL?: string;
  113979. }
  113980. /** @hidden */
  113981. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  113982. /** BONES */
  113983. NUM_BONE_INFLUENCERS: number;
  113984. BonesPerMesh: number;
  113985. BONETEXTURE: boolean;
  113986. /** MORPH TARGETS */
  113987. MORPHTARGETS: boolean;
  113988. MORPHTARGETS_NORMAL: boolean;
  113989. MORPHTARGETS_TANGENT: boolean;
  113990. MORPHTARGETS_UV: boolean;
  113991. NUM_MORPH_INFLUENCERS: number;
  113992. /** IMAGE PROCESSING */
  113993. IMAGEPROCESSING: boolean;
  113994. VIGNETTE: boolean;
  113995. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113996. VIGNETTEBLENDMODEOPAQUE: boolean;
  113997. TONEMAPPING: boolean;
  113998. TONEMAPPING_ACES: boolean;
  113999. CONTRAST: boolean;
  114000. EXPOSURE: boolean;
  114001. COLORCURVES: boolean;
  114002. COLORGRADING: boolean;
  114003. COLORGRADING3D: boolean;
  114004. SAMPLER3DGREENDEPTH: boolean;
  114005. SAMPLER3DBGRMAP: boolean;
  114006. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114007. constructor();
  114008. setValue(name: string, value: boolean): void;
  114009. }
  114010. /**
  114011. * Class used to configure NodeMaterial
  114012. */
  114013. export interface INodeMaterialOptions {
  114014. /**
  114015. * Defines if blocks should emit comments
  114016. */
  114017. emitComments: boolean;
  114018. }
  114019. /**
  114020. * Class used to create a node based material built by assembling shader blocks
  114021. */
  114022. export class NodeMaterial extends PushMaterial {
  114023. private _options;
  114024. private _vertexCompilationState;
  114025. private _fragmentCompilationState;
  114026. private _sharedData;
  114027. private _buildId;
  114028. private _buildWasSuccessful;
  114029. private _cachedWorldViewMatrix;
  114030. private _cachedWorldViewProjectionMatrix;
  114031. private _textureConnectionPoints;
  114032. private _optimizers;
  114033. /** Define the URl to load node editor script */
  114034. static EditorURL: string;
  114035. private BJSNODEMATERIALEDITOR;
  114036. /** Get the inspector from bundle or global */
  114037. private _getGlobalNodeMaterialEditor;
  114038. /**
  114039. * Defines the maximum number of lights that can be used in the material
  114040. */
  114041. maxSimultaneousLights: number;
  114042. /**
  114043. * Observable raised when the material is built
  114044. */
  114045. onBuildObservable: Observable<NodeMaterial>;
  114046. /**
  114047. * Gets or sets the root nodes of the material vertex shader
  114048. */
  114049. _vertexOutputNodes: NodeMaterialBlock[];
  114050. /**
  114051. * Gets or sets the root nodes of the material fragment (pixel) shader
  114052. */
  114053. _fragmentOutputNodes: NodeMaterialBlock[];
  114054. /** Gets or sets options to control the node material overall behavior */
  114055. options: INodeMaterialOptions;
  114056. /**
  114057. * Default configuration related to image processing available in the standard Material.
  114058. */
  114059. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114060. /**
  114061. * Gets the image processing configuration used either in this material.
  114062. */
  114063. /**
  114064. * Sets the Default image processing configuration used either in the this material.
  114065. *
  114066. * If sets to null, the scene one is in use.
  114067. */
  114068. imageProcessingConfiguration: ImageProcessingConfiguration;
  114069. /**
  114070. * Create a new node based material
  114071. * @param name defines the material name
  114072. * @param scene defines the hosting scene
  114073. * @param options defines creation option
  114074. */
  114075. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  114076. /**
  114077. * Gets the current class name of the material e.g. "NodeMaterial"
  114078. * @returns the class name
  114079. */
  114080. getClassName(): string;
  114081. /**
  114082. * Keep track of the image processing observer to allow dispose and replace.
  114083. */
  114084. private _imageProcessingObserver;
  114085. /**
  114086. * Attaches a new image processing configuration to the Standard Material.
  114087. * @param configuration
  114088. */
  114089. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114090. /**
  114091. * Adds a new optimizer to the list of optimizers
  114092. * @param optimizer defines the optimizers to add
  114093. * @returns the current material
  114094. */
  114095. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  114096. /**
  114097. * Remove an optimizer from the list of optimizers
  114098. * @param optimizer defines the optimizers to remove
  114099. * @returns the current material
  114100. */
  114101. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  114102. /**
  114103. * Add a new block to the list of output nodes
  114104. * @param node defines the node to add
  114105. * @returns the current material
  114106. */
  114107. addOutputNode(node: NodeMaterialBlock): this;
  114108. /**
  114109. * Remove a block from the list of root nodes
  114110. * @param node defines the node to remove
  114111. * @returns the current material
  114112. */
  114113. removeOutputNode(node: NodeMaterialBlock): this;
  114114. private _addVertexOutputNode;
  114115. private _removeVertexOutputNode;
  114116. private _addFragmentOutputNode;
  114117. private _removeFragmentOutputNode;
  114118. /**
  114119. * Specifies if the material will require alpha blending
  114120. * @returns a boolean specifying if alpha blending is needed
  114121. */
  114122. needAlphaBlending(): boolean;
  114123. /**
  114124. * Specifies if this material should be rendered in alpha test mode
  114125. * @returns a boolean specifying if an alpha test is needed.
  114126. */
  114127. needAlphaTesting(): boolean;
  114128. private _initializeBlock;
  114129. private _resetDualBlocks;
  114130. /**
  114131. * Build the material and generates the inner effect
  114132. * @param verbose defines if the build should log activity
  114133. */
  114134. build(verbose?: boolean): void;
  114135. /**
  114136. * Runs an otpimization phase to try to improve the shader code
  114137. */
  114138. optimize(): void;
  114139. private _prepareDefinesForAttributes;
  114140. /**
  114141. * Get if the submesh is ready to be used and all its information available.
  114142. * Child classes can use it to update shaders
  114143. * @param mesh defines the mesh to check
  114144. * @param subMesh defines which submesh to check
  114145. * @param useInstances specifies that instances should be used
  114146. * @returns a boolean indicating that the submesh is ready or not
  114147. */
  114148. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114149. /**
  114150. * Binds the world matrix to the material
  114151. * @param world defines the world transformation matrix
  114152. */
  114153. bindOnlyWorldMatrix(world: Matrix): void;
  114154. /**
  114155. * Binds the submesh to this material by preparing the effect and shader to draw
  114156. * @param world defines the world transformation matrix
  114157. * @param mesh defines the mesh containing the submesh
  114158. * @param subMesh defines the submesh to bind the material to
  114159. */
  114160. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114161. /**
  114162. * Gets the active textures from the material
  114163. * @returns an array of textures
  114164. */
  114165. getActiveTextures(): BaseTexture[];
  114166. /**
  114167. * Specifies if the material uses a texture
  114168. * @param texture defines the texture to check against the material
  114169. * @returns a boolean specifying if the material uses the texture
  114170. */
  114171. hasTexture(texture: BaseTexture): boolean;
  114172. /**
  114173. * Disposes the material
  114174. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  114175. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  114176. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  114177. */
  114178. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  114179. /** Creates the node editor window. */
  114180. private _createNodeEditor;
  114181. /**
  114182. * Launch the node material editor
  114183. * @param config Define the configuration of the editor
  114184. * @return a promise fulfilled when the node editor is visible
  114185. */
  114186. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  114187. /**
  114188. * Clear the current material
  114189. */
  114190. clear(): void;
  114191. /**
  114192. * Clear the current material and set it to a default state
  114193. */
  114194. setToDefault(): void;
  114195. }
  114196. }
  114197. declare module BABYLON {
  114198. /**
  114199. * Defines a block that can be used inside a node based material
  114200. */
  114201. export class NodeMaterialBlock {
  114202. private _buildId;
  114203. private _target;
  114204. private _isFinalMerger;
  114205. /** @hidden */
  114206. _inputs: NodeMaterialConnectionPoint[];
  114207. /** @hidden */
  114208. _outputs: NodeMaterialConnectionPoint[];
  114209. /**
  114210. * Gets or sets the name of the block
  114211. */
  114212. name: string;
  114213. /**
  114214. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  114215. */
  114216. readonly isFinalMerger: boolean;
  114217. /**
  114218. * Gets or sets the build Id
  114219. */
  114220. buildId: number;
  114221. /**
  114222. * Gets or sets the target of the block
  114223. */
  114224. target: NodeMaterialBlockTargets;
  114225. /**
  114226. * Gets the list of input points
  114227. */
  114228. readonly inputs: NodeMaterialConnectionPoint[];
  114229. /** Gets the list of output points */
  114230. readonly outputs: NodeMaterialConnectionPoint[];
  114231. /**
  114232. * Find an input by its name
  114233. * @param name defines the name of the input to look for
  114234. * @returns the input or null if not found
  114235. */
  114236. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114237. /**
  114238. * Find an output by its name
  114239. * @param name defines the name of the outputto look for
  114240. * @returns the output or null if not found
  114241. */
  114242. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114243. /**
  114244. * Creates a new NodeMaterialBlock
  114245. * @param name defines the block name
  114246. * @param target defines the target of that block (Vertex by default)
  114247. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  114248. */
  114249. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  114250. /**
  114251. * Initialize the block and prepare the context for build
  114252. * @param state defines the state that will be used for the build
  114253. */
  114254. initialize(state: NodeMaterialBuildState): void;
  114255. /**
  114256. * Bind data to effect. Will only be called for blocks with isBindable === true
  114257. * @param effect defines the effect to bind data to
  114258. * @param nodeMaterial defines the hosting NodeMaterial
  114259. * @param mesh defines the mesh that will be rendered
  114260. */
  114261. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114262. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  114263. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  114264. protected _writeFloat(value: number): string;
  114265. /**
  114266. * Gets the current class name e.g. "NodeMaterialBlock"
  114267. * @returns the class name
  114268. */
  114269. getClassName(): string;
  114270. /**
  114271. * Register a new input. Must be called inside a block constructor
  114272. * @param name defines the connection point name
  114273. * @param type defines the connection point type
  114274. * @param isOptional defines a boolean indicating that this input can be omitted
  114275. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114276. * @returns the current block
  114277. */
  114278. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  114279. /**
  114280. * Register a new output. Must be called inside a block constructor
  114281. * @param name defines the connection point name
  114282. * @param type defines the connection point type
  114283. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114284. * @returns the current block
  114285. */
  114286. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  114287. /**
  114288. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  114289. * @param forOutput defines an optional connection point to check compatibility with
  114290. * @returns the first available input or null
  114291. */
  114292. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  114293. /**
  114294. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  114295. * @param forBlock defines an optional block to check compatibility with
  114296. * @returns the first available input or null
  114297. */
  114298. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  114299. /**
  114300. * Connect current block with another block
  114301. * @param other defines the block to connect with
  114302. * @param options define the various options to help pick the right connections
  114303. * @returns the current block
  114304. */
  114305. connectTo(other: NodeMaterialBlock, options?: {
  114306. input?: string;
  114307. output?: string;
  114308. outputSwizzle?: string;
  114309. }): this | undefined;
  114310. protected _buildBlock(state: NodeMaterialBuildState): void;
  114311. /**
  114312. * Add potential fallbacks if shader compilation fails
  114313. * @param mesh defines the mesh to be rendered
  114314. * @param fallbacks defines the current prioritized list of fallbacks
  114315. */
  114316. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114317. /**
  114318. * Update defines for shader compilation
  114319. * @param mesh defines the mesh to be rendered
  114320. * @param nodeMaterial defines the node material requesting the update
  114321. * @param defines defines the material defines to update
  114322. * @param useInstances specifies that instances should be used
  114323. */
  114324. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114325. /**
  114326. * Lets the block try to connect some inputs automatically
  114327. */
  114328. autoConfigure(): void;
  114329. /**
  114330. * Function called when a block is declared as repeatable content generator
  114331. * @param vertexShaderState defines the current compilation state for the vertex shader
  114332. * @param fragmentShaderState defines the current compilation state for the fragment shader
  114333. * @param mesh defines the mesh to be rendered
  114334. * @param defines defines the material defines to update
  114335. */
  114336. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114337. /**
  114338. * Checks if the block is ready
  114339. * @param mesh defines the mesh to be rendered
  114340. * @param nodeMaterial defines the node material requesting the update
  114341. * @param defines defines the material defines to update
  114342. * @param useInstances specifies that instances should be used
  114343. * @returns true if the block is ready
  114344. */
  114345. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  114346. /**
  114347. * Compile the current node and generate the shader code
  114348. * @param state defines the current compilation state (uniforms, samplers, current string)
  114349. * @returns the current block
  114350. */
  114351. build(state: NodeMaterialBuildState): this | undefined;
  114352. }
  114353. }
  114354. declare module BABYLON {
  114355. /**
  114356. * Defines a connection point for a block
  114357. */
  114358. export class NodeMaterialConnectionPoint {
  114359. /** @hidden */
  114360. _ownerBlock: NodeMaterialBlock;
  114361. /** @hidden */
  114362. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114363. private _associatedVariableName;
  114364. private _endpoints;
  114365. private _storedValue;
  114366. private _valueCallback;
  114367. private _mode;
  114368. /** @hidden */
  114369. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114370. /** @hidden */
  114371. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  114372. /** @hidden */
  114373. _needToEmitVarying: boolean;
  114374. /** @hidden */
  114375. _forceUniformInVertexShaderOnly: boolean;
  114376. private _type;
  114377. /**
  114378. * Gets or sets the connection point type (default is float)
  114379. */
  114380. type: NodeMaterialBlockConnectionPointTypes;
  114381. /**
  114382. * Gets or sets the connection point name
  114383. */
  114384. name: string;
  114385. /**
  114386. * Gets or sets the swizzle to apply to this connection point when reading or writing
  114387. */
  114388. swizzle: string;
  114389. /**
  114390. * Gets or sets a boolean indicating that this connection point can be omitted
  114391. */
  114392. isOptional: boolean;
  114393. /**
  114394. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  114395. */
  114396. define: string;
  114397. /** Gets or sets the target of that connection point */
  114398. target: NodeMaterialBlockTargets;
  114399. /**
  114400. * Gets or sets the value of that point.
  114401. * Please note that this value will be ignored if valueCallback is defined
  114402. */
  114403. value: any;
  114404. /**
  114405. * Gets or sets a callback used to get the value of that point.
  114406. * Please note that setting this value will force the connection point to ignore the value property
  114407. */
  114408. valueCallback: () => any;
  114409. /**
  114410. * Gets or sets the associated variable name in the shader
  114411. */
  114412. associatedVariableName: string;
  114413. /**
  114414. * Gets a boolean indicating that this connection point not defined yet
  114415. */
  114416. readonly isUndefined: boolean;
  114417. /**
  114418. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  114419. * In this case the connection point name must be the name of the uniform to use.
  114420. * Can only be set on inputs
  114421. */
  114422. isUniform: boolean;
  114423. /**
  114424. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  114425. * In this case the connection point name must be the name of the attribute to use
  114426. * Can only be set on inputs
  114427. */
  114428. isAttribute: boolean;
  114429. /**
  114430. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  114431. * Can only be set on exit points
  114432. */
  114433. isVarying: boolean;
  114434. /** Get the other side of the connection (if any) */
  114435. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114436. /** Get the block that owns this connection point */
  114437. readonly ownerBlock: NodeMaterialBlock;
  114438. /** Get the block connected on the other side of this connection (if any) */
  114439. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  114440. /** Get the block connected on the endpoints of this connection (if any) */
  114441. readonly connectedBlocks: Array<NodeMaterialBlock>;
  114442. /**
  114443. * Creates a new connection point
  114444. * @param name defines the connection point name
  114445. * @param ownerBlock defines the block hosting this connection point
  114446. */
  114447. constructor(name: string, ownerBlock: NodeMaterialBlock);
  114448. /**
  114449. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  114450. * @returns the class name
  114451. */
  114452. getClassName(): string;
  114453. /**
  114454. * Set the source of this connection point to a vertex attribute
  114455. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  114456. * @returns the current connection point
  114457. */
  114458. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  114459. /**
  114460. * Set the source of this connection point to a well known value
  114461. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  114462. * @returns the current connection point
  114463. */
  114464. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  114465. /**
  114466. * Gets a boolean indicating that the current connection point is a well known value
  114467. */
  114468. readonly isWellKnownValue: boolean;
  114469. /**
  114470. * Gets or sets the current well known value or null if not defined as well know value
  114471. */
  114472. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114473. private _getTypeLength;
  114474. /**
  114475. * Connect this point to another connection point
  114476. * @param connectionPoint defines the other connection point
  114477. * @returns the current connection point
  114478. */
  114479. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114480. /**
  114481. * Disconnect this point from one of his endpoint
  114482. * @param endpoint defines the other connection point
  114483. * @returns the current connection point
  114484. */
  114485. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114486. /**
  114487. * When connection point is an uniform, this function will send its value to the effect
  114488. * @param effect defines the effect to transmit value to
  114489. * @param world defines the world matrix
  114490. * @param worldView defines the worldxview matrix
  114491. * @param worldViewProjection defines the worldxviewxprojection matrix
  114492. */
  114493. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  114494. /**
  114495. * When connection point is an uniform, this function will send its value to the effect
  114496. * @param effect defines the effect to transmit value to
  114497. * @param scene defines the hosting scene
  114498. */
  114499. transmit(effect: Effect, scene: Scene): void;
  114500. }
  114501. }
  114502. declare module BABYLON {
  114503. /**
  114504. * Block used to add support for vertex skinning (bones)
  114505. */
  114506. export class BonesBlock extends NodeMaterialBlock {
  114507. /**
  114508. * Creates a new BonesBlock
  114509. * @param name defines the block name
  114510. */
  114511. constructor(name: string);
  114512. /**
  114513. * Initialize the block and prepare the context for build
  114514. * @param state defines the state that will be used for the build
  114515. */
  114516. initialize(state: NodeMaterialBuildState): void;
  114517. /**
  114518. * Gets the current class name
  114519. * @returns the class name
  114520. */
  114521. getClassName(): string;
  114522. /**
  114523. * Gets the matrix indices input component
  114524. */
  114525. readonly matricesIndices: NodeMaterialConnectionPoint;
  114526. /**
  114527. * Gets the matrix weights input component
  114528. */
  114529. readonly matricesWeights: NodeMaterialConnectionPoint;
  114530. /**
  114531. * Gets the extra matrix indices input component
  114532. */
  114533. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  114534. /**
  114535. * Gets the extra matrix weights input component
  114536. */
  114537. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  114538. /**
  114539. * Gets the world input component
  114540. */
  114541. readonly world: NodeMaterialConnectionPoint;
  114542. /**
  114543. * Gets the output component
  114544. */
  114545. readonly output: NodeMaterialConnectionPoint;
  114546. autoConfigure(): void;
  114547. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114548. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114549. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114550. protected _buildBlock(state: NodeMaterialBuildState): this;
  114551. }
  114552. }
  114553. declare module BABYLON {
  114554. /**
  114555. * Block used to add support for instances
  114556. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114557. */
  114558. export class InstancesBlock extends NodeMaterialBlock {
  114559. /**
  114560. * Creates a new InstancesBlock
  114561. * @param name defines the block name
  114562. */
  114563. constructor(name: string);
  114564. /**
  114565. * Gets the current class name
  114566. * @returns the class name
  114567. */
  114568. getClassName(): string;
  114569. /**
  114570. * Gets the first world row input component
  114571. */
  114572. readonly world0: NodeMaterialConnectionPoint;
  114573. /**
  114574. * Gets the second world row input component
  114575. */
  114576. readonly world1: NodeMaterialConnectionPoint;
  114577. /**
  114578. * Gets the third world row input component
  114579. */
  114580. readonly world2: NodeMaterialConnectionPoint;
  114581. /**
  114582. * Gets the forth world row input component
  114583. */
  114584. readonly world3: NodeMaterialConnectionPoint;
  114585. /**
  114586. * Gets the world input component
  114587. */
  114588. readonly world: NodeMaterialConnectionPoint;
  114589. /**
  114590. * Gets the output component
  114591. */
  114592. readonly output: NodeMaterialConnectionPoint;
  114593. autoConfigure(): void;
  114594. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114595. protected _buildBlock(state: NodeMaterialBuildState): this;
  114596. }
  114597. }
  114598. declare module BABYLON {
  114599. /**
  114600. * Block used to add morph targets support to vertex shader
  114601. */
  114602. export class MorphTargetsBlock extends NodeMaterialBlock {
  114603. private _repeatableContentAnchor;
  114604. private _repeatebleContentGenerated;
  114605. /**
  114606. * Create a new MorphTargetsBlock
  114607. * @param name defines the block name
  114608. */
  114609. constructor(name: string);
  114610. /**
  114611. * Gets the current class name
  114612. * @returns the class name
  114613. */
  114614. getClassName(): string;
  114615. /**
  114616. * Gets the position input component
  114617. */
  114618. readonly position: NodeMaterialConnectionPoint;
  114619. /**
  114620. * Gets the normal input component
  114621. */
  114622. readonly normal: NodeMaterialConnectionPoint;
  114623. /**
  114624. * Gets the tangent input component
  114625. */
  114626. readonly tangent: NodeMaterialConnectionPoint;
  114627. /**
  114628. * Gets the tangent input component
  114629. */
  114630. readonly uv: NodeMaterialConnectionPoint;
  114631. /**
  114632. * Gets the position output component
  114633. */
  114634. readonly positionOutput: NodeMaterialConnectionPoint;
  114635. /**
  114636. * Gets the normal output component
  114637. */
  114638. readonly normalOutput: NodeMaterialConnectionPoint;
  114639. /**
  114640. * Gets the tangent output component
  114641. */
  114642. readonly tangentOutput: NodeMaterialConnectionPoint;
  114643. /**
  114644. * Gets the tangent output component
  114645. */
  114646. readonly uvOutput: NodeMaterialConnectionPoint;
  114647. initialize(state: NodeMaterialBuildState): void;
  114648. autoConfigure(): void;
  114649. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114650. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114651. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114652. protected _buildBlock(state: NodeMaterialBuildState): this;
  114653. }
  114654. }
  114655. declare module BABYLON {
  114656. /**
  114657. * Block used to add an alpha test in the fragment shader
  114658. */
  114659. export class AlphaTestBlock extends NodeMaterialBlock {
  114660. /**
  114661. * Gets or sets the alpha value where alpha testing happens
  114662. */
  114663. alphaCutOff: number;
  114664. /**
  114665. * Create a new AlphaTestBlock
  114666. * @param name defines the block name
  114667. */
  114668. constructor(name: string);
  114669. /**
  114670. * Gets the current class name
  114671. * @returns the class name
  114672. */
  114673. getClassName(): string;
  114674. /**
  114675. * Gets the color input component
  114676. */
  114677. readonly color: NodeMaterialConnectionPoint;
  114678. protected _buildBlock(state: NodeMaterialBuildState): this;
  114679. }
  114680. }
  114681. declare module BABYLON {
  114682. /**
  114683. * Block used to create a Color4 out of 4 inputs (one for each component)
  114684. */
  114685. export class RGBAMergerBlock extends NodeMaterialBlock {
  114686. /**
  114687. * Create a new RGBAMergerBlock
  114688. * @param name defines the block name
  114689. */
  114690. constructor(name: string);
  114691. /**
  114692. * Gets the current class name
  114693. * @returns the class name
  114694. */
  114695. getClassName(): string;
  114696. /**
  114697. * Gets the R input component
  114698. */
  114699. readonly r: NodeMaterialConnectionPoint;
  114700. /**
  114701. * Gets the G input component
  114702. */
  114703. readonly g: NodeMaterialConnectionPoint;
  114704. /**
  114705. * Gets the B input component
  114706. */
  114707. readonly b: NodeMaterialConnectionPoint;
  114708. /**
  114709. * Gets the RGB input component
  114710. */
  114711. readonly rgb: NodeMaterialConnectionPoint;
  114712. /**
  114713. * Gets the R input component
  114714. */
  114715. readonly a: NodeMaterialConnectionPoint;
  114716. /**
  114717. * Gets the output component
  114718. */
  114719. readonly output: NodeMaterialConnectionPoint;
  114720. protected _buildBlock(state: NodeMaterialBuildState): this;
  114721. }
  114722. }
  114723. declare module BABYLON {
  114724. /**
  114725. * Block used to create a Color3 out of 3 inputs (one for each component)
  114726. */
  114727. export class RGBMergerBlock extends NodeMaterialBlock {
  114728. /**
  114729. * Create a new RGBMergerBlock
  114730. * @param name defines the block name
  114731. */
  114732. constructor(name: string);
  114733. /**
  114734. * Gets the current class name
  114735. * @returns the class name
  114736. */
  114737. getClassName(): string;
  114738. /**
  114739. * Gets the R component input
  114740. */
  114741. readonly r: NodeMaterialConnectionPoint;
  114742. /**
  114743. * Gets the G component input
  114744. */
  114745. readonly g: NodeMaterialConnectionPoint;
  114746. /**
  114747. * Gets the B component input
  114748. */
  114749. readonly b: NodeMaterialConnectionPoint;
  114750. /**
  114751. * Gets the output component
  114752. */
  114753. readonly output: NodeMaterialConnectionPoint;
  114754. protected _buildBlock(state: NodeMaterialBuildState): this;
  114755. }
  114756. }
  114757. declare module BABYLON {
  114758. /**
  114759. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  114760. */
  114761. export class RGBASplitterBlock extends NodeMaterialBlock {
  114762. /**
  114763. * Create a new RGBASplitterBlock
  114764. * @param name defines the block name
  114765. */
  114766. constructor(name: string);
  114767. /**
  114768. * Gets the current class name
  114769. * @returns the class name
  114770. */
  114771. getClassName(): string;
  114772. /**
  114773. * Gets the input component
  114774. */
  114775. readonly input: NodeMaterialConnectionPoint;
  114776. protected _buildBlock(state: NodeMaterialBuildState): this;
  114777. }
  114778. }
  114779. declare module BABYLON {
  114780. /**
  114781. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  114782. */
  114783. export class RGBSplitterBlock extends NodeMaterialBlock {
  114784. /**
  114785. * Create a new RGBSplitterBlock
  114786. * @param name defines the block name
  114787. */
  114788. constructor(name: string);
  114789. /**
  114790. * Gets the current class name
  114791. * @returns the class name
  114792. */
  114793. getClassName(): string;
  114794. /**
  114795. * Gets the input component
  114796. */
  114797. readonly input: NodeMaterialConnectionPoint;
  114798. protected _buildBlock(state: NodeMaterialBuildState): this;
  114799. }
  114800. }
  114801. declare module BABYLON {
  114802. /**
  114803. * Block used to read a texture from a sampler
  114804. */
  114805. export class TextureBlock extends NodeMaterialBlock {
  114806. private _defineName;
  114807. /**
  114808. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  114809. */
  114810. autoConnectTextureMatrix: boolean;
  114811. /**
  114812. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  114813. */
  114814. autoSelectUV: boolean;
  114815. /**
  114816. * Create a new TextureBlock
  114817. * @param name defines the block name
  114818. */
  114819. constructor(name: string);
  114820. /**
  114821. * Gets the current class name
  114822. * @returns the class name
  114823. */
  114824. getClassName(): string;
  114825. /**
  114826. * Gets the uv input component
  114827. */
  114828. readonly uv: NodeMaterialConnectionPoint;
  114829. /**
  114830. * Gets the texture information input component
  114831. */
  114832. readonly textureInfo: NodeMaterialConnectionPoint;
  114833. /**
  114834. * Gets the transformed uv input component
  114835. */
  114836. readonly transformedUV: NodeMaterialConnectionPoint;
  114837. /**
  114838. * Gets the texture input component
  114839. */
  114840. readonly texture: NodeMaterialConnectionPoint;
  114841. /**
  114842. * Gets the texture transform input component
  114843. */
  114844. readonly textureTransform: NodeMaterialConnectionPoint;
  114845. /**
  114846. * Gets the output component
  114847. */
  114848. readonly output: NodeMaterialConnectionPoint;
  114849. autoConfigure(): void;
  114850. initialize(state: NodeMaterialBuildState): void;
  114851. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114852. isReady(): boolean;
  114853. private _injectVertexCode;
  114854. protected _buildBlock(state: NodeMaterialBuildState): this;
  114855. }
  114856. }
  114857. declare module BABYLON {
  114858. /**
  114859. * Block used to add image processing support to fragment shader
  114860. */
  114861. export class ImageProcessingBlock extends NodeMaterialBlock {
  114862. /**
  114863. * Create a new ImageProcessingBlock
  114864. * @param name defines the block name
  114865. */
  114866. constructor(name: string);
  114867. /**
  114868. * Gets the current class name
  114869. * @returns the class name
  114870. */
  114871. getClassName(): string;
  114872. /**
  114873. * Gets the color input component
  114874. */
  114875. readonly color: NodeMaterialConnectionPoint;
  114876. /**
  114877. * Gets the output component
  114878. */
  114879. readonly output: NodeMaterialConnectionPoint;
  114880. /**
  114881. * Initialize the block and prepare the context for build
  114882. * @param state defines the state that will be used for the build
  114883. */
  114884. initialize(state: NodeMaterialBuildState): void;
  114885. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  114886. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114887. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114888. protected _buildBlock(state: NodeMaterialBuildState): this;
  114889. }
  114890. }
  114891. declare module BABYLON {
  114892. /**
  114893. * Block used to add support for scene fog
  114894. */
  114895. export class FogBlock extends NodeMaterialBlock {
  114896. /**
  114897. * Create a new FogBlock
  114898. * @param name defines the block name
  114899. */
  114900. constructor(name: string);
  114901. /**
  114902. * Gets the current class name
  114903. * @returns the class name
  114904. */
  114905. getClassName(): string;
  114906. /**
  114907. * Gets the world position input component
  114908. */
  114909. readonly worldPosition: NodeMaterialConnectionPoint;
  114910. /**
  114911. * Gets the view input component
  114912. */
  114913. readonly view: NodeMaterialConnectionPoint;
  114914. /**
  114915. * Gets the color input component
  114916. */
  114917. readonly color: NodeMaterialConnectionPoint;
  114918. /**
  114919. * Gets the fog color input component
  114920. */
  114921. readonly fogColor: NodeMaterialConnectionPoint;
  114922. /**
  114923. * Gets the for parameter input component
  114924. */
  114925. readonly fogParameters: NodeMaterialConnectionPoint;
  114926. /**
  114927. * Gets the output component
  114928. */
  114929. readonly output: NodeMaterialConnectionPoint;
  114930. autoConfigure(): void;
  114931. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114932. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114933. protected _buildBlock(state: NodeMaterialBuildState): this;
  114934. }
  114935. }
  114936. declare module BABYLON {
  114937. /**
  114938. * Block used to add light in the fragment shader
  114939. */
  114940. export class LightBlock extends NodeMaterialBlock {
  114941. private _lightId;
  114942. /**
  114943. * Create a new LightBlock
  114944. * @param name defines the block name
  114945. */
  114946. constructor(name: string);
  114947. /**
  114948. * Gets the current class name
  114949. * @returns the class name
  114950. */
  114951. getClassName(): string;
  114952. /**
  114953. * Gets the world position input component
  114954. */
  114955. readonly worldPosition: NodeMaterialConnectionPoint;
  114956. /**
  114957. * Gets the world normal input component
  114958. */
  114959. readonly worldNormal: NodeMaterialConnectionPoint;
  114960. /**
  114961. * Gets the light input component
  114962. */
  114963. readonly light: NodeMaterialConnectionPoint;
  114964. /**
  114965. * Gets the camera (or eye) position component
  114966. */
  114967. readonly cameraPosition: NodeMaterialConnectionPoint;
  114968. /**
  114969. * Gets the diffuse output component
  114970. */
  114971. readonly diffuseOutput: NodeMaterialConnectionPoint;
  114972. /**
  114973. * Gets the specular output component
  114974. */
  114975. readonly specularOutput: NodeMaterialConnectionPoint;
  114976. autoConfigure(): void;
  114977. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114978. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114979. private _injectVertexCode;
  114980. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  114981. }
  114982. }
  114983. declare module BABYLON {
  114984. /**
  114985. * Block used to multiply 2 vector4
  114986. */
  114987. export class MultiplyBlock extends NodeMaterialBlock {
  114988. /**
  114989. * Creates a new MultiplyBlock
  114990. * @param name defines the block name
  114991. */
  114992. constructor(name: string);
  114993. /**
  114994. * Gets the current class name
  114995. * @returns the class name
  114996. */
  114997. getClassName(): string;
  114998. /**
  114999. * Gets the left operand input component
  115000. */
  115001. readonly left: NodeMaterialConnectionPoint;
  115002. /**
  115003. * Gets the right operand input component
  115004. */
  115005. readonly right: NodeMaterialConnectionPoint;
  115006. /**
  115007. * Gets the output component
  115008. */
  115009. readonly output: NodeMaterialConnectionPoint;
  115010. protected _buildBlock(state: NodeMaterialBuildState): this;
  115011. }
  115012. }
  115013. declare module BABYLON {
  115014. /**
  115015. * Block used to add 2 vector4
  115016. */
  115017. export class AddBlock extends NodeMaterialBlock {
  115018. /**
  115019. * Creates a new AddBlock
  115020. * @param name defines the block name
  115021. */
  115022. constructor(name: string);
  115023. /**
  115024. * Gets the current class name
  115025. * @returns the class name
  115026. */
  115027. getClassName(): string;
  115028. /**
  115029. * Gets the left operand input component
  115030. */
  115031. readonly left: NodeMaterialConnectionPoint;
  115032. /**
  115033. * Gets the right operand input component
  115034. */
  115035. readonly right: NodeMaterialConnectionPoint;
  115036. /**
  115037. * Gets the output component
  115038. */
  115039. readonly output: NodeMaterialConnectionPoint;
  115040. protected _buildBlock(state: NodeMaterialBuildState): this;
  115041. }
  115042. }
  115043. declare module BABYLON {
  115044. /**
  115045. * Block used to clamp a float
  115046. */
  115047. export class ClampBlock extends NodeMaterialBlock {
  115048. /** Gets or sets the minimum range */
  115049. minimum: number;
  115050. /** Gets or sets the maximum range */
  115051. maximum: number;
  115052. /**
  115053. * Creates a new ClampBlock
  115054. * @param name defines the block name
  115055. */
  115056. constructor(name: string);
  115057. /**
  115058. * Gets the current class name
  115059. * @returns the class name
  115060. */
  115061. getClassName(): string;
  115062. /**
  115063. * Gets the value input component
  115064. */
  115065. readonly value: NodeMaterialConnectionPoint;
  115066. /**
  115067. * Gets the output component
  115068. */
  115069. readonly output: NodeMaterialConnectionPoint;
  115070. protected _buildBlock(state: NodeMaterialBuildState): this;
  115071. }
  115072. }
  115073. declare module BABYLON {
  115074. /**
  115075. * Block used to scale a value
  115076. */
  115077. export class ScaleBlock extends NodeMaterialBlock {
  115078. /**
  115079. * Creates a new ScaleBlock
  115080. * @param name defines the block name
  115081. */
  115082. constructor(name: string);
  115083. /**
  115084. * Gets the current class name
  115085. * @returns the class name
  115086. */
  115087. getClassName(): string;
  115088. /**
  115089. * Gets the value operand input component
  115090. */
  115091. readonly value: NodeMaterialConnectionPoint;
  115092. /**
  115093. * Gets the scale operand input component
  115094. */
  115095. readonly scale: NodeMaterialConnectionPoint;
  115096. /**
  115097. * Gets the output component
  115098. */
  115099. readonly output: NodeMaterialConnectionPoint;
  115100. protected _buildBlock(state: NodeMaterialBuildState): this;
  115101. }
  115102. }
  115103. declare module BABYLON {
  115104. /**
  115105. * Block used to transform a vector2 with a matrix
  115106. */
  115107. export class Vector2TransformBlock extends NodeMaterialBlock {
  115108. /**
  115109. * Defines the value to use to complement Vector2 to transform it to a Vector4
  115110. */
  115111. complementZ: number;
  115112. /**
  115113. * Defines the value to use to complement Vector2 to transform it to a Vector4
  115114. */
  115115. complementW: number;
  115116. /**
  115117. * Creates a new Vector2TransformBlock
  115118. * @param name defines the block name
  115119. */
  115120. constructor(name: string);
  115121. /**
  115122. * Gets the vector input
  115123. */
  115124. readonly vector: NodeMaterialConnectionPoint;
  115125. /**
  115126. * Gets the matrix transform input
  115127. */
  115128. readonly transform: NodeMaterialConnectionPoint;
  115129. /**
  115130. * Gets the output component
  115131. */
  115132. readonly output: NodeMaterialConnectionPoint;
  115133. /**
  115134. * Gets the current class name
  115135. * @returns the class name
  115136. */
  115137. getClassName(): string;
  115138. protected _buildBlock(state: NodeMaterialBuildState): this;
  115139. }
  115140. }
  115141. declare module BABYLON {
  115142. /**
  115143. * Block used to transform a vector3 with a matrix
  115144. */
  115145. export class Vector3TransformBlock extends NodeMaterialBlock {
  115146. /**
  115147. * Defines the value to use to complement Vector3 to transform it to a Vector4
  115148. */
  115149. complement: number;
  115150. /**
  115151. * Creates a new Vector3TransformBlock
  115152. * @param name defines the block name
  115153. */
  115154. constructor(name: string);
  115155. /**
  115156. * Gets the vector input
  115157. */
  115158. readonly vector: NodeMaterialConnectionPoint;
  115159. /**
  115160. * Gets the matrix transform input
  115161. */
  115162. readonly transform: NodeMaterialConnectionPoint;
  115163. /**
  115164. * Gets the output component
  115165. */
  115166. readonly output: NodeMaterialConnectionPoint;
  115167. /**
  115168. * Gets the current class name
  115169. * @returns the class name
  115170. */
  115171. getClassName(): string;
  115172. protected _buildBlock(state: NodeMaterialBuildState): this;
  115173. }
  115174. }
  115175. declare module BABYLON {
  115176. /**
  115177. * Block used to multiply two matrices
  115178. */
  115179. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  115180. /**
  115181. * Creates a new MatrixMultiplicationBlock
  115182. * @param name defines the block name
  115183. */
  115184. constructor(name: string);
  115185. /**
  115186. * Gets the left operand
  115187. */
  115188. readonly left: NodeMaterialConnectionPoint;
  115189. /**
  115190. * Gets the right operand
  115191. */
  115192. readonly right: NodeMaterialConnectionPoint;
  115193. /**
  115194. * Gets the output component
  115195. */
  115196. readonly output: NodeMaterialConnectionPoint;
  115197. /**
  115198. * Gets the current class name
  115199. * @returns the class name
  115200. */
  115201. getClassName(): string;
  115202. protected _buildBlock(state: NodeMaterialBuildState): this;
  115203. }
  115204. }
  115205. declare module BABYLON {
  115206. /**
  115207. * Helper class to push actions to a pool of workers.
  115208. */
  115209. export class WorkerPool implements IDisposable {
  115210. private _workerInfos;
  115211. private _pendingActions;
  115212. /**
  115213. * Constructor
  115214. * @param workers Array of workers to use for actions
  115215. */
  115216. constructor(workers: Array<Worker>);
  115217. /**
  115218. * Terminates all workers and clears any pending actions.
  115219. */
  115220. dispose(): void;
  115221. /**
  115222. * Pushes an action to the worker pool. If all the workers are active, the action will be
  115223. * pended until a worker has completed its action.
  115224. * @param action The action to perform. Call onComplete when the action is complete.
  115225. */
  115226. push(action: (worker: Worker, onComplete: () => void) => void): void;
  115227. private _execute;
  115228. }
  115229. }
  115230. declare module BABYLON {
  115231. /**
  115232. * Configuration for Draco compression
  115233. */
  115234. export interface IDracoCompressionConfiguration {
  115235. /**
  115236. * Configuration for the decoder.
  115237. */
  115238. decoder: {
  115239. /**
  115240. * The url to the WebAssembly module.
  115241. */
  115242. wasmUrl?: string;
  115243. /**
  115244. * The url to the WebAssembly binary.
  115245. */
  115246. wasmBinaryUrl?: string;
  115247. /**
  115248. * The url to the fallback JavaScript module.
  115249. */
  115250. fallbackUrl?: string;
  115251. };
  115252. }
  115253. /**
  115254. * Draco compression (https://google.github.io/draco/)
  115255. *
  115256. * This class wraps the Draco module.
  115257. *
  115258. * **Encoder**
  115259. *
  115260. * The encoder is not currently implemented.
  115261. *
  115262. * **Decoder**
  115263. *
  115264. * 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.
  115265. *
  115266. * To update the configuration, use the following code:
  115267. * ```javascript
  115268. * DracoCompression.Configuration = {
  115269. * decoder: {
  115270. * wasmUrl: "<url to the WebAssembly library>",
  115271. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  115272. * fallbackUrl: "<url to the fallback JavaScript library>",
  115273. * }
  115274. * };
  115275. * ```
  115276. *
  115277. * 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.
  115278. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  115279. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  115280. *
  115281. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  115282. * ```javascript
  115283. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  115284. * ```
  115285. *
  115286. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  115287. */
  115288. export class DracoCompression implements IDisposable {
  115289. private _workerPoolPromise?;
  115290. private _decoderModulePromise?;
  115291. /**
  115292. * The configuration. Defaults to the following urls:
  115293. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  115294. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  115295. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  115296. */
  115297. static Configuration: IDracoCompressionConfiguration;
  115298. /**
  115299. * Returns true if the decoder configuration is available.
  115300. */
  115301. static readonly DecoderAvailable: boolean;
  115302. /**
  115303. * Default number of workers to create when creating the draco compression object.
  115304. */
  115305. static DefaultNumWorkers: number;
  115306. private static GetDefaultNumWorkers;
  115307. private static _Default;
  115308. /**
  115309. * Default instance for the draco compression object.
  115310. */
  115311. static readonly Default: DracoCompression;
  115312. /**
  115313. * Constructor
  115314. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  115315. */
  115316. constructor(numWorkers?: number);
  115317. /**
  115318. * Stop all async operations and release resources.
  115319. */
  115320. dispose(): void;
  115321. /**
  115322. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  115323. * @returns a promise that resolves when ready
  115324. */
  115325. whenReadyAsync(): Promise<void>;
  115326. /**
  115327. * Decode Draco compressed mesh data to vertex data.
  115328. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  115329. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  115330. * @returns A promise that resolves with the decoded vertex data
  115331. */
  115332. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  115333. [kind: string]: number;
  115334. }): Promise<VertexData>;
  115335. }
  115336. }
  115337. declare module BABYLON {
  115338. /**
  115339. * Class for building Constructive Solid Geometry
  115340. */
  115341. export class CSG {
  115342. private polygons;
  115343. /**
  115344. * The world matrix
  115345. */
  115346. matrix: Matrix;
  115347. /**
  115348. * Stores the position
  115349. */
  115350. position: Vector3;
  115351. /**
  115352. * Stores the rotation
  115353. */
  115354. rotation: Vector3;
  115355. /**
  115356. * Stores the rotation quaternion
  115357. */
  115358. rotationQuaternion: Nullable<Quaternion>;
  115359. /**
  115360. * Stores the scaling vector
  115361. */
  115362. scaling: Vector3;
  115363. /**
  115364. * Convert the Mesh to CSG
  115365. * @param mesh The Mesh to convert to CSG
  115366. * @returns A new CSG from the Mesh
  115367. */
  115368. static FromMesh(mesh: Mesh): CSG;
  115369. /**
  115370. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  115371. * @param polygons Polygons used to construct a CSG solid
  115372. */
  115373. private static FromPolygons;
  115374. /**
  115375. * Clones, or makes a deep copy, of the CSG
  115376. * @returns A new CSG
  115377. */
  115378. clone(): CSG;
  115379. /**
  115380. * Unions this CSG with another CSG
  115381. * @param csg The CSG to union against this CSG
  115382. * @returns The unioned CSG
  115383. */
  115384. union(csg: CSG): CSG;
  115385. /**
  115386. * Unions this CSG with another CSG in place
  115387. * @param csg The CSG to union against this CSG
  115388. */
  115389. unionInPlace(csg: CSG): void;
  115390. /**
  115391. * Subtracts this CSG with another CSG
  115392. * @param csg The CSG to subtract against this CSG
  115393. * @returns A new CSG
  115394. */
  115395. subtract(csg: CSG): CSG;
  115396. /**
  115397. * Subtracts this CSG with another CSG in place
  115398. * @param csg The CSG to subtact against this CSG
  115399. */
  115400. subtractInPlace(csg: CSG): void;
  115401. /**
  115402. * Intersect this CSG with another CSG
  115403. * @param csg The CSG to intersect against this CSG
  115404. * @returns A new CSG
  115405. */
  115406. intersect(csg: CSG): CSG;
  115407. /**
  115408. * Intersects this CSG with another CSG in place
  115409. * @param csg The CSG to intersect against this CSG
  115410. */
  115411. intersectInPlace(csg: CSG): void;
  115412. /**
  115413. * Return a new CSG solid with solid and empty space switched. This solid is
  115414. * not modified.
  115415. * @returns A new CSG solid with solid and empty space switched
  115416. */
  115417. inverse(): CSG;
  115418. /**
  115419. * Inverses the CSG in place
  115420. */
  115421. inverseInPlace(): void;
  115422. /**
  115423. * This is used to keep meshes transformations so they can be restored
  115424. * when we build back a Babylon Mesh
  115425. * NB : All CSG operations are performed in world coordinates
  115426. * @param csg The CSG to copy the transform attributes from
  115427. * @returns This CSG
  115428. */
  115429. copyTransformAttributes(csg: CSG): CSG;
  115430. /**
  115431. * Build Raw mesh from CSG
  115432. * Coordinates here are in world space
  115433. * @param name The name of the mesh geometry
  115434. * @param scene The Scene
  115435. * @param keepSubMeshes Specifies if the submeshes should be kept
  115436. * @returns A new Mesh
  115437. */
  115438. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  115439. /**
  115440. * Build Mesh from CSG taking material and transforms into account
  115441. * @param name The name of the Mesh
  115442. * @param material The material of the Mesh
  115443. * @param scene The Scene
  115444. * @param keepSubMeshes Specifies if submeshes should be kept
  115445. * @returns The new Mesh
  115446. */
  115447. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  115448. }
  115449. }
  115450. declare module BABYLON {
  115451. /**
  115452. * Class used to create a trail following a mesh
  115453. */
  115454. export class TrailMesh extends Mesh {
  115455. private _generator;
  115456. private _autoStart;
  115457. private _running;
  115458. private _diameter;
  115459. private _length;
  115460. private _sectionPolygonPointsCount;
  115461. private _sectionVectors;
  115462. private _sectionNormalVectors;
  115463. private _beforeRenderObserver;
  115464. /**
  115465. * @constructor
  115466. * @param name The value used by scene.getMeshByName() to do a lookup.
  115467. * @param generator The mesh to generate a trail.
  115468. * @param scene The scene to add this mesh to.
  115469. * @param diameter Diameter of trailing mesh. Default is 1.
  115470. * @param length Length of trailing mesh. Default is 60.
  115471. * @param autoStart Automatically start trailing mesh. Default true.
  115472. */
  115473. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  115474. /**
  115475. * "TrailMesh"
  115476. * @returns "TrailMesh"
  115477. */
  115478. getClassName(): string;
  115479. private _createMesh;
  115480. /**
  115481. * Start trailing mesh.
  115482. */
  115483. start(): void;
  115484. /**
  115485. * Stop trailing mesh.
  115486. */
  115487. stop(): void;
  115488. /**
  115489. * Update trailing mesh geometry.
  115490. */
  115491. update(): void;
  115492. /**
  115493. * Returns a new TrailMesh object.
  115494. * @param name is a string, the name given to the new mesh
  115495. * @param newGenerator use new generator object for cloned trail mesh
  115496. * @returns a new mesh
  115497. */
  115498. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  115499. /**
  115500. * Serializes this trail mesh
  115501. * @param serializationObject object to write serialization to
  115502. */
  115503. serialize(serializationObject: any): void;
  115504. /**
  115505. * Parses a serialized trail mesh
  115506. * @param parsedMesh the serialized mesh
  115507. * @param scene the scene to create the trail mesh in
  115508. * @returns the created trail mesh
  115509. */
  115510. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  115511. }
  115512. }
  115513. declare module BABYLON {
  115514. /**
  115515. * Class containing static functions to help procedurally build meshes
  115516. */
  115517. export class TiledBoxBuilder {
  115518. /**
  115519. * Creates a box mesh
  115520. * faceTiles sets the pattern, tile size and number of tiles for a face * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  115521. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115523. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115525. * @param name defines the name of the mesh
  115526. * @param options defines the options used to create the mesh
  115527. * @param scene defines the hosting scene
  115528. * @returns the box mesh
  115529. */
  115530. static CreateTiledBox(name: string, options: {
  115531. pattern?: number;
  115532. width?: number;
  115533. height?: number;
  115534. depth?: number;
  115535. tileSize?: number;
  115536. tileWidth?: number;
  115537. tileHeight?: number;
  115538. alignHorizontal?: number;
  115539. alignVertical?: number;
  115540. faceUV?: Vector4[];
  115541. faceColors?: Color4[];
  115542. sideOrientation?: number;
  115543. updatable?: boolean;
  115544. }, scene?: Nullable<Scene>): Mesh;
  115545. }
  115546. }
  115547. declare module BABYLON {
  115548. /**
  115549. * Class containing static functions to help procedurally build meshes
  115550. */
  115551. export class TorusKnotBuilder {
  115552. /**
  115553. * Creates a torus knot mesh
  115554. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115555. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115556. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115557. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115561. * @param name defines the name of the mesh
  115562. * @param options defines the options used to create the mesh
  115563. * @param scene defines the hosting scene
  115564. * @returns the torus knot mesh
  115565. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115566. */
  115567. static CreateTorusKnot(name: string, options: {
  115568. radius?: number;
  115569. tube?: number;
  115570. radialSegments?: number;
  115571. tubularSegments?: number;
  115572. p?: number;
  115573. q?: number;
  115574. updatable?: boolean;
  115575. sideOrientation?: number;
  115576. frontUVs?: Vector4;
  115577. backUVs?: Vector4;
  115578. }, scene: any): Mesh;
  115579. }
  115580. }
  115581. declare module BABYLON {
  115582. /**
  115583. * Polygon
  115584. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  115585. */
  115586. export class Polygon {
  115587. /**
  115588. * Creates a rectangle
  115589. * @param xmin bottom X coord
  115590. * @param ymin bottom Y coord
  115591. * @param xmax top X coord
  115592. * @param ymax top Y coord
  115593. * @returns points that make the resulting rectation
  115594. */
  115595. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  115596. /**
  115597. * Creates a circle
  115598. * @param radius radius of circle
  115599. * @param cx scale in x
  115600. * @param cy scale in y
  115601. * @param numberOfSides number of sides that make up the circle
  115602. * @returns points that make the resulting circle
  115603. */
  115604. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  115605. /**
  115606. * Creates a polygon from input string
  115607. * @param input Input polygon data
  115608. * @returns the parsed points
  115609. */
  115610. static Parse(input: string): Vector2[];
  115611. /**
  115612. * Starts building a polygon from x and y coordinates
  115613. * @param x x coordinate
  115614. * @param y y coordinate
  115615. * @returns the started path2
  115616. */
  115617. static StartingAt(x: number, y: number): Path2;
  115618. }
  115619. /**
  115620. * Builds a polygon
  115621. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  115622. */
  115623. export class PolygonMeshBuilder {
  115624. private _points;
  115625. private _outlinepoints;
  115626. private _holes;
  115627. private _name;
  115628. private _scene;
  115629. private _epoints;
  115630. private _eholes;
  115631. private _addToepoint;
  115632. /**
  115633. * Babylon reference to the earcut plugin.
  115634. */
  115635. bjsEarcut: any;
  115636. /**
  115637. * Creates a PolygonMeshBuilder
  115638. * @param name name of the builder
  115639. * @param contours Path of the polygon
  115640. * @param scene scene to add to when creating the mesh
  115641. * @param earcutInjection can be used to inject your own earcut reference
  115642. */
  115643. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  115644. /**
  115645. * Adds a whole within the polygon
  115646. * @param hole Array of points defining the hole
  115647. * @returns this
  115648. */
  115649. addHole(hole: Vector2[]): PolygonMeshBuilder;
  115650. /**
  115651. * Creates the polygon
  115652. * @param updatable If the mesh should be updatable
  115653. * @param depth The depth of the mesh created
  115654. * @returns the created mesh
  115655. */
  115656. build(updatable?: boolean, depth?: number): Mesh;
  115657. /**
  115658. * Creates the polygon
  115659. * @param depth The depth of the mesh created
  115660. * @returns the created VertexData
  115661. */
  115662. buildVertexData(depth?: number): VertexData;
  115663. /**
  115664. * Adds a side to the polygon
  115665. * @param positions points that make the polygon
  115666. * @param normals normals of the polygon
  115667. * @param uvs uvs of the polygon
  115668. * @param indices indices of the polygon
  115669. * @param bounds bounds of the polygon
  115670. * @param points points of the polygon
  115671. * @param depth depth of the polygon
  115672. * @param flip flip of the polygon
  115673. */
  115674. private addSide;
  115675. }
  115676. }
  115677. declare module BABYLON {
  115678. /**
  115679. * Class containing static functions to help procedurally build meshes
  115680. */
  115681. export class PolygonBuilder {
  115682. /**
  115683. * Creates a polygon mesh
  115684. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115685. * * 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
  115686. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115689. * * Remember you can only change the shape positions, not their number when updating a polygon
  115690. * @param name defines the name of the mesh
  115691. * @param options defines the options used to create the mesh
  115692. * @param scene defines the hosting scene
  115693. * @param earcutInjection can be used to inject your own earcut reference
  115694. * @returns the polygon mesh
  115695. */
  115696. static CreatePolygon(name: string, options: {
  115697. shape: Vector3[];
  115698. holes?: Vector3[][];
  115699. depth?: number;
  115700. faceUV?: Vector4[];
  115701. faceColors?: Color4[];
  115702. updatable?: boolean;
  115703. sideOrientation?: number;
  115704. frontUVs?: Vector4;
  115705. backUVs?: Vector4;
  115706. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115707. /**
  115708. * Creates an extruded polygon mesh, with depth in the Y direction.
  115709. * * 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)
  115710. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115711. * @param name defines the name of the mesh
  115712. * @param options defines the options used to create the mesh
  115713. * @param scene defines the hosting scene
  115714. * @param earcutInjection can be used to inject your own earcut reference
  115715. * @returns the polygon mesh
  115716. */
  115717. static ExtrudePolygon(name: string, options: {
  115718. shape: Vector3[];
  115719. holes?: Vector3[][];
  115720. depth?: number;
  115721. faceUV?: Vector4[];
  115722. faceColors?: Color4[];
  115723. updatable?: boolean;
  115724. sideOrientation?: number;
  115725. frontUVs?: Vector4;
  115726. backUVs?: Vector4;
  115727. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115728. }
  115729. }
  115730. declare module BABYLON {
  115731. /**
  115732. * Class containing static functions to help procedurally build meshes
  115733. */
  115734. export class LatheBuilder {
  115735. /**
  115736. * Creates lathe mesh.
  115737. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115738. * * 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
  115739. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115740. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115741. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115742. * * 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
  115743. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115744. * * 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
  115745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115747. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115749. * @param name defines the name of the mesh
  115750. * @param options defines the options used to create the mesh
  115751. * @param scene defines the hosting scene
  115752. * @returns the lathe mesh
  115753. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115754. */
  115755. static CreateLathe(name: string, options: {
  115756. shape: Vector3[];
  115757. radius?: number;
  115758. tessellation?: number;
  115759. clip?: number;
  115760. arc?: number;
  115761. closed?: boolean;
  115762. updatable?: boolean;
  115763. sideOrientation?: number;
  115764. frontUVs?: Vector4;
  115765. backUVs?: Vector4;
  115766. cap?: number;
  115767. invertUV?: boolean;
  115768. }, scene?: Nullable<Scene>): Mesh;
  115769. }
  115770. }
  115771. declare module BABYLON {
  115772. /**
  115773. * Class containing static functions to help procedurally build meshes
  115774. */
  115775. export class TiledPlaneBuilder {
  115776. /**
  115777. * Creates a tiled plane mesh
  115778. * * The parameter `pattern` will, depending on value, do nothing or
  115779. * * * flip (reflect about central vertical) alternate tiles across and up
  115780. * * * flip every tile on alternate rows
  115781. * * * rotate (180 degs) alternate tiles across and up
  115782. * * * rotate every tile on alternate rows
  115783. * * * flip and rotate alternate tiles across and up
  115784. * * * flip and rotate every tile on alternate rows
  115785. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  115786. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  115787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115788. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115789. * * 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)
  115790. * * 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)
  115791. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115792. * @param name defines the name of the mesh
  115793. * @param options defines the options used to create the mesh
  115794. * @param scene defines the hosting scene
  115795. * @returns the box mesh
  115796. */
  115797. static CreateTiledPlane(name: string, options: {
  115798. pattern?: number;
  115799. tileSize?: number;
  115800. tileWidth?: number;
  115801. tileHeight?: number;
  115802. size?: number;
  115803. width?: number;
  115804. height?: number;
  115805. alignHorizontal?: number;
  115806. alignVertical?: number;
  115807. sideOrientation?: number;
  115808. frontUVs?: Vector4;
  115809. backUVs?: Vector4;
  115810. updatable?: boolean;
  115811. }, scene?: Nullable<Scene>): Mesh;
  115812. }
  115813. }
  115814. declare module BABYLON {
  115815. /**
  115816. * Class containing static functions to help procedurally build meshes
  115817. */
  115818. export class TubeBuilder {
  115819. /**
  115820. * Creates a tube mesh.
  115821. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115822. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115823. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115824. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115825. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115826. * * 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)
  115827. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115828. * * 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
  115829. * * 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
  115830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115831. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115832. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115834. * @param name defines the name of the mesh
  115835. * @param options defines the options used to create the mesh
  115836. * @param scene defines the hosting scene
  115837. * @returns the tube mesh
  115838. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115839. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115840. */
  115841. static CreateTube(name: string, options: {
  115842. path: Vector3[];
  115843. radius?: number;
  115844. tessellation?: number;
  115845. radiusFunction?: {
  115846. (i: number, distance: number): number;
  115847. };
  115848. cap?: number;
  115849. arc?: number;
  115850. updatable?: boolean;
  115851. sideOrientation?: number;
  115852. frontUVs?: Vector4;
  115853. backUVs?: Vector4;
  115854. instance?: Mesh;
  115855. invertUV?: boolean;
  115856. }, scene?: Nullable<Scene>): Mesh;
  115857. }
  115858. }
  115859. declare module BABYLON {
  115860. /**
  115861. * Class containing static functions to help procedurally build meshes
  115862. */
  115863. export class IcoSphereBuilder {
  115864. /**
  115865. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115866. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115867. * * 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`)
  115868. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115869. * * 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
  115870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115871. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115873. * @param name defines the name of the mesh
  115874. * @param options defines the options used to create the mesh
  115875. * @param scene defines the hosting scene
  115876. * @returns the icosahedron mesh
  115877. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115878. */
  115879. static CreateIcoSphere(name: string, options: {
  115880. radius?: number;
  115881. radiusX?: number;
  115882. radiusY?: number;
  115883. radiusZ?: number;
  115884. flat?: boolean;
  115885. subdivisions?: number;
  115886. sideOrientation?: number;
  115887. frontUVs?: Vector4;
  115888. backUVs?: Vector4;
  115889. updatable?: boolean;
  115890. }, scene?: Nullable<Scene>): Mesh;
  115891. }
  115892. }
  115893. declare module BABYLON {
  115894. /**
  115895. * Class containing static functions to help procedurally build meshes
  115896. */
  115897. export class DecalBuilder {
  115898. /**
  115899. * Creates a decal mesh.
  115900. * 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
  115901. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115902. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115903. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115904. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115905. * @param name defines the name of the mesh
  115906. * @param sourceMesh defines the mesh where the decal must be applied
  115907. * @param options defines the options used to create the mesh
  115908. * @param scene defines the hosting scene
  115909. * @returns the decal mesh
  115910. * @see https://doc.babylonjs.com/how_to/decals
  115911. */
  115912. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115913. position?: Vector3;
  115914. normal?: Vector3;
  115915. size?: Vector3;
  115916. angle?: number;
  115917. }): Mesh;
  115918. }
  115919. }
  115920. declare module BABYLON {
  115921. /**
  115922. * Class containing static functions to help procedurally build meshes
  115923. */
  115924. export class MeshBuilder {
  115925. /**
  115926. * Creates a box mesh
  115927. * * The parameter `size` sets the size (float) of each box side (default 1)
  115928. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  115929. * * 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)
  115930. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115931. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115932. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115934. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115935. * @param name defines the name of the mesh
  115936. * @param options defines the options used to create the mesh
  115937. * @param scene defines the hosting scene
  115938. * @returns the box mesh
  115939. */
  115940. static CreateBox(name: string, options: {
  115941. size?: number;
  115942. width?: number;
  115943. height?: number;
  115944. depth?: number;
  115945. faceUV?: Vector4[];
  115946. faceColors?: Color4[];
  115947. sideOrientation?: number;
  115948. frontUVs?: Vector4;
  115949. backUVs?: Vector4;
  115950. updatable?: boolean;
  115951. }, scene?: Nullable<Scene>): Mesh;
  115952. /**
  115953. * Creates a tiled box mesh
  115954. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115956. * @param name defines the name of the mesh
  115957. * @param options defines the options used to create the mesh
  115958. * @param scene defines the hosting scene
  115959. * @returns the tiled box mesh
  115960. */
  115961. static CreateTiledBox(name: string, options: {
  115962. pattern?: number;
  115963. size?: number;
  115964. width?: number;
  115965. height?: number;
  115966. depth: number;
  115967. tileSize?: number;
  115968. tileWidth?: number;
  115969. tileHeight?: number;
  115970. faceUV?: Vector4[];
  115971. faceColors?: Color4[];
  115972. alignHorizontal?: number;
  115973. alignVertical?: number;
  115974. sideOrientation?: number;
  115975. updatable?: boolean;
  115976. }, scene?: Nullable<Scene>): Mesh;
  115977. /**
  115978. * Creates a sphere mesh
  115979. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  115980. * * 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`)
  115981. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  115982. * * 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
  115983. * * 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)
  115984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115985. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115987. * @param name defines the name of the mesh
  115988. * @param options defines the options used to create the mesh
  115989. * @param scene defines the hosting scene
  115990. * @returns the sphere mesh
  115991. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  115992. */
  115993. static CreateSphere(name: string, options: {
  115994. segments?: number;
  115995. diameter?: number;
  115996. diameterX?: number;
  115997. diameterY?: number;
  115998. diameterZ?: number;
  115999. arc?: number;
  116000. slice?: number;
  116001. sideOrientation?: number;
  116002. frontUVs?: Vector4;
  116003. backUVs?: Vector4;
  116004. updatable?: boolean;
  116005. }, scene?: Nullable<Scene>): Mesh;
  116006. /**
  116007. * Creates a plane polygonal mesh. By default, this is a disc
  116008. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  116009. * * 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
  116010. * * 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
  116011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116014. * @param name defines the name of the mesh
  116015. * @param options defines the options used to create the mesh
  116016. * @param scene defines the hosting scene
  116017. * @returns the plane polygonal mesh
  116018. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  116019. */
  116020. static CreateDisc(name: string, options: {
  116021. radius?: number;
  116022. tessellation?: number;
  116023. arc?: number;
  116024. updatable?: boolean;
  116025. sideOrientation?: number;
  116026. frontUVs?: Vector4;
  116027. backUVs?: Vector4;
  116028. }, scene?: Nullable<Scene>): Mesh;
  116029. /**
  116030. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  116031. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  116032. * * 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`)
  116033. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  116034. * * 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
  116035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116038. * @param name defines the name of the mesh
  116039. * @param options defines the options used to create the mesh
  116040. * @param scene defines the hosting scene
  116041. * @returns the icosahedron mesh
  116042. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  116043. */
  116044. static CreateIcoSphere(name: string, options: {
  116045. radius?: number;
  116046. radiusX?: number;
  116047. radiusY?: number;
  116048. radiusZ?: number;
  116049. flat?: boolean;
  116050. subdivisions?: number;
  116051. sideOrientation?: number;
  116052. frontUVs?: Vector4;
  116053. backUVs?: Vector4;
  116054. updatable?: boolean;
  116055. }, scene?: Nullable<Scene>): Mesh;
  116056. /**
  116057. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116058. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116059. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116060. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116061. * * 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
  116062. * * 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
  116063. * * 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
  116064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116065. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116066. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116067. * * 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
  116068. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116069. * * 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
  116070. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116072. * @param name defines the name of the mesh
  116073. * @param options defines the options used to create the mesh
  116074. * @param scene defines the hosting scene
  116075. * @returns the ribbon mesh
  116076. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116077. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116078. */
  116079. static CreateRibbon(name: string, options: {
  116080. pathArray: Vector3[][];
  116081. closeArray?: boolean;
  116082. closePath?: boolean;
  116083. offset?: number;
  116084. updatable?: boolean;
  116085. sideOrientation?: number;
  116086. frontUVs?: Vector4;
  116087. backUVs?: Vector4;
  116088. instance?: Mesh;
  116089. invertUV?: boolean;
  116090. uvs?: Vector2[];
  116091. colors?: Color4[];
  116092. }, scene?: Nullable<Scene>): Mesh;
  116093. /**
  116094. * Creates a cylinder or a cone mesh
  116095. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  116096. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  116097. * * 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.
  116098. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  116099. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  116100. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  116101. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  116102. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  116103. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  116104. * * 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).
  116105. * * 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
  116106. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  116107. * * 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
  116108. * * 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.
  116109. * * If `enclose` is false, a ring surface is one element.
  116110. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  116111. * * 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
  116112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116115. * @param name defines the name of the mesh
  116116. * @param options defines the options used to create the mesh
  116117. * @param scene defines the hosting scene
  116118. * @returns the cylinder mesh
  116119. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  116120. */
  116121. static CreateCylinder(name: string, options: {
  116122. height?: number;
  116123. diameterTop?: number;
  116124. diameterBottom?: number;
  116125. diameter?: number;
  116126. tessellation?: number;
  116127. subdivisions?: number;
  116128. arc?: number;
  116129. faceColors?: Color4[];
  116130. faceUV?: Vector4[];
  116131. updatable?: boolean;
  116132. hasRings?: boolean;
  116133. enclose?: boolean;
  116134. cap?: number;
  116135. sideOrientation?: number;
  116136. frontUVs?: Vector4;
  116137. backUVs?: Vector4;
  116138. }, scene?: Nullable<Scene>): Mesh;
  116139. /**
  116140. * Creates a torus mesh
  116141. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  116142. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  116143. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  116144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116147. * @param name defines the name of the mesh
  116148. * @param options defines the options used to create the mesh
  116149. * @param scene defines the hosting scene
  116150. * @returns the torus mesh
  116151. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  116152. */
  116153. static CreateTorus(name: string, options: {
  116154. diameter?: number;
  116155. thickness?: number;
  116156. tessellation?: number;
  116157. updatable?: boolean;
  116158. sideOrientation?: number;
  116159. frontUVs?: Vector4;
  116160. backUVs?: Vector4;
  116161. }, scene?: Nullable<Scene>): Mesh;
  116162. /**
  116163. * Creates a torus knot mesh
  116164. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  116165. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  116166. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  116167. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  116168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116169. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116171. * @param name defines the name of the mesh
  116172. * @param options defines the options used to create the mesh
  116173. * @param scene defines the hosting scene
  116174. * @returns the torus knot mesh
  116175. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  116176. */
  116177. static CreateTorusKnot(name: string, options: {
  116178. radius?: number;
  116179. tube?: number;
  116180. radialSegments?: number;
  116181. tubularSegments?: number;
  116182. p?: number;
  116183. q?: number;
  116184. updatable?: boolean;
  116185. sideOrientation?: number;
  116186. frontUVs?: Vector4;
  116187. backUVs?: Vector4;
  116188. }, scene?: Nullable<Scene>): Mesh;
  116189. /**
  116190. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116191. * * 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
  116192. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116193. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116194. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116195. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116196. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116197. * * 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
  116198. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116200. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116201. * @param name defines the name of the new line system
  116202. * @param options defines the options used to create the line system
  116203. * @param scene defines the hosting scene
  116204. * @returns a new line system mesh
  116205. */
  116206. static CreateLineSystem(name: string, options: {
  116207. lines: Vector3[][];
  116208. updatable?: boolean;
  116209. instance?: Nullable<LinesMesh>;
  116210. colors?: Nullable<Color4[][]>;
  116211. useVertexAlpha?: boolean;
  116212. }, scene: Nullable<Scene>): LinesMesh;
  116213. /**
  116214. * Creates a line mesh
  116215. * 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
  116216. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116217. * * The parameter `points` is an array successive Vector3
  116218. * * 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
  116219. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116220. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116221. * * When updating an instance, remember that only point positions can change, not the number of points
  116222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116223. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116224. * @param name defines the name of the new line system
  116225. * @param options defines the options used to create the line system
  116226. * @param scene defines the hosting scene
  116227. * @returns a new line mesh
  116228. */
  116229. static CreateLines(name: string, options: {
  116230. points: Vector3[];
  116231. updatable?: boolean;
  116232. instance?: Nullable<LinesMesh>;
  116233. colors?: Color4[];
  116234. useVertexAlpha?: boolean;
  116235. }, scene?: Nullable<Scene>): LinesMesh;
  116236. /**
  116237. * Creates a dashed line mesh
  116238. * * 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
  116239. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116240. * * The parameter `points` is an array successive Vector3
  116241. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116242. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116243. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116244. * * 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
  116245. * * When updating an instance, remember that only point positions can change, not the number of points
  116246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116247. * @param name defines the name of the mesh
  116248. * @param options defines the options used to create the mesh
  116249. * @param scene defines the hosting scene
  116250. * @returns the dashed line mesh
  116251. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116252. */
  116253. static CreateDashedLines(name: string, options: {
  116254. points: Vector3[];
  116255. dashSize?: number;
  116256. gapSize?: number;
  116257. dashNb?: number;
  116258. updatable?: boolean;
  116259. instance?: LinesMesh;
  116260. }, scene?: Nullable<Scene>): LinesMesh;
  116261. /**
  116262. * 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.
  116263. * * 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.
  116264. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116265. * * 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.
  116266. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116267. * * 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
  116268. * * 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
  116269. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116272. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116274. * @param name defines the name of the mesh
  116275. * @param options defines the options used to create the mesh
  116276. * @param scene defines the hosting scene
  116277. * @returns the extruded shape mesh
  116278. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116279. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116280. */
  116281. static ExtrudeShape(name: string, options: {
  116282. shape: Vector3[];
  116283. path: Vector3[];
  116284. scale?: number;
  116285. rotation?: number;
  116286. cap?: number;
  116287. updatable?: boolean;
  116288. sideOrientation?: number;
  116289. frontUVs?: Vector4;
  116290. backUVs?: Vector4;
  116291. instance?: Mesh;
  116292. invertUV?: boolean;
  116293. }, scene?: Nullable<Scene>): Mesh;
  116294. /**
  116295. * Creates an custom extruded shape mesh.
  116296. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116297. * * 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.
  116298. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116299. * * 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
  116300. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116301. * * 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
  116302. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116303. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116304. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116305. * * 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
  116306. * * 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
  116307. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116309. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116310. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116312. * @param name defines the name of the mesh
  116313. * @param options defines the options used to create the mesh
  116314. * @param scene defines the hosting scene
  116315. * @returns the custom extruded shape mesh
  116316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116317. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116318. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116319. */
  116320. static ExtrudeShapeCustom(name: string, options: {
  116321. shape: Vector3[];
  116322. path: Vector3[];
  116323. scaleFunction?: any;
  116324. rotationFunction?: any;
  116325. ribbonCloseArray?: boolean;
  116326. ribbonClosePath?: boolean;
  116327. cap?: number;
  116328. updatable?: boolean;
  116329. sideOrientation?: number;
  116330. frontUVs?: Vector4;
  116331. backUVs?: Vector4;
  116332. instance?: Mesh;
  116333. invertUV?: boolean;
  116334. }, scene?: Nullable<Scene>): Mesh;
  116335. /**
  116336. * Creates lathe mesh.
  116337. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  116338. * * 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
  116339. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  116340. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  116341. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  116342. * * 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
  116343. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  116344. * * 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
  116345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116346. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116347. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116349. * @param name defines the name of the mesh
  116350. * @param options defines the options used to create the mesh
  116351. * @param scene defines the hosting scene
  116352. * @returns the lathe mesh
  116353. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  116354. */
  116355. static CreateLathe(name: string, options: {
  116356. shape: Vector3[];
  116357. radius?: number;
  116358. tessellation?: number;
  116359. clip?: number;
  116360. arc?: number;
  116361. closed?: boolean;
  116362. updatable?: boolean;
  116363. sideOrientation?: number;
  116364. frontUVs?: Vector4;
  116365. backUVs?: Vector4;
  116366. cap?: number;
  116367. invertUV?: boolean;
  116368. }, scene?: Nullable<Scene>): Mesh;
  116369. /**
  116370. * Creates a tiled plane mesh
  116371. * * You can set a limited pattern arrangement with the tiles
  116372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116375. * @param name defines the name of the mesh
  116376. * @param options defines the options used to create the mesh
  116377. * @param scene defines the hosting scene
  116378. * @returns the plane mesh
  116379. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116380. */
  116381. static CreateTiledPlane(name: string, options: {
  116382. pattern?: number;
  116383. tileSize?: number;
  116384. tileWidth?: number;
  116385. tileHeight?: number;
  116386. size?: number;
  116387. width?: number;
  116388. height?: number;
  116389. alignHorizontal?: number;
  116390. alignVertical?: number;
  116391. sideOrientation?: number;
  116392. frontUVs?: Vector4;
  116393. backUVs?: Vector4;
  116394. updatable?: boolean;
  116395. }, scene?: Nullable<Scene>): Mesh;
  116396. /**
  116397. * Creates a plane mesh
  116398. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  116399. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  116400. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  116401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116402. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116404. * @param name defines the name of the mesh
  116405. * @param options defines the options used to create the mesh
  116406. * @param scene defines the hosting scene
  116407. * @returns the plane mesh
  116408. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116409. */
  116410. static CreatePlane(name: string, options: {
  116411. size?: number;
  116412. width?: number;
  116413. height?: number;
  116414. sideOrientation?: number;
  116415. frontUVs?: Vector4;
  116416. backUVs?: Vector4;
  116417. updatable?: boolean;
  116418. sourcePlane?: Plane;
  116419. }, scene?: Nullable<Scene>): Mesh;
  116420. /**
  116421. * Creates a ground mesh
  116422. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  116423. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  116424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116425. * @param name defines the name of the mesh
  116426. * @param options defines the options used to create the mesh
  116427. * @param scene defines the hosting scene
  116428. * @returns the ground mesh
  116429. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  116430. */
  116431. static CreateGround(name: string, options: {
  116432. width?: number;
  116433. height?: number;
  116434. subdivisions?: number;
  116435. subdivisionsX?: number;
  116436. subdivisionsY?: number;
  116437. updatable?: boolean;
  116438. }, scene?: Nullable<Scene>): Mesh;
  116439. /**
  116440. * Creates a tiled ground mesh
  116441. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  116442. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  116443. * * 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
  116444. * * 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
  116445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116446. * @param name defines the name of the mesh
  116447. * @param options defines the options used to create the mesh
  116448. * @param scene defines the hosting scene
  116449. * @returns the tiled ground mesh
  116450. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  116451. */
  116452. static CreateTiledGround(name: string, options: {
  116453. xmin: number;
  116454. zmin: number;
  116455. xmax: number;
  116456. zmax: number;
  116457. subdivisions?: {
  116458. w: number;
  116459. h: number;
  116460. };
  116461. precision?: {
  116462. w: number;
  116463. h: number;
  116464. };
  116465. updatable?: boolean;
  116466. }, scene?: Nullable<Scene>): Mesh;
  116467. /**
  116468. * Creates a ground mesh from a height map
  116469. * * The parameter `url` sets the URL of the height map image resource.
  116470. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  116471. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  116472. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  116473. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  116474. * * 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.
  116475. * * 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).
  116476. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  116477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116478. * @param name defines the name of the mesh
  116479. * @param url defines the url to the height map
  116480. * @param options defines the options used to create the mesh
  116481. * @param scene defines the hosting scene
  116482. * @returns the ground mesh
  116483. * @see https://doc.babylonjs.com/babylon101/height_map
  116484. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  116485. */
  116486. static CreateGroundFromHeightMap(name: string, url: string, options: {
  116487. width?: number;
  116488. height?: number;
  116489. subdivisions?: number;
  116490. minHeight?: number;
  116491. maxHeight?: number;
  116492. colorFilter?: Color3;
  116493. alphaFilter?: number;
  116494. updatable?: boolean;
  116495. onReady?: (mesh: GroundMesh) => void;
  116496. }, scene?: Nullable<Scene>): GroundMesh;
  116497. /**
  116498. * Creates a polygon mesh
  116499. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  116500. * * 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
  116501. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  116502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  116504. * * Remember you can only change the shape positions, not their number when updating a polygon
  116505. * @param name defines the name of the mesh
  116506. * @param options defines the options used to create the mesh
  116507. * @param scene defines the hosting scene
  116508. * @param earcutInjection can be used to inject your own earcut reference
  116509. * @returns the polygon mesh
  116510. */
  116511. static CreatePolygon(name: string, options: {
  116512. shape: Vector3[];
  116513. holes?: Vector3[][];
  116514. depth?: number;
  116515. faceUV?: Vector4[];
  116516. faceColors?: Color4[];
  116517. updatable?: boolean;
  116518. sideOrientation?: number;
  116519. frontUVs?: Vector4;
  116520. backUVs?: Vector4;
  116521. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116522. /**
  116523. * Creates an extruded polygon mesh, with depth in the Y direction.
  116524. * * 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)
  116525. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116526. * @param name defines the name of the mesh
  116527. * @param options defines the options used to create the mesh
  116528. * @param scene defines the hosting scene
  116529. * @param earcutInjection can be used to inject your own earcut reference
  116530. * @returns the polygon mesh
  116531. */
  116532. static ExtrudePolygon(name: string, options: {
  116533. shape: Vector3[];
  116534. holes?: Vector3[][];
  116535. depth?: number;
  116536. faceUV?: Vector4[];
  116537. faceColors?: Color4[];
  116538. updatable?: boolean;
  116539. sideOrientation?: number;
  116540. frontUVs?: Vector4;
  116541. backUVs?: Vector4;
  116542. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116543. /**
  116544. * Creates a tube mesh.
  116545. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116546. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  116547. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  116548. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  116549. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  116550. * * 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)
  116551. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  116552. * * 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
  116553. * * 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
  116554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116556. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116558. * @param name defines the name of the mesh
  116559. * @param options defines the options used to create the mesh
  116560. * @param scene defines the hosting scene
  116561. * @returns the tube mesh
  116562. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116563. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  116564. */
  116565. static CreateTube(name: string, options: {
  116566. path: Vector3[];
  116567. radius?: number;
  116568. tessellation?: number;
  116569. radiusFunction?: {
  116570. (i: number, distance: number): number;
  116571. };
  116572. cap?: number;
  116573. arc?: number;
  116574. updatable?: boolean;
  116575. sideOrientation?: number;
  116576. frontUVs?: Vector4;
  116577. backUVs?: Vector4;
  116578. instance?: Mesh;
  116579. invertUV?: boolean;
  116580. }, scene?: Nullable<Scene>): Mesh;
  116581. /**
  116582. * Creates a polyhedron mesh
  116583. * * 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
  116584. * * The parameter `size` (positive float, default 1) sets the polygon size
  116585. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  116586. * * 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`
  116587. * * 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
  116588. * * 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)`)
  116589. * * 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
  116590. * * 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
  116591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116592. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116594. * @param name defines the name of the mesh
  116595. * @param options defines the options used to create the mesh
  116596. * @param scene defines the hosting scene
  116597. * @returns the polyhedron mesh
  116598. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  116599. */
  116600. static CreatePolyhedron(name: string, options: {
  116601. type?: number;
  116602. size?: number;
  116603. sizeX?: number;
  116604. sizeY?: number;
  116605. sizeZ?: number;
  116606. custom?: any;
  116607. faceUV?: Vector4[];
  116608. faceColors?: Color4[];
  116609. flat?: boolean;
  116610. updatable?: boolean;
  116611. sideOrientation?: number;
  116612. frontUVs?: Vector4;
  116613. backUVs?: Vector4;
  116614. }, scene?: Nullable<Scene>): Mesh;
  116615. /**
  116616. * Creates a decal mesh.
  116617. * 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
  116618. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  116619. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  116620. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  116621. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  116622. * @param name defines the name of the mesh
  116623. * @param sourceMesh defines the mesh where the decal must be applied
  116624. * @param options defines the options used to create the mesh
  116625. * @param scene defines the hosting scene
  116626. * @returns the decal mesh
  116627. * @see https://doc.babylonjs.com/how_to/decals
  116628. */
  116629. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  116630. position?: Vector3;
  116631. normal?: Vector3;
  116632. size?: Vector3;
  116633. angle?: number;
  116634. }): Mesh;
  116635. }
  116636. }
  116637. declare module BABYLON {
  116638. /**
  116639. * A simplifier interface for future simplification implementations
  116640. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116641. */
  116642. export interface ISimplifier {
  116643. /**
  116644. * Simplification of a given mesh according to the given settings.
  116645. * Since this requires computation, it is assumed that the function runs async.
  116646. * @param settings The settings of the simplification, including quality and distance
  116647. * @param successCallback A callback that will be called after the mesh was simplified.
  116648. * @param errorCallback in case of an error, this callback will be called. optional.
  116649. */
  116650. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  116651. }
  116652. /**
  116653. * Expected simplification settings.
  116654. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  116655. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116656. */
  116657. export interface ISimplificationSettings {
  116658. /**
  116659. * Gets or sets the expected quality
  116660. */
  116661. quality: number;
  116662. /**
  116663. * Gets or sets the distance when this optimized version should be used
  116664. */
  116665. distance: number;
  116666. /**
  116667. * Gets an already optimized mesh
  116668. */
  116669. optimizeMesh?: boolean;
  116670. }
  116671. /**
  116672. * Class used to specify simplification options
  116673. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116674. */
  116675. export class SimplificationSettings implements ISimplificationSettings {
  116676. /** expected quality */
  116677. quality: number;
  116678. /** distance when this optimized version should be used */
  116679. distance: number;
  116680. /** already optimized mesh */
  116681. optimizeMesh?: boolean | undefined;
  116682. /**
  116683. * Creates a SimplificationSettings
  116684. * @param quality expected quality
  116685. * @param distance distance when this optimized version should be used
  116686. * @param optimizeMesh already optimized mesh
  116687. */
  116688. constructor(
  116689. /** expected quality */
  116690. quality: number,
  116691. /** distance when this optimized version should be used */
  116692. distance: number,
  116693. /** already optimized mesh */
  116694. optimizeMesh?: boolean | undefined);
  116695. }
  116696. /**
  116697. * Interface used to define a simplification task
  116698. */
  116699. export interface ISimplificationTask {
  116700. /**
  116701. * Array of settings
  116702. */
  116703. settings: Array<ISimplificationSettings>;
  116704. /**
  116705. * Simplification type
  116706. */
  116707. simplificationType: SimplificationType;
  116708. /**
  116709. * Mesh to simplify
  116710. */
  116711. mesh: Mesh;
  116712. /**
  116713. * Callback called on success
  116714. */
  116715. successCallback?: () => void;
  116716. /**
  116717. * Defines if parallel processing can be used
  116718. */
  116719. parallelProcessing: boolean;
  116720. }
  116721. /**
  116722. * Queue used to order the simplification tasks
  116723. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116724. */
  116725. export class SimplificationQueue {
  116726. private _simplificationArray;
  116727. /**
  116728. * Gets a boolean indicating that the process is still running
  116729. */
  116730. running: boolean;
  116731. /**
  116732. * Creates a new queue
  116733. */
  116734. constructor();
  116735. /**
  116736. * Adds a new simplification task
  116737. * @param task defines a task to add
  116738. */
  116739. addTask(task: ISimplificationTask): void;
  116740. /**
  116741. * Execute next task
  116742. */
  116743. executeNext(): void;
  116744. /**
  116745. * Execute a simplification task
  116746. * @param task defines the task to run
  116747. */
  116748. runSimplification(task: ISimplificationTask): void;
  116749. private getSimplifier;
  116750. }
  116751. /**
  116752. * The implemented types of simplification
  116753. * At the moment only Quadratic Error Decimation is implemented
  116754. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116755. */
  116756. export enum SimplificationType {
  116757. /** Quadratic error decimation */
  116758. QUADRATIC = 0
  116759. }
  116760. }
  116761. declare module BABYLON {
  116762. interface Scene {
  116763. /** @hidden (Backing field) */
  116764. _simplificationQueue: SimplificationQueue;
  116765. /**
  116766. * Gets or sets the simplification queue attached to the scene
  116767. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116768. */
  116769. simplificationQueue: SimplificationQueue;
  116770. }
  116771. interface Mesh {
  116772. /**
  116773. * Simplify the mesh according to the given array of settings.
  116774. * Function will return immediately and will simplify async
  116775. * @param settings a collection of simplification settings
  116776. * @param parallelProcessing should all levels calculate parallel or one after the other
  116777. * @param simplificationType the type of simplification to run
  116778. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  116779. * @returns the current mesh
  116780. */
  116781. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  116782. }
  116783. /**
  116784. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  116785. * created in a scene
  116786. */
  116787. export class SimplicationQueueSceneComponent implements ISceneComponent {
  116788. /**
  116789. * The component name helpfull to identify the component in the list of scene components.
  116790. */
  116791. readonly name: string;
  116792. /**
  116793. * The scene the component belongs to.
  116794. */
  116795. scene: Scene;
  116796. /**
  116797. * Creates a new instance of the component for the given scene
  116798. * @param scene Defines the scene to register the component in
  116799. */
  116800. constructor(scene: Scene);
  116801. /**
  116802. * Registers the component in a given scene
  116803. */
  116804. register(): void;
  116805. /**
  116806. * Rebuilds the elements related to this component in case of
  116807. * context lost for instance.
  116808. */
  116809. rebuild(): void;
  116810. /**
  116811. * Disposes the component and the associated ressources
  116812. */
  116813. dispose(): void;
  116814. private _beforeCameraUpdate;
  116815. }
  116816. }
  116817. declare module BABYLON {
  116818. /**
  116819. * Class used to enable access to IndexedDB
  116820. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116821. */
  116822. export class Database implements IOfflineProvider {
  116823. private _callbackManifestChecked;
  116824. private _currentSceneUrl;
  116825. private _db;
  116826. private _enableSceneOffline;
  116827. private _enableTexturesOffline;
  116828. private _manifestVersionFound;
  116829. private _mustUpdateRessources;
  116830. private _hasReachedQuota;
  116831. private _isSupported;
  116832. private _idbFactory;
  116833. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  116834. private static IsUASupportingBlobStorage;
  116835. /**
  116836. * Gets a boolean indicating if Database storate is enabled (off by default)
  116837. */
  116838. static IDBStorageEnabled: boolean;
  116839. /**
  116840. * Gets a boolean indicating if scene must be saved in the database
  116841. */
  116842. readonly enableSceneOffline: boolean;
  116843. /**
  116844. * Gets a boolean indicating if textures must be saved in the database
  116845. */
  116846. readonly enableTexturesOffline: boolean;
  116847. /**
  116848. * Creates a new Database
  116849. * @param urlToScene defines the url to load the scene
  116850. * @param callbackManifestChecked defines the callback to use when manifest is checked
  116851. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  116852. */
  116853. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  116854. private static _ParseURL;
  116855. private static _ReturnFullUrlLocation;
  116856. private _checkManifestFile;
  116857. /**
  116858. * Open the database and make it available
  116859. * @param successCallback defines the callback to call on success
  116860. * @param errorCallback defines the callback to call on error
  116861. */
  116862. open(successCallback: () => void, errorCallback: () => void): void;
  116863. /**
  116864. * Loads an image from the database
  116865. * @param url defines the url to load from
  116866. * @param image defines the target DOM image
  116867. */
  116868. loadImage(url: string, image: HTMLImageElement): void;
  116869. private _loadImageFromDBAsync;
  116870. private _saveImageIntoDBAsync;
  116871. private _checkVersionFromDB;
  116872. private _loadVersionFromDBAsync;
  116873. private _saveVersionIntoDBAsync;
  116874. /**
  116875. * Loads a file from database
  116876. * @param url defines the URL to load from
  116877. * @param sceneLoaded defines a callback to call on success
  116878. * @param progressCallBack defines a callback to call when progress changed
  116879. * @param errorCallback defines a callback to call on error
  116880. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  116881. */
  116882. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  116883. private _loadFileAsync;
  116884. private _saveFileAsync;
  116885. /**
  116886. * Validates if xhr data is correct
  116887. * @param xhr defines the request to validate
  116888. * @param dataType defines the expected data type
  116889. * @returns true if data is correct
  116890. */
  116891. private static _ValidateXHRData;
  116892. }
  116893. }
  116894. declare module BABYLON {
  116895. /** @hidden */
  116896. export var gpuUpdateParticlesPixelShader: {
  116897. name: string;
  116898. shader: string;
  116899. };
  116900. }
  116901. declare module BABYLON {
  116902. /** @hidden */
  116903. export var gpuUpdateParticlesVertexShader: {
  116904. name: string;
  116905. shader: string;
  116906. };
  116907. }
  116908. declare module BABYLON {
  116909. /** @hidden */
  116910. export var clipPlaneFragmentDeclaration2: {
  116911. name: string;
  116912. shader: string;
  116913. };
  116914. }
  116915. declare module BABYLON {
  116916. /** @hidden */
  116917. export var gpuRenderParticlesPixelShader: {
  116918. name: string;
  116919. shader: string;
  116920. };
  116921. }
  116922. declare module BABYLON {
  116923. /** @hidden */
  116924. export var clipPlaneVertexDeclaration2: {
  116925. name: string;
  116926. shader: string;
  116927. };
  116928. }
  116929. declare module BABYLON {
  116930. /** @hidden */
  116931. export var gpuRenderParticlesVertexShader: {
  116932. name: string;
  116933. shader: string;
  116934. };
  116935. }
  116936. declare module BABYLON {
  116937. /**
  116938. * This represents a GPU particle system in Babylon
  116939. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  116940. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  116941. */
  116942. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  116943. /**
  116944. * The layer mask we are rendering the particles through.
  116945. */
  116946. layerMask: number;
  116947. private _capacity;
  116948. private _activeCount;
  116949. private _currentActiveCount;
  116950. private _accumulatedCount;
  116951. private _renderEffect;
  116952. private _updateEffect;
  116953. private _buffer0;
  116954. private _buffer1;
  116955. private _spriteBuffer;
  116956. private _updateVAO;
  116957. private _renderVAO;
  116958. private _targetIndex;
  116959. private _sourceBuffer;
  116960. private _targetBuffer;
  116961. private _engine;
  116962. private _currentRenderId;
  116963. private _started;
  116964. private _stopped;
  116965. private _timeDelta;
  116966. private _randomTexture;
  116967. private _randomTexture2;
  116968. private _attributesStrideSize;
  116969. private _updateEffectOptions;
  116970. private _randomTextureSize;
  116971. private _actualFrame;
  116972. private readonly _rawTextureWidth;
  116973. /**
  116974. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  116975. */
  116976. static readonly IsSupported: boolean;
  116977. /**
  116978. * An event triggered when the system is disposed.
  116979. */
  116980. onDisposeObservable: Observable<GPUParticleSystem>;
  116981. /**
  116982. * Gets the maximum number of particles active at the same time.
  116983. * @returns The max number of active particles.
  116984. */
  116985. getCapacity(): number;
  116986. /**
  116987. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  116988. * to override the particles.
  116989. */
  116990. forceDepthWrite: boolean;
  116991. /**
  116992. * Gets or set the number of active particles
  116993. */
  116994. activeParticleCount: number;
  116995. private _preWarmDone;
  116996. /**
  116997. * Is this system ready to be used/rendered
  116998. * @return true if the system is ready
  116999. */
  117000. isReady(): boolean;
  117001. /**
  117002. * Gets if the system has been started. (Note: this will still be true after stop is called)
  117003. * @returns True if it has been started, otherwise false.
  117004. */
  117005. isStarted(): boolean;
  117006. /**
  117007. * Starts the particle system and begins to emit
  117008. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  117009. */
  117010. start(delay?: number): void;
  117011. /**
  117012. * Stops the particle system.
  117013. */
  117014. stop(): void;
  117015. /**
  117016. * Remove all active particles
  117017. */
  117018. reset(): void;
  117019. /**
  117020. * Returns the string "GPUParticleSystem"
  117021. * @returns a string containing the class name
  117022. */
  117023. getClassName(): string;
  117024. private _colorGradientsTexture;
  117025. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  117026. /**
  117027. * Adds a new color gradient
  117028. * @param gradient defines the gradient to use (between 0 and 1)
  117029. * @param color1 defines the color to affect to the specified gradient
  117030. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  117031. * @returns the current particle system
  117032. */
  117033. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  117034. /**
  117035. * Remove a specific color gradient
  117036. * @param gradient defines the gradient to remove
  117037. * @returns the current particle system
  117038. */
  117039. removeColorGradient(gradient: number): GPUParticleSystem;
  117040. private _angularSpeedGradientsTexture;
  117041. private _sizeGradientsTexture;
  117042. private _velocityGradientsTexture;
  117043. private _limitVelocityGradientsTexture;
  117044. private _dragGradientsTexture;
  117045. private _addFactorGradient;
  117046. /**
  117047. * Adds a new size gradient
  117048. * @param gradient defines the gradient to use (between 0 and 1)
  117049. * @param factor defines the size factor to affect to the specified gradient
  117050. * @returns the current particle system
  117051. */
  117052. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  117053. /**
  117054. * Remove a specific size gradient
  117055. * @param gradient defines the gradient to remove
  117056. * @returns the current particle system
  117057. */
  117058. removeSizeGradient(gradient: number): GPUParticleSystem;
  117059. /**
  117060. * Adds a new angular speed gradient
  117061. * @param gradient defines the gradient to use (between 0 and 1)
  117062. * @param factor defines the angular speed to affect to the specified gradient
  117063. * @returns the current particle system
  117064. */
  117065. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  117066. /**
  117067. * Remove a specific angular speed gradient
  117068. * @param gradient defines the gradient to remove
  117069. * @returns the current particle system
  117070. */
  117071. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  117072. /**
  117073. * Adds a new velocity gradient
  117074. * @param gradient defines the gradient to use (between 0 and 1)
  117075. * @param factor defines the velocity to affect to the specified gradient
  117076. * @returns the current particle system
  117077. */
  117078. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  117079. /**
  117080. * Remove a specific velocity gradient
  117081. * @param gradient defines the gradient to remove
  117082. * @returns the current particle system
  117083. */
  117084. removeVelocityGradient(gradient: number): GPUParticleSystem;
  117085. /**
  117086. * Adds a new limit velocity gradient
  117087. * @param gradient defines the gradient to use (between 0 and 1)
  117088. * @param factor defines the limit velocity value to affect to the specified gradient
  117089. * @returns the current particle system
  117090. */
  117091. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  117092. /**
  117093. * Remove a specific limit velocity gradient
  117094. * @param gradient defines the gradient to remove
  117095. * @returns the current particle system
  117096. */
  117097. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  117098. /**
  117099. * Adds a new drag gradient
  117100. * @param gradient defines the gradient to use (between 0 and 1)
  117101. * @param factor defines the drag value to affect to the specified gradient
  117102. * @returns the current particle system
  117103. */
  117104. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  117105. /**
  117106. * Remove a specific drag gradient
  117107. * @param gradient defines the gradient to remove
  117108. * @returns the current particle system
  117109. */
  117110. removeDragGradient(gradient: number): GPUParticleSystem;
  117111. /**
  117112. * Not supported by GPUParticleSystem
  117113. * @param gradient defines the gradient to use (between 0 and 1)
  117114. * @param factor defines the emit rate value to affect to the specified gradient
  117115. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117116. * @returns the current particle system
  117117. */
  117118. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117119. /**
  117120. * Not supported by GPUParticleSystem
  117121. * @param gradient defines the gradient to remove
  117122. * @returns the current particle system
  117123. */
  117124. removeEmitRateGradient(gradient: number): IParticleSystem;
  117125. /**
  117126. * Not supported by GPUParticleSystem
  117127. * @param gradient defines the gradient to use (between 0 and 1)
  117128. * @param factor defines the start size value to affect to the specified gradient
  117129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117130. * @returns the current particle system
  117131. */
  117132. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117133. /**
  117134. * Not supported by GPUParticleSystem
  117135. * @param gradient defines the gradient to remove
  117136. * @returns the current particle system
  117137. */
  117138. removeStartSizeGradient(gradient: number): IParticleSystem;
  117139. /**
  117140. * Not supported by GPUParticleSystem
  117141. * @param gradient defines the gradient to use (between 0 and 1)
  117142. * @param min defines the color remap minimal range
  117143. * @param max defines the color remap maximal range
  117144. * @returns the current particle system
  117145. */
  117146. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  117147. /**
  117148. * Not supported by GPUParticleSystem
  117149. * @param gradient defines the gradient to remove
  117150. * @returns the current particle system
  117151. */
  117152. removeColorRemapGradient(): IParticleSystem;
  117153. /**
  117154. * Not supported by GPUParticleSystem
  117155. * @param gradient defines the gradient to use (between 0 and 1)
  117156. * @param min defines the alpha remap minimal range
  117157. * @param max defines the alpha remap maximal range
  117158. * @returns the current particle system
  117159. */
  117160. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  117161. /**
  117162. * Not supported by GPUParticleSystem
  117163. * @param gradient defines the gradient to remove
  117164. * @returns the current particle system
  117165. */
  117166. removeAlphaRemapGradient(): IParticleSystem;
  117167. /**
  117168. * Not supported by GPUParticleSystem
  117169. * @param gradient defines the gradient to use (between 0 and 1)
  117170. * @param color defines the color to affect to the specified gradient
  117171. * @returns the current particle system
  117172. */
  117173. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  117174. /**
  117175. * Not supported by GPUParticleSystem
  117176. * @param gradient defines the gradient to remove
  117177. * @returns the current particle system
  117178. */
  117179. removeRampGradient(): IParticleSystem;
  117180. /**
  117181. * Not supported by GPUParticleSystem
  117182. * @returns the list of ramp gradients
  117183. */
  117184. getRampGradients(): Nullable<Array<Color3Gradient>>;
  117185. /**
  117186. * Not supported by GPUParticleSystem
  117187. * Gets or sets a boolean indicating that ramp gradients must be used
  117188. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  117189. */
  117190. useRampGradients: boolean;
  117191. /**
  117192. * Not supported by GPUParticleSystem
  117193. * @param gradient defines the gradient to use (between 0 and 1)
  117194. * @param factor defines the life time factor to affect to the specified gradient
  117195. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117196. * @returns the current particle system
  117197. */
  117198. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117199. /**
  117200. * Not supported by GPUParticleSystem
  117201. * @param gradient defines the gradient to remove
  117202. * @returns the current particle system
  117203. */
  117204. removeLifeTimeGradient(gradient: number): IParticleSystem;
  117205. /**
  117206. * Instantiates a GPU particle system.
  117207. * 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.
  117208. * @param name The name of the particle system
  117209. * @param options The options used to create the system
  117210. * @param scene The scene the particle system belongs to
  117211. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  117212. */
  117213. constructor(name: string, options: Partial<{
  117214. capacity: number;
  117215. randomTextureSize: number;
  117216. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  117217. protected _reset(): void;
  117218. private _createUpdateVAO;
  117219. private _createRenderVAO;
  117220. private _initialize;
  117221. /** @hidden */
  117222. _recreateUpdateEffect(): void;
  117223. /** @hidden */
  117224. _recreateRenderEffect(): void;
  117225. /**
  117226. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  117227. * @param preWarm defines if we are in the pre-warmimg phase
  117228. */
  117229. animate(preWarm?: boolean): void;
  117230. private _createFactorGradientTexture;
  117231. private _createSizeGradientTexture;
  117232. private _createAngularSpeedGradientTexture;
  117233. private _createVelocityGradientTexture;
  117234. private _createLimitVelocityGradientTexture;
  117235. private _createDragGradientTexture;
  117236. private _createColorGradientTexture;
  117237. /**
  117238. * Renders the particle system in its current state
  117239. * @param preWarm defines if the system should only update the particles but not render them
  117240. * @returns the current number of particles
  117241. */
  117242. render(preWarm?: boolean): number;
  117243. /**
  117244. * Rebuilds the particle system
  117245. */
  117246. rebuild(): void;
  117247. private _releaseBuffers;
  117248. private _releaseVAOs;
  117249. /**
  117250. * Disposes the particle system and free the associated resources
  117251. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  117252. */
  117253. dispose(disposeTexture?: boolean): void;
  117254. /**
  117255. * Clones the particle system.
  117256. * @param name The name of the cloned object
  117257. * @param newEmitter The new emitter to use
  117258. * @returns the cloned particle system
  117259. */
  117260. clone(name: string, newEmitter: any): GPUParticleSystem;
  117261. /**
  117262. * Serializes the particle system to a JSON object.
  117263. * @returns the JSON object
  117264. */
  117265. serialize(): any;
  117266. /**
  117267. * Parses a JSON object to create a GPU particle system.
  117268. * @param parsedParticleSystem The JSON object to parse
  117269. * @param scene The scene to create the particle system in
  117270. * @param rootUrl The root url to use to load external dependencies like texture
  117271. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  117272. * @returns the parsed GPU particle system
  117273. */
  117274. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  117275. }
  117276. }
  117277. declare module BABYLON {
  117278. /**
  117279. * Represents a set of particle systems working together to create a specific effect
  117280. */
  117281. export class ParticleSystemSet implements IDisposable {
  117282. private _emitterCreationOptions;
  117283. private _emitterNode;
  117284. /**
  117285. * Gets the particle system list
  117286. */
  117287. systems: IParticleSystem[];
  117288. /**
  117289. * Gets the emitter node used with this set
  117290. */
  117291. readonly emitterNode: Nullable<TransformNode>;
  117292. /**
  117293. * Creates a new emitter mesh as a sphere
  117294. * @param options defines the options used to create the sphere
  117295. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  117296. * @param scene defines the hosting scene
  117297. */
  117298. setEmitterAsSphere(options: {
  117299. diameter: number;
  117300. segments: number;
  117301. color: Color3;
  117302. }, renderingGroupId: number, scene: Scene): void;
  117303. /**
  117304. * Starts all particle systems of the set
  117305. * @param emitter defines an optional mesh to use as emitter for the particle systems
  117306. */
  117307. start(emitter?: AbstractMesh): void;
  117308. /**
  117309. * Release all associated resources
  117310. */
  117311. dispose(): void;
  117312. /**
  117313. * Serialize the set into a JSON compatible object
  117314. * @returns a JSON compatible representation of the set
  117315. */
  117316. serialize(): any;
  117317. /**
  117318. * Parse a new ParticleSystemSet from a serialized source
  117319. * @param data defines a JSON compatible representation of the set
  117320. * @param scene defines the hosting scene
  117321. * @param gpu defines if we want GPU particles or CPU particles
  117322. * @returns a new ParticleSystemSet
  117323. */
  117324. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  117325. }
  117326. }
  117327. declare module BABYLON {
  117328. /**
  117329. * This class is made for on one-liner static method to help creating particle system set.
  117330. */
  117331. export class ParticleHelper {
  117332. /**
  117333. * Gets or sets base Assets URL
  117334. */
  117335. static BaseAssetsUrl: string;
  117336. /**
  117337. * Create a default particle system that you can tweak
  117338. * @param emitter defines the emitter to use
  117339. * @param capacity defines the system capacity (default is 500 particles)
  117340. * @param scene defines the hosting scene
  117341. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  117342. * @returns the new Particle system
  117343. */
  117344. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  117345. /**
  117346. * This is the main static method (one-liner) of this helper to create different particle systems
  117347. * @param type This string represents the type to the particle system to create
  117348. * @param scene The scene where the particle system should live
  117349. * @param gpu If the system will use gpu
  117350. * @returns the ParticleSystemSet created
  117351. */
  117352. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  117353. /**
  117354. * Static function used to export a particle system to a ParticleSystemSet variable.
  117355. * Please note that the emitter shape is not exported
  117356. * @param systems defines the particle systems to export
  117357. * @returns the created particle system set
  117358. */
  117359. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  117360. }
  117361. }
  117362. declare module BABYLON {
  117363. interface Engine {
  117364. /**
  117365. * Create an effect to use with particle systems.
  117366. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  117367. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  117368. * @param uniformsNames defines a list of attribute names
  117369. * @param samplers defines an array of string used to represent textures
  117370. * @param defines defines the string containing the defines to use to compile the shaders
  117371. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  117372. * @param onCompiled defines a function to call when the effect creation is successful
  117373. * @param onError defines a function to call when the effect creation has failed
  117374. * @returns the new Effect
  117375. */
  117376. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  117377. }
  117378. interface Mesh {
  117379. /**
  117380. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  117381. * @returns an array of IParticleSystem
  117382. */
  117383. getEmittedParticleSystems(): IParticleSystem[];
  117384. /**
  117385. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  117386. * @returns an array of IParticleSystem
  117387. */
  117388. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  117389. }
  117390. /**
  117391. * @hidden
  117392. */
  117393. export var _IDoNeedToBeInTheBuild: number;
  117394. }
  117395. declare module BABYLON {
  117396. interface Scene {
  117397. /** @hidden (Backing field) */
  117398. _physicsEngine: Nullable<IPhysicsEngine>;
  117399. /**
  117400. * Gets the current physics engine
  117401. * @returns a IPhysicsEngine or null if none attached
  117402. */
  117403. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  117404. /**
  117405. * Enables physics to the current scene
  117406. * @param gravity defines the scene's gravity for the physics engine
  117407. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  117408. * @return a boolean indicating if the physics engine was initialized
  117409. */
  117410. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  117411. /**
  117412. * Disables and disposes the physics engine associated with the scene
  117413. */
  117414. disablePhysicsEngine(): void;
  117415. /**
  117416. * Gets a boolean indicating if there is an active physics engine
  117417. * @returns a boolean indicating if there is an active physics engine
  117418. */
  117419. isPhysicsEnabled(): boolean;
  117420. /**
  117421. * Deletes a physics compound impostor
  117422. * @param compound defines the compound to delete
  117423. */
  117424. deleteCompoundImpostor(compound: any): void;
  117425. /**
  117426. * An event triggered when physic simulation is about to be run
  117427. */
  117428. onBeforePhysicsObservable: Observable<Scene>;
  117429. /**
  117430. * An event triggered when physic simulation has been done
  117431. */
  117432. onAfterPhysicsObservable: Observable<Scene>;
  117433. }
  117434. interface AbstractMesh {
  117435. /** @hidden */
  117436. _physicsImpostor: Nullable<PhysicsImpostor>;
  117437. /**
  117438. * Gets or sets impostor used for physic simulation
  117439. * @see http://doc.babylonjs.com/features/physics_engine
  117440. */
  117441. physicsImpostor: Nullable<PhysicsImpostor>;
  117442. /**
  117443. * Gets the current physics impostor
  117444. * @see http://doc.babylonjs.com/features/physics_engine
  117445. * @returns a physics impostor or null
  117446. */
  117447. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  117448. /** Apply a physic impulse to the mesh
  117449. * @param force defines the force to apply
  117450. * @param contactPoint defines where to apply the force
  117451. * @returns the current mesh
  117452. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117453. */
  117454. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  117455. /**
  117456. * Creates a physic joint between two meshes
  117457. * @param otherMesh defines the other mesh to use
  117458. * @param pivot1 defines the pivot to use on this mesh
  117459. * @param pivot2 defines the pivot to use on the other mesh
  117460. * @param options defines additional options (can be plugin dependent)
  117461. * @returns the current mesh
  117462. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  117463. */
  117464. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  117465. /** @hidden */
  117466. _disposePhysicsObserver: Nullable<Observer<Node>>;
  117467. }
  117468. /**
  117469. * Defines the physics engine scene component responsible to manage a physics engine
  117470. */
  117471. export class PhysicsEngineSceneComponent implements ISceneComponent {
  117472. /**
  117473. * The component name helpful to identify the component in the list of scene components.
  117474. */
  117475. readonly name: string;
  117476. /**
  117477. * The scene the component belongs to.
  117478. */
  117479. scene: Scene;
  117480. /**
  117481. * Creates a new instance of the component for the given scene
  117482. * @param scene Defines the scene to register the component in
  117483. */
  117484. constructor(scene: Scene);
  117485. /**
  117486. * Registers the component in a given scene
  117487. */
  117488. register(): void;
  117489. /**
  117490. * Rebuilds the elements related to this component in case of
  117491. * context lost for instance.
  117492. */
  117493. rebuild(): void;
  117494. /**
  117495. * Disposes the component and the associated ressources
  117496. */
  117497. dispose(): void;
  117498. }
  117499. }
  117500. declare module BABYLON {
  117501. /**
  117502. * A helper for physics simulations
  117503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117504. */
  117505. export class PhysicsHelper {
  117506. private _scene;
  117507. private _physicsEngine;
  117508. /**
  117509. * Initializes the Physics helper
  117510. * @param scene Babylon.js scene
  117511. */
  117512. constructor(scene: Scene);
  117513. /**
  117514. * Applies a radial explosion impulse
  117515. * @param origin the origin of the explosion
  117516. * @param radiusOrEventOptions the radius or the options of radial explosion
  117517. * @param strength the explosion strength
  117518. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117519. * @returns A physics radial explosion event, or null
  117520. */
  117521. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117522. /**
  117523. * Applies a radial explosion force
  117524. * @param origin the origin of the explosion
  117525. * @param radiusOrEventOptions the radius or the options of radial explosion
  117526. * @param strength the explosion strength
  117527. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117528. * @returns A physics radial explosion event, or null
  117529. */
  117530. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117531. /**
  117532. * Creates a gravitational field
  117533. * @param origin the origin of the explosion
  117534. * @param radiusOrEventOptions the radius or the options of radial explosion
  117535. * @param strength the explosion strength
  117536. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117537. * @returns A physics gravitational field event, or null
  117538. */
  117539. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  117540. /**
  117541. * Creates a physics updraft event
  117542. * @param origin the origin of the updraft
  117543. * @param radiusOrEventOptions the radius or the options of the updraft
  117544. * @param strength the strength of the updraft
  117545. * @param height the height of the updraft
  117546. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  117547. * @returns A physics updraft event, or null
  117548. */
  117549. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  117550. /**
  117551. * Creates a physics vortex event
  117552. * @param origin the of the vortex
  117553. * @param radiusOrEventOptions the radius or the options of the vortex
  117554. * @param strength the strength of the vortex
  117555. * @param height the height of the vortex
  117556. * @returns a Physics vortex event, or null
  117557. * A physics vortex event or null
  117558. */
  117559. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  117560. }
  117561. /**
  117562. * Represents a physics radial explosion event
  117563. */
  117564. class PhysicsRadialExplosionEvent {
  117565. private _scene;
  117566. private _options;
  117567. private _sphere;
  117568. private _dataFetched;
  117569. /**
  117570. * Initializes a radial explosioin event
  117571. * @param _scene BabylonJS scene
  117572. * @param _options The options for the vortex event
  117573. */
  117574. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  117575. /**
  117576. * Returns the data related to the radial explosion event (sphere).
  117577. * @returns The radial explosion event data
  117578. */
  117579. getData(): PhysicsRadialExplosionEventData;
  117580. /**
  117581. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  117582. * @param impostor A physics imposter
  117583. * @param origin the origin of the explosion
  117584. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  117585. */
  117586. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  117587. /**
  117588. * Triggers affecterd impostors callbacks
  117589. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  117590. */
  117591. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  117592. /**
  117593. * Disposes the sphere.
  117594. * @param force Specifies if the sphere should be disposed by force
  117595. */
  117596. dispose(force?: boolean): void;
  117597. /*** Helpers ***/
  117598. private _prepareSphere;
  117599. private _intersectsWithSphere;
  117600. }
  117601. /**
  117602. * Represents a gravitational field event
  117603. */
  117604. class PhysicsGravitationalFieldEvent {
  117605. private _physicsHelper;
  117606. private _scene;
  117607. private _origin;
  117608. private _options;
  117609. private _tickCallback;
  117610. private _sphere;
  117611. private _dataFetched;
  117612. /**
  117613. * Initializes the physics gravitational field event
  117614. * @param _physicsHelper A physics helper
  117615. * @param _scene BabylonJS scene
  117616. * @param _origin The origin position of the gravitational field event
  117617. * @param _options The options for the vortex event
  117618. */
  117619. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  117620. /**
  117621. * Returns the data related to the gravitational field event (sphere).
  117622. * @returns A gravitational field event
  117623. */
  117624. getData(): PhysicsGravitationalFieldEventData;
  117625. /**
  117626. * Enables the gravitational field.
  117627. */
  117628. enable(): void;
  117629. /**
  117630. * Disables the gravitational field.
  117631. */
  117632. disable(): void;
  117633. /**
  117634. * Disposes the sphere.
  117635. * @param force The force to dispose from the gravitational field event
  117636. */
  117637. dispose(force?: boolean): void;
  117638. private _tick;
  117639. }
  117640. /**
  117641. * Represents a physics updraft event
  117642. */
  117643. class PhysicsUpdraftEvent {
  117644. private _scene;
  117645. private _origin;
  117646. private _options;
  117647. private _physicsEngine;
  117648. private _originTop;
  117649. private _originDirection;
  117650. private _tickCallback;
  117651. private _cylinder;
  117652. private _cylinderPosition;
  117653. private _dataFetched;
  117654. /**
  117655. * Initializes the physics updraft event
  117656. * @param _scene BabylonJS scene
  117657. * @param _origin The origin position of the updraft
  117658. * @param _options The options for the updraft event
  117659. */
  117660. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  117661. /**
  117662. * Returns the data related to the updraft event (cylinder).
  117663. * @returns A physics updraft event
  117664. */
  117665. getData(): PhysicsUpdraftEventData;
  117666. /**
  117667. * Enables the updraft.
  117668. */
  117669. enable(): void;
  117670. /**
  117671. * Disables the updraft.
  117672. */
  117673. disable(): void;
  117674. /**
  117675. * Disposes the cylinder.
  117676. * @param force Specifies if the updraft should be disposed by force
  117677. */
  117678. dispose(force?: boolean): void;
  117679. private getImpostorHitData;
  117680. private _tick;
  117681. /*** Helpers ***/
  117682. private _prepareCylinder;
  117683. private _intersectsWithCylinder;
  117684. }
  117685. /**
  117686. * Represents a physics vortex event
  117687. */
  117688. class PhysicsVortexEvent {
  117689. private _scene;
  117690. private _origin;
  117691. private _options;
  117692. private _physicsEngine;
  117693. private _originTop;
  117694. private _tickCallback;
  117695. private _cylinder;
  117696. private _cylinderPosition;
  117697. private _dataFetched;
  117698. /**
  117699. * Initializes the physics vortex event
  117700. * @param _scene The BabylonJS scene
  117701. * @param _origin The origin position of the vortex
  117702. * @param _options The options for the vortex event
  117703. */
  117704. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  117705. /**
  117706. * Returns the data related to the vortex event (cylinder).
  117707. * @returns The physics vortex event data
  117708. */
  117709. getData(): PhysicsVortexEventData;
  117710. /**
  117711. * Enables the vortex.
  117712. */
  117713. enable(): void;
  117714. /**
  117715. * Disables the cortex.
  117716. */
  117717. disable(): void;
  117718. /**
  117719. * Disposes the sphere.
  117720. * @param force
  117721. */
  117722. dispose(force?: boolean): void;
  117723. private getImpostorHitData;
  117724. private _tick;
  117725. /*** Helpers ***/
  117726. private _prepareCylinder;
  117727. private _intersectsWithCylinder;
  117728. }
  117729. /**
  117730. * Options fot the radial explosion event
  117731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117732. */
  117733. export class PhysicsRadialExplosionEventOptions {
  117734. /**
  117735. * The radius of the sphere for the radial explosion.
  117736. */
  117737. radius: number;
  117738. /**
  117739. * The strenth of the explosion.
  117740. */
  117741. strength: number;
  117742. /**
  117743. * The strenght of the force in correspondence to the distance of the affected object
  117744. */
  117745. falloff: PhysicsRadialImpulseFalloff;
  117746. /**
  117747. * Sphere options for the radial explosion.
  117748. */
  117749. sphere: {
  117750. segments: number;
  117751. diameter: number;
  117752. };
  117753. /**
  117754. * Sphere options for the radial explosion.
  117755. */
  117756. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  117757. }
  117758. /**
  117759. * Options fot the updraft event
  117760. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117761. */
  117762. export class PhysicsUpdraftEventOptions {
  117763. /**
  117764. * The radius of the cylinder for the vortex
  117765. */
  117766. radius: number;
  117767. /**
  117768. * The strenth of the updraft.
  117769. */
  117770. strength: number;
  117771. /**
  117772. * The height of the cylinder for the updraft.
  117773. */
  117774. height: number;
  117775. /**
  117776. * The mode for the the updraft.
  117777. */
  117778. updraftMode: PhysicsUpdraftMode;
  117779. }
  117780. /**
  117781. * Options fot the vortex event
  117782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117783. */
  117784. export class PhysicsVortexEventOptions {
  117785. /**
  117786. * The radius of the cylinder for the vortex
  117787. */
  117788. radius: number;
  117789. /**
  117790. * The strenth of the vortex.
  117791. */
  117792. strength: number;
  117793. /**
  117794. * The height of the cylinder for the vortex.
  117795. */
  117796. height: number;
  117797. /**
  117798. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  117799. */
  117800. centripetalForceThreshold: number;
  117801. /**
  117802. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  117803. */
  117804. centripetalForceMultiplier: number;
  117805. /**
  117806. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  117807. */
  117808. centrifugalForceMultiplier: number;
  117809. /**
  117810. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  117811. */
  117812. updraftForceMultiplier: number;
  117813. }
  117814. /**
  117815. * The strenght of the force in correspondence to the distance of the affected object
  117816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117817. */
  117818. export enum PhysicsRadialImpulseFalloff {
  117819. /** Defines that impulse is constant in strength across it's whole radius */
  117820. Constant = 0,
  117821. /** Defines that impulse gets weaker if it's further from the origin */
  117822. Linear = 1
  117823. }
  117824. /**
  117825. * The strength of the force in correspondence to the distance of the affected object
  117826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117827. */
  117828. export enum PhysicsUpdraftMode {
  117829. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  117830. Center = 0,
  117831. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  117832. Perpendicular = 1
  117833. }
  117834. /**
  117835. * Interface for a physics hit data
  117836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117837. */
  117838. export interface PhysicsHitData {
  117839. /**
  117840. * The force applied at the contact point
  117841. */
  117842. force: Vector3;
  117843. /**
  117844. * The contact point
  117845. */
  117846. contactPoint: Vector3;
  117847. /**
  117848. * The distance from the origin to the contact point
  117849. */
  117850. distanceFromOrigin: number;
  117851. }
  117852. /**
  117853. * Interface for radial explosion event data
  117854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117855. */
  117856. export interface PhysicsRadialExplosionEventData {
  117857. /**
  117858. * A sphere used for the radial explosion event
  117859. */
  117860. sphere: Mesh;
  117861. }
  117862. /**
  117863. * Interface for gravitational field event data
  117864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117865. */
  117866. export interface PhysicsGravitationalFieldEventData {
  117867. /**
  117868. * A sphere mesh used for the gravitational field event
  117869. */
  117870. sphere: Mesh;
  117871. }
  117872. /**
  117873. * Interface for updraft event data
  117874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117875. */
  117876. export interface PhysicsUpdraftEventData {
  117877. /**
  117878. * A cylinder used for the updraft event
  117879. */
  117880. cylinder: Mesh;
  117881. }
  117882. /**
  117883. * Interface for vortex event data
  117884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117885. */
  117886. export interface PhysicsVortexEventData {
  117887. /**
  117888. * A cylinder used for the vortex event
  117889. */
  117890. cylinder: Mesh;
  117891. }
  117892. /**
  117893. * Interface for an affected physics impostor
  117894. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117895. */
  117896. export interface PhysicsAffectedImpostorWithData {
  117897. /**
  117898. * The impostor affected by the effect
  117899. */
  117900. impostor: PhysicsImpostor;
  117901. /**
  117902. * The data about the hit/horce from the explosion
  117903. */
  117904. hitData: PhysicsHitData;
  117905. }
  117906. }
  117907. declare module BABYLON {
  117908. /** @hidden */
  117909. export var blackAndWhitePixelShader: {
  117910. name: string;
  117911. shader: string;
  117912. };
  117913. }
  117914. declare module BABYLON {
  117915. /**
  117916. * Post process used to render in black and white
  117917. */
  117918. export class BlackAndWhitePostProcess extends PostProcess {
  117919. /**
  117920. * Linear about to convert he result to black and white (default: 1)
  117921. */
  117922. degree: number;
  117923. /**
  117924. * Creates a black and white post process
  117925. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  117926. * @param name The name of the effect.
  117927. * @param options The required width/height ratio to downsize to before computing the render pass.
  117928. * @param camera The camera to apply the render pass to.
  117929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117930. * @param engine The engine which the post process will be applied. (default: current engine)
  117931. * @param reusable If the post process can be reused on the same frame. (default: false)
  117932. */
  117933. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117934. }
  117935. }
  117936. declare module BABYLON {
  117937. /**
  117938. * This represents a set of one or more post processes in Babylon.
  117939. * A post process can be used to apply a shader to a texture after it is rendered.
  117940. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117941. */
  117942. export class PostProcessRenderEffect {
  117943. private _postProcesses;
  117944. private _getPostProcesses;
  117945. private _singleInstance;
  117946. private _cameras;
  117947. private _indicesForCamera;
  117948. /**
  117949. * Name of the effect
  117950. * @hidden
  117951. */
  117952. _name: string;
  117953. /**
  117954. * Instantiates a post process render effect.
  117955. * A post process can be used to apply a shader to a texture after it is rendered.
  117956. * @param engine The engine the effect is tied to
  117957. * @param name The name of the effect
  117958. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  117959. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  117960. */
  117961. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  117962. /**
  117963. * Checks if all the post processes in the effect are supported.
  117964. */
  117965. readonly isSupported: boolean;
  117966. /**
  117967. * Updates the current state of the effect
  117968. * @hidden
  117969. */
  117970. _update(): void;
  117971. /**
  117972. * Attaches the effect on cameras
  117973. * @param cameras The camera to attach to.
  117974. * @hidden
  117975. */
  117976. _attachCameras(cameras: Camera): void;
  117977. /**
  117978. * Attaches the effect on cameras
  117979. * @param cameras The camera to attach to.
  117980. * @hidden
  117981. */
  117982. _attachCameras(cameras: Camera[]): void;
  117983. /**
  117984. * Detaches the effect on cameras
  117985. * @param cameras The camera to detatch from.
  117986. * @hidden
  117987. */
  117988. _detachCameras(cameras: Camera): void;
  117989. /**
  117990. * Detatches the effect on cameras
  117991. * @param cameras The camera to detatch from.
  117992. * @hidden
  117993. */
  117994. _detachCameras(cameras: Camera[]): void;
  117995. /**
  117996. * Enables the effect on given cameras
  117997. * @param cameras The camera to enable.
  117998. * @hidden
  117999. */
  118000. _enable(cameras: Camera): void;
  118001. /**
  118002. * Enables the effect on given cameras
  118003. * @param cameras The camera to enable.
  118004. * @hidden
  118005. */
  118006. _enable(cameras: Nullable<Camera[]>): void;
  118007. /**
  118008. * Disables the effect on the given cameras
  118009. * @param cameras The camera to disable.
  118010. * @hidden
  118011. */
  118012. _disable(cameras: Camera): void;
  118013. /**
  118014. * Disables the effect on the given cameras
  118015. * @param cameras The camera to disable.
  118016. * @hidden
  118017. */
  118018. _disable(cameras: Nullable<Camera[]>): void;
  118019. /**
  118020. * Gets a list of the post processes contained in the effect.
  118021. * @param camera The camera to get the post processes on.
  118022. * @returns The list of the post processes in the effect.
  118023. */
  118024. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  118025. }
  118026. }
  118027. declare module BABYLON {
  118028. /** @hidden */
  118029. export var extractHighlightsPixelShader: {
  118030. name: string;
  118031. shader: string;
  118032. };
  118033. }
  118034. declare module BABYLON {
  118035. /**
  118036. * 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.
  118037. */
  118038. export class ExtractHighlightsPostProcess extends PostProcess {
  118039. /**
  118040. * The luminance threshold, pixels below this value will be set to black.
  118041. */
  118042. threshold: number;
  118043. /** @hidden */
  118044. _exposure: number;
  118045. /**
  118046. * Post process which has the input texture to be used when performing highlight extraction
  118047. * @hidden
  118048. */
  118049. _inputPostProcess: Nullable<PostProcess>;
  118050. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118051. }
  118052. }
  118053. declare module BABYLON {
  118054. /** @hidden */
  118055. export var bloomMergePixelShader: {
  118056. name: string;
  118057. shader: string;
  118058. };
  118059. }
  118060. declare module BABYLON {
  118061. /**
  118062. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118063. */
  118064. export class BloomMergePostProcess extends PostProcess {
  118065. /** Weight of the bloom to be added to the original input. */
  118066. weight: number;
  118067. /**
  118068. * Creates a new instance of @see BloomMergePostProcess
  118069. * @param name The name of the effect.
  118070. * @param originalFromInput Post process which's input will be used for the merge.
  118071. * @param blurred Blurred highlights post process which's output will be used.
  118072. * @param weight Weight of the bloom to be added to the original input.
  118073. * @param options The required width/height ratio to downsize to before computing the render pass.
  118074. * @param camera The camera to apply the render pass to.
  118075. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118076. * @param engine The engine which the post process will be applied. (default: current engine)
  118077. * @param reusable If the post process can be reused on the same frame. (default: false)
  118078. * @param textureType Type of textures used when performing the post process. (default: 0)
  118079. * @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)
  118080. */
  118081. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  118082. /** Weight of the bloom to be added to the original input. */
  118083. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118084. }
  118085. }
  118086. declare module BABYLON {
  118087. /**
  118088. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  118089. */
  118090. export class BloomEffect extends PostProcessRenderEffect {
  118091. private bloomScale;
  118092. /**
  118093. * @hidden Internal
  118094. */
  118095. _effects: Array<PostProcess>;
  118096. /**
  118097. * @hidden Internal
  118098. */
  118099. _downscale: ExtractHighlightsPostProcess;
  118100. private _blurX;
  118101. private _blurY;
  118102. private _merge;
  118103. /**
  118104. * The luminance threshold to find bright areas of the image to bloom.
  118105. */
  118106. threshold: number;
  118107. /**
  118108. * The strength of the bloom.
  118109. */
  118110. weight: number;
  118111. /**
  118112. * Specifies the size of the bloom blur kernel, relative to the final output size
  118113. */
  118114. kernel: number;
  118115. /**
  118116. * Creates a new instance of @see BloomEffect
  118117. * @param scene The scene the effect belongs to.
  118118. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  118119. * @param bloomKernel The size of the kernel to be used when applying the blur.
  118120. * @param bloomWeight The the strength of bloom.
  118121. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118122. * @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)
  118123. */
  118124. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  118125. /**
  118126. * Disposes each of the internal effects for a given camera.
  118127. * @param camera The camera to dispose the effect on.
  118128. */
  118129. disposeEffects(camera: Camera): void;
  118130. /**
  118131. * @hidden Internal
  118132. */
  118133. _updateEffects(): void;
  118134. /**
  118135. * Internal
  118136. * @returns if all the contained post processes are ready.
  118137. * @hidden
  118138. */
  118139. _isReady(): boolean;
  118140. }
  118141. }
  118142. declare module BABYLON {
  118143. /** @hidden */
  118144. export var chromaticAberrationPixelShader: {
  118145. name: string;
  118146. shader: string;
  118147. };
  118148. }
  118149. declare module BABYLON {
  118150. /**
  118151. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  118152. */
  118153. export class ChromaticAberrationPostProcess extends PostProcess {
  118154. /**
  118155. * The amount of seperation of rgb channels (default: 30)
  118156. */
  118157. aberrationAmount: number;
  118158. /**
  118159. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  118160. */
  118161. radialIntensity: number;
  118162. /**
  118163. * 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))
  118164. */
  118165. direction: Vector2;
  118166. /**
  118167. * 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))
  118168. */
  118169. centerPosition: Vector2;
  118170. /**
  118171. * Creates a new instance ChromaticAberrationPostProcess
  118172. * @param name The name of the effect.
  118173. * @param screenWidth The width of the screen to apply the effect on.
  118174. * @param screenHeight The height of the screen to apply the effect on.
  118175. * @param options The required width/height ratio to downsize to before computing the render pass.
  118176. * @param camera The camera to apply the render pass to.
  118177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118178. * @param engine The engine which the post process will be applied. (default: current engine)
  118179. * @param reusable If the post process can be reused on the same frame. (default: false)
  118180. * @param textureType Type of textures used when performing the post process. (default: 0)
  118181. * @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)
  118182. */
  118183. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118184. }
  118185. }
  118186. declare module BABYLON {
  118187. /** @hidden */
  118188. export var circleOfConfusionPixelShader: {
  118189. name: string;
  118190. shader: string;
  118191. };
  118192. }
  118193. declare module BABYLON {
  118194. /**
  118195. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  118196. */
  118197. export class CircleOfConfusionPostProcess extends PostProcess {
  118198. /**
  118199. * 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.
  118200. */
  118201. lensSize: number;
  118202. /**
  118203. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118204. */
  118205. fStop: number;
  118206. /**
  118207. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118208. */
  118209. focusDistance: number;
  118210. /**
  118211. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  118212. */
  118213. focalLength: number;
  118214. private _depthTexture;
  118215. /**
  118216. * Creates a new instance CircleOfConfusionPostProcess
  118217. * @param name The name of the effect.
  118218. * @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.
  118219. * @param options The required width/height ratio to downsize to before computing the render pass.
  118220. * @param camera The camera to apply the render pass to.
  118221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118222. * @param engine The engine which the post process will be applied. (default: current engine)
  118223. * @param reusable If the post process can be reused on the same frame. (default: false)
  118224. * @param textureType Type of textures used when performing the post process. (default: 0)
  118225. * @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)
  118226. */
  118227. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118228. /**
  118229. * 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.
  118230. */
  118231. depthTexture: RenderTargetTexture;
  118232. }
  118233. }
  118234. declare module BABYLON {
  118235. /** @hidden */
  118236. export var colorCorrectionPixelShader: {
  118237. name: string;
  118238. shader: string;
  118239. };
  118240. }
  118241. declare module BABYLON {
  118242. /**
  118243. *
  118244. * This post-process allows the modification of rendered colors by using
  118245. * a 'look-up table' (LUT). This effect is also called Color Grading.
  118246. *
  118247. * The object needs to be provided an url to a texture containing the color
  118248. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  118249. * Use an image editing software to tweak the LUT to match your needs.
  118250. *
  118251. * For an example of a color LUT, see here:
  118252. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  118253. * For explanations on color grading, see here:
  118254. * @see http://udn.epicgames.com/Three/ColorGrading.html
  118255. *
  118256. */
  118257. export class ColorCorrectionPostProcess extends PostProcess {
  118258. private _colorTableTexture;
  118259. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118260. }
  118261. }
  118262. declare module BABYLON {
  118263. /** @hidden */
  118264. export var convolutionPixelShader: {
  118265. name: string;
  118266. shader: string;
  118267. };
  118268. }
  118269. declare module BABYLON {
  118270. /**
  118271. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  118272. * input texture to perform effects such as edge detection or sharpening
  118273. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118274. */
  118275. export class ConvolutionPostProcess extends PostProcess {
  118276. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118277. kernel: number[];
  118278. /**
  118279. * Creates a new instance ConvolutionPostProcess
  118280. * @param name The name of the effect.
  118281. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  118282. * @param options The required width/height ratio to downsize to before computing the render pass.
  118283. * @param camera The camera to apply the render pass to.
  118284. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118285. * @param engine The engine which the post process will be applied. (default: current engine)
  118286. * @param reusable If the post process can be reused on the same frame. (default: false)
  118287. * @param textureType Type of textures used when performing the post process. (default: 0)
  118288. */
  118289. constructor(name: string,
  118290. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118291. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118292. /**
  118293. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118294. */
  118295. static EdgeDetect0Kernel: number[];
  118296. /**
  118297. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118298. */
  118299. static EdgeDetect1Kernel: number[];
  118300. /**
  118301. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118302. */
  118303. static EdgeDetect2Kernel: number[];
  118304. /**
  118305. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118306. */
  118307. static SharpenKernel: number[];
  118308. /**
  118309. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118310. */
  118311. static EmbossKernel: number[];
  118312. /**
  118313. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118314. */
  118315. static GaussianKernel: number[];
  118316. }
  118317. }
  118318. declare module BABYLON {
  118319. /**
  118320. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  118321. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  118322. * based on samples that have a large difference in distance than the center pixel.
  118323. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  118324. */
  118325. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  118326. direction: Vector2;
  118327. /**
  118328. * Creates a new instance CircleOfConfusionPostProcess
  118329. * @param name The name of the effect.
  118330. * @param scene The scene the effect belongs to.
  118331. * @param direction The direction the blur should be applied.
  118332. * @param kernel The size of the kernel used to blur.
  118333. * @param options The required width/height ratio to downsize to before computing the render pass.
  118334. * @param camera The camera to apply the render pass to.
  118335. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  118336. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  118337. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118338. * @param engine The engine which the post process will be applied. (default: current engine)
  118339. * @param reusable If the post process can be reused on the same frame. (default: false)
  118340. * @param textureType Type of textures used when performing the post process. (default: 0)
  118341. * @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)
  118342. */
  118343. 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);
  118344. }
  118345. }
  118346. declare module BABYLON {
  118347. /** @hidden */
  118348. export var depthOfFieldMergePixelShader: {
  118349. name: string;
  118350. shader: string;
  118351. };
  118352. }
  118353. declare module BABYLON {
  118354. /**
  118355. * Options to be set when merging outputs from the default pipeline.
  118356. */
  118357. export class DepthOfFieldMergePostProcessOptions {
  118358. /**
  118359. * The original image to merge on top of
  118360. */
  118361. originalFromInput: PostProcess;
  118362. /**
  118363. * Parameters to perform the merge of the depth of field effect
  118364. */
  118365. depthOfField?: {
  118366. circleOfConfusion: PostProcess;
  118367. blurSteps: Array<PostProcess>;
  118368. };
  118369. /**
  118370. * Parameters to perform the merge of bloom effect
  118371. */
  118372. bloom?: {
  118373. blurred: PostProcess;
  118374. weight: number;
  118375. };
  118376. }
  118377. /**
  118378. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118379. */
  118380. export class DepthOfFieldMergePostProcess extends PostProcess {
  118381. private blurSteps;
  118382. /**
  118383. * Creates a new instance of DepthOfFieldMergePostProcess
  118384. * @param name The name of the effect.
  118385. * @param originalFromInput Post process which's input will be used for the merge.
  118386. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  118387. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  118388. * @param options The required width/height ratio to downsize to before computing the render pass.
  118389. * @param camera The camera to apply the render pass to.
  118390. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118391. * @param engine The engine which the post process will be applied. (default: current engine)
  118392. * @param reusable If the post process can be reused on the same frame. (default: false)
  118393. * @param textureType Type of textures used when performing the post process. (default: 0)
  118394. * @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)
  118395. */
  118396. 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);
  118397. /**
  118398. * Updates the effect with the current post process compile time values and recompiles the shader.
  118399. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118400. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118401. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118402. * @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
  118403. * @param onCompiled Called when the shader has been compiled.
  118404. * @param onError Called if there is an error when compiling a shader.
  118405. */
  118406. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  118407. }
  118408. }
  118409. declare module BABYLON {
  118410. /**
  118411. * Specifies the level of max blur that should be applied when using the depth of field effect
  118412. */
  118413. export enum DepthOfFieldEffectBlurLevel {
  118414. /**
  118415. * Subtle blur
  118416. */
  118417. Low = 0,
  118418. /**
  118419. * Medium blur
  118420. */
  118421. Medium = 1,
  118422. /**
  118423. * Large blur
  118424. */
  118425. High = 2
  118426. }
  118427. /**
  118428. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  118429. */
  118430. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  118431. private _circleOfConfusion;
  118432. /**
  118433. * @hidden Internal, blurs from high to low
  118434. */
  118435. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  118436. private _depthOfFieldBlurY;
  118437. private _dofMerge;
  118438. /**
  118439. * @hidden Internal post processes in depth of field effect
  118440. */
  118441. _effects: Array<PostProcess>;
  118442. /**
  118443. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  118444. */
  118445. focalLength: number;
  118446. /**
  118447. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118448. */
  118449. fStop: number;
  118450. /**
  118451. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118452. */
  118453. focusDistance: number;
  118454. /**
  118455. * 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.
  118456. */
  118457. lensSize: number;
  118458. /**
  118459. * Creates a new instance DepthOfFieldEffect
  118460. * @param scene The scene the effect belongs to.
  118461. * @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.
  118462. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118463. * @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)
  118464. */
  118465. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  118466. /**
  118467. * Get the current class name of the current effet
  118468. * @returns "DepthOfFieldEffect"
  118469. */
  118470. getClassName(): string;
  118471. /**
  118472. * 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.
  118473. */
  118474. depthTexture: RenderTargetTexture;
  118475. /**
  118476. * Disposes each of the internal effects for a given camera.
  118477. * @param camera The camera to dispose the effect on.
  118478. */
  118479. disposeEffects(camera: Camera): void;
  118480. /**
  118481. * @hidden Internal
  118482. */
  118483. _updateEffects(): void;
  118484. /**
  118485. * Internal
  118486. * @returns if all the contained post processes are ready.
  118487. * @hidden
  118488. */
  118489. _isReady(): boolean;
  118490. }
  118491. }
  118492. declare module BABYLON {
  118493. /** @hidden */
  118494. export var displayPassPixelShader: {
  118495. name: string;
  118496. shader: string;
  118497. };
  118498. }
  118499. declare module BABYLON {
  118500. /**
  118501. * DisplayPassPostProcess which produces an output the same as it's input
  118502. */
  118503. export class DisplayPassPostProcess extends PostProcess {
  118504. /**
  118505. * Creates the DisplayPassPostProcess
  118506. * @param name The name of the effect.
  118507. * @param options The required width/height ratio to downsize to before computing the render pass.
  118508. * @param camera The camera to apply the render pass to.
  118509. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118510. * @param engine The engine which the post process will be applied. (default: current engine)
  118511. * @param reusable If the post process can be reused on the same frame. (default: false)
  118512. */
  118513. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118514. }
  118515. }
  118516. declare module BABYLON {
  118517. /** @hidden */
  118518. export var filterPixelShader: {
  118519. name: string;
  118520. shader: string;
  118521. };
  118522. }
  118523. declare module BABYLON {
  118524. /**
  118525. * Applies a kernel filter to the image
  118526. */
  118527. export class FilterPostProcess extends PostProcess {
  118528. /** The matrix to be applied to the image */
  118529. kernelMatrix: Matrix;
  118530. /**
  118531. *
  118532. * @param name The name of the effect.
  118533. * @param kernelMatrix The matrix to be applied to the image
  118534. * @param options The required width/height ratio to downsize to before computing the render pass.
  118535. * @param camera The camera to apply the render pass to.
  118536. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118537. * @param engine The engine which the post process will be applied. (default: current engine)
  118538. * @param reusable If the post process can be reused on the same frame. (default: false)
  118539. */
  118540. constructor(name: string,
  118541. /** The matrix to be applied to the image */
  118542. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118543. }
  118544. }
  118545. declare module BABYLON {
  118546. /** @hidden */
  118547. export var fxaaPixelShader: {
  118548. name: string;
  118549. shader: string;
  118550. };
  118551. }
  118552. declare module BABYLON {
  118553. /** @hidden */
  118554. export var fxaaVertexShader: {
  118555. name: string;
  118556. shader: string;
  118557. };
  118558. }
  118559. declare module BABYLON {
  118560. /**
  118561. * Fxaa post process
  118562. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  118563. */
  118564. export class FxaaPostProcess extends PostProcess {
  118565. /** @hidden */
  118566. texelWidth: number;
  118567. /** @hidden */
  118568. texelHeight: number;
  118569. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118570. private _getDefines;
  118571. }
  118572. }
  118573. declare module BABYLON {
  118574. /** @hidden */
  118575. export var grainPixelShader: {
  118576. name: string;
  118577. shader: string;
  118578. };
  118579. }
  118580. declare module BABYLON {
  118581. /**
  118582. * The GrainPostProcess adds noise to the image at mid luminance levels
  118583. */
  118584. export class GrainPostProcess extends PostProcess {
  118585. /**
  118586. * The intensity of the grain added (default: 30)
  118587. */
  118588. intensity: number;
  118589. /**
  118590. * If the grain should be randomized on every frame
  118591. */
  118592. animated: boolean;
  118593. /**
  118594. * Creates a new instance of @see GrainPostProcess
  118595. * @param name The name of the effect.
  118596. * @param options The required width/height ratio to downsize to before computing the render pass.
  118597. * @param camera The camera to apply the render pass to.
  118598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118599. * @param engine The engine which the post process will be applied. (default: current engine)
  118600. * @param reusable If the post process can be reused on the same frame. (default: false)
  118601. * @param textureType Type of textures used when performing the post process. (default: 0)
  118602. * @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)
  118603. */
  118604. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118605. }
  118606. }
  118607. declare module BABYLON {
  118608. /** @hidden */
  118609. export var highlightsPixelShader: {
  118610. name: string;
  118611. shader: string;
  118612. };
  118613. }
  118614. declare module BABYLON {
  118615. /**
  118616. * Extracts highlights from the image
  118617. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118618. */
  118619. export class HighlightsPostProcess extends PostProcess {
  118620. /**
  118621. * Extracts highlights from the image
  118622. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118623. * @param name The name of the effect.
  118624. * @param options The required width/height ratio to downsize to before computing the render pass.
  118625. * @param camera The camera to apply the render pass to.
  118626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118627. * @param engine The engine which the post process will be applied. (default: current engine)
  118628. * @param reusable If the post process can be reused on the same frame. (default: false)
  118629. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  118630. */
  118631. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118632. }
  118633. }
  118634. declare module BABYLON {
  118635. /** @hidden */
  118636. export var mrtFragmentDeclaration: {
  118637. name: string;
  118638. shader: string;
  118639. };
  118640. }
  118641. declare module BABYLON {
  118642. /** @hidden */
  118643. export var geometryPixelShader: {
  118644. name: string;
  118645. shader: string;
  118646. };
  118647. }
  118648. declare module BABYLON {
  118649. /** @hidden */
  118650. export var geometryVertexShader: {
  118651. name: string;
  118652. shader: string;
  118653. };
  118654. }
  118655. declare module BABYLON {
  118656. /** @hidden */
  118657. interface ISavedTransformationMatrix {
  118658. world: Matrix;
  118659. viewProjection: Matrix;
  118660. }
  118661. /**
  118662. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  118663. */
  118664. export class GeometryBufferRenderer {
  118665. /**
  118666. * Constant used to retrieve the position texture index in the G-Buffer textures array
  118667. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  118668. */
  118669. static readonly POSITION_TEXTURE_TYPE: number;
  118670. /**
  118671. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  118672. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  118673. */
  118674. static readonly VELOCITY_TEXTURE_TYPE: number;
  118675. /**
  118676. * Dictionary used to store the previous transformation matrices of each rendered mesh
  118677. * in order to compute objects velocities when enableVelocity is set to "true"
  118678. * @hidden
  118679. */
  118680. _previousTransformationMatrices: {
  118681. [index: number]: ISavedTransformationMatrix;
  118682. };
  118683. /**
  118684. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  118685. * in order to compute objects velocities when enableVelocity is set to "true"
  118686. * @hidden
  118687. */
  118688. _previousBonesTransformationMatrices: {
  118689. [index: number]: Float32Array;
  118690. };
  118691. /**
  118692. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  118693. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  118694. */
  118695. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  118696. private _scene;
  118697. private _multiRenderTarget;
  118698. private _ratio;
  118699. private _enablePosition;
  118700. private _enableVelocity;
  118701. private _positionIndex;
  118702. private _velocityIndex;
  118703. protected _effect: Effect;
  118704. protected _cachedDefines: string;
  118705. /**
  118706. * Set the render list (meshes to be rendered) used in the G buffer.
  118707. */
  118708. renderList: Mesh[];
  118709. /**
  118710. * Gets wether or not G buffer are supported by the running hardware.
  118711. * This requires draw buffer supports
  118712. */
  118713. readonly isSupported: boolean;
  118714. /**
  118715. * Returns the index of the given texture type in the G-Buffer textures array
  118716. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  118717. * @returns the index of the given texture type in the G-Buffer textures array
  118718. */
  118719. getTextureIndex(textureType: number): number;
  118720. /**
  118721. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  118722. */
  118723. /**
  118724. * Sets whether or not objects positions are enabled for the G buffer.
  118725. */
  118726. enablePosition: boolean;
  118727. /**
  118728. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  118729. */
  118730. /**
  118731. * Sets wether or not objects velocities are enabled for the G buffer.
  118732. */
  118733. enableVelocity: boolean;
  118734. /**
  118735. * Gets the scene associated with the buffer.
  118736. */
  118737. readonly scene: Scene;
  118738. /**
  118739. * Gets the ratio used by the buffer during its creation.
  118740. * How big is the buffer related to the main canvas.
  118741. */
  118742. readonly ratio: number;
  118743. /** @hidden */
  118744. static _SceneComponentInitialization: (scene: Scene) => void;
  118745. /**
  118746. * Creates a new G Buffer for the scene
  118747. * @param scene The scene the buffer belongs to
  118748. * @param ratio How big is the buffer related to the main canvas.
  118749. */
  118750. constructor(scene: Scene, ratio?: number);
  118751. /**
  118752. * Checks wether everything is ready to render a submesh to the G buffer.
  118753. * @param subMesh the submesh to check readiness for
  118754. * @param useInstances is the mesh drawn using instance or not
  118755. * @returns true if ready otherwise false
  118756. */
  118757. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118758. /**
  118759. * Gets the current underlying G Buffer.
  118760. * @returns the buffer
  118761. */
  118762. getGBuffer(): MultiRenderTarget;
  118763. /**
  118764. * Gets the number of samples used to render the buffer (anti aliasing).
  118765. */
  118766. /**
  118767. * Sets the number of samples used to render the buffer (anti aliasing).
  118768. */
  118769. samples: number;
  118770. /**
  118771. * Disposes the renderer and frees up associated resources.
  118772. */
  118773. dispose(): void;
  118774. protected _createRenderTargets(): void;
  118775. private _copyBonesTransformationMatrices;
  118776. }
  118777. }
  118778. declare module BABYLON {
  118779. interface Scene {
  118780. /** @hidden (Backing field) */
  118781. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118782. /**
  118783. * Gets or Sets the current geometry buffer associated to the scene.
  118784. */
  118785. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118786. /**
  118787. * Enables a GeometryBufferRender and associates it with the scene
  118788. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  118789. * @returns the GeometryBufferRenderer
  118790. */
  118791. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  118792. /**
  118793. * Disables the GeometryBufferRender associated with the scene
  118794. */
  118795. disableGeometryBufferRenderer(): void;
  118796. }
  118797. /**
  118798. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  118799. * in several rendering techniques.
  118800. */
  118801. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  118802. /**
  118803. * The component name helpful to identify the component in the list of scene components.
  118804. */
  118805. readonly name: string;
  118806. /**
  118807. * The scene the component belongs to.
  118808. */
  118809. scene: Scene;
  118810. /**
  118811. * Creates a new instance of the component for the given scene
  118812. * @param scene Defines the scene to register the component in
  118813. */
  118814. constructor(scene: Scene);
  118815. /**
  118816. * Registers the component in a given scene
  118817. */
  118818. register(): void;
  118819. /**
  118820. * Rebuilds the elements related to this component in case of
  118821. * context lost for instance.
  118822. */
  118823. rebuild(): void;
  118824. /**
  118825. * Disposes the component and the associated ressources
  118826. */
  118827. dispose(): void;
  118828. private _gatherRenderTargets;
  118829. }
  118830. }
  118831. declare module BABYLON {
  118832. /** @hidden */
  118833. export var motionBlurPixelShader: {
  118834. name: string;
  118835. shader: string;
  118836. };
  118837. }
  118838. declare module BABYLON {
  118839. /**
  118840. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118841. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118842. * As an example, all you have to do is to create the post-process:
  118843. * var mb = new BABYLON.MotionBlurPostProcess(
  118844. * 'mb', // The name of the effect.
  118845. * scene, // The scene containing the objects to blur according to their velocity.
  118846. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118847. * camera // The camera to apply the render pass to.
  118848. * );
  118849. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118850. */
  118851. export class MotionBlurPostProcess extends PostProcess {
  118852. /**
  118853. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118854. */
  118855. motionStrength: number;
  118856. /**
  118857. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118858. */
  118859. /**
  118860. * Sets the number of iterations to be used for motion blur quality
  118861. */
  118862. motionBlurSamples: number;
  118863. private _motionBlurSamples;
  118864. private _geometryBufferRenderer;
  118865. /**
  118866. * Creates a new instance MotionBlurPostProcess
  118867. * @param name The name of the effect.
  118868. * @param scene The scene containing the objects to blur according to their velocity.
  118869. * @param options The required width/height ratio to downsize to before computing the render pass.
  118870. * @param camera The camera to apply the render pass to.
  118871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118872. * @param engine The engine which the post process will be applied. (default: current engine)
  118873. * @param reusable If the post process can be reused on the same frame. (default: false)
  118874. * @param textureType Type of textures used when performing the post process. (default: 0)
  118875. * @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)
  118876. */
  118877. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118878. /**
  118879. * Excludes the given skinned mesh from computing bones velocities.
  118880. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  118881. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  118882. */
  118883. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118884. /**
  118885. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  118886. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  118887. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  118888. */
  118889. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118890. /**
  118891. * Disposes the post process.
  118892. * @param camera The camera to dispose the post process on.
  118893. */
  118894. dispose(camera?: Camera): void;
  118895. }
  118896. }
  118897. declare module BABYLON {
  118898. /** @hidden */
  118899. export var refractionPixelShader: {
  118900. name: string;
  118901. shader: string;
  118902. };
  118903. }
  118904. declare module BABYLON {
  118905. /**
  118906. * Post process which applies a refractin texture
  118907. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118908. */
  118909. export class RefractionPostProcess extends PostProcess {
  118910. /** the base color of the refraction (used to taint the rendering) */
  118911. color: Color3;
  118912. /** simulated refraction depth */
  118913. depth: number;
  118914. /** the coefficient of the base color (0 to remove base color tainting) */
  118915. colorLevel: number;
  118916. private _refTexture;
  118917. private _ownRefractionTexture;
  118918. /**
  118919. * Gets or sets the refraction texture
  118920. * Please note that you are responsible for disposing the texture if you set it manually
  118921. */
  118922. refractionTexture: Texture;
  118923. /**
  118924. * Initializes the RefractionPostProcess
  118925. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118926. * @param name The name of the effect.
  118927. * @param refractionTextureUrl Url of the refraction texture to use
  118928. * @param color the base color of the refraction (used to taint the rendering)
  118929. * @param depth simulated refraction depth
  118930. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  118931. * @param camera The camera to apply the render pass to.
  118932. * @param options The required width/height ratio to downsize to before computing the render pass.
  118933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118934. * @param engine The engine which the post process will be applied. (default: current engine)
  118935. * @param reusable If the post process can be reused on the same frame. (default: false)
  118936. */
  118937. constructor(name: string, refractionTextureUrl: string,
  118938. /** the base color of the refraction (used to taint the rendering) */
  118939. color: Color3,
  118940. /** simulated refraction depth */
  118941. depth: number,
  118942. /** the coefficient of the base color (0 to remove base color tainting) */
  118943. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118944. /**
  118945. * Disposes of the post process
  118946. * @param camera Camera to dispose post process on
  118947. */
  118948. dispose(camera: Camera): void;
  118949. }
  118950. }
  118951. declare module BABYLON {
  118952. /** @hidden */
  118953. export var sharpenPixelShader: {
  118954. name: string;
  118955. shader: string;
  118956. };
  118957. }
  118958. declare module BABYLON {
  118959. /**
  118960. * The SharpenPostProcess applies a sharpen kernel to every pixel
  118961. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118962. */
  118963. export class SharpenPostProcess extends PostProcess {
  118964. /**
  118965. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  118966. */
  118967. colorAmount: number;
  118968. /**
  118969. * How much sharpness should be applied (default: 0.3)
  118970. */
  118971. edgeAmount: number;
  118972. /**
  118973. * Creates a new instance ConvolutionPostProcess
  118974. * @param name The name of the effect.
  118975. * @param options The required width/height ratio to downsize to before computing the render pass.
  118976. * @param camera The camera to apply the render pass to.
  118977. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118978. * @param engine The engine which the post process will be applied. (default: current engine)
  118979. * @param reusable If the post process can be reused on the same frame. (default: false)
  118980. * @param textureType Type of textures used when performing the post process. (default: 0)
  118981. * @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)
  118982. */
  118983. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118984. }
  118985. }
  118986. declare module BABYLON {
  118987. /**
  118988. * PostProcessRenderPipeline
  118989. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118990. */
  118991. export class PostProcessRenderPipeline {
  118992. private engine;
  118993. private _renderEffects;
  118994. private _renderEffectsForIsolatedPass;
  118995. /**
  118996. * List of inspectable custom properties (used by the Inspector)
  118997. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  118998. */
  118999. inspectableCustomProperties: IInspectable[];
  119000. /**
  119001. * @hidden
  119002. */
  119003. protected _cameras: Camera[];
  119004. /** @hidden */
  119005. _name: string;
  119006. /**
  119007. * Gets pipeline name
  119008. */
  119009. readonly name: string;
  119010. /**
  119011. * Initializes a PostProcessRenderPipeline
  119012. * @param engine engine to add the pipeline to
  119013. * @param name name of the pipeline
  119014. */
  119015. constructor(engine: Engine, name: string);
  119016. /**
  119017. * Gets the class name
  119018. * @returns "PostProcessRenderPipeline"
  119019. */
  119020. getClassName(): string;
  119021. /**
  119022. * If all the render effects in the pipeline are supported
  119023. */
  119024. readonly isSupported: boolean;
  119025. /**
  119026. * Adds an effect to the pipeline
  119027. * @param renderEffect the effect to add
  119028. */
  119029. addEffect(renderEffect: PostProcessRenderEffect): void;
  119030. /** @hidden */
  119031. _rebuild(): void;
  119032. /** @hidden */
  119033. _enableEffect(renderEffectName: string, cameras: Camera): void;
  119034. /** @hidden */
  119035. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  119036. /** @hidden */
  119037. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  119038. /** @hidden */
  119039. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  119040. /** @hidden */
  119041. _attachCameras(cameras: Camera, unique: boolean): void;
  119042. /** @hidden */
  119043. _attachCameras(cameras: Camera[], unique: boolean): void;
  119044. /** @hidden */
  119045. _detachCameras(cameras: Camera): void;
  119046. /** @hidden */
  119047. _detachCameras(cameras: Nullable<Camera[]>): void;
  119048. /** @hidden */
  119049. _update(): void;
  119050. /** @hidden */
  119051. _reset(): void;
  119052. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  119053. /**
  119054. * Disposes of the pipeline
  119055. */
  119056. dispose(): void;
  119057. }
  119058. }
  119059. declare module BABYLON {
  119060. /**
  119061. * PostProcessRenderPipelineManager class
  119062. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119063. */
  119064. export class PostProcessRenderPipelineManager {
  119065. private _renderPipelines;
  119066. /**
  119067. * Initializes a PostProcessRenderPipelineManager
  119068. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119069. */
  119070. constructor();
  119071. /**
  119072. * Gets the list of supported render pipelines
  119073. */
  119074. readonly supportedPipelines: PostProcessRenderPipeline[];
  119075. /**
  119076. * Adds a pipeline to the manager
  119077. * @param renderPipeline The pipeline to add
  119078. */
  119079. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  119080. /**
  119081. * Attaches a camera to the pipeline
  119082. * @param renderPipelineName The name of the pipeline to attach to
  119083. * @param cameras the camera to attach
  119084. * @param unique if the camera can be attached multiple times to the pipeline
  119085. */
  119086. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  119087. /**
  119088. * Detaches a camera from the pipeline
  119089. * @param renderPipelineName The name of the pipeline to detach from
  119090. * @param cameras the camera to detach
  119091. */
  119092. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  119093. /**
  119094. * Enables an effect by name on a pipeline
  119095. * @param renderPipelineName the name of the pipeline to enable the effect in
  119096. * @param renderEffectName the name of the effect to enable
  119097. * @param cameras the cameras that the effect should be enabled on
  119098. */
  119099. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  119100. /**
  119101. * Disables an effect by name on a pipeline
  119102. * @param renderPipelineName the name of the pipeline to disable the effect in
  119103. * @param renderEffectName the name of the effect to disable
  119104. * @param cameras the cameras that the effect should be disabled on
  119105. */
  119106. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  119107. /**
  119108. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  119109. */
  119110. update(): void;
  119111. /** @hidden */
  119112. _rebuild(): void;
  119113. /**
  119114. * Disposes of the manager and pipelines
  119115. */
  119116. dispose(): void;
  119117. }
  119118. }
  119119. declare module BABYLON {
  119120. interface Scene {
  119121. /** @hidden (Backing field) */
  119122. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  119123. /**
  119124. * Gets the postprocess render pipeline manager
  119125. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119126. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119127. */
  119128. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  119129. }
  119130. /**
  119131. * Defines the Render Pipeline scene component responsible to rendering pipelines
  119132. */
  119133. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  119134. /**
  119135. * The component name helpfull to identify the component in the list of scene components.
  119136. */
  119137. readonly name: string;
  119138. /**
  119139. * The scene the component belongs to.
  119140. */
  119141. scene: Scene;
  119142. /**
  119143. * Creates a new instance of the component for the given scene
  119144. * @param scene Defines the scene to register the component in
  119145. */
  119146. constructor(scene: Scene);
  119147. /**
  119148. * Registers the component in a given scene
  119149. */
  119150. register(): void;
  119151. /**
  119152. * Rebuilds the elements related to this component in case of
  119153. * context lost for instance.
  119154. */
  119155. rebuild(): void;
  119156. /**
  119157. * Disposes the component and the associated ressources
  119158. */
  119159. dispose(): void;
  119160. private _gatherRenderTargets;
  119161. }
  119162. }
  119163. declare module BABYLON {
  119164. /**
  119165. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  119166. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119167. */
  119168. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119169. private _scene;
  119170. private _camerasToBeAttached;
  119171. /**
  119172. * ID of the sharpen post process,
  119173. */
  119174. private readonly SharpenPostProcessId;
  119175. /**
  119176. * @ignore
  119177. * ID of the image processing post process;
  119178. */
  119179. readonly ImageProcessingPostProcessId: string;
  119180. /**
  119181. * @ignore
  119182. * ID of the Fast Approximate Anti-Aliasing post process;
  119183. */
  119184. readonly FxaaPostProcessId: string;
  119185. /**
  119186. * ID of the chromatic aberration post process,
  119187. */
  119188. private readonly ChromaticAberrationPostProcessId;
  119189. /**
  119190. * ID of the grain post process
  119191. */
  119192. private readonly GrainPostProcessId;
  119193. /**
  119194. * Sharpen post process which will apply a sharpen convolution to enhance edges
  119195. */
  119196. sharpen: SharpenPostProcess;
  119197. private _sharpenEffect;
  119198. private bloom;
  119199. /**
  119200. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  119201. */
  119202. depthOfField: DepthOfFieldEffect;
  119203. /**
  119204. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119205. */
  119206. fxaa: FxaaPostProcess;
  119207. /**
  119208. * Image post processing pass used to perform operations such as tone mapping or color grading.
  119209. */
  119210. imageProcessing: ImageProcessingPostProcess;
  119211. /**
  119212. * Chromatic aberration post process which will shift rgb colors in the image
  119213. */
  119214. chromaticAberration: ChromaticAberrationPostProcess;
  119215. private _chromaticAberrationEffect;
  119216. /**
  119217. * Grain post process which add noise to the image
  119218. */
  119219. grain: GrainPostProcess;
  119220. private _grainEffect;
  119221. /**
  119222. * Glow post process which adds a glow to emissive areas of the image
  119223. */
  119224. private _glowLayer;
  119225. /**
  119226. * Animations which can be used to tweak settings over a period of time
  119227. */
  119228. animations: Animation[];
  119229. private _imageProcessingConfigurationObserver;
  119230. private _sharpenEnabled;
  119231. private _bloomEnabled;
  119232. private _depthOfFieldEnabled;
  119233. private _depthOfFieldBlurLevel;
  119234. private _fxaaEnabled;
  119235. private _imageProcessingEnabled;
  119236. private _defaultPipelineTextureType;
  119237. private _bloomScale;
  119238. private _chromaticAberrationEnabled;
  119239. private _grainEnabled;
  119240. private _buildAllowed;
  119241. /**
  119242. * Gets active scene
  119243. */
  119244. readonly scene: Scene;
  119245. /**
  119246. * Enable or disable the sharpen process from the pipeline
  119247. */
  119248. sharpenEnabled: boolean;
  119249. private _resizeObserver;
  119250. private _hardwareScaleLevel;
  119251. private _bloomKernel;
  119252. /**
  119253. * Specifies the size of the bloom blur kernel, relative to the final output size
  119254. */
  119255. bloomKernel: number;
  119256. /**
  119257. * Specifies the weight of the bloom in the final rendering
  119258. */
  119259. private _bloomWeight;
  119260. /**
  119261. * Specifies the luma threshold for the area that will be blurred by the bloom
  119262. */
  119263. private _bloomThreshold;
  119264. private _hdr;
  119265. /**
  119266. * The strength of the bloom.
  119267. */
  119268. bloomWeight: number;
  119269. /**
  119270. * The strength of the bloom.
  119271. */
  119272. bloomThreshold: number;
  119273. /**
  119274. * The scale of the bloom, lower value will provide better performance.
  119275. */
  119276. bloomScale: number;
  119277. /**
  119278. * Enable or disable the bloom from the pipeline
  119279. */
  119280. bloomEnabled: boolean;
  119281. private _rebuildBloom;
  119282. /**
  119283. * If the depth of field is enabled.
  119284. */
  119285. depthOfFieldEnabled: boolean;
  119286. /**
  119287. * Blur level of the depth of field effect. (Higher blur will effect performance)
  119288. */
  119289. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  119290. /**
  119291. * If the anti aliasing is enabled.
  119292. */
  119293. fxaaEnabled: boolean;
  119294. private _samples;
  119295. /**
  119296. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119297. */
  119298. samples: number;
  119299. /**
  119300. * If image processing is enabled.
  119301. */
  119302. imageProcessingEnabled: boolean;
  119303. /**
  119304. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  119305. */
  119306. glowLayerEnabled: boolean;
  119307. /**
  119308. * Gets the glow layer (or null if not defined)
  119309. */
  119310. readonly glowLayer: Nullable<GlowLayer>;
  119311. /**
  119312. * Enable or disable the chromaticAberration process from the pipeline
  119313. */
  119314. chromaticAberrationEnabled: boolean;
  119315. /**
  119316. * Enable or disable the grain process from the pipeline
  119317. */
  119318. grainEnabled: boolean;
  119319. /**
  119320. * @constructor
  119321. * @param name - The rendering pipeline name (default: "")
  119322. * @param hdr - If high dynamic range textures should be used (default: true)
  119323. * @param scene - The scene linked to this pipeline (default: the last created scene)
  119324. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  119325. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  119326. */
  119327. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  119328. /**
  119329. * Get the class name
  119330. * @returns "DefaultRenderingPipeline"
  119331. */
  119332. getClassName(): string;
  119333. /**
  119334. * Force the compilation of the entire pipeline.
  119335. */
  119336. prepare(): void;
  119337. private _hasCleared;
  119338. private _prevPostProcess;
  119339. private _prevPrevPostProcess;
  119340. private _setAutoClearAndTextureSharing;
  119341. private _depthOfFieldSceneObserver;
  119342. private _buildPipeline;
  119343. private _disposePostProcesses;
  119344. /**
  119345. * Adds a camera to the pipeline
  119346. * @param camera the camera to be added
  119347. */
  119348. addCamera(camera: Camera): void;
  119349. /**
  119350. * Removes a camera from the pipeline
  119351. * @param camera the camera to remove
  119352. */
  119353. removeCamera(camera: Camera): void;
  119354. /**
  119355. * Dispose of the pipeline and stop all post processes
  119356. */
  119357. dispose(): void;
  119358. /**
  119359. * Serialize the rendering pipeline (Used when exporting)
  119360. * @returns the serialized object
  119361. */
  119362. serialize(): any;
  119363. /**
  119364. * Parse the serialized pipeline
  119365. * @param source Source pipeline.
  119366. * @param scene The scene to load the pipeline to.
  119367. * @param rootUrl The URL of the serialized pipeline.
  119368. * @returns An instantiated pipeline from the serialized object.
  119369. */
  119370. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  119371. }
  119372. }
  119373. declare module BABYLON {
  119374. /** @hidden */
  119375. export var lensHighlightsPixelShader: {
  119376. name: string;
  119377. shader: string;
  119378. };
  119379. }
  119380. declare module BABYLON {
  119381. /** @hidden */
  119382. export var depthOfFieldPixelShader: {
  119383. name: string;
  119384. shader: string;
  119385. };
  119386. }
  119387. declare module BABYLON {
  119388. /**
  119389. * BABYLON.JS Chromatic Aberration GLSL Shader
  119390. * Author: Olivier Guyot
  119391. * Separates very slightly R, G and B colors on the edges of the screen
  119392. * Inspired by Francois Tarlier & Martins Upitis
  119393. */
  119394. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  119395. /**
  119396. * @ignore
  119397. * The chromatic aberration PostProcess id in the pipeline
  119398. */
  119399. LensChromaticAberrationEffect: string;
  119400. /**
  119401. * @ignore
  119402. * The highlights enhancing PostProcess id in the pipeline
  119403. */
  119404. HighlightsEnhancingEffect: string;
  119405. /**
  119406. * @ignore
  119407. * The depth-of-field PostProcess id in the pipeline
  119408. */
  119409. LensDepthOfFieldEffect: string;
  119410. private _scene;
  119411. private _depthTexture;
  119412. private _grainTexture;
  119413. private _chromaticAberrationPostProcess;
  119414. private _highlightsPostProcess;
  119415. private _depthOfFieldPostProcess;
  119416. private _edgeBlur;
  119417. private _grainAmount;
  119418. private _chromaticAberration;
  119419. private _distortion;
  119420. private _highlightsGain;
  119421. private _highlightsThreshold;
  119422. private _dofDistance;
  119423. private _dofAperture;
  119424. private _dofDarken;
  119425. private _dofPentagon;
  119426. private _blurNoise;
  119427. /**
  119428. * @constructor
  119429. *
  119430. * Effect parameters are as follow:
  119431. * {
  119432. * chromatic_aberration: number; // from 0 to x (1 for realism)
  119433. * edge_blur: number; // from 0 to x (1 for realism)
  119434. * distortion: number; // from 0 to x (1 for realism)
  119435. * grain_amount: number; // from 0 to 1
  119436. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  119437. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  119438. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  119439. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  119440. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  119441. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  119442. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  119443. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  119444. * }
  119445. * Note: if an effect parameter is unset, effect is disabled
  119446. *
  119447. * @param name The rendering pipeline name
  119448. * @param parameters - An object containing all parameters (see above)
  119449. * @param scene The scene linked to this pipeline
  119450. * @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)
  119451. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119452. */
  119453. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  119454. /**
  119455. * Get the class name
  119456. * @returns "LensRenderingPipeline"
  119457. */
  119458. getClassName(): string;
  119459. /**
  119460. * Gets associated scene
  119461. */
  119462. readonly scene: Scene;
  119463. /**
  119464. * Gets or sets the edge blur
  119465. */
  119466. edgeBlur: number;
  119467. /**
  119468. * Gets or sets the grain amount
  119469. */
  119470. grainAmount: number;
  119471. /**
  119472. * Gets or sets the chromatic aberration amount
  119473. */
  119474. chromaticAberration: number;
  119475. /**
  119476. * Gets or sets the depth of field aperture
  119477. */
  119478. dofAperture: number;
  119479. /**
  119480. * Gets or sets the edge distortion
  119481. */
  119482. edgeDistortion: number;
  119483. /**
  119484. * Gets or sets the depth of field distortion
  119485. */
  119486. dofDistortion: number;
  119487. /**
  119488. * Gets or sets the darken out of focus amount
  119489. */
  119490. darkenOutOfFocus: number;
  119491. /**
  119492. * Gets or sets a boolean indicating if blur noise is enabled
  119493. */
  119494. blurNoise: boolean;
  119495. /**
  119496. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  119497. */
  119498. pentagonBokeh: boolean;
  119499. /**
  119500. * Gets or sets the highlight grain amount
  119501. */
  119502. highlightsGain: number;
  119503. /**
  119504. * Gets or sets the highlight threshold
  119505. */
  119506. highlightsThreshold: number;
  119507. /**
  119508. * Sets the amount of blur at the edges
  119509. * @param amount blur amount
  119510. */
  119511. setEdgeBlur(amount: number): void;
  119512. /**
  119513. * Sets edge blur to 0
  119514. */
  119515. disableEdgeBlur(): void;
  119516. /**
  119517. * Sets the amout of grain
  119518. * @param amount Amount of grain
  119519. */
  119520. setGrainAmount(amount: number): void;
  119521. /**
  119522. * Set grain amount to 0
  119523. */
  119524. disableGrain(): void;
  119525. /**
  119526. * Sets the chromatic aberration amount
  119527. * @param amount amount of chromatic aberration
  119528. */
  119529. setChromaticAberration(amount: number): void;
  119530. /**
  119531. * Sets chromatic aberration amount to 0
  119532. */
  119533. disableChromaticAberration(): void;
  119534. /**
  119535. * Sets the EdgeDistortion amount
  119536. * @param amount amount of EdgeDistortion
  119537. */
  119538. setEdgeDistortion(amount: number): void;
  119539. /**
  119540. * Sets edge distortion to 0
  119541. */
  119542. disableEdgeDistortion(): void;
  119543. /**
  119544. * Sets the FocusDistance amount
  119545. * @param amount amount of FocusDistance
  119546. */
  119547. setFocusDistance(amount: number): void;
  119548. /**
  119549. * Disables depth of field
  119550. */
  119551. disableDepthOfField(): void;
  119552. /**
  119553. * Sets the Aperture amount
  119554. * @param amount amount of Aperture
  119555. */
  119556. setAperture(amount: number): void;
  119557. /**
  119558. * Sets the DarkenOutOfFocus amount
  119559. * @param amount amount of DarkenOutOfFocus
  119560. */
  119561. setDarkenOutOfFocus(amount: number): void;
  119562. private _pentagonBokehIsEnabled;
  119563. /**
  119564. * Creates a pentagon bokeh effect
  119565. */
  119566. enablePentagonBokeh(): void;
  119567. /**
  119568. * Disables the pentagon bokeh effect
  119569. */
  119570. disablePentagonBokeh(): void;
  119571. /**
  119572. * Enables noise blur
  119573. */
  119574. enableNoiseBlur(): void;
  119575. /**
  119576. * Disables noise blur
  119577. */
  119578. disableNoiseBlur(): void;
  119579. /**
  119580. * Sets the HighlightsGain amount
  119581. * @param amount amount of HighlightsGain
  119582. */
  119583. setHighlightsGain(amount: number): void;
  119584. /**
  119585. * Sets the HighlightsThreshold amount
  119586. * @param amount amount of HighlightsThreshold
  119587. */
  119588. setHighlightsThreshold(amount: number): void;
  119589. /**
  119590. * Disables highlights
  119591. */
  119592. disableHighlights(): void;
  119593. /**
  119594. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  119595. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  119596. */
  119597. dispose(disableDepthRender?: boolean): void;
  119598. private _createChromaticAberrationPostProcess;
  119599. private _createHighlightsPostProcess;
  119600. private _createDepthOfFieldPostProcess;
  119601. private _createGrainTexture;
  119602. }
  119603. }
  119604. declare module BABYLON {
  119605. /** @hidden */
  119606. export var ssao2PixelShader: {
  119607. name: string;
  119608. shader: string;
  119609. };
  119610. }
  119611. declare module BABYLON {
  119612. /** @hidden */
  119613. export var ssaoCombinePixelShader: {
  119614. name: string;
  119615. shader: string;
  119616. };
  119617. }
  119618. declare module BABYLON {
  119619. /**
  119620. * Render pipeline to produce ssao effect
  119621. */
  119622. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  119623. /**
  119624. * @ignore
  119625. * The PassPostProcess id in the pipeline that contains the original scene color
  119626. */
  119627. SSAOOriginalSceneColorEffect: string;
  119628. /**
  119629. * @ignore
  119630. * The SSAO PostProcess id in the pipeline
  119631. */
  119632. SSAORenderEffect: string;
  119633. /**
  119634. * @ignore
  119635. * The horizontal blur PostProcess id in the pipeline
  119636. */
  119637. SSAOBlurHRenderEffect: string;
  119638. /**
  119639. * @ignore
  119640. * The vertical blur PostProcess id in the pipeline
  119641. */
  119642. SSAOBlurVRenderEffect: string;
  119643. /**
  119644. * @ignore
  119645. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119646. */
  119647. SSAOCombineRenderEffect: string;
  119648. /**
  119649. * The output strength of the SSAO post-process. Default value is 1.0.
  119650. */
  119651. totalStrength: number;
  119652. /**
  119653. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  119654. */
  119655. maxZ: number;
  119656. /**
  119657. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  119658. */
  119659. minZAspect: number;
  119660. private _samples;
  119661. /**
  119662. * Number of samples used for the SSAO calculations. Default value is 8
  119663. */
  119664. samples: number;
  119665. private _textureSamples;
  119666. /**
  119667. * Number of samples to use for antialiasing
  119668. */
  119669. textureSamples: number;
  119670. /**
  119671. * Ratio object used for SSAO ratio and blur ratio
  119672. */
  119673. private _ratio;
  119674. /**
  119675. * Dynamically generated sphere sampler.
  119676. */
  119677. private _sampleSphere;
  119678. /**
  119679. * Blur filter offsets
  119680. */
  119681. private _samplerOffsets;
  119682. private _expensiveBlur;
  119683. /**
  119684. * If bilateral blur should be used
  119685. */
  119686. expensiveBlur: boolean;
  119687. /**
  119688. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  119689. */
  119690. radius: number;
  119691. /**
  119692. * The base color of the SSAO post-process
  119693. * The final result is "base + ssao" between [0, 1]
  119694. */
  119695. base: number;
  119696. /**
  119697. * Support test.
  119698. */
  119699. static readonly IsSupported: boolean;
  119700. private _scene;
  119701. private _depthTexture;
  119702. private _normalTexture;
  119703. private _randomTexture;
  119704. private _originalColorPostProcess;
  119705. private _ssaoPostProcess;
  119706. private _blurHPostProcess;
  119707. private _blurVPostProcess;
  119708. private _ssaoCombinePostProcess;
  119709. private _firstUpdate;
  119710. /**
  119711. * Gets active scene
  119712. */
  119713. readonly scene: Scene;
  119714. /**
  119715. * @constructor
  119716. * @param name The rendering pipeline name
  119717. * @param scene The scene linked to this pipeline
  119718. * @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 }
  119719. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119720. */
  119721. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119722. /**
  119723. * Get the class name
  119724. * @returns "SSAO2RenderingPipeline"
  119725. */
  119726. getClassName(): string;
  119727. /**
  119728. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119729. */
  119730. dispose(disableGeometryBufferRenderer?: boolean): void;
  119731. private _createBlurPostProcess;
  119732. /** @hidden */
  119733. _rebuild(): void;
  119734. private _bits;
  119735. private _radicalInverse_VdC;
  119736. private _hammersley;
  119737. private _hemisphereSample_uniform;
  119738. private _generateHemisphere;
  119739. private _createSSAOPostProcess;
  119740. private _createSSAOCombinePostProcess;
  119741. private _createRandomTexture;
  119742. /**
  119743. * Serialize the rendering pipeline (Used when exporting)
  119744. * @returns the serialized object
  119745. */
  119746. serialize(): any;
  119747. /**
  119748. * Parse the serialized pipeline
  119749. * @param source Source pipeline.
  119750. * @param scene The scene to load the pipeline to.
  119751. * @param rootUrl The URL of the serialized pipeline.
  119752. * @returns An instantiated pipeline from the serialized object.
  119753. */
  119754. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  119755. }
  119756. }
  119757. declare module BABYLON {
  119758. /** @hidden */
  119759. export var ssaoPixelShader: {
  119760. name: string;
  119761. shader: string;
  119762. };
  119763. }
  119764. declare module BABYLON {
  119765. /**
  119766. * Render pipeline to produce ssao effect
  119767. */
  119768. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  119769. /**
  119770. * @ignore
  119771. * The PassPostProcess id in the pipeline that contains the original scene color
  119772. */
  119773. SSAOOriginalSceneColorEffect: string;
  119774. /**
  119775. * @ignore
  119776. * The SSAO PostProcess id in the pipeline
  119777. */
  119778. SSAORenderEffect: string;
  119779. /**
  119780. * @ignore
  119781. * The horizontal blur PostProcess id in the pipeline
  119782. */
  119783. SSAOBlurHRenderEffect: string;
  119784. /**
  119785. * @ignore
  119786. * The vertical blur PostProcess id in the pipeline
  119787. */
  119788. SSAOBlurVRenderEffect: string;
  119789. /**
  119790. * @ignore
  119791. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119792. */
  119793. SSAOCombineRenderEffect: string;
  119794. /**
  119795. * The output strength of the SSAO post-process. Default value is 1.0.
  119796. */
  119797. totalStrength: number;
  119798. /**
  119799. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  119800. */
  119801. radius: number;
  119802. /**
  119803. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  119804. * Must not be equal to fallOff and superior to fallOff.
  119805. * Default value is 0.0075
  119806. */
  119807. area: number;
  119808. /**
  119809. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  119810. * Must not be equal to area and inferior to area.
  119811. * Default value is 0.000001
  119812. */
  119813. fallOff: number;
  119814. /**
  119815. * The base color of the SSAO post-process
  119816. * The final result is "base + ssao" between [0, 1]
  119817. */
  119818. base: number;
  119819. private _scene;
  119820. private _depthTexture;
  119821. private _randomTexture;
  119822. private _originalColorPostProcess;
  119823. private _ssaoPostProcess;
  119824. private _blurHPostProcess;
  119825. private _blurVPostProcess;
  119826. private _ssaoCombinePostProcess;
  119827. private _firstUpdate;
  119828. /**
  119829. * Gets active scene
  119830. */
  119831. readonly scene: Scene;
  119832. /**
  119833. * @constructor
  119834. * @param name - The rendering pipeline name
  119835. * @param scene - The scene linked to this pipeline
  119836. * @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 }
  119837. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  119838. */
  119839. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119840. /**
  119841. * Get the class name
  119842. * @returns "SSAORenderingPipeline"
  119843. */
  119844. getClassName(): string;
  119845. /**
  119846. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119847. */
  119848. dispose(disableDepthRender?: boolean): void;
  119849. private _createBlurPostProcess;
  119850. /** @hidden */
  119851. _rebuild(): void;
  119852. private _createSSAOPostProcess;
  119853. private _createSSAOCombinePostProcess;
  119854. private _createRandomTexture;
  119855. }
  119856. }
  119857. declare module BABYLON {
  119858. /** @hidden */
  119859. export var standardPixelShader: {
  119860. name: string;
  119861. shader: string;
  119862. };
  119863. }
  119864. declare module BABYLON {
  119865. /**
  119866. * Standard rendering pipeline
  119867. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119868. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  119869. */
  119870. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119871. /**
  119872. * Public members
  119873. */
  119874. /**
  119875. * Post-process which contains the original scene color before the pipeline applies all the effects
  119876. */
  119877. originalPostProcess: Nullable<PostProcess>;
  119878. /**
  119879. * Post-process used to down scale an image x4
  119880. */
  119881. downSampleX4PostProcess: Nullable<PostProcess>;
  119882. /**
  119883. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  119884. */
  119885. brightPassPostProcess: Nullable<PostProcess>;
  119886. /**
  119887. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  119888. */
  119889. blurHPostProcesses: PostProcess[];
  119890. /**
  119891. * Post-process array storing all the vertical blur post-processes used by the pipeline
  119892. */
  119893. blurVPostProcesses: PostProcess[];
  119894. /**
  119895. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  119896. */
  119897. textureAdderPostProcess: Nullable<PostProcess>;
  119898. /**
  119899. * Post-process used to create volumetric lighting effect
  119900. */
  119901. volumetricLightPostProcess: Nullable<PostProcess>;
  119902. /**
  119903. * Post-process used to smooth the previous volumetric light post-process on the X axis
  119904. */
  119905. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  119906. /**
  119907. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  119908. */
  119909. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  119910. /**
  119911. * Post-process used to merge the volumetric light effect and the real scene color
  119912. */
  119913. volumetricLightMergePostProces: Nullable<PostProcess>;
  119914. /**
  119915. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  119916. */
  119917. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  119918. /**
  119919. * Base post-process used to calculate the average luminance of the final image for HDR
  119920. */
  119921. luminancePostProcess: Nullable<PostProcess>;
  119922. /**
  119923. * Post-processes used to create down sample post-processes in order to get
  119924. * the average luminance of the final image for HDR
  119925. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  119926. */
  119927. luminanceDownSamplePostProcesses: PostProcess[];
  119928. /**
  119929. * Post-process used to create a HDR effect (light adaptation)
  119930. */
  119931. hdrPostProcess: Nullable<PostProcess>;
  119932. /**
  119933. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  119934. */
  119935. textureAdderFinalPostProcess: Nullable<PostProcess>;
  119936. /**
  119937. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  119938. */
  119939. lensFlareFinalPostProcess: Nullable<PostProcess>;
  119940. /**
  119941. * Post-process used to merge the final HDR post-process and the real scene color
  119942. */
  119943. hdrFinalPostProcess: Nullable<PostProcess>;
  119944. /**
  119945. * Post-process used to create a lens flare effect
  119946. */
  119947. lensFlarePostProcess: Nullable<PostProcess>;
  119948. /**
  119949. * Post-process that merges the result of the lens flare post-process and the real scene color
  119950. */
  119951. lensFlareComposePostProcess: Nullable<PostProcess>;
  119952. /**
  119953. * Post-process used to create a motion blur effect
  119954. */
  119955. motionBlurPostProcess: Nullable<PostProcess>;
  119956. /**
  119957. * Post-process used to create a depth of field effect
  119958. */
  119959. depthOfFieldPostProcess: Nullable<PostProcess>;
  119960. /**
  119961. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119962. */
  119963. fxaaPostProcess: Nullable<FxaaPostProcess>;
  119964. /**
  119965. * Represents the brightness threshold in order to configure the illuminated surfaces
  119966. */
  119967. brightThreshold: number;
  119968. /**
  119969. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  119970. */
  119971. blurWidth: number;
  119972. /**
  119973. * Sets if the blur for highlighted surfaces must be only horizontal
  119974. */
  119975. horizontalBlur: boolean;
  119976. /**
  119977. * Gets the overall exposure used by the pipeline
  119978. */
  119979. /**
  119980. * Sets the overall exposure used by the pipeline
  119981. */
  119982. exposure: number;
  119983. /**
  119984. * Texture used typically to simulate "dirty" on camera lens
  119985. */
  119986. lensTexture: Nullable<Texture>;
  119987. /**
  119988. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  119989. */
  119990. volumetricLightCoefficient: number;
  119991. /**
  119992. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  119993. */
  119994. volumetricLightPower: number;
  119995. /**
  119996. * Used the set the blur intensity to smooth the volumetric lights
  119997. */
  119998. volumetricLightBlurScale: number;
  119999. /**
  120000. * Light (spot or directional) used to generate the volumetric lights rays
  120001. * The source light must have a shadow generate so the pipeline can get its
  120002. * depth map
  120003. */
  120004. sourceLight: Nullable<SpotLight | DirectionalLight>;
  120005. /**
  120006. * For eye adaptation, represents the minimum luminance the eye can see
  120007. */
  120008. hdrMinimumLuminance: number;
  120009. /**
  120010. * For eye adaptation, represents the decrease luminance speed
  120011. */
  120012. hdrDecreaseRate: number;
  120013. /**
  120014. * For eye adaptation, represents the increase luminance speed
  120015. */
  120016. hdrIncreaseRate: number;
  120017. /**
  120018. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120019. */
  120020. /**
  120021. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120022. */
  120023. hdrAutoExposure: boolean;
  120024. /**
  120025. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  120026. */
  120027. lensColorTexture: Nullable<Texture>;
  120028. /**
  120029. * The overall strengh for the lens flare effect
  120030. */
  120031. lensFlareStrength: number;
  120032. /**
  120033. * Dispersion coefficient for lens flare ghosts
  120034. */
  120035. lensFlareGhostDispersal: number;
  120036. /**
  120037. * Main lens flare halo width
  120038. */
  120039. lensFlareHaloWidth: number;
  120040. /**
  120041. * Based on the lens distortion effect, defines how much the lens flare result
  120042. * is distorted
  120043. */
  120044. lensFlareDistortionStrength: number;
  120045. /**
  120046. * Lens star texture must be used to simulate rays on the flares and is available
  120047. * in the documentation
  120048. */
  120049. lensStarTexture: Nullable<Texture>;
  120050. /**
  120051. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  120052. * flare effect by taking account of the dirt texture
  120053. */
  120054. lensFlareDirtTexture: Nullable<Texture>;
  120055. /**
  120056. * Represents the focal length for the depth of field effect
  120057. */
  120058. depthOfFieldDistance: number;
  120059. /**
  120060. * Represents the blur intensity for the blurred part of the depth of field effect
  120061. */
  120062. depthOfFieldBlurWidth: number;
  120063. /**
  120064. * Gets how much the image is blurred by the movement while using the motion blur post-process
  120065. */
  120066. /**
  120067. * Sets how much the image is blurred by the movement while using the motion blur post-process
  120068. */
  120069. motionStrength: number;
  120070. /**
  120071. * Gets wether or not the motion blur post-process is object based or screen based.
  120072. */
  120073. /**
  120074. * Sets wether or not the motion blur post-process should be object based or screen based
  120075. */
  120076. objectBasedMotionBlur: boolean;
  120077. /**
  120078. * List of animations for the pipeline (IAnimatable implementation)
  120079. */
  120080. animations: Animation[];
  120081. /**
  120082. * Private members
  120083. */
  120084. private _scene;
  120085. private _currentDepthOfFieldSource;
  120086. private _basePostProcess;
  120087. private _fixedExposure;
  120088. private _currentExposure;
  120089. private _hdrAutoExposure;
  120090. private _hdrCurrentLuminance;
  120091. private _motionStrength;
  120092. private _isObjectBasedMotionBlur;
  120093. private _floatTextureType;
  120094. private _ratio;
  120095. private _bloomEnabled;
  120096. private _depthOfFieldEnabled;
  120097. private _vlsEnabled;
  120098. private _lensFlareEnabled;
  120099. private _hdrEnabled;
  120100. private _motionBlurEnabled;
  120101. private _fxaaEnabled;
  120102. private _motionBlurSamples;
  120103. private _volumetricLightStepsCount;
  120104. private _samples;
  120105. /**
  120106. * @ignore
  120107. * Specifies if the bloom pipeline is enabled
  120108. */
  120109. BloomEnabled: boolean;
  120110. /**
  120111. * @ignore
  120112. * Specifies if the depth of field pipeline is enabed
  120113. */
  120114. DepthOfFieldEnabled: boolean;
  120115. /**
  120116. * @ignore
  120117. * Specifies if the lens flare pipeline is enabed
  120118. */
  120119. LensFlareEnabled: boolean;
  120120. /**
  120121. * @ignore
  120122. * Specifies if the HDR pipeline is enabled
  120123. */
  120124. HDREnabled: boolean;
  120125. /**
  120126. * @ignore
  120127. * Specifies if the volumetric lights scattering effect is enabled
  120128. */
  120129. VLSEnabled: boolean;
  120130. /**
  120131. * @ignore
  120132. * Specifies if the motion blur effect is enabled
  120133. */
  120134. MotionBlurEnabled: boolean;
  120135. /**
  120136. * Specifies if anti-aliasing is enabled
  120137. */
  120138. fxaaEnabled: boolean;
  120139. /**
  120140. * Specifies the number of steps used to calculate the volumetric lights
  120141. * Typically in interval [50, 200]
  120142. */
  120143. volumetricLightStepsCount: number;
  120144. /**
  120145. * Specifies the number of samples used for the motion blur effect
  120146. * Typically in interval [16, 64]
  120147. */
  120148. motionBlurSamples: number;
  120149. /**
  120150. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  120151. */
  120152. samples: number;
  120153. /**
  120154. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  120155. * @constructor
  120156. * @param name The rendering pipeline name
  120157. * @param scene The scene linked to this pipeline
  120158. * @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)
  120159. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  120160. * @param cameras The array of cameras that the rendering pipeline will be attached to
  120161. */
  120162. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  120163. private _buildPipeline;
  120164. private _createDownSampleX4PostProcess;
  120165. private _createBrightPassPostProcess;
  120166. private _createBlurPostProcesses;
  120167. private _createTextureAdderPostProcess;
  120168. private _createVolumetricLightPostProcess;
  120169. private _createLuminancePostProcesses;
  120170. private _createHdrPostProcess;
  120171. private _createLensFlarePostProcess;
  120172. private _createDepthOfFieldPostProcess;
  120173. private _createMotionBlurPostProcess;
  120174. private _getDepthTexture;
  120175. private _disposePostProcesses;
  120176. /**
  120177. * Dispose of the pipeline and stop all post processes
  120178. */
  120179. dispose(): void;
  120180. /**
  120181. * Serialize the rendering pipeline (Used when exporting)
  120182. * @returns the serialized object
  120183. */
  120184. serialize(): any;
  120185. /**
  120186. * Parse the serialized pipeline
  120187. * @param source Source pipeline.
  120188. * @param scene The scene to load the pipeline to.
  120189. * @param rootUrl The URL of the serialized pipeline.
  120190. * @returns An instantiated pipeline from the serialized object.
  120191. */
  120192. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  120193. /**
  120194. * Luminance steps
  120195. */
  120196. static LuminanceSteps: number;
  120197. }
  120198. }
  120199. declare module BABYLON {
  120200. /** @hidden */
  120201. export var tonemapPixelShader: {
  120202. name: string;
  120203. shader: string;
  120204. };
  120205. }
  120206. declare module BABYLON {
  120207. /** Defines operator used for tonemapping */
  120208. export enum TonemappingOperator {
  120209. /** Hable */
  120210. Hable = 0,
  120211. /** Reinhard */
  120212. Reinhard = 1,
  120213. /** HejiDawson */
  120214. HejiDawson = 2,
  120215. /** Photographic */
  120216. Photographic = 3
  120217. }
  120218. /**
  120219. * Defines a post process to apply tone mapping
  120220. */
  120221. export class TonemapPostProcess extends PostProcess {
  120222. private _operator;
  120223. /** Defines the required exposure adjustement */
  120224. exposureAdjustment: number;
  120225. /**
  120226. * Creates a new TonemapPostProcess
  120227. * @param name defines the name of the postprocess
  120228. * @param _operator defines the operator to use
  120229. * @param exposureAdjustment defines the required exposure adjustement
  120230. * @param camera defines the camera to use (can be null)
  120231. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  120232. * @param engine defines the hosting engine (can be ignore if camera is set)
  120233. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  120234. */
  120235. constructor(name: string, _operator: TonemappingOperator,
  120236. /** Defines the required exposure adjustement */
  120237. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  120238. }
  120239. }
  120240. declare module BABYLON {
  120241. /** @hidden */
  120242. export var depthVertexShader: {
  120243. name: string;
  120244. shader: string;
  120245. };
  120246. }
  120247. declare module BABYLON {
  120248. /** @hidden */
  120249. export var volumetricLightScatteringPixelShader: {
  120250. name: string;
  120251. shader: string;
  120252. };
  120253. }
  120254. declare module BABYLON {
  120255. /** @hidden */
  120256. export var volumetricLightScatteringPassPixelShader: {
  120257. name: string;
  120258. shader: string;
  120259. };
  120260. }
  120261. declare module BABYLON {
  120262. /**
  120263. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  120264. */
  120265. export class VolumetricLightScatteringPostProcess extends PostProcess {
  120266. private _volumetricLightScatteringPass;
  120267. private _volumetricLightScatteringRTT;
  120268. private _viewPort;
  120269. private _screenCoordinates;
  120270. private _cachedDefines;
  120271. /**
  120272. * If not undefined, the mesh position is computed from the attached node position
  120273. */
  120274. attachedNode: {
  120275. position: Vector3;
  120276. };
  120277. /**
  120278. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  120279. */
  120280. customMeshPosition: Vector3;
  120281. /**
  120282. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  120283. */
  120284. useCustomMeshPosition: boolean;
  120285. /**
  120286. * If the post-process should inverse the light scattering direction
  120287. */
  120288. invert: boolean;
  120289. /**
  120290. * The internal mesh used by the post-process
  120291. */
  120292. mesh: Mesh;
  120293. /**
  120294. * @hidden
  120295. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  120296. */
  120297. useDiffuseColor: boolean;
  120298. /**
  120299. * Array containing the excluded meshes not rendered in the internal pass
  120300. */
  120301. excludedMeshes: AbstractMesh[];
  120302. /**
  120303. * Controls the overall intensity of the post-process
  120304. */
  120305. exposure: number;
  120306. /**
  120307. * Dissipates each sample's contribution in range [0, 1]
  120308. */
  120309. decay: number;
  120310. /**
  120311. * Controls the overall intensity of each sample
  120312. */
  120313. weight: number;
  120314. /**
  120315. * Controls the density of each sample
  120316. */
  120317. density: number;
  120318. /**
  120319. * @constructor
  120320. * @param name The post-process name
  120321. * @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)
  120322. * @param camera The camera that the post-process will be attached to
  120323. * @param mesh The mesh used to create the light scattering
  120324. * @param samples The post-process quality, default 100
  120325. * @param samplingModeThe post-process filtering mode
  120326. * @param engine The babylon engine
  120327. * @param reusable If the post-process is reusable
  120328. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  120329. */
  120330. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  120331. /**
  120332. * Returns the string "VolumetricLightScatteringPostProcess"
  120333. * @returns "VolumetricLightScatteringPostProcess"
  120334. */
  120335. getClassName(): string;
  120336. private _isReady;
  120337. /**
  120338. * Sets the new light position for light scattering effect
  120339. * @param position The new custom light position
  120340. */
  120341. setCustomMeshPosition(position: Vector3): void;
  120342. /**
  120343. * Returns the light position for light scattering effect
  120344. * @return Vector3 The custom light position
  120345. */
  120346. getCustomMeshPosition(): Vector3;
  120347. /**
  120348. * Disposes the internal assets and detaches the post-process from the camera
  120349. */
  120350. dispose(camera: Camera): void;
  120351. /**
  120352. * Returns the render target texture used by the post-process
  120353. * @return the render target texture used by the post-process
  120354. */
  120355. getPass(): RenderTargetTexture;
  120356. private _meshExcluded;
  120357. private _createPass;
  120358. private _updateMeshScreenCoordinates;
  120359. /**
  120360. * Creates a default mesh for the Volumeric Light Scattering post-process
  120361. * @param name The mesh name
  120362. * @param scene The scene where to create the mesh
  120363. * @return the default mesh
  120364. */
  120365. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  120366. }
  120367. }
  120368. declare module BABYLON {
  120369. interface Scene {
  120370. /** @hidden (Backing field) */
  120371. _boundingBoxRenderer: BoundingBoxRenderer;
  120372. /** @hidden (Backing field) */
  120373. _forceShowBoundingBoxes: boolean;
  120374. /**
  120375. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  120376. */
  120377. forceShowBoundingBoxes: boolean;
  120378. /**
  120379. * Gets the bounding box renderer associated with the scene
  120380. * @returns a BoundingBoxRenderer
  120381. */
  120382. getBoundingBoxRenderer(): BoundingBoxRenderer;
  120383. }
  120384. interface AbstractMesh {
  120385. /** @hidden (Backing field) */
  120386. _showBoundingBox: boolean;
  120387. /**
  120388. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  120389. */
  120390. showBoundingBox: boolean;
  120391. }
  120392. /**
  120393. * Component responsible of rendering the bounding box of the meshes in a scene.
  120394. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  120395. */
  120396. export class BoundingBoxRenderer implements ISceneComponent {
  120397. /**
  120398. * The component name helpfull to identify the component in the list of scene components.
  120399. */
  120400. readonly name: string;
  120401. /**
  120402. * The scene the component belongs to.
  120403. */
  120404. scene: Scene;
  120405. /**
  120406. * Color of the bounding box lines placed in front of an object
  120407. */
  120408. frontColor: Color3;
  120409. /**
  120410. * Color of the bounding box lines placed behind an object
  120411. */
  120412. backColor: Color3;
  120413. /**
  120414. * Defines if the renderer should show the back lines or not
  120415. */
  120416. showBackLines: boolean;
  120417. /**
  120418. * @hidden
  120419. */
  120420. renderList: SmartArray<BoundingBox>;
  120421. private _colorShader;
  120422. private _vertexBuffers;
  120423. private _indexBuffer;
  120424. private _fillIndexBuffer;
  120425. private _fillIndexData;
  120426. /**
  120427. * Instantiates a new bounding box renderer in a scene.
  120428. * @param scene the scene the renderer renders in
  120429. */
  120430. constructor(scene: Scene);
  120431. /**
  120432. * Registers the component in a given scene
  120433. */
  120434. register(): void;
  120435. private _evaluateSubMesh;
  120436. private _activeMesh;
  120437. private _prepareRessources;
  120438. private _createIndexBuffer;
  120439. /**
  120440. * Rebuilds the elements related to this component in case of
  120441. * context lost for instance.
  120442. */
  120443. rebuild(): void;
  120444. /**
  120445. * @hidden
  120446. */
  120447. reset(): void;
  120448. /**
  120449. * Render the bounding boxes of a specific rendering group
  120450. * @param renderingGroupId defines the rendering group to render
  120451. */
  120452. render(renderingGroupId: number): void;
  120453. /**
  120454. * In case of occlusion queries, we can render the occlusion bounding box through this method
  120455. * @param mesh Define the mesh to render the occlusion bounding box for
  120456. */
  120457. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  120458. /**
  120459. * Dispose and release the resources attached to this renderer.
  120460. */
  120461. dispose(): void;
  120462. }
  120463. }
  120464. declare module BABYLON {
  120465. /** @hidden */
  120466. export var depthPixelShader: {
  120467. name: string;
  120468. shader: string;
  120469. };
  120470. }
  120471. declare module BABYLON {
  120472. /**
  120473. * This represents a depth renderer in Babylon.
  120474. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  120475. */
  120476. export class DepthRenderer {
  120477. private _scene;
  120478. private _depthMap;
  120479. private _effect;
  120480. private _cachedDefines;
  120481. private _camera;
  120482. /**
  120483. * Specifiess that the depth renderer will only be used within
  120484. * the camera it is created for.
  120485. * This can help forcing its rendering during the camera processing.
  120486. */
  120487. useOnlyInActiveCamera: boolean;
  120488. /** @hidden */
  120489. static _SceneComponentInitialization: (scene: Scene) => void;
  120490. /**
  120491. * Instantiates a depth renderer
  120492. * @param scene The scene the renderer belongs to
  120493. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  120494. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  120495. */
  120496. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  120497. /**
  120498. * Creates the depth rendering effect and checks if the effect is ready.
  120499. * @param subMesh The submesh to be used to render the depth map of
  120500. * @param useInstances If multiple world instances should be used
  120501. * @returns if the depth renderer is ready to render the depth map
  120502. */
  120503. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120504. /**
  120505. * Gets the texture which the depth map will be written to.
  120506. * @returns The depth map texture
  120507. */
  120508. getDepthMap(): RenderTargetTexture;
  120509. /**
  120510. * Disposes of the depth renderer.
  120511. */
  120512. dispose(): void;
  120513. }
  120514. }
  120515. declare module BABYLON {
  120516. interface Scene {
  120517. /** @hidden (Backing field) */
  120518. _depthRenderer: {
  120519. [id: string]: DepthRenderer;
  120520. };
  120521. /**
  120522. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  120523. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  120524. * @returns the created depth renderer
  120525. */
  120526. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  120527. /**
  120528. * Disables a depth renderer for a given camera
  120529. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  120530. */
  120531. disableDepthRenderer(camera?: Nullable<Camera>): void;
  120532. }
  120533. /**
  120534. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  120535. * in several rendering techniques.
  120536. */
  120537. export class DepthRendererSceneComponent implements ISceneComponent {
  120538. /**
  120539. * The component name helpfull to identify the component in the list of scene components.
  120540. */
  120541. readonly name: string;
  120542. /**
  120543. * The scene the component belongs to.
  120544. */
  120545. scene: Scene;
  120546. /**
  120547. * Creates a new instance of the component for the given scene
  120548. * @param scene Defines the scene to register the component in
  120549. */
  120550. constructor(scene: Scene);
  120551. /**
  120552. * Registers the component in a given scene
  120553. */
  120554. register(): void;
  120555. /**
  120556. * Rebuilds the elements related to this component in case of
  120557. * context lost for instance.
  120558. */
  120559. rebuild(): void;
  120560. /**
  120561. * Disposes the component and the associated ressources
  120562. */
  120563. dispose(): void;
  120564. private _gatherRenderTargets;
  120565. private _gatherActiveCameraRenderTargets;
  120566. }
  120567. }
  120568. declare module BABYLON {
  120569. /** @hidden */
  120570. export var outlinePixelShader: {
  120571. name: string;
  120572. shader: string;
  120573. };
  120574. }
  120575. declare module BABYLON {
  120576. /** @hidden */
  120577. export var outlineVertexShader: {
  120578. name: string;
  120579. shader: string;
  120580. };
  120581. }
  120582. declare module BABYLON {
  120583. interface Scene {
  120584. /** @hidden */
  120585. _outlineRenderer: OutlineRenderer;
  120586. /**
  120587. * Gets the outline renderer associated with the scene
  120588. * @returns a OutlineRenderer
  120589. */
  120590. getOutlineRenderer(): OutlineRenderer;
  120591. }
  120592. interface AbstractMesh {
  120593. /** @hidden (Backing field) */
  120594. _renderOutline: boolean;
  120595. /**
  120596. * Gets or sets a boolean indicating if the outline must be rendered as well
  120597. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  120598. */
  120599. renderOutline: boolean;
  120600. /** @hidden (Backing field) */
  120601. _renderOverlay: boolean;
  120602. /**
  120603. * Gets or sets a boolean indicating if the overlay must be rendered as well
  120604. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  120605. */
  120606. renderOverlay: boolean;
  120607. }
  120608. /**
  120609. * This class is responsible to draw bothe outline/overlay of meshes.
  120610. * It should not be used directly but through the available method on mesh.
  120611. */
  120612. export class OutlineRenderer implements ISceneComponent {
  120613. /**
  120614. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  120615. */
  120616. private static _StencilReference;
  120617. /**
  120618. * The name of the component. Each component must have a unique name.
  120619. */
  120620. name: string;
  120621. /**
  120622. * The scene the component belongs to.
  120623. */
  120624. scene: Scene;
  120625. /**
  120626. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  120627. */
  120628. zOffset: number;
  120629. private _engine;
  120630. private _effect;
  120631. private _cachedDefines;
  120632. private _savedDepthWrite;
  120633. /**
  120634. * Instantiates a new outline renderer. (There could be only one per scene).
  120635. * @param scene Defines the scene it belongs to
  120636. */
  120637. constructor(scene: Scene);
  120638. /**
  120639. * Register the component to one instance of a scene.
  120640. */
  120641. register(): void;
  120642. /**
  120643. * Rebuilds the elements related to this component in case of
  120644. * context lost for instance.
  120645. */
  120646. rebuild(): void;
  120647. /**
  120648. * Disposes the component and the associated ressources.
  120649. */
  120650. dispose(): void;
  120651. /**
  120652. * Renders the outline in the canvas.
  120653. * @param subMesh Defines the sumesh to render
  120654. * @param batch Defines the batch of meshes in case of instances
  120655. * @param useOverlay Defines if the rendering is for the overlay or the outline
  120656. */
  120657. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  120658. /**
  120659. * Returns whether or not the outline renderer is ready for a given submesh.
  120660. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  120661. * @param subMesh Defines the submesh to check readyness for
  120662. * @param useInstances Defines wheter wee are trying to render instances or not
  120663. * @returns true if ready otherwise false
  120664. */
  120665. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120666. private _beforeRenderingMesh;
  120667. private _afterRenderingMesh;
  120668. }
  120669. }
  120670. declare module BABYLON {
  120671. /**
  120672. * Defines the list of states available for a task inside a AssetsManager
  120673. */
  120674. export enum AssetTaskState {
  120675. /**
  120676. * Initialization
  120677. */
  120678. INIT = 0,
  120679. /**
  120680. * Running
  120681. */
  120682. RUNNING = 1,
  120683. /**
  120684. * Done
  120685. */
  120686. DONE = 2,
  120687. /**
  120688. * Error
  120689. */
  120690. ERROR = 3
  120691. }
  120692. /**
  120693. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  120694. */
  120695. export abstract class AbstractAssetTask {
  120696. /**
  120697. * Task name
  120698. */ name: string;
  120699. /**
  120700. * Callback called when the task is successful
  120701. */
  120702. onSuccess: (task: any) => void;
  120703. /**
  120704. * Callback called when the task is not successful
  120705. */
  120706. onError: (task: any, message?: string, exception?: any) => void;
  120707. /**
  120708. * Creates a new AssetsManager
  120709. * @param name defines the name of the task
  120710. */
  120711. constructor(
  120712. /**
  120713. * Task name
  120714. */ name: string);
  120715. private _isCompleted;
  120716. private _taskState;
  120717. private _errorObject;
  120718. /**
  120719. * Get if the task is completed
  120720. */
  120721. readonly isCompleted: boolean;
  120722. /**
  120723. * Gets the current state of the task
  120724. */
  120725. readonly taskState: AssetTaskState;
  120726. /**
  120727. * Gets the current error object (if task is in error)
  120728. */
  120729. readonly errorObject: {
  120730. message?: string;
  120731. exception?: any;
  120732. };
  120733. /**
  120734. * Internal only
  120735. * @hidden
  120736. */
  120737. _setErrorObject(message?: string, exception?: any): void;
  120738. /**
  120739. * Execute the current task
  120740. * @param scene defines the scene where you want your assets to be loaded
  120741. * @param onSuccess is a callback called when the task is successfully executed
  120742. * @param onError is a callback called if an error occurs
  120743. */
  120744. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120745. /**
  120746. * Execute the current task
  120747. * @param scene defines the scene where you want your assets to be loaded
  120748. * @param onSuccess is a callback called when the task is successfully executed
  120749. * @param onError is a callback called if an error occurs
  120750. */
  120751. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120752. /**
  120753. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  120754. * This can be used with failed tasks that have the reason for failure fixed.
  120755. */
  120756. reset(): void;
  120757. private onErrorCallback;
  120758. private onDoneCallback;
  120759. }
  120760. /**
  120761. * Define the interface used by progress events raised during assets loading
  120762. */
  120763. export interface IAssetsProgressEvent {
  120764. /**
  120765. * Defines the number of remaining tasks to process
  120766. */
  120767. remainingCount: number;
  120768. /**
  120769. * Defines the total number of tasks
  120770. */
  120771. totalCount: number;
  120772. /**
  120773. * Defines the task that was just processed
  120774. */
  120775. task: AbstractAssetTask;
  120776. }
  120777. /**
  120778. * Class used to share progress information about assets loading
  120779. */
  120780. export class AssetsProgressEvent implements IAssetsProgressEvent {
  120781. /**
  120782. * Defines the number of remaining tasks to process
  120783. */
  120784. remainingCount: number;
  120785. /**
  120786. * Defines the total number of tasks
  120787. */
  120788. totalCount: number;
  120789. /**
  120790. * Defines the task that was just processed
  120791. */
  120792. task: AbstractAssetTask;
  120793. /**
  120794. * Creates a AssetsProgressEvent
  120795. * @param remainingCount defines the number of remaining tasks to process
  120796. * @param totalCount defines the total number of tasks
  120797. * @param task defines the task that was just processed
  120798. */
  120799. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  120800. }
  120801. /**
  120802. * Define a task used by AssetsManager to load meshes
  120803. */
  120804. export class MeshAssetTask extends AbstractAssetTask {
  120805. /**
  120806. * Defines the name of the task
  120807. */
  120808. name: string;
  120809. /**
  120810. * Defines the list of mesh's names you want to load
  120811. */
  120812. meshesNames: any;
  120813. /**
  120814. * Defines the root url to use as a base to load your meshes and associated resources
  120815. */
  120816. rootUrl: string;
  120817. /**
  120818. * Defines the filename of the scene to load from
  120819. */
  120820. sceneFilename: string;
  120821. /**
  120822. * Gets the list of loaded meshes
  120823. */
  120824. loadedMeshes: Array<AbstractMesh>;
  120825. /**
  120826. * Gets the list of loaded particle systems
  120827. */
  120828. loadedParticleSystems: Array<IParticleSystem>;
  120829. /**
  120830. * Gets the list of loaded skeletons
  120831. */
  120832. loadedSkeletons: Array<Skeleton>;
  120833. /**
  120834. * Gets the list of loaded animation groups
  120835. */
  120836. loadedAnimationGroups: Array<AnimationGroup>;
  120837. /**
  120838. * Callback called when the task is successful
  120839. */
  120840. onSuccess: (task: MeshAssetTask) => void;
  120841. /**
  120842. * Callback called when the task is successful
  120843. */
  120844. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  120845. /**
  120846. * Creates a new MeshAssetTask
  120847. * @param name defines the name of the task
  120848. * @param meshesNames defines the list of mesh's names you want to load
  120849. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  120850. * @param sceneFilename defines the filename of the scene to load from
  120851. */
  120852. constructor(
  120853. /**
  120854. * Defines the name of the task
  120855. */
  120856. name: string,
  120857. /**
  120858. * Defines the list of mesh's names you want to load
  120859. */
  120860. meshesNames: any,
  120861. /**
  120862. * Defines the root url to use as a base to load your meshes and associated resources
  120863. */
  120864. rootUrl: string,
  120865. /**
  120866. * Defines the filename of the scene to load from
  120867. */
  120868. sceneFilename: string);
  120869. /**
  120870. * Execute the current task
  120871. * @param scene defines the scene where you want your assets to be loaded
  120872. * @param onSuccess is a callback called when the task is successfully executed
  120873. * @param onError is a callback called if an error occurs
  120874. */
  120875. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120876. }
  120877. /**
  120878. * Define a task used by AssetsManager to load text content
  120879. */
  120880. export class TextFileAssetTask extends AbstractAssetTask {
  120881. /**
  120882. * Defines the name of the task
  120883. */
  120884. name: string;
  120885. /**
  120886. * Defines the location of the file to load
  120887. */
  120888. url: string;
  120889. /**
  120890. * Gets the loaded text string
  120891. */
  120892. text: string;
  120893. /**
  120894. * Callback called when the task is successful
  120895. */
  120896. onSuccess: (task: TextFileAssetTask) => void;
  120897. /**
  120898. * Callback called when the task is successful
  120899. */
  120900. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  120901. /**
  120902. * Creates a new TextFileAssetTask object
  120903. * @param name defines the name of the task
  120904. * @param url defines the location of the file to load
  120905. */
  120906. constructor(
  120907. /**
  120908. * Defines the name of the task
  120909. */
  120910. name: string,
  120911. /**
  120912. * Defines the location of the file to load
  120913. */
  120914. url: string);
  120915. /**
  120916. * Execute the current task
  120917. * @param scene defines the scene where you want your assets to be loaded
  120918. * @param onSuccess is a callback called when the task is successfully executed
  120919. * @param onError is a callback called if an error occurs
  120920. */
  120921. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120922. }
  120923. /**
  120924. * Define a task used by AssetsManager to load binary data
  120925. */
  120926. export class BinaryFileAssetTask extends AbstractAssetTask {
  120927. /**
  120928. * Defines the name of the task
  120929. */
  120930. name: string;
  120931. /**
  120932. * Defines the location of the file to load
  120933. */
  120934. url: string;
  120935. /**
  120936. * Gets the lodaded data (as an array buffer)
  120937. */
  120938. data: ArrayBuffer;
  120939. /**
  120940. * Callback called when the task is successful
  120941. */
  120942. onSuccess: (task: BinaryFileAssetTask) => void;
  120943. /**
  120944. * Callback called when the task is successful
  120945. */
  120946. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  120947. /**
  120948. * Creates a new BinaryFileAssetTask object
  120949. * @param name defines the name of the new task
  120950. * @param url defines the location of the file to load
  120951. */
  120952. constructor(
  120953. /**
  120954. * Defines the name of the task
  120955. */
  120956. name: string,
  120957. /**
  120958. * Defines the location of the file to load
  120959. */
  120960. url: string);
  120961. /**
  120962. * Execute the current task
  120963. * @param scene defines the scene where you want your assets to be loaded
  120964. * @param onSuccess is a callback called when the task is successfully executed
  120965. * @param onError is a callback called if an error occurs
  120966. */
  120967. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120968. }
  120969. /**
  120970. * Define a task used by AssetsManager to load images
  120971. */
  120972. export class ImageAssetTask extends AbstractAssetTask {
  120973. /**
  120974. * Defines the name of the task
  120975. */
  120976. name: string;
  120977. /**
  120978. * Defines the location of the image to load
  120979. */
  120980. url: string;
  120981. /**
  120982. * Gets the loaded images
  120983. */
  120984. image: HTMLImageElement;
  120985. /**
  120986. * Callback called when the task is successful
  120987. */
  120988. onSuccess: (task: ImageAssetTask) => void;
  120989. /**
  120990. * Callback called when the task is successful
  120991. */
  120992. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  120993. /**
  120994. * Creates a new ImageAssetTask
  120995. * @param name defines the name of the task
  120996. * @param url defines the location of the image to load
  120997. */
  120998. constructor(
  120999. /**
  121000. * Defines the name of the task
  121001. */
  121002. name: string,
  121003. /**
  121004. * Defines the location of the image to load
  121005. */
  121006. url: string);
  121007. /**
  121008. * Execute the current task
  121009. * @param scene defines the scene where you want your assets to be loaded
  121010. * @param onSuccess is a callback called when the task is successfully executed
  121011. * @param onError is a callback called if an error occurs
  121012. */
  121013. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121014. }
  121015. /**
  121016. * Defines the interface used by texture loading tasks
  121017. */
  121018. export interface ITextureAssetTask<TEX extends BaseTexture> {
  121019. /**
  121020. * Gets the loaded texture
  121021. */
  121022. texture: TEX;
  121023. }
  121024. /**
  121025. * Define a task used by AssetsManager to load 2D textures
  121026. */
  121027. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  121028. /**
  121029. * Defines the name of the task
  121030. */
  121031. name: string;
  121032. /**
  121033. * Defines the location of the file to load
  121034. */
  121035. url: string;
  121036. /**
  121037. * Defines if mipmap should not be generated (default is false)
  121038. */
  121039. noMipmap?: boolean | undefined;
  121040. /**
  121041. * Defines if texture must be inverted on Y axis (default is false)
  121042. */
  121043. invertY?: boolean | undefined;
  121044. /**
  121045. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121046. */
  121047. samplingMode: number;
  121048. /**
  121049. * Gets the loaded texture
  121050. */
  121051. texture: Texture;
  121052. /**
  121053. * Callback called when the task is successful
  121054. */
  121055. onSuccess: (task: TextureAssetTask) => void;
  121056. /**
  121057. * Callback called when the task is successful
  121058. */
  121059. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  121060. /**
  121061. * Creates a new TextureAssetTask object
  121062. * @param name defines the name of the task
  121063. * @param url defines the location of the file to load
  121064. * @param noMipmap defines if mipmap should not be generated (default is false)
  121065. * @param invertY defines if texture must be inverted on Y axis (default is false)
  121066. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121067. */
  121068. constructor(
  121069. /**
  121070. * Defines the name of the task
  121071. */
  121072. name: string,
  121073. /**
  121074. * Defines the location of the file to load
  121075. */
  121076. url: string,
  121077. /**
  121078. * Defines if mipmap should not be generated (default is false)
  121079. */
  121080. noMipmap?: boolean | undefined,
  121081. /**
  121082. * Defines if texture must be inverted on Y axis (default is false)
  121083. */
  121084. invertY?: boolean | undefined,
  121085. /**
  121086. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121087. */
  121088. samplingMode?: number);
  121089. /**
  121090. * Execute the current task
  121091. * @param scene defines the scene where you want your assets to be loaded
  121092. * @param onSuccess is a callback called when the task is successfully executed
  121093. * @param onError is a callback called if an error occurs
  121094. */
  121095. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121096. }
  121097. /**
  121098. * Define a task used by AssetsManager to load cube textures
  121099. */
  121100. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  121101. /**
  121102. * Defines the name of the task
  121103. */
  121104. name: string;
  121105. /**
  121106. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121107. */
  121108. url: string;
  121109. /**
  121110. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121111. */
  121112. extensions?: string[] | undefined;
  121113. /**
  121114. * Defines if mipmaps should not be generated (default is false)
  121115. */
  121116. noMipmap?: boolean | undefined;
  121117. /**
  121118. * Defines the explicit list of files (undefined by default)
  121119. */
  121120. files?: string[] | undefined;
  121121. /**
  121122. * Gets the loaded texture
  121123. */
  121124. texture: CubeTexture;
  121125. /**
  121126. * Callback called when the task is successful
  121127. */
  121128. onSuccess: (task: CubeTextureAssetTask) => void;
  121129. /**
  121130. * Callback called when the task is successful
  121131. */
  121132. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  121133. /**
  121134. * Creates a new CubeTextureAssetTask
  121135. * @param name defines the name of the task
  121136. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121137. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121138. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121139. * @param files defines the explicit list of files (undefined by default)
  121140. */
  121141. constructor(
  121142. /**
  121143. * Defines the name of the task
  121144. */
  121145. name: string,
  121146. /**
  121147. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121148. */
  121149. url: string,
  121150. /**
  121151. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121152. */
  121153. extensions?: string[] | undefined,
  121154. /**
  121155. * Defines if mipmaps should not be generated (default is false)
  121156. */
  121157. noMipmap?: boolean | undefined,
  121158. /**
  121159. * Defines the explicit list of files (undefined by default)
  121160. */
  121161. files?: string[] | undefined);
  121162. /**
  121163. * Execute the current task
  121164. * @param scene defines the scene where you want your assets to be loaded
  121165. * @param onSuccess is a callback called when the task is successfully executed
  121166. * @param onError is a callback called if an error occurs
  121167. */
  121168. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121169. }
  121170. /**
  121171. * Define a task used by AssetsManager to load HDR cube textures
  121172. */
  121173. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  121174. /**
  121175. * Defines the name of the task
  121176. */
  121177. name: string;
  121178. /**
  121179. * Defines the location of the file to load
  121180. */
  121181. url: string;
  121182. /**
  121183. * Defines the desired size (the more it increases the longer the generation will be)
  121184. */
  121185. size: number;
  121186. /**
  121187. * Defines if mipmaps should not be generated (default is false)
  121188. */
  121189. noMipmap: boolean;
  121190. /**
  121191. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121192. */
  121193. generateHarmonics: boolean;
  121194. /**
  121195. * 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)
  121196. */
  121197. gammaSpace: boolean;
  121198. /**
  121199. * Internal Use Only
  121200. */
  121201. reserved: boolean;
  121202. /**
  121203. * Gets the loaded texture
  121204. */
  121205. texture: HDRCubeTexture;
  121206. /**
  121207. * Callback called when the task is successful
  121208. */
  121209. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  121210. /**
  121211. * Callback called when the task is successful
  121212. */
  121213. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  121214. /**
  121215. * Creates a new HDRCubeTextureAssetTask object
  121216. * @param name defines the name of the task
  121217. * @param url defines the location of the file to load
  121218. * @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.
  121219. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121220. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121221. * @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)
  121222. * @param reserved Internal use only
  121223. */
  121224. constructor(
  121225. /**
  121226. * Defines the name of the task
  121227. */
  121228. name: string,
  121229. /**
  121230. * Defines the location of the file to load
  121231. */
  121232. url: string,
  121233. /**
  121234. * Defines the desired size (the more it increases the longer the generation will be)
  121235. */
  121236. size: number,
  121237. /**
  121238. * Defines if mipmaps should not be generated (default is false)
  121239. */
  121240. noMipmap?: boolean,
  121241. /**
  121242. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121243. */
  121244. generateHarmonics?: boolean,
  121245. /**
  121246. * 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)
  121247. */
  121248. gammaSpace?: boolean,
  121249. /**
  121250. * Internal Use Only
  121251. */
  121252. reserved?: boolean);
  121253. /**
  121254. * Execute the current task
  121255. * @param scene defines the scene where you want your assets to be loaded
  121256. * @param onSuccess is a callback called when the task is successfully executed
  121257. * @param onError is a callback called if an error occurs
  121258. */
  121259. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121260. }
  121261. /**
  121262. * Define a task used by AssetsManager to load Equirectangular cube textures
  121263. */
  121264. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  121265. /**
  121266. * Defines the name of the task
  121267. */
  121268. name: string;
  121269. /**
  121270. * Defines the location of the file to load
  121271. */
  121272. url: string;
  121273. /**
  121274. * Defines the desired size (the more it increases the longer the generation will be)
  121275. */
  121276. size: number;
  121277. /**
  121278. * Defines if mipmaps should not be generated (default is false)
  121279. */
  121280. noMipmap: boolean;
  121281. /**
  121282. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121283. * but the standard material would require them in Gamma space) (default is true)
  121284. */
  121285. gammaSpace: boolean;
  121286. /**
  121287. * Gets the loaded texture
  121288. */
  121289. texture: EquiRectangularCubeTexture;
  121290. /**
  121291. * Callback called when the task is successful
  121292. */
  121293. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  121294. /**
  121295. * Callback called when the task is successful
  121296. */
  121297. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  121298. /**
  121299. * Creates a new EquiRectangularCubeTextureAssetTask object
  121300. * @param name defines the name of the task
  121301. * @param url defines the location of the file to load
  121302. * @param size defines the desired size (the more it increases the longer the generation will be)
  121303. * If the size is omitted this implies you are using a preprocessed cubemap.
  121304. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121305. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  121306. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  121307. * (default is true)
  121308. */
  121309. constructor(
  121310. /**
  121311. * Defines the name of the task
  121312. */
  121313. name: string,
  121314. /**
  121315. * Defines the location of the file to load
  121316. */
  121317. url: string,
  121318. /**
  121319. * Defines the desired size (the more it increases the longer the generation will be)
  121320. */
  121321. size: number,
  121322. /**
  121323. * Defines if mipmaps should not be generated (default is false)
  121324. */
  121325. noMipmap?: boolean,
  121326. /**
  121327. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121328. * but the standard material would require them in Gamma space) (default is true)
  121329. */
  121330. gammaSpace?: boolean);
  121331. /**
  121332. * Execute the current task
  121333. * @param scene defines the scene where you want your assets to be loaded
  121334. * @param onSuccess is a callback called when the task is successfully executed
  121335. * @param onError is a callback called if an error occurs
  121336. */
  121337. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121338. }
  121339. /**
  121340. * This class can be used to easily import assets into a scene
  121341. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  121342. */
  121343. export class AssetsManager {
  121344. private _scene;
  121345. private _isLoading;
  121346. protected _tasks: AbstractAssetTask[];
  121347. protected _waitingTasksCount: number;
  121348. protected _totalTasksCount: number;
  121349. /**
  121350. * Callback called when all tasks are processed
  121351. */
  121352. onFinish: (tasks: AbstractAssetTask[]) => void;
  121353. /**
  121354. * Callback called when a task is successful
  121355. */
  121356. onTaskSuccess: (task: AbstractAssetTask) => void;
  121357. /**
  121358. * Callback called when a task had an error
  121359. */
  121360. onTaskError: (task: AbstractAssetTask) => void;
  121361. /**
  121362. * Callback called when a task is done (whatever the result is)
  121363. */
  121364. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  121365. /**
  121366. * Observable called when all tasks are processed
  121367. */
  121368. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  121369. /**
  121370. * Observable called when a task had an error
  121371. */
  121372. onTaskErrorObservable: Observable<AbstractAssetTask>;
  121373. /**
  121374. * Observable called when all tasks were executed
  121375. */
  121376. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  121377. /**
  121378. * Observable called when a task is done (whatever the result is)
  121379. */
  121380. onProgressObservable: Observable<IAssetsProgressEvent>;
  121381. /**
  121382. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  121383. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121384. */
  121385. useDefaultLoadingScreen: boolean;
  121386. /**
  121387. * Creates a new AssetsManager
  121388. * @param scene defines the scene to work on
  121389. */
  121390. constructor(scene: Scene);
  121391. /**
  121392. * Add a MeshAssetTask to the list of active tasks
  121393. * @param taskName defines the name of the new task
  121394. * @param meshesNames defines the name of meshes to load
  121395. * @param rootUrl defines the root url to use to locate files
  121396. * @param sceneFilename defines the filename of the scene file
  121397. * @returns a new MeshAssetTask object
  121398. */
  121399. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  121400. /**
  121401. * Add a TextFileAssetTask to the list of active tasks
  121402. * @param taskName defines the name of the new task
  121403. * @param url defines the url of the file to load
  121404. * @returns a new TextFileAssetTask object
  121405. */
  121406. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  121407. /**
  121408. * Add a BinaryFileAssetTask to the list of active tasks
  121409. * @param taskName defines the name of the new task
  121410. * @param url defines the url of the file to load
  121411. * @returns a new BinaryFileAssetTask object
  121412. */
  121413. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  121414. /**
  121415. * Add a ImageAssetTask to the list of active tasks
  121416. * @param taskName defines the name of the new task
  121417. * @param url defines the url of the file to load
  121418. * @returns a new ImageAssetTask object
  121419. */
  121420. addImageTask(taskName: string, url: string): ImageAssetTask;
  121421. /**
  121422. * Add a TextureAssetTask to the list of active tasks
  121423. * @param taskName defines the name of the new task
  121424. * @param url defines the url of the file to load
  121425. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121426. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  121427. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121428. * @returns a new TextureAssetTask object
  121429. */
  121430. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  121431. /**
  121432. * Add a CubeTextureAssetTask to the list of active tasks
  121433. * @param taskName defines the name of the new task
  121434. * @param url defines the url of the file to load
  121435. * @param extensions defines the extension to use to load the cube map (can be null)
  121436. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121437. * @param files defines the list of files to load (can be null)
  121438. * @returns a new CubeTextureAssetTask object
  121439. */
  121440. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  121441. /**
  121442. *
  121443. * Add a HDRCubeTextureAssetTask to the list of active tasks
  121444. * @param taskName defines the name of the new task
  121445. * @param url defines the url of the file to load
  121446. * @param size defines the size you want for the cubemap (can be null)
  121447. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121448. * @param generateHarmonics defines if you want to automatically generate (true by default)
  121449. * @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)
  121450. * @param reserved Internal use only
  121451. * @returns a new HDRCubeTextureAssetTask object
  121452. */
  121453. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  121454. /**
  121455. *
  121456. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  121457. * @param taskName defines the name of the new task
  121458. * @param url defines the url of the file to load
  121459. * @param size defines the size you want for the cubemap (can be null)
  121460. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121461. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  121462. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  121463. * @returns a new EquiRectangularCubeTextureAssetTask object
  121464. */
  121465. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  121466. /**
  121467. * Remove a task from the assets manager.
  121468. * @param task the task to remove
  121469. */
  121470. removeTask(task: AbstractAssetTask): void;
  121471. private _decreaseWaitingTasksCount;
  121472. private _runTask;
  121473. /**
  121474. * Reset the AssetsManager and remove all tasks
  121475. * @return the current instance of the AssetsManager
  121476. */
  121477. reset(): AssetsManager;
  121478. /**
  121479. * Start the loading process
  121480. * @return the current instance of the AssetsManager
  121481. */
  121482. load(): AssetsManager;
  121483. /**
  121484. * Start the loading process as an async operation
  121485. * @return a promise returning the list of failed tasks
  121486. */
  121487. loadAsync(): Promise<void>;
  121488. }
  121489. }
  121490. declare module BABYLON {
  121491. /**
  121492. * Wrapper class for promise with external resolve and reject.
  121493. */
  121494. export class Deferred<T> {
  121495. /**
  121496. * The promise associated with this deferred object.
  121497. */
  121498. readonly promise: Promise<T>;
  121499. private _resolve;
  121500. private _reject;
  121501. /**
  121502. * The resolve method of the promise associated with this deferred object.
  121503. */
  121504. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  121505. /**
  121506. * The reject method of the promise associated with this deferred object.
  121507. */
  121508. readonly reject: (reason?: any) => void;
  121509. /**
  121510. * Constructor for this deferred object.
  121511. */
  121512. constructor();
  121513. }
  121514. }
  121515. declare module BABYLON {
  121516. /**
  121517. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  121518. */
  121519. export class MeshExploder {
  121520. private _centerMesh;
  121521. private _meshes;
  121522. private _meshesOrigins;
  121523. private _toCenterVectors;
  121524. private _scaledDirection;
  121525. private _newPosition;
  121526. private _centerPosition;
  121527. /**
  121528. * Explodes meshes from a center mesh.
  121529. * @param meshes The meshes to explode.
  121530. * @param centerMesh The mesh to be center of explosion.
  121531. */
  121532. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  121533. private _setCenterMesh;
  121534. /**
  121535. * Get class name
  121536. * @returns "MeshExploder"
  121537. */
  121538. getClassName(): string;
  121539. /**
  121540. * "Exploded meshes"
  121541. * @returns Array of meshes with the centerMesh at index 0.
  121542. */
  121543. getMeshes(): Array<Mesh>;
  121544. /**
  121545. * Explodes meshes giving a specific direction
  121546. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  121547. */
  121548. explode(direction?: number): void;
  121549. }
  121550. }
  121551. declare module BABYLON {
  121552. /**
  121553. * Class used to help managing file picking and drag'n'drop
  121554. */
  121555. export class FilesInput {
  121556. /**
  121557. * List of files ready to be loaded
  121558. */
  121559. static readonly FilesToLoad: {
  121560. [key: string]: File;
  121561. };
  121562. /**
  121563. * Callback called when a file is processed
  121564. */
  121565. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  121566. private _engine;
  121567. private _currentScene;
  121568. private _sceneLoadedCallback;
  121569. private _progressCallback;
  121570. private _additionalRenderLoopLogicCallback;
  121571. private _textureLoadingCallback;
  121572. private _startingProcessingFilesCallback;
  121573. private _onReloadCallback;
  121574. private _errorCallback;
  121575. private _elementToMonitor;
  121576. private _sceneFileToLoad;
  121577. private _filesToLoad;
  121578. /**
  121579. * Creates a new FilesInput
  121580. * @param engine defines the rendering engine
  121581. * @param scene defines the hosting scene
  121582. * @param sceneLoadedCallback callback called when scene is loaded
  121583. * @param progressCallback callback called to track progress
  121584. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  121585. * @param textureLoadingCallback callback called when a texture is loading
  121586. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  121587. * @param onReloadCallback callback called when a reload is requested
  121588. * @param errorCallback callback call if an error occurs
  121589. */
  121590. 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);
  121591. private _dragEnterHandler;
  121592. private _dragOverHandler;
  121593. private _dropHandler;
  121594. /**
  121595. * Calls this function to listen to drag'n'drop events on a specific DOM element
  121596. * @param elementToMonitor defines the DOM element to track
  121597. */
  121598. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  121599. /**
  121600. * Release all associated resources
  121601. */
  121602. dispose(): void;
  121603. private renderFunction;
  121604. private drag;
  121605. private drop;
  121606. private _traverseFolder;
  121607. private _processFiles;
  121608. /**
  121609. * Load files from a drop event
  121610. * @param event defines the drop event to use as source
  121611. */
  121612. loadFiles(event: any): void;
  121613. private _processReload;
  121614. /**
  121615. * Reload the current scene from the loaded files
  121616. */
  121617. reload(): void;
  121618. }
  121619. }
  121620. declare module BABYLON {
  121621. /**
  121622. * Defines the root class used to create scene optimization to use with SceneOptimizer
  121623. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121624. */
  121625. export class SceneOptimization {
  121626. /**
  121627. * Defines the priority of this optimization (0 by default which means first in the list)
  121628. */
  121629. priority: number;
  121630. /**
  121631. * Gets a string describing the action executed by the current optimization
  121632. * @returns description string
  121633. */
  121634. getDescription(): string;
  121635. /**
  121636. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121637. * @param scene defines the current scene where to apply this optimization
  121638. * @param optimizer defines the current optimizer
  121639. * @returns true if everything that can be done was applied
  121640. */
  121641. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121642. /**
  121643. * Creates the SceneOptimization object
  121644. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121645. * @param desc defines the description associated with the optimization
  121646. */
  121647. constructor(
  121648. /**
  121649. * Defines the priority of this optimization (0 by default which means first in the list)
  121650. */
  121651. priority?: number);
  121652. }
  121653. /**
  121654. * Defines an optimization used to reduce the size of render target textures
  121655. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121656. */
  121657. export class TextureOptimization extends SceneOptimization {
  121658. /**
  121659. * Defines the priority of this optimization (0 by default which means first in the list)
  121660. */
  121661. priority: number;
  121662. /**
  121663. * 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
  121664. */
  121665. maximumSize: number;
  121666. /**
  121667. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121668. */
  121669. step: number;
  121670. /**
  121671. * Gets a string describing the action executed by the current optimization
  121672. * @returns description string
  121673. */
  121674. getDescription(): string;
  121675. /**
  121676. * Creates the TextureOptimization object
  121677. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121678. * @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
  121679. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121680. */
  121681. constructor(
  121682. /**
  121683. * Defines the priority of this optimization (0 by default which means first in the list)
  121684. */
  121685. priority?: number,
  121686. /**
  121687. * 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
  121688. */
  121689. maximumSize?: number,
  121690. /**
  121691. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121692. */
  121693. step?: number);
  121694. /**
  121695. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121696. * @param scene defines the current scene where to apply this optimization
  121697. * @param optimizer defines the current optimizer
  121698. * @returns true if everything that can be done was applied
  121699. */
  121700. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121701. }
  121702. /**
  121703. * Defines an optimization used to increase or decrease the rendering resolution
  121704. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121705. */
  121706. export class HardwareScalingOptimization extends SceneOptimization {
  121707. /**
  121708. * Defines the priority of this optimization (0 by default which means first in the list)
  121709. */
  121710. priority: number;
  121711. /**
  121712. * Defines the maximum scale to use (2 by default)
  121713. */
  121714. maximumScale: number;
  121715. /**
  121716. * Defines the step to use between two passes (0.5 by default)
  121717. */
  121718. step: number;
  121719. private _currentScale;
  121720. private _directionOffset;
  121721. /**
  121722. * Gets a string describing the action executed by the current optimization
  121723. * @return description string
  121724. */
  121725. getDescription(): string;
  121726. /**
  121727. * Creates the HardwareScalingOptimization object
  121728. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121729. * @param maximumScale defines the maximum scale to use (2 by default)
  121730. * @param step defines the step to use between two passes (0.5 by default)
  121731. */
  121732. constructor(
  121733. /**
  121734. * Defines the priority of this optimization (0 by default which means first in the list)
  121735. */
  121736. priority?: number,
  121737. /**
  121738. * Defines the maximum scale to use (2 by default)
  121739. */
  121740. maximumScale?: number,
  121741. /**
  121742. * Defines the step to use between two passes (0.5 by default)
  121743. */
  121744. step?: number);
  121745. /**
  121746. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121747. * @param scene defines the current scene where to apply this optimization
  121748. * @param optimizer defines the current optimizer
  121749. * @returns true if everything that can be done was applied
  121750. */
  121751. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121752. }
  121753. /**
  121754. * Defines an optimization used to remove shadows
  121755. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121756. */
  121757. export class ShadowsOptimization extends SceneOptimization {
  121758. /**
  121759. * Gets a string describing the action executed by the current optimization
  121760. * @return description string
  121761. */
  121762. getDescription(): string;
  121763. /**
  121764. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121765. * @param scene defines the current scene where to apply this optimization
  121766. * @param optimizer defines the current optimizer
  121767. * @returns true if everything that can be done was applied
  121768. */
  121769. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121770. }
  121771. /**
  121772. * Defines an optimization used to turn post-processes off
  121773. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121774. */
  121775. export class PostProcessesOptimization extends SceneOptimization {
  121776. /**
  121777. * Gets a string describing the action executed by the current optimization
  121778. * @return description string
  121779. */
  121780. getDescription(): string;
  121781. /**
  121782. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121783. * @param scene defines the current scene where to apply this optimization
  121784. * @param optimizer defines the current optimizer
  121785. * @returns true if everything that can be done was applied
  121786. */
  121787. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121788. }
  121789. /**
  121790. * Defines an optimization used to turn lens flares off
  121791. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121792. */
  121793. export class LensFlaresOptimization extends SceneOptimization {
  121794. /**
  121795. * Gets a string describing the action executed by the current optimization
  121796. * @return description string
  121797. */
  121798. getDescription(): string;
  121799. /**
  121800. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121801. * @param scene defines the current scene where to apply this optimization
  121802. * @param optimizer defines the current optimizer
  121803. * @returns true if everything that can be done was applied
  121804. */
  121805. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121806. }
  121807. /**
  121808. * Defines an optimization based on user defined callback.
  121809. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121810. */
  121811. export class CustomOptimization extends SceneOptimization {
  121812. /**
  121813. * Callback called to apply the custom optimization.
  121814. */
  121815. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  121816. /**
  121817. * Callback called to get custom description
  121818. */
  121819. onGetDescription: () => string;
  121820. /**
  121821. * Gets a string describing the action executed by the current optimization
  121822. * @returns description string
  121823. */
  121824. getDescription(): string;
  121825. /**
  121826. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121827. * @param scene defines the current scene where to apply this optimization
  121828. * @param optimizer defines the current optimizer
  121829. * @returns true if everything that can be done was applied
  121830. */
  121831. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121832. }
  121833. /**
  121834. * Defines an optimization used to turn particles off
  121835. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121836. */
  121837. export class ParticlesOptimization extends SceneOptimization {
  121838. /**
  121839. * Gets a string describing the action executed by the current optimization
  121840. * @return description string
  121841. */
  121842. getDescription(): string;
  121843. /**
  121844. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121845. * @param scene defines the current scene where to apply this optimization
  121846. * @param optimizer defines the current optimizer
  121847. * @returns true if everything that can be done was applied
  121848. */
  121849. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121850. }
  121851. /**
  121852. * Defines an optimization used to turn render targets off
  121853. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121854. */
  121855. export class RenderTargetsOptimization extends SceneOptimization {
  121856. /**
  121857. * Gets a string describing the action executed by the current optimization
  121858. * @return description string
  121859. */
  121860. getDescription(): string;
  121861. /**
  121862. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121863. * @param scene defines the current scene where to apply this optimization
  121864. * @param optimizer defines the current optimizer
  121865. * @returns true if everything that can be done was applied
  121866. */
  121867. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121868. }
  121869. /**
  121870. * Defines an optimization used to merge meshes with compatible materials
  121871. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121872. */
  121873. export class MergeMeshesOptimization extends SceneOptimization {
  121874. private static _UpdateSelectionTree;
  121875. /**
  121876. * Gets or sets a boolean which defines if optimization octree has to be updated
  121877. */
  121878. /**
  121879. * Gets or sets a boolean which defines if optimization octree has to be updated
  121880. */
  121881. static UpdateSelectionTree: boolean;
  121882. /**
  121883. * Gets a string describing the action executed by the current optimization
  121884. * @return description string
  121885. */
  121886. getDescription(): string;
  121887. private _canBeMerged;
  121888. /**
  121889. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121890. * @param scene defines the current scene where to apply this optimization
  121891. * @param optimizer defines the current optimizer
  121892. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  121893. * @returns true if everything that can be done was applied
  121894. */
  121895. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  121896. }
  121897. /**
  121898. * Defines a list of options used by SceneOptimizer
  121899. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121900. */
  121901. export class SceneOptimizerOptions {
  121902. /**
  121903. * Defines the target frame rate to reach (60 by default)
  121904. */
  121905. targetFrameRate: number;
  121906. /**
  121907. * Defines the interval between two checkes (2000ms by default)
  121908. */
  121909. trackerDuration: number;
  121910. /**
  121911. * Gets the list of optimizations to apply
  121912. */
  121913. optimizations: SceneOptimization[];
  121914. /**
  121915. * Creates a new list of options used by SceneOptimizer
  121916. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  121917. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  121918. */
  121919. constructor(
  121920. /**
  121921. * Defines the target frame rate to reach (60 by default)
  121922. */
  121923. targetFrameRate?: number,
  121924. /**
  121925. * Defines the interval between two checkes (2000ms by default)
  121926. */
  121927. trackerDuration?: number);
  121928. /**
  121929. * Add a new optimization
  121930. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  121931. * @returns the current SceneOptimizerOptions
  121932. */
  121933. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  121934. /**
  121935. * Add a new custom optimization
  121936. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  121937. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  121938. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121939. * @returns the current SceneOptimizerOptions
  121940. */
  121941. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  121942. /**
  121943. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  121944. * @param targetFrameRate defines the target frame rate (60 by default)
  121945. * @returns a SceneOptimizerOptions object
  121946. */
  121947. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121948. /**
  121949. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  121950. * @param targetFrameRate defines the target frame rate (60 by default)
  121951. * @returns a SceneOptimizerOptions object
  121952. */
  121953. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121954. /**
  121955. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  121956. * @param targetFrameRate defines the target frame rate (60 by default)
  121957. * @returns a SceneOptimizerOptions object
  121958. */
  121959. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121960. }
  121961. /**
  121962. * Class used to run optimizations in order to reach a target frame rate
  121963. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121964. */
  121965. export class SceneOptimizer implements IDisposable {
  121966. private _isRunning;
  121967. private _options;
  121968. private _scene;
  121969. private _currentPriorityLevel;
  121970. private _targetFrameRate;
  121971. private _trackerDuration;
  121972. private _currentFrameRate;
  121973. private _sceneDisposeObserver;
  121974. private _improvementMode;
  121975. /**
  121976. * Defines an observable called when the optimizer reaches the target frame rate
  121977. */
  121978. onSuccessObservable: Observable<SceneOptimizer>;
  121979. /**
  121980. * Defines an observable called when the optimizer enables an optimization
  121981. */
  121982. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  121983. /**
  121984. * Defines an observable called when the optimizer is not able to reach the target frame rate
  121985. */
  121986. onFailureObservable: Observable<SceneOptimizer>;
  121987. /**
  121988. * Gets a boolean indicating if the optimizer is in improvement mode
  121989. */
  121990. readonly isInImprovementMode: boolean;
  121991. /**
  121992. * Gets the current priority level (0 at start)
  121993. */
  121994. readonly currentPriorityLevel: number;
  121995. /**
  121996. * Gets the current frame rate checked by the SceneOptimizer
  121997. */
  121998. readonly currentFrameRate: number;
  121999. /**
  122000. * Gets or sets the current target frame rate (60 by default)
  122001. */
  122002. /**
  122003. * Gets or sets the current target frame rate (60 by default)
  122004. */
  122005. targetFrameRate: number;
  122006. /**
  122007. * Gets or sets the current interval between two checks (every 2000ms by default)
  122008. */
  122009. /**
  122010. * Gets or sets the current interval between two checks (every 2000ms by default)
  122011. */
  122012. trackerDuration: number;
  122013. /**
  122014. * Gets the list of active optimizations
  122015. */
  122016. readonly optimizations: SceneOptimization[];
  122017. /**
  122018. * Creates a new SceneOptimizer
  122019. * @param scene defines the scene to work on
  122020. * @param options defines the options to use with the SceneOptimizer
  122021. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  122022. * @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)
  122023. */
  122024. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  122025. /**
  122026. * Stops the current optimizer
  122027. */
  122028. stop(): void;
  122029. /**
  122030. * Reset the optimizer to initial step (current priority level = 0)
  122031. */
  122032. reset(): void;
  122033. /**
  122034. * Start the optimizer. By default it will try to reach a specific framerate
  122035. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  122036. */
  122037. start(): void;
  122038. private _checkCurrentState;
  122039. /**
  122040. * Release all resources
  122041. */
  122042. dispose(): void;
  122043. /**
  122044. * Helper function to create a SceneOptimizer with one single line of code
  122045. * @param scene defines the scene to work on
  122046. * @param options defines the options to use with the SceneOptimizer
  122047. * @param onSuccess defines a callback to call on success
  122048. * @param onFailure defines a callback to call on failure
  122049. * @returns the new SceneOptimizer object
  122050. */
  122051. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  122052. }
  122053. }
  122054. declare module BABYLON {
  122055. /**
  122056. * Class used to serialize a scene into a string
  122057. */
  122058. export class SceneSerializer {
  122059. /**
  122060. * Clear cache used by a previous serialization
  122061. */
  122062. static ClearCache(): void;
  122063. /**
  122064. * Serialize a scene into a JSON compatible object
  122065. * @param scene defines the scene to serialize
  122066. * @returns a JSON compatible object
  122067. */
  122068. static Serialize(scene: Scene): any;
  122069. /**
  122070. * Serialize a mesh into a JSON compatible object
  122071. * @param toSerialize defines the mesh to serialize
  122072. * @param withParents defines if parents must be serialized as well
  122073. * @param withChildren defines if children must be serialized as well
  122074. * @returns a JSON compatible object
  122075. */
  122076. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  122077. }
  122078. }
  122079. declare module BABYLON {
  122080. /**
  122081. * Class used to host texture specific utilities
  122082. */
  122083. export class TextureTools {
  122084. /**
  122085. * Uses the GPU to create a copy texture rescaled at a given size
  122086. * @param texture Texture to copy from
  122087. * @param width defines the desired width
  122088. * @param height defines the desired height
  122089. * @param useBilinearMode defines if bilinear mode has to be used
  122090. * @return the generated texture
  122091. */
  122092. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  122093. }
  122094. }
  122095. declare module BABYLON {
  122096. /**
  122097. * This represents the different options available for the video capture.
  122098. */
  122099. export interface VideoRecorderOptions {
  122100. /** Defines the mime type of the video. */
  122101. mimeType: string;
  122102. /** Defines the FPS the video should be recorded at. */
  122103. fps: number;
  122104. /** Defines the chunk size for the recording data. */
  122105. recordChunckSize: number;
  122106. /** The audio tracks to attach to the recording. */
  122107. audioTracks?: MediaStreamTrack[];
  122108. }
  122109. /**
  122110. * This can help with recording videos from BabylonJS.
  122111. * This is based on the available WebRTC functionalities of the browser.
  122112. *
  122113. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  122114. */
  122115. export class VideoRecorder {
  122116. private static readonly _defaultOptions;
  122117. /**
  122118. * Returns whether or not the VideoRecorder is available in your browser.
  122119. * @param engine Defines the Babylon Engine.
  122120. * @returns true if supported otherwise false.
  122121. */
  122122. static IsSupported(engine: Engine): boolean;
  122123. private readonly _options;
  122124. private _canvas;
  122125. private _mediaRecorder;
  122126. private _recordedChunks;
  122127. private _fileName;
  122128. private _resolve;
  122129. private _reject;
  122130. /**
  122131. * True when a recording is already in progress.
  122132. */
  122133. readonly isRecording: boolean;
  122134. /**
  122135. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  122136. * @param engine Defines the BabylonJS Engine you wish to record.
  122137. * @param options Defines options that can be used to customize the capture.
  122138. */
  122139. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  122140. /**
  122141. * Stops the current recording before the default capture timeout passed in the startRecording function.
  122142. */
  122143. stopRecording(): void;
  122144. /**
  122145. * Starts recording the canvas for a max duration specified in parameters.
  122146. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  122147. * If null no automatic download will start and you can rely on the promise to get the data back.
  122148. * @param maxDuration Defines the maximum recording time in seconds.
  122149. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  122150. * @return A promise callback at the end of the recording with the video data in Blob.
  122151. */
  122152. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  122153. /**
  122154. * Releases internal resources used during the recording.
  122155. */
  122156. dispose(): void;
  122157. private _handleDataAvailable;
  122158. private _handleError;
  122159. private _handleStop;
  122160. }
  122161. }
  122162. declare module BABYLON {
  122163. /**
  122164. * Class containing a set of static utilities functions for screenshots
  122165. */
  122166. export class ScreenshotTools {
  122167. /**
  122168. * Captures a screenshot of the current rendering
  122169. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122170. * @param engine defines the rendering engine
  122171. * @param camera defines the source camera
  122172. * @param size This parameter can be set to a single number or to an object with the
  122173. * following (optional) properties: precision, width, height. If a single number is passed,
  122174. * it will be used for both width and height. If an object is passed, the screenshot size
  122175. * will be derived from the parameters. The precision property is a multiplier allowing
  122176. * rendering at a higher or lower resolution
  122177. * @param successCallback defines the callback receives a single parameter which contains the
  122178. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122179. * src parameter of an <img> to display it
  122180. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122181. * Check your browser for supported MIME types
  122182. */
  122183. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  122184. /**
  122185. * Generates an image screenshot from the specified camera.
  122186. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122187. * @param engine The engine to use for rendering
  122188. * @param camera The camera to use for rendering
  122189. * @param size This parameter can be set to a single number or to an object with the
  122190. * following (optional) properties: precision, width, height. If a single number is passed,
  122191. * it will be used for both width and height. If an object is passed, the screenshot size
  122192. * will be derived from the parameters. The precision property is a multiplier allowing
  122193. * rendering at a higher or lower resolution
  122194. * @param successCallback The callback receives a single parameter which contains the
  122195. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122196. * src parameter of an <img> to display it
  122197. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122198. * Check your browser for supported MIME types
  122199. * @param samples Texture samples (default: 1)
  122200. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122201. * @param fileName A name for for the downloaded file.
  122202. */
  122203. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122204. }
  122205. }
  122206. declare module BABYLON {
  122207. /**
  122208. * A cursor which tracks a point on a path
  122209. */
  122210. export class PathCursor {
  122211. private path;
  122212. /**
  122213. * Stores path cursor callbacks for when an onchange event is triggered
  122214. */
  122215. private _onchange;
  122216. /**
  122217. * The value of the path cursor
  122218. */
  122219. value: number;
  122220. /**
  122221. * The animation array of the path cursor
  122222. */
  122223. animations: Animation[];
  122224. /**
  122225. * Initializes the path cursor
  122226. * @param path The path to track
  122227. */
  122228. constructor(path: Path2);
  122229. /**
  122230. * Gets the cursor point on the path
  122231. * @returns A point on the path cursor at the cursor location
  122232. */
  122233. getPoint(): Vector3;
  122234. /**
  122235. * Moves the cursor ahead by the step amount
  122236. * @param step The amount to move the cursor forward
  122237. * @returns This path cursor
  122238. */
  122239. moveAhead(step?: number): PathCursor;
  122240. /**
  122241. * Moves the cursor behind by the step amount
  122242. * @param step The amount to move the cursor back
  122243. * @returns This path cursor
  122244. */
  122245. moveBack(step?: number): PathCursor;
  122246. /**
  122247. * Moves the cursor by the step amount
  122248. * If the step amount is greater than one, an exception is thrown
  122249. * @param step The amount to move the cursor
  122250. * @returns This path cursor
  122251. */
  122252. move(step: number): PathCursor;
  122253. /**
  122254. * Ensures that the value is limited between zero and one
  122255. * @returns This path cursor
  122256. */
  122257. private ensureLimits;
  122258. /**
  122259. * Runs onchange callbacks on change (used by the animation engine)
  122260. * @returns This path cursor
  122261. */
  122262. private raiseOnChange;
  122263. /**
  122264. * Executes a function on change
  122265. * @param f A path cursor onchange callback
  122266. * @returns This path cursor
  122267. */
  122268. onchange(f: (cursor: PathCursor) => void): PathCursor;
  122269. }
  122270. }
  122271. declare module BABYLON {
  122272. /** @hidden */
  122273. export var blurPixelShader: {
  122274. name: string;
  122275. shader: string;
  122276. };
  122277. }
  122278. declare module BABYLON {
  122279. /** @hidden */
  122280. export var pointCloudVertexDeclaration: {
  122281. name: string;
  122282. shader: string;
  122283. };
  122284. }
  122285. // Mixins
  122286. interface Window {
  122287. mozIndexedDB: IDBFactory;
  122288. webkitIndexedDB: IDBFactory;
  122289. msIndexedDB: IDBFactory;
  122290. webkitURL: typeof URL;
  122291. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  122292. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  122293. WebGLRenderingContext: WebGLRenderingContext;
  122294. MSGesture: MSGesture;
  122295. CANNON: any;
  122296. AudioContext: AudioContext;
  122297. webkitAudioContext: AudioContext;
  122298. PointerEvent: any;
  122299. Math: Math;
  122300. Uint8Array: Uint8ArrayConstructor;
  122301. Float32Array: Float32ArrayConstructor;
  122302. mozURL: typeof URL;
  122303. msURL: typeof URL;
  122304. VRFrameData: any; // WebVR, from specs 1.1
  122305. DracoDecoderModule: any;
  122306. setImmediate(handler: (...args: any[]) => void): number;
  122307. }
  122308. interface HTMLCanvasElement {
  122309. requestPointerLock(): void;
  122310. msRequestPointerLock?(): void;
  122311. mozRequestPointerLock?(): void;
  122312. webkitRequestPointerLock?(): void;
  122313. /** Track wether a record is in progress */
  122314. isRecording: boolean;
  122315. /** Capture Stream method defined by some browsers */
  122316. captureStream(fps?: number): MediaStream;
  122317. }
  122318. interface CanvasRenderingContext2D {
  122319. msImageSmoothingEnabled: boolean;
  122320. }
  122321. interface MouseEvent {
  122322. mozMovementX: number;
  122323. mozMovementY: number;
  122324. webkitMovementX: number;
  122325. webkitMovementY: number;
  122326. msMovementX: number;
  122327. msMovementY: number;
  122328. }
  122329. interface Navigator {
  122330. mozGetVRDevices: (any: any) => any;
  122331. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122332. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122333. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122334. webkitGetGamepads(): Gamepad[];
  122335. msGetGamepads(): Gamepad[];
  122336. webkitGamepads(): Gamepad[];
  122337. }
  122338. interface HTMLVideoElement {
  122339. mozSrcObject: any;
  122340. }
  122341. interface Math {
  122342. fround(x: number): number;
  122343. imul(a: number, b: number): number;
  122344. }
  122345. interface WebGLRenderingContext {
  122346. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  122347. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  122348. vertexAttribDivisor(index: number, divisor: number): void;
  122349. createVertexArray(): any;
  122350. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  122351. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  122352. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  122353. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  122354. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  122355. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  122356. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  122357. // Queries
  122358. createQuery(): WebGLQuery;
  122359. deleteQuery(query: WebGLQuery): void;
  122360. beginQuery(target: number, query: WebGLQuery): void;
  122361. endQuery(target: number): void;
  122362. getQueryParameter(query: WebGLQuery, pname: number): any;
  122363. getQuery(target: number, pname: number): any;
  122364. MAX_SAMPLES: number;
  122365. RGBA8: number;
  122366. READ_FRAMEBUFFER: number;
  122367. DRAW_FRAMEBUFFER: number;
  122368. UNIFORM_BUFFER: number;
  122369. HALF_FLOAT_OES: number;
  122370. RGBA16F: number;
  122371. RGBA32F: number;
  122372. R32F: number;
  122373. RG32F: number;
  122374. RGB32F: number;
  122375. R16F: number;
  122376. RG16F: number;
  122377. RGB16F: number;
  122378. RED: number;
  122379. RG: number;
  122380. R8: number;
  122381. RG8: number;
  122382. UNSIGNED_INT_24_8: number;
  122383. DEPTH24_STENCIL8: number;
  122384. /* Multiple Render Targets */
  122385. drawBuffers(buffers: number[]): void;
  122386. readBuffer(src: number): void;
  122387. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  122388. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  122389. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  122390. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  122391. // Occlusion Query
  122392. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  122393. ANY_SAMPLES_PASSED: number;
  122394. QUERY_RESULT_AVAILABLE: number;
  122395. QUERY_RESULT: number;
  122396. }
  122397. interface WebGLProgram {
  122398. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  122399. }
  122400. interface EXT_disjoint_timer_query {
  122401. QUERY_COUNTER_BITS_EXT: number;
  122402. TIME_ELAPSED_EXT: number;
  122403. TIMESTAMP_EXT: number;
  122404. GPU_DISJOINT_EXT: number;
  122405. QUERY_RESULT_EXT: number;
  122406. QUERY_RESULT_AVAILABLE_EXT: number;
  122407. queryCounterEXT(query: WebGLQuery, target: number): void;
  122408. createQueryEXT(): WebGLQuery;
  122409. beginQueryEXT(target: number, query: WebGLQuery): void;
  122410. endQueryEXT(target: number): void;
  122411. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  122412. deleteQueryEXT(query: WebGLQuery): void;
  122413. }
  122414. interface WebGLUniformLocation {
  122415. _currentState: any;
  122416. }
  122417. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  122418. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  122419. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  122420. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122421. interface WebGLRenderingContext {
  122422. readonly RASTERIZER_DISCARD: number;
  122423. readonly DEPTH_COMPONENT24: number;
  122424. readonly TEXTURE_3D: number;
  122425. readonly TEXTURE_2D_ARRAY: number;
  122426. readonly TEXTURE_COMPARE_FUNC: number;
  122427. readonly TEXTURE_COMPARE_MODE: number;
  122428. readonly COMPARE_REF_TO_TEXTURE: number;
  122429. readonly TEXTURE_WRAP_R: number;
  122430. readonly HALF_FLOAT: number;
  122431. readonly RGB8: number;
  122432. readonly RED_INTEGER: number;
  122433. readonly RG_INTEGER: number;
  122434. readonly RGB_INTEGER: number;
  122435. readonly RGBA_INTEGER: number;
  122436. readonly R8_SNORM: number;
  122437. readonly RG8_SNORM: number;
  122438. readonly RGB8_SNORM: number;
  122439. readonly RGBA8_SNORM: number;
  122440. readonly R8I: number;
  122441. readonly RG8I: number;
  122442. readonly RGB8I: number;
  122443. readonly RGBA8I: number;
  122444. readonly R8UI: number;
  122445. readonly RG8UI: number;
  122446. readonly RGB8UI: number;
  122447. readonly RGBA8UI: number;
  122448. readonly R16I: number;
  122449. readonly RG16I: number;
  122450. readonly RGB16I: number;
  122451. readonly RGBA16I: number;
  122452. readonly R16UI: number;
  122453. readonly RG16UI: number;
  122454. readonly RGB16UI: number;
  122455. readonly RGBA16UI: number;
  122456. readonly R32I: number;
  122457. readonly RG32I: number;
  122458. readonly RGB32I: number;
  122459. readonly RGBA32I: number;
  122460. readonly R32UI: number;
  122461. readonly RG32UI: number;
  122462. readonly RGB32UI: number;
  122463. readonly RGBA32UI: number;
  122464. readonly RGB10_A2UI: number;
  122465. readonly R11F_G11F_B10F: number;
  122466. readonly RGB9_E5: number;
  122467. readonly RGB10_A2: number;
  122468. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  122469. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  122470. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  122471. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  122472. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  122473. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  122474. 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;
  122475. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  122476. readonly TRANSFORM_FEEDBACK: number;
  122477. readonly INTERLEAVED_ATTRIBS: number;
  122478. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  122479. createTransformFeedback(): WebGLTransformFeedback;
  122480. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  122481. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  122482. beginTransformFeedback(primitiveMode: number): void;
  122483. endTransformFeedback(): void;
  122484. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  122485. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122486. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122487. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122488. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  122489. }
  122490. interface ImageBitmap {
  122491. readonly width: number;
  122492. readonly height: number;
  122493. close(): void;
  122494. }
  122495. interface WebGLQuery extends WebGLObject {
  122496. }
  122497. declare var WebGLQuery: {
  122498. prototype: WebGLQuery;
  122499. new(): WebGLQuery;
  122500. };
  122501. interface WebGLSampler extends WebGLObject {
  122502. }
  122503. declare var WebGLSampler: {
  122504. prototype: WebGLSampler;
  122505. new(): WebGLSampler;
  122506. };
  122507. interface WebGLSync extends WebGLObject {
  122508. }
  122509. declare var WebGLSync: {
  122510. prototype: WebGLSync;
  122511. new(): WebGLSync;
  122512. };
  122513. interface WebGLTransformFeedback extends WebGLObject {
  122514. }
  122515. declare var WebGLTransformFeedback: {
  122516. prototype: WebGLTransformFeedback;
  122517. new(): WebGLTransformFeedback;
  122518. };
  122519. interface WebGLVertexArrayObject extends WebGLObject {
  122520. }
  122521. declare var WebGLVertexArrayObject: {
  122522. prototype: WebGLVertexArrayObject;
  122523. new(): WebGLVertexArrayObject;
  122524. };
  122525. // Type definitions for WebVR API
  122526. // Project: https://w3c.github.io/webvr/
  122527. // Definitions by: six a <https://github.com/lostfictions>
  122528. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122529. interface VRDisplay extends EventTarget {
  122530. /**
  122531. * Dictionary of capabilities describing the VRDisplay.
  122532. */
  122533. readonly capabilities: VRDisplayCapabilities;
  122534. /**
  122535. * z-depth defining the far plane of the eye view frustum
  122536. * enables mapping of values in the render target depth
  122537. * attachment to scene coordinates. Initially set to 10000.0.
  122538. */
  122539. depthFar: number;
  122540. /**
  122541. * z-depth defining the near plane of the eye view frustum
  122542. * enables mapping of values in the render target depth
  122543. * attachment to scene coordinates. Initially set to 0.01.
  122544. */
  122545. depthNear: number;
  122546. /**
  122547. * An identifier for this distinct VRDisplay. Used as an
  122548. * association point in the Gamepad API.
  122549. */
  122550. readonly displayId: number;
  122551. /**
  122552. * A display name, a user-readable name identifying it.
  122553. */
  122554. readonly displayName: string;
  122555. readonly isConnected: boolean;
  122556. readonly isPresenting: boolean;
  122557. /**
  122558. * If this VRDisplay supports room-scale experiences, the optional
  122559. * stage attribute contains details on the room-scale parameters.
  122560. */
  122561. readonly stageParameters: VRStageParameters | null;
  122562. /**
  122563. * Passing the value returned by `requestAnimationFrame` to
  122564. * `cancelAnimationFrame` will unregister the callback.
  122565. * @param handle Define the hanle of the request to cancel
  122566. */
  122567. cancelAnimationFrame(handle: number): void;
  122568. /**
  122569. * Stops presenting to the VRDisplay.
  122570. * @returns a promise to know when it stopped
  122571. */
  122572. exitPresent(): Promise<void>;
  122573. /**
  122574. * Return the current VREyeParameters for the given eye.
  122575. * @param whichEye Define the eye we want the parameter for
  122576. * @returns the eye parameters
  122577. */
  122578. getEyeParameters(whichEye: string): VREyeParameters;
  122579. /**
  122580. * Populates the passed VRFrameData with the information required to render
  122581. * the current frame.
  122582. * @param frameData Define the data structure to populate
  122583. * @returns true if ok otherwise false
  122584. */
  122585. getFrameData(frameData: VRFrameData): boolean;
  122586. /**
  122587. * Get the layers currently being presented.
  122588. * @returns the list of VR layers
  122589. */
  122590. getLayers(): VRLayer[];
  122591. /**
  122592. * Return a VRPose containing the future predicted pose of the VRDisplay
  122593. * when the current frame will be presented. The value returned will not
  122594. * change until JavaScript has returned control to the browser.
  122595. *
  122596. * The VRPose will contain the position, orientation, velocity,
  122597. * and acceleration of each of these properties.
  122598. * @returns the pose object
  122599. */
  122600. getPose(): VRPose;
  122601. /**
  122602. * Return the current instantaneous pose of the VRDisplay, with no
  122603. * prediction applied.
  122604. * @returns the current instantaneous pose
  122605. */
  122606. getImmediatePose(): VRPose;
  122607. /**
  122608. * The callback passed to `requestAnimationFrame` will be called
  122609. * any time a new frame should be rendered. When the VRDisplay is
  122610. * presenting the callback will be called at the native refresh
  122611. * rate of the HMD. When not presenting this function acts
  122612. * identically to how window.requestAnimationFrame acts. Content should
  122613. * make no assumptions of frame rate or vsync behavior as the HMD runs
  122614. * asynchronously from other displays and at differing refresh rates.
  122615. * @param callback Define the eaction to run next frame
  122616. * @returns the request handle it
  122617. */
  122618. requestAnimationFrame(callback: FrameRequestCallback): number;
  122619. /**
  122620. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  122621. * Repeat calls while already presenting will update the VRLayers being displayed.
  122622. * @param layers Define the list of layer to present
  122623. * @returns a promise to know when the request has been fulfilled
  122624. */
  122625. requestPresent(layers: VRLayer[]): Promise<void>;
  122626. /**
  122627. * Reset the pose for this display, treating its current position and
  122628. * orientation as the "origin/zero" values. VRPose.position,
  122629. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  122630. * updated when calling resetPose(). This should be called in only
  122631. * sitting-space experiences.
  122632. */
  122633. resetPose(): void;
  122634. /**
  122635. * The VRLayer provided to the VRDisplay will be captured and presented
  122636. * in the HMD. Calling this function has the same effect on the source
  122637. * canvas as any other operation that uses its source image, and canvases
  122638. * created without preserveDrawingBuffer set to true will be cleared.
  122639. * @param pose Define the pose to submit
  122640. */
  122641. submitFrame(pose?: VRPose): void;
  122642. }
  122643. declare var VRDisplay: {
  122644. prototype: VRDisplay;
  122645. new(): VRDisplay;
  122646. };
  122647. interface VRLayer {
  122648. leftBounds?: number[] | Float32Array | null;
  122649. rightBounds?: number[] | Float32Array | null;
  122650. source?: HTMLCanvasElement | null;
  122651. }
  122652. interface VRDisplayCapabilities {
  122653. readonly canPresent: boolean;
  122654. readonly hasExternalDisplay: boolean;
  122655. readonly hasOrientation: boolean;
  122656. readonly hasPosition: boolean;
  122657. readonly maxLayers: number;
  122658. }
  122659. interface VREyeParameters {
  122660. /** @deprecated */
  122661. readonly fieldOfView: VRFieldOfView;
  122662. readonly offset: Float32Array;
  122663. readonly renderHeight: number;
  122664. readonly renderWidth: number;
  122665. }
  122666. interface VRFieldOfView {
  122667. readonly downDegrees: number;
  122668. readonly leftDegrees: number;
  122669. readonly rightDegrees: number;
  122670. readonly upDegrees: number;
  122671. }
  122672. interface VRFrameData {
  122673. readonly leftProjectionMatrix: Float32Array;
  122674. readonly leftViewMatrix: Float32Array;
  122675. readonly pose: VRPose;
  122676. readonly rightProjectionMatrix: Float32Array;
  122677. readonly rightViewMatrix: Float32Array;
  122678. readonly timestamp: number;
  122679. }
  122680. interface VRPose {
  122681. readonly angularAcceleration: Float32Array | null;
  122682. readonly angularVelocity: Float32Array | null;
  122683. readonly linearAcceleration: Float32Array | null;
  122684. readonly linearVelocity: Float32Array | null;
  122685. readonly orientation: Float32Array | null;
  122686. readonly position: Float32Array | null;
  122687. readonly timestamp: number;
  122688. }
  122689. interface VRStageParameters {
  122690. sittingToStandingTransform?: Float32Array;
  122691. sizeX?: number;
  122692. sizeY?: number;
  122693. }
  122694. interface Navigator {
  122695. getVRDisplays(): Promise<VRDisplay[]>;
  122696. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  122697. }
  122698. interface Window {
  122699. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  122700. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  122701. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  122702. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122703. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122704. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  122705. }
  122706. interface Gamepad {
  122707. readonly displayId: number;
  122708. }
  122709. interface XRDevice {
  122710. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  122711. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  122712. }
  122713. interface XRSession {
  122714. getInputSources(): Array<any>;
  122715. baseLayer: XRWebGLLayer;
  122716. requestFrameOfReference(type: string): Promise<void>;
  122717. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  122718. end(): Promise<void>;
  122719. requestAnimationFrame: Function;
  122720. addEventListener: Function;
  122721. }
  122722. interface XRSessionCreationOptions {
  122723. outputContext?: WebGLRenderingContext | null;
  122724. immersive?: boolean;
  122725. environmentIntegration?: boolean;
  122726. }
  122727. interface XRLayer {
  122728. getViewport: Function;
  122729. framebufferWidth: number;
  122730. framebufferHeight: number;
  122731. }
  122732. interface XRView {
  122733. projectionMatrix: Float32Array;
  122734. }
  122735. interface XRFrame {
  122736. getDevicePose: Function;
  122737. getInputPose: Function;
  122738. views: Array<XRView>;
  122739. baseLayer: XRLayer;
  122740. }
  122741. interface XRFrameOfReference {
  122742. }
  122743. interface XRWebGLLayer extends XRLayer {
  122744. framebuffer: WebGLFramebuffer;
  122745. }
  122746. declare var XRWebGLLayer: {
  122747. prototype: XRWebGLLayer;
  122748. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  122749. };